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 #include <RDGeneral/export.h>
11 #ifndef _RD_FRAGCATALOGENTRY_H_
12 #define _RD_FRAGCATALOGENTRY_H_
13 
14 #include "FragCatParams.h"
15 #include <RDGeneral/utils.h>
16 #include <Catalogs/CatalogEntry.h>
17 #include <GraphMol/RDKitBase.h>
22 #include <map>
23 #include <sstream>
24 
25 namespace RDKit {
26 
28  public:
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,
35  const MatchVectType &aidToFid);
36  FragCatalogEntry(const std::string &pickle);
37 
39  delete dp_mol;
40  dp_mol = 0;
41  if (dp_props) {
42  delete dp_props;
43  dp_props = 0;
44  }
45  }
46 
47  std::string getDescription() const { return d_descrip; }
48 
49  void setDescription(const std::string &val) { d_descrip = val; }
50 
51  void setDescription(const FragCatParams *params);
52 
53  // check if this fragment macthes the one specified
54  //
55 
56  bool match(const FragCatalogEntry *other, double tol) const;
57 
58  Subgraphs::DiscrimTuple getDiscrims() const;
59 
60  unsigned int getOrder() const { return dp_mol->getNumBonds(); }
61 
62  const INT_INT_VECT_MAP &getFuncGroupMap() const { return d_aToFmap; }
63 
64  // REVIEW: this should be removed?
65  std::string getSmarts() { return ""; }
66 
67  // FUnctions on the property dictionary
68  template <typename T>
69  void setProp(const char *key, T &val) const {
70  dp_props->setVal(key, val);
71  }
72 
73  template <typename T>
74  void setProp(const std::string &key, T &val) const {
75  setProp(key.c_str(), val);
76  }
77 
78  void setProp(const char *key, int val) const { dp_props->setVal(key, val); }
79 
80  void setProp(const std::string &key, int val) const {
81  setProp(key.c_str(), val);
82  }
83 
84  void setProp(const char *key, float val) const { dp_props->setVal(key, val); }
85 
86  void setProp(const std::string &key, float val) const {
87  setProp(key.c_str(), val);
88  }
89 
90  void setProp(const std::string &key, std::string &val) const {
91  setProp(key.c_str(), val);
92  }
93 
94  template <typename T>
95  void getProp(const char *key, T &res) const {
96  dp_props->getVal(key, res);
97  }
98  template <typename T>
99  void getProp(const std::string &key, T &res) const {
100  getProp(key.c_str(), res);
101  }
102 
103  bool hasProp(const char *key) const {
104  if (!dp_props) return false;
105  return dp_props->hasVal(key);
106  }
107  bool hasProp(const std::string &key) const { return hasProp(key.c_str()); }
108 
109  void clearProp(const char *key) const { dp_props->clearVal(key); }
110 
111  void clearProp(const std::string &key) const { clearProp(key.c_str()); }
112 
113  void toStream(std::ostream &ss) const;
114  std::string Serialize() const;
115  void initFromStream(std::istream &ss);
116  void initFromString(const std::string &text);
117 
118  private:
119  ROMol *dp_mol;
120  Dict *dp_props;
121 
122  std::string d_descrip;
123 
124  unsigned int d_order;
125 
126  // a map between the atom ids in mol that connect to
127  // a functional group and the corresponding functional
128  // group ID
129  INT_INT_VECT_MAP d_aToFmap;
130 };
131 }
132 
133 #endif
void setProp(const std::string &key, float val) const
void clearProp(const std::string &key) const
unsigned int getOrder() const
bool hasProp(const char *key) const
std::vector< std::pair< int, int > > MatchVectType
used to return matches from substructure searching, The format is (queryAtomIdx, molAtomIdx) ...
void setProp(const std::string &key, int val) const
const INT_INT_VECT_MAP & getFuncGroupMap() const
RDKIT_CHEMREACTIONS_EXPORT void pickle(const boost::shared_ptr< EnumerationStrategyBase > &enumerator, std::ostream &ss)
pickles a EnumerationStrategy and adds the results to a stream ss
pulls in the core RDKit functionality
void setProp(const std::string &key, T &val) const
void setProp(const char *key, T &val) const
void setProp(const char *key, int val) const
void setProp(const char *key, float val) const
std::string getDescription() const
returns a text description of this entry
Std stuff.
Definition: Atom.h:30
void getProp(const char *key, T &res) const
void clearProp(const char *key) const
boost::tuples::tuple< boost::uint32_t, boost::uint32_t, boost::uint32_t > DiscrimTuple
used to return path discriminators (three unsigned ints):
Definition: SubgraphUtils.h:24
Abstract base class to be used to represent an entry in a Catalog.
Definition: CatalogEntry.h:20
container for user parameters used to create a fragment catalog
Definition: FragCatParams.h:24
RDKIT_RDGENERAL_EXPORT std::ostream & toStream(std::ostream &)
void getProp(const std::string &key, T &res) const
std::map< int, INT_VECT > INT_INT_VECT_MAP
Definition: types.h:282
void setDescription(const std::string &val)
functionality for finding subgraphs and paths in molecules
std::vector< int > PATH_TYPE
Definition: Subgraphs.h:37
The Dict class can be used to store objects of arbitrary type keyed by strings.
Definition: Dict.h:36
bool hasProp(const std::string &key) const
void setProp(const std::string &key, std::string &val) const
#define RDKIT_FRAGCATALOG_EXPORT
Definition: export.h:268