RDKit: MolCatalogEntry.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MolCatalogEntry.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Greg Landrum
3 //
4 #ifndef _RD_MOLCATALOGENTRY_H_
5 #define _RD_MOLCATALOGENTRY_H_
6
7 #include <RDGeneral/Dict.h>
8 #include <Catalogs/CatalogEntry.h>
9 #include <fstream>
10 #include <string>
11
12 namespace RDKit {
13 class ROMol;
14
15 //! This class is used to store ROMol objects in a MolCatalog
16 class MolCatalogEntry : public RDCatalog::CatalogEntry {
17 public:
18 MolCatalogEntry() : dp_mol(0), d_descrip("") {
19 dp_props = new Dict();
20 setBitId(-1);
21 }
22
23 //! copy constructor
24 MolCatalogEntry(const MolCatalogEntry &other);
25
26 //! create an entry to hold the provided ROMol
27 /*!
28 The MolCatalogEntry takes ownership of the pointer
29 */
30 MolCatalogEntry(const ROMol *omol);
31
32 //! construct from a pickle
33 MolCatalogEntry(const std::string &pickle) { this->initFromString(pickle); }
34
35 ~MolCatalogEntry();
36
37 std::string getDescription() const { return d_descrip; }
38
39 void setDescription(std::string val) { d_descrip = val; }
40
41 unsigned int getOrder() const { return d_order; };
42 void setOrder(unsigned int order) { d_order = order; };
43
44 const ROMol *getMol() const { return dp_mol; };
45 //! hold the provided ROMol
46 /*!
47 The MolCatalogEntry takes ownership of the pointer.
48 If the MolCatalogEntry already has a molecule, this one will be deleted.
49 */
50 void setMol(const ROMol *molPtr);
51
52 //! set a named property
53 template <typename T>
54 void setProp(const char *key, T &val) const {
55 dp_props->setVal(key, val);
56 }
57
58 //! \overload
59 template <typename T>
60 void setProp(const std::string &key, T &val) const {
61 setProp(key.c_str(), val);
62 }
63
64 //! get the value of a named property
65 template <typename T>
66 void getProp(const char *key, T &res) const {
67 dp_props->getVal(key, res);
68 }
69 //! \overload
70 template <typename T>
71 void getProp(const std::string &key, T &res) const {
72 getProp(key.c_str(), res);
73 }
74
75 //! returns true if such a property exists
76 bool hasProp(const char *key) const {
77 if (!dp_props) return false;
78 return dp_props->hasVal(key);
79 }
80 //! \overload
81 bool hasProp(const std::string &key) const { return hasProp(key.c_str()); }
82
83 //! clears a named property
84 void clearProp(const char *key) const { dp_props->clearVal(key); }
85 //! \overload
86 void clearProp(const std::string &key) const { clearProp(key.c_str()); }
87
88 //! serializes this entry to the stream
89 void toStream(std::ostream &ss) const;
90 //! returns a serialized (pickled) form of the entry
91 std::string Serialize() const;
92 //! initialize from a stream containing a pickle
93 void initFromStream(std::istream &ss);
94 //! initialize from a string containing a pickle
95 void initFromString(const std::string &text);
96
97 private:
98 const ROMol *dp_mol;
99 Dict *dp_props;
100
101 unsigned int d_order;
102 std::string d_descrip;
103 };
104 }
105
106 #endif
RDKit::MolCatalogEntry::getOrder
unsigned int getOrder() const
Definition: MolCatalogEntry.h:41
RDKit::MolCatalogEntry::~MolCatalogEntry
~MolCatalogEntry()
CatalogEntry.h
RDKit::MolCatalogEntry
This class is used to store ROMol objects in a MolCatalog.
Definition: MolCatalogEntry.h:16
RDKit::Dict::setVal
void setVal(const std::string &what, T &val)
Sets the value associated with a key.
Definition: Dict.h:169
RDKit::MolCatalogEntry::hasProp
bool hasProp(const std::string &key) const
Definition: MolCatalogEntry.h:81
RDKit::MolCatalogEntry::hasProp
bool hasProp(const char *key) const
returns true if such a property exists
Definition: MolCatalogEntry.h:76
RDKit::MolCatalogEntry::getProp
void getProp(const std::string &key, T &res) const
Definition: MolCatalogEntry.h:71
RDKit::MolCatalogEntry::initFromString
void initFromString(const std::string &text)
initialize from a string containing a pickle
RDKit::MolCatalogEntry::MolCatalogEntry
MolCatalogEntry()
Definition: MolCatalogEntry.h:18
Dict.h
Defines the Dict class.
RDKit::ROMol
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:102
RDKit::Dict::clearVal
void clearVal(const std::string &what)
Clears the value associated with a particular key, removing the key from the dictionary.
Definition: Dict.h:195
RDKit::Dict::getVal
void getVal(const std::string &what, T &res) const
Gets the value associated with a particular key.
Definition: Dict.h:84
RDKit::MolCatalogEntry::setOrder
void setOrder(unsigned int order)
Definition: MolCatalogEntry.h:42
RDCatalog::CatalogEntry::setBitId
void setBitId(int bid)
sets our bit Id
Definition: CatalogEntry.h:24
RDKit::MolCatalogEntry::getMol
const ROMol * getMol() const
Definition: MolCatalogEntry.h:44
RDKit::MolCatalogEntry::getDescription
std::string getDescription() const
returns a text description of this entry
Definition: MolCatalogEntry.h:37
RDKit::MolCatalogEntry::setProp
void setProp(const char *key, T &val) const
set a named property
Definition: MolCatalogEntry.h:54
RDKit
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
RDKit::MolCatalogEntry::clearProp
void clearProp(const char *key) const
clears a named property
Definition: MolCatalogEntry.h:84
RDKit::MolCatalogEntry::setMol
void setMol(const ROMol *molPtr)
hold the provided ROMol
RDKit::Dict::hasVal
bool hasVal(const char *what) const
Returns whether or not the dictionary contains a particular key.
Definition: Dict.h:48
RDCatalog::CatalogEntry
Abstract base class to be used to represent an entry in a Catalog.
Definition: CatalogEntry.h:19
RDKit::MolCatalogEntry::setProp
void setProp(const std::string &key, T &val) const
Definition: MolCatalogEntry.h:60
RDKit::MolCatalogEntry::MolCatalogEntry
MolCatalogEntry(const std::string &pickle)
construct from a pickle
Definition: MolCatalogEntry.h:33
RDKit::MolCatalogEntry::initFromStream
void initFromStream(std::istream &ss)
initialize from a stream containing a pickle
RDKit::MolCatalogEntry::Serialize
std::string Serialize() const
returns a serialized (pickled) form of the entry
RDKit::MolCatalogEntry::toStream
void toStream(std::ostream &ss) const
serializes this entry to the stream
RDKit::Dict
The Dict class can be used to store objects of arbitrary type keyed by strings.
Definition: Dict.h:33
RDKit::MolCatalogEntry::setDescription
void setDescription(std::string val)
Definition: MolCatalogEntry.h:39
RDKit::MolCatalogEntry::clearProp
void clearProp(const std::string &key) const
Definition: MolCatalogEntry.h:86
RDKit::MolCatalogEntry::getProp
void getProp(const char *key, T &res) const
get the value of a named property
Definition: MolCatalogEntry.h:66