RDKit
Open-source cheminformatics and machine learning.
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>
21 #include <map>
22 #include <sstream>
23 
24 namespace RDKit {
25 
27  public :
28 
29  FragCatalogEntry() : dp_mol(0),d_descrip(""),d_order(0) {
30  dp_props = new Dict();
31  setBitId(-1);
32  }
33 
34  FragCatalogEntry(const ROMol *omol, const PATH_TYPE &path, const MatchVectType &aidToFid);
35  FragCatalogEntry(const std::string &pickle);
36 
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(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 
58 
59  unsigned int getOrder() const {
60  return dp_mol->getNumBonds();
61  }
62 
64  return d_aToFmap;
65  }
66 
67  // REVIEW: this should be removed?
68  std::string getSmarts(){return "";}
69 
70  // FUnctions on the property dictionary
71  template <typename T> void setProp(const char *key, T &val) const {
72  dp_props->setVal(key, val);
73  }
74 
75  template <typename T> void setProp(const std::string &key, T &val) const {
76  setProp(key.c_str(), val);
77  }
78 
79  void setProp(const char *key, int val) const {
80  dp_props->setVal(key, val);
81  }
82 
83  void setProp(const std::string &key, int val) const {
84  setProp(key.c_str(), val);
85  }
86 
87  void setProp(const char *key, float val) const {
88  dp_props->setVal(key, val);
89  }
90 
91  void setProp(const std::string &key, float val) const {
92  setProp(key.c_str(), val);
93  }
94 
95  void setProp(const std::string &key, std::string &val) const {
96  setProp(key.c_str(), val);
97  }
98 
99  template <typename T>
100  void getProp(const char *key, T &res) const {
101  dp_props->getVal(key, res);
102  }
103  template <typename T>
104  void getProp(const std::string key, T &res) const {
105  getProp(key.c_str(), res);
106  }
107 
108  bool hasProp(const char *key) const {
109  if (!dp_props) return false;
110  return dp_props->hasVal(key);
111  }
112  bool hasProp(const std::string &key) const {
113  return hasProp(key.c_str());
114  }
115 
116  void clearProp(const char *key) const {
117  dp_props->clearVal(key);
118  }
119 
120  void clearProp(const std::string &key) const {
121  clearProp(key.c_str());
122  }
123 
124  void toStream(std::ostream &ss) const;
125  std::string Serialize() const;
126  void initFromStream(std::istream &ss);
127  void initFromString(const std::string &text);
128 
129 
130  private:
131 
132  ROMol *dp_mol;
133  Dict *dp_props;
134 
135  std::string d_descrip;
136 
137  unsigned int d_order;
138 
139  // a map between the atom ids in mol that connect to
140  // a functional group and the corresponding functional
141  // group ID
142  INT_INT_VECT_MAP d_aToFmap;
143  };
144 }
145 
146 #endif
147 
Subgraphs::DiscrimTuple getDiscrims() const
void setProp(const char *key, int val) const
bool match(const FragCatalogEntry *other, double tol) const
void clearProp(const std::string &key) const
void setVal(const std::string &what, T &val)
Sets the value associated with a key.
Definition: Dict.h:170
boost::tuples::tuple< boost::uint32_t, boost::uint32_t, boost::uint32_t > DiscrimTuple
used to return path discriminators (three unsigned ints):
Definition: SubgraphUtils.h:22
void initFromString(const std::string &text)
initializes from a string pickle
std::string Serialize() const
returns a string with a serialized (pickled) representation
void setDescription(std::string val)
std::vector< std::pair< int, int > > MatchVectType
used to return matches from substructure searching, The format is (queryAtomIdx, molAtomIdx) ...
void toStream(std::ostream &ss) const
serializes (pickles) to a stream
void setProp(const char *key, float val) const
pulls in the core RDKit functionality
void setProp(const std::string &key, int val) const
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:105
void setProp(const std::string &key, std::string &val) const
void clearVal(const std::string &what)
Clears the value associated with a particular key, removing the key from the dictionary.
Definition: Dict.h:198
bool hasProp(const char *key) const
void getVal(const std::string &what, T &res) const
Gets the value associated with a particular key.
Definition: Dict.h:86
void clearProp(const char *key) const
void setBitId(int bid)
sets our bit Id
Definition: CatalogEntry.h:24
unsigned int getNumBonds(bool onlyHeavy=1) const
returns our number of Bonds
const INT_INT_VECT_MAP & getFuncGroupMap() const
void getProp(const char *key, T &res) const
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
bool hasVal(const char *what) const
Returns whether or not the dictionary contains a particular key.
Definition: Dict.h:50
Abstract base class to be used to represent an entry in a Catalog.
Definition: CatalogEntry.h:19
container for user parameters used to create a fragment catalog
Definition: FragCatParams.h:24
unsigned int getOrder() const
std::map< int, INT_VECT > INT_INT_VECT_MAP
Definition: types.h:182
functionality for finding subgraphs and paths in molecules
std::vector< int > PATH_TYPE
Definition: Subgraphs.h:37
bool hasProp(const std::string &key) const
void setProp(const std::string &key, T &val) const
void setProp(const std::string &key, float val) const
void getProp(const std::string key, T &res) const
The Dict class can be used to store objects of arbitrary type keyed by strings.
Definition: Dict.h:33
void setProp(const char *key, T &val) const
std::string getDescription() const
returns a text description of this entry
void initFromStream(std::istream &ss)
initializes from a stream pickle