RDKit
Open-source cheminformatics and machine learning.
TopologicalTorsionGenerator.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_TOPOLOGICALTORSIONGEN_H_2018_07
13 #define RD_TOPOLOGICALTORSIONGEN_H_2018_07
14 
17 
18 namespace RDKit {
19 namespace TopologicalTorsion {
20 
21 template <typename OutputType>
23  : public FingerprintArguments<OutputType> {
24  public:
25  const bool df_includeChirality;
26  const uint32_t d_torsionAtomCount;
27 
28  OutputType getResultSize() const override;
29 
30  std::string infoString() const override;
31 
32  /**
33  \brief Construct a new Topological Torsion Arguments object
34 
35  \param includeChirality if set, chirality will be used in sparse result
36  \param torsionAtomCount the number of atoms to include in the "torsions"
37  \param useCountSimulation if set, use count simulation while
38  generating the fingerprint
39  \param countBounds boundaries for count simulation, corresponding bit will
40  be set if the count is higher than the number provided for that spot
41  \param fpSize size of the generated fingerprint, does not affect the sparse
42  versions
43  */
44  TopologicalTorsionArguments(const bool includeChirality,
45  const uint32_t torsionAtomCount,
46  const bool countSimulation,
47  const std::vector<std::uint32_t> countBounds,
48  const std::uint32_t fpSize);
49 };
50 
51 template <typename OutputType>
53  : public AtomEnvironment<OutputType> {
54  const OutputType d_bitId;
55  const INT_VECT d_atomPath;
56 
57  public:
59  const std::vector<std::uint32_t> *atomInvariants,
60  const std::vector<std::uint32_t> *bondInvariants,
61  const AdditionalOutput *additionalOutput,
62  const bool hashResults = false,
63  const std::uint64_t fpSize = 0) const override;
64  /**
65  \brief Construct a new Topological Torsion Atom Env object
66 
67  \param bitId bitId generated for this environment
68  */
69  TopologicalTorsionAtomEnv(OutputType bitId, INT_VECT atomPath)
70  : d_bitId(bitId), d_atomPath(std::move(atomPath)) {}
71 };
72 
73 template <typename OutputType>
75  : public AtomEnvironmentGenerator<OutputType> {
76  public:
77  std::vector<AtomEnvironment<OutputType> *> getEnvironments(
78  const ROMol &mol, FingerprintArguments<OutputType> *arguments,
79  const std::vector<std::uint32_t> *fromAtoms,
80  const std::vector<std::uint32_t> *ignoreAtoms, const int confId,
81  const AdditionalOutput *additionalOutput,
82  const std::vector<std::uint32_t> *atomInvariants,
83  const std::vector<std::uint32_t> *bondInvariants,
84  const bool hashResults = false) const override;
85 
86  std::string infoString() const override;
87 };
88 
89 /**
90  \brief Get the Topological Torsion Generator object
91 
92  \tparam OutputType determines the size of the bitIds and the result, can only
93  be 64 bit unsigned integer for this type
94  \param includeChirality includeChirality argument for both the default atom
95  invariants generator and the fingerprint arguments
96  \param torsionAtomCount the number of atoms to include in the "torsions"
97  \param atomInvariantsGenerator custom atom invariants generator to use
98  \param useCountSimulation if set, use count simulation while
99  generating the fingerprint
100  \param countBounds boundaries for count simulation, corresponding bit will
101  be set if the count is higher than the number provided for that spot
102  \param fpSize size of the generated fingerprint, does not affect the sparse
103  versions
104  \param ownsAtomInvGen if set atom invariants generator is destroyed with the
105  fingerprint generator
106 
107  /return FingerprintGenerator<OutputType>* that generates topological-torsion
108  fingerprints
109 
110  This generator supports the following \c AdditionalOutput types:
111  - \c atomToBits : which bits each atom is involved in
112  - \c atomCounts : how many bits each atom sets
113  - \c bitPaths : map from bitId to vectors of atom indices
114 
115  */
116 template <typename OutputType>
119  const bool includeChirality = false, const uint32_t torsionAtomCount = 4,
120  AtomInvariantsGenerator *atomInvariantsGenerator = nullptr,
121  const bool countSimulation = true,
122  const std::vector<std::uint32_t> countBounds = {1, 2, 4, 8},
123  const std::uint32_t fpSize = 2048, const bool ownsAtomInvGen = false);
124 } // namespace TopologicalTorsion
125 } // namespace RDKit
126 
127 #endif
abstract base class that generates atom-environments from a molecule
abstract base class that holds atom-environments that will be hashed to generate the fingerprint
abstract base class for atom invariants generators
Abstract base class that holds molecule independent arguments that are common amongst all fingerprint...
class that generates same fingerprint style for different output formats
OutputType getResultSize() const override
Returns the size of the fingerprint based on arguments.
TopologicalTorsionArguments(const bool includeChirality, const uint32_t torsionAtomCount, const bool countSimulation, const std::vector< std::uint32_t > countBounds, const std::uint32_t fpSize)
Construct a new Topological Torsion Arguments object.
std::string infoString() const override
method that returns information string about the fingerprint specific argument set and the arguments ...
OutputType getBitId(FingerprintArguments< OutputType > *arguments, const std::vector< std::uint32_t > *atomInvariants, const std::vector< std::uint32_t > *bondInvariants, const AdditionalOutput *additionalOutput, const bool hashResults=false, const std::uint64_t fpSize=0) const override
calculates and returns the bit id to be set for this atom-environment
TopologicalTorsionAtomEnv(OutputType bitId, INT_VECT atomPath)
Construct a new Topological Torsion Atom Env object.
std::string infoString() const override
method that returns information about this /c AtomEnvironmentGenerator and its arguments if any
std::vector< AtomEnvironment< OutputType > * > getEnvironments(const ROMol &mol, FingerprintArguments< OutputType > *arguments, const std::vector< std::uint32_t > *fromAtoms, const std::vector< std::uint32_t > *ignoreAtoms, const int confId, const AdditionalOutput *additionalOutput, const std::vector< std::uint32_t > *atomInvariants, const std::vector< std::uint32_t > *bondInvariants, const bool hashResults=false) const override
generate and return all atom-envorinments from a molecule
#define RDKIT_FINGERPRINTS_EXPORT
Definition: export.h:169
RDKIT_FINGERPRINTS_EXPORT FingerprintGenerator< OutputType > * getTopologicalTorsionGenerator(const bool includeChirality=false, const uint32_t torsionAtomCount=4, AtomInvariantsGenerator *atomInvariantsGenerator=nullptr, const bool countSimulation=true, const std::vector< std::uint32_t > countBounds={1, 2, 4, 8}, const std::uint32_t fpSize=2048, const bool ownsAtomInvGen=false)
Get the Topological Torsion Generator object.
Std stuff.
Definition: Abbreviations.h:18
std::vector< int > INT_VECT
Definition: types.h:277