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  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 
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 
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
Subgraphs::DiscrimTuple getDiscrims() const
void setProp(const char *key, int val) const
bool hasVal(const std::string &what) const
Returns whether or not the dictionary contains a particular key.
Definition: Dict.h:90
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:186
void initFromString(const std::string &text)
initializes from a string pickle
std::string Serialize() const
returns a string with a serialized (pickled) representation
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:106
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:248
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:125
void clearProp(const char *key) const
void setBitId(int bid)
sets our bit Id
Definition: CatalogEntry.h:24
void getProp(const std::string &key, T &res) const
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:29
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
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:23
unsigned int getOrder() const
std::map< int, INT_VECT > INT_INT_VECT_MAP
Definition: types.h:225
void setDescription(const std::string &val)
functionality for finding subgraphs and paths in molecules
std::vector< int > PATH_TYPE
Definition: Subgraphs.h:36
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
The Dict class can be used to store objects of arbitrary type keyed by strings.
Definition: Dict.h:35
void setProp(const char *key, T &val) const
void pickle(const boost::shared_ptr< EnumerationStrategyBase > &enumerator, std::ostream &ss)
pickles a EnumerationStrategy and adds the results to a stream ss
std::string getDescription() const
returns a text description of this entry
void initFromStream(std::istream &ss)
initializes from a stream pickle