RDKit: FragCatalogEntry.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

FragCatalogEntry.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2006 Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #ifndef _RD_FRAGCATALOGENTRY_H_
11 #define _RD_FRAGCATALOGENTRY_H_
12
13 #include "FragCatParams.h"
14 #include <RDGeneral/utils.h>
15 #include <Catalogs/CatalogEntry.h>
16 #include <GraphMol/RDKitBase.h>
17 #include <GraphMol/Subgraphs/Subgraphs.h>
18 #include <GraphMol/Subgraphs/SubgraphUtils.h>
19 #include <GraphMol/SmilesParse/SmilesWrite.h>
20 #include <GraphMol/Substruct/SubstructMatch.h>
21 #include <map>
22 #include <sstream>
23
24 namespace RDKit {
25
26 class FragCatalogEntry : public RDCatalog::CatalogEntry {
27 public:
28 FragCatalogEntry() : dp_mol(0), d_descrip(""), d_order(0) {
29 dp_props = new Dict();
30 setBitId(-1);
31 }
32
33 FragCatalogEntry(const ROMol *omol, const PATH_TYPE &path,
34 const MatchVectType &aidToFid);
35 FragCatalogEntry(const std::string &pickle);
36
37 ~FragCatalogEntry() {
38 delete dp_mol;
39 dp_mol = 0;
40 if (dp_props) {
41 delete dp_props;
42 dp_props = 0;
43 }
44 }
45
46 std::string getDescription() const { return d_descrip; }
47
48 void setDescription(const std::string &val) { d_descrip = val; }
49
50 void setDescription(const FragCatParams *params);
51
52 // check if this fragment macthes the one specified
53 //
54
55 bool match(const FragCatalogEntry *other, double tol) const;
56
57 Subgraphs::DiscrimTuple getDiscrims() const;
58
59 unsigned int getOrder() const { return dp_mol->getNumBonds(); }
60
61 const INT_INT_VECT_MAP &getFuncGroupMap() const { return d_aToFmap; }
62
63 // REVIEW: this should be removed?
64 std::string getSmarts() { return ""; }
65
66 // FUnctions on the property dictionary
67 template <typename T>
68 void setProp(const char *key, T &val) const {
69 dp_props->setVal(key, val);
70 }
71
72 template <typename T>
73 void setProp(const std::string &key, T &val) const {
74 setProp(key.c_str(), val);
75 }
76
77 void setProp(const char *key, int val) const { dp_props->setVal(key, val); }
78
79 void setProp(const std::string &key, int val) const {
80 setProp(key.c_str(), val);
81 }
82
83 void setProp(const char *key, float val) const { dp_props->setVal(key, val); }
84
85 void setProp(const std::string &key, float val) const {
86 setProp(key.c_str(), val);
87 }
88
89 void setProp(const std::string &key, std::string &val) const {
90 setProp(key.c_str(), val);
91 }
92
93 template <typename T>
94 void getProp(const char *key, T &res) const {
95 dp_props->getVal(key, res);
96 }
97 template <typename T>
98 void getProp(const std::string &key, T &res) const {
99 getProp(key.c_str(), res);
100 }
101
102 bool hasProp(const char *key) const {
103 if (!dp_props) return false;
104 return dp_props->hasVal(key);
105 }
106 bool hasProp(const std::string &key) const { return hasProp(key.c_str()); }
107
108 void clearProp(const char *key) const { dp_props->clearVal(key); }
109
110 void clearProp(const std::string &key) const { clearProp(key.c_str()); }
111
112 void toStream(std::ostream &ss) const;
113 std::string Serialize() const;
114 void initFromStream(std::istream &ss);
115 void initFromString(const std::string &text);
116
117 private:
118 ROMol *dp_mol;
119 Dict *dp_props;
120
121 std::string d_descrip;
122
123 unsigned int d_order;
124
125 // a map between the atom ids in mol that connect to
126 // a functional group and the corresponding functional
127 // group ID
128 INT_INT_VECT_MAP d_aToFmap;
129 };
130 }
131
132 #endif
RDKit::FragCatalogEntry::getDiscrims
Subgraphs::DiscrimTuple getDiscrims() const
RDKit::FragCatalogEntry::setProp
void setProp(const char *key, int val) const
Definition: FragCatalogEntry.h:77
RDKit::Dict::hasVal
bool hasVal(const std::string &what) const
Returns whether or not the dictionary contains a particular key.
Definition: Dict.h:117
RDKit::FragCatalogEntry::match
bool match(const FragCatalogEntry *other, double tol) const
CatalogEntry.h
RDKit::FragCatalogEntry::clearProp
void clearProp(const std::string &key) const
Definition: FragCatalogEntry.h:110
RDKit::Dict::setVal
void setVal(const std::string &what, T &val)
Sets the value associated with a key.
Definition: Dict.h:212
RDKit::FragCatalogEntry::initFromString
void initFromString(const std::string &text)
initializes from a string pickle
RDKit::FragCatalogEntry::Serialize
std::string Serialize() const
returns a string with a serialized (pickled) representation
RDKit::MatchVectType
std::vector< std::pair< int, int > > MatchVectType
used to return matches from substructure searching, The format is (queryAtomIdx, molAtomIdx) ...
Definition: FragFPGenerator.h:23
RDKit::FragCatalogEntry::toStream
void toStream(std::ostream &ss) const
serializes (pickles) to a stream
RDKit::FragCatalogEntry::getSmarts
std::string getSmarts()
Definition: FragCatalogEntry.h:64
RDKit::FragCatalogEntry::setProp
void setProp(const char *key, float val) const
Definition: FragCatalogEntry.h:83
SmilesWrite.h
SubgraphUtils.h
SubstructMatch.h
utils.h
RDKitBase.h
pulls in the core RDKit functionality
RDKit::FragCatalogEntry::setProp
void setProp(const std::string &key, int val) const
Definition: FragCatalogEntry.h:79
RDKit::ROMol
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:103
RDKit::FragCatalogEntry::setProp
void setProp(const std::string &key, std::string &val) const
Definition: FragCatalogEntry.h:89
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:266
RDKit::FragCatalogEntry::hasProp
bool hasProp(const char *key) const
Definition: FragCatalogEntry.h:102
RDKit::Dict::getVal
void getVal(const std::string &what, T &res) const
Gets the value associated with a particular key.
Definition: Dict.h:152
RDKit::FragCatalogEntry
Definition: FragCatalogEntry.h:26
RDKit::FragCatalogEntry::clearProp
void clearProp(const char *key) const
Definition: FragCatalogEntry.h:108
RDCatalog::CatalogEntry::setBitId
void setBitId(int bid)
sets our bit Id
Definition: CatalogEntry.h:24
RDKit::FragCatalogEntry::getProp
void getProp(const std::string &key, T &res) const
Definition: FragCatalogEntry.h:98
RDKit::ROMol::getNumBonds
unsigned int getNumBonds(bool onlyHeavy=1) const
returns our number of Bonds
RDKit::FragCatalogEntry::getFuncGroupMap
const INT_INT_VECT_MAP & getFuncGroupMap() const
Definition: FragCatalogEntry.h:61
RDKit::FragCatalogEntry::getProp
void getProp(const char *key, T &res) const
Definition: FragCatalogEntry.h:94
RDKit
Std stuff.
Definition: Atom.h:29
RDKit::Subgraphs::DiscrimTuple
boost::tuples::tuple< boost::uint32_t, boost::uint32_t, boost::uint32_t > DiscrimTuple
used to return path discriminators (three unsigned ints):
Definition: SubgraphUtils.h:23
RDKit::FragCatalogEntry::~FragCatalogEntry
~FragCatalogEntry()
Definition: FragCatalogEntry.h:37
RDCatalog::CatalogEntry
Abstract base class to be used to represent an entry in a Catalog.
Definition: CatalogEntry.h:19
RDKit::FragCatParams
container for user parameters used to create a fragment catalog
Definition: FragCatParams.h:23
RDKit::FragCatalogEntry::getOrder
unsigned int getOrder() const
Definition: FragCatalogEntry.h:59
RDKit::INT_INT_VECT_MAP
std::map< int, INT_VECT > INT_INT_VECT_MAP
Definition: types.h:226
RDKit::FragCatalogEntry::setDescription
void setDescription(const std::string &val)
Definition: FragCatalogEntry.h:48
RDKit::FragCatalogEntry::FragCatalogEntry
FragCatalogEntry()
Definition: FragCatalogEntry.h:28
Subgraphs.h
functionality for finding subgraphs and paths in molecules
RDKit::PATH_TYPE
std::vector< int > PATH_TYPE
Definition: Subgraphs.h:36
RDKit::FragCatalogEntry::hasProp
bool hasProp(const std::string &key) const
Definition: FragCatalogEntry.h:106
RDKit::FragCatalogEntry::setProp
void setProp(const std::string &key, T &val) const
Definition: FragCatalogEntry.h:73
RDKit::FragCatalogEntry::setProp
void setProp(const std::string &key, float val) const
Definition: FragCatalogEntry.h:85
FragCatParams.h
RDKit::Dict
The Dict class can be used to store objects of arbitrary type keyed by strings.
Definition: Dict.h:35
RDKit::FragCatalogEntry::setProp
void setProp(const char *key, T &val) const
Definition: FragCatalogEntry.h:68
RDKit::EnumerationStrategyPickler::pickle
void pickle(const boost::shared_ptr< EnumerationStrategyBase > &enumerator, std::ostream &ss)
pickles a EnumerationStrategy and adds the results to a stream ss
RDKit::FragCatalogEntry::getDescription
std::string getDescription() const
returns a text description of this entry
Definition: FragCatalogEntry.h:46
RDKit::FragCatalogEntry::initFromStream
void initFromStream(std::istream &ss)
initializes from a stream pickle