RDKit: FragCatalogEntry.h Source File

| RDKit Open-source cheminformatics and machine learning.

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