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