RDKit
Open-source cheminformatics and machine learning.
AtomPairGenerator.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2018 Boran Adas, Google Summer of Code
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 
11 #include <RDGeneral/export.h>
12 #ifndef RD_ATOMPAIRGEN_H_2018_06
13 #define RD_ATOMPAIRGEN_H_2018_06
14 
17 
18 namespace RDKit {
19 namespace AtomPair {
20 using namespace AtomPairs;
21 
23  : public AtomInvariantsGenerator {
24  const bool df_includeChirality;
25  const bool df_topologicalTorsionCorrection;
26 
27  public:
28  /**
29  \brief Construct a new AtomPairAtomInvGenerator object
30 
31  \param includeChirality toggles the inclusions of bits indicating R/S
32  chirality
33  \param topologicalTorsionCorrection when set subtracts 2 from invariants
34  returned, added so TopologicalTorsionGenerator can use this
35  */
36  AtomPairAtomInvGenerator(bool includeChirality = false,
37  bool topologicalTorsionCorrection = false);
38 
39  std::vector<std::uint32_t> *getAtomInvariants(const ROMol &mol) const;
40 
41  std::string infoString() const;
42  AtomPairAtomInvGenerator *clone() const;
43 };
44 
45 /*!
46  \brief class that holds atom-pair fingerprint specific arguments
47 
48  */
49 template <typename OutputType>
51  : public FingerprintArguments<OutputType> {
52  public:
53  const bool df_includeChirality;
54  const bool df_use2D;
55  const unsigned int d_minDistance;
56  const unsigned int d_maxDistance;
57 
58  OutputType getResultSize() const;
59 
60  std::string infoString() const;
61 
62  /*!
63  \brief construct a new AtomPairArguments object
64 
65  \param countSimulation if set, use count simulation while generating the
66  fingerprint
67  \param includeChirality if set, chirality will be used in the atom
68  invariants, this is ignored if atomInvariantsGenerator is present for
69  the /c FingerprintGenerator that uses this
70  \param use2D if set, the 2D (topological) distance matrix will be
71  used
72  \param minDistance minimum distance between atoms to be considered in a
73  pair, default is 1 bond
74  \param maxDistance maximum distance between atoms to be considered in a
75  pair, default is maxPathLen-1 bonds
76  \param countBounds boundaries for count simulation, corresponding bit
77  will be set if the count is higher than the number provided for that spot
78  \param fpSize size of the generated fingerprint, does not affect the sparse
79  versions
80 
81  */
82  AtomPairArguments(const bool countSimulation = true,
83  const bool includeChirality = false,
84  const bool use2D = true, const unsigned int minDistance = 1,
85  const unsigned int maxDistance = (maxPathLen - 1),
86  const std::vector<std::uint32_t> countBounds = {1, 2, 4, 8},
87  const std::uint32_t fpSize = 2048);
88 };
89 
90 /*!
91  \brief class that holds atom-environment data needed for atom-pair fingerprint
92  generation
93 
94  */
95 template <typename OutputType>
97  : public AtomEnvironment<OutputType> {
98  const unsigned int d_atomIdFirst;
99  const unsigned int d_atomIdSecond;
100  const unsigned int d_distance;
101 
102  public:
103  OutputType getBitId(FingerprintArguments<OutputType> *arguments,
104  const std::vector<std::uint32_t> *atomInvariants,
105  const std::vector<std::uint32_t> *bondInvariants,
106  const AdditionalOutput *additionalOutput,
107  const bool hashResults = false) const;
108 
109  /*!
110  \brief construct a new AtomPairAtomEnv object
111 
112  \param atomIdFirst id of the first atom of the atom-pair
113  \param atomIdSecond id of the second atom of the atom-pair
114  \param distance distance between the atoms
115  */
116  AtomPairAtomEnv(const unsigned int atomIdFirst,
117  const unsigned int atomIdSecond, const unsigned int distance);
118 };
119 
120 /*!
121  \brief class that generates atom-environments for atom-pair fingerprint
122 
123  */
124 template <typename OutputType>
126  : public AtomEnvironmentGenerator<OutputType> {
127  public:
128  std::vector<AtomEnvironment<OutputType> *> getEnvironments(
129  const ROMol &mol, FingerprintArguments<OutputType> *arguments,
130  const std::vector<std::uint32_t> *fromAtoms,
131  const std::vector<std::uint32_t> *ignoreAtoms, const int confId,
132  const AdditionalOutput *additionalOutput,
133  const std::vector<std::uint32_t> *atomInvariants,
134  const std::vector<std::uint32_t> *bondInvariants,
135  const bool hashResults = false) const;
136 
137  std::string infoString() const;
138 };
139 
140 /*!
141  \brief helper function that generates a /c FingerprintGenerator that generates
142  atom-pair fingerprints
143  \tparam OutputType determines the size of the bitIds and the result, can be 32
144  or 64 bit unsigned integer
145  \param minDistance minimum distance between atoms to be considered in a pair,
146  default is 1 bond
147  \param maxDistance maximum distance between atoms to be considered in a pair,
148  default is maxPathLen-1 bonds
149  \param includeChirality if set, chirality will be used in the atom invariants,
150  this is ignored if atomInvariantsGenerator is provided
151  \param use2D if set, the 2D (topological) distance matrix will be used
152  \param atomInvariantsGenerator atom invariants to be used during fingerprint
153  generation
154  \param useCountSimulation if set, use count simulation while generating the
155  fingerprint
156  \param countBounds boundaries for count simulation, corresponding bit will be
157  set if the count is higher than the number provided for that spot
158  \param fpSize size of the generated fingerprint, does not affect the sparse
159  versions
160  \param ownsAtomInvGen if set atom invariants generator is destroyed with the
161  fingerprint generator
162 
163  \return FingerprintGenerator<OutputType>* that generates atom-pair
164  fingerprints
165  */
166 template <typename OutputType>
169  const unsigned int minDistance = 1,
170  const unsigned int maxDistance = maxPathLen - 1,
171  const bool includeChirality = false, const bool use2D = true,
172  AtomInvariantsGenerator *atomInvariantsGenerator = nullptr,
173  const bool useCountSimulation = true, const std::uint32_t fpSize = 2048,
174  const std::vector<std::uint32_t> countBounds = {1, 2, 4, 8},
175  const bool ownsAtomInvGen = false);
176 
177 } // namespace AtomPair
178 } // namespace RDKit
179 
180 #endif
abstract base class that holds atom-environments that will be hashed to generate the fingerprint ...
const unsigned int maxPathLen
RDKIT_FINGERPRINTS_EXPORT FingerprintGenerator< OutputType > * getAtomPairGenerator(const unsigned int minDistance=1, const unsigned int maxDistance=maxPathLen - 1, const bool includeChirality=false, const bool use2D=true, AtomInvariantsGenerator *atomInvariantsGenerator=nullptr, const bool useCountSimulation=true, const std::uint32_t fpSize=2048, const std::vector< std::uint32_t > countBounds={1, 2, 4, 8}, const bool ownsAtomInvGen=false)
helper function that generates a /c FingerprintGenerator that generates atom-pair fingerprints ...
abstract base class for atom invariants generators
class that generates atom-environments for atom-pair fingerprint
class that holds atom-environment data needed for atom-pair fingerprint generation ...
abstract base class that generates atom-environments from a molecule
Std stuff.
Definition: Atom.h:30
#define RDKIT_FINGERPRINTS_EXPORT
Definition: export.h:229
class that holds atom-pair fingerprint specific arguments
class that generates same fingerprint style for different output formats
Abstract base class that holds molecule independent arguments that are common amongst all fingerprint...