RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
TopologicalTorsionGenerator.h
Go to the documentation of this file.
1//
2// Copyright (C) 2018-2022 Boran Adas and other RDKit contributors
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
18namespace RDKit {
20
22 : public FingerprintArguments {
23 public:
24 uint32_t d_torsionAtomCount = 4;
26
27 std::string infoString() const override;
28 void toJSON(boost::property_tree::ptree &pt) const override;
29 void fromJSON(const boost::property_tree::ptree &pt) override;
30
31 /**
32 \brief Construct a new Topological Torsion Arguments object
33
34 \param includeChirality if set, chirality will be used in sparse result
35 \param torsionAtomCount the number of atoms to include in the "torsions"
36 \param useCountSimulation if set, use count simulation while
37 generating the fingerprint
38 \param countBounds boundaries for count simulation, corresponding bit will
39 be set if the count is higher than the number provided for that spot
40 \param fpSize size of the generated fingerprint, does not affect the sparse
41 versions
42 */
44 const bool includeChirality = false, const uint32_t torsionAtomCount = 4,
45 const bool countSimulation = true,
46 const std::vector<std::uint32_t> countBounds = {1, 2, 4, 8},
47 const std::uint32_t fpSize = 2048);
48};
49
50template <typename OutputType>
52 : public AtomEnvironment<OutputType> {
53 const OutputType d_bitId;
54 const INT_VECT d_atomPath;
55
56 public:
57 OutputType getBitId(
58 FingerprintArguments *arguments, // unused
59 const std::vector<std::uint32_t> *atomInvariants, // unused
60 const std::vector<std::uint32_t> *bondInvariants, // unused
61 AdditionalOutput *additionalOutput, // unused
62 const bool hashResults = false, // unused
63 const std::uint64_t fpSize = 0 // unused
64 ) const override;
66 size_t bitId) const override;
67 /**
68 \brief Construct a new Topological Torsion Atom Env object
69
70 \param bitId bitId generated for this environment
71 */
72 TopologicalTorsionAtomEnv(OutputType bitId, INT_VECT atomPath)
73 : d_bitId(bitId), d_atomPath(std::move(atomPath)) {}
74};
75
76template <typename OutputType>
78 : public AtomEnvironmentGenerator<OutputType> {
79 public:
80 std::vector<AtomEnvironment<OutputType> *> getEnvironments(
81 const ROMol &mol, FingerprintArguments *arguments,
82 const std::vector<std::uint32_t> *fromAtoms,
83 const std::vector<std::uint32_t> *ignoreAtoms, const int confId,
84 const AdditionalOutput *additionalOutput,
85 const std::vector<std::uint32_t> *atomInvariants,
86 const std::vector<std::uint32_t> *bondInvariants,
87 const bool hashResults = false) const override;
88
89 std::string infoString() const override;
90 void toJSON(boost::property_tree::ptree &pt) const override;
91 void fromJSON(const boost::property_tree::ptree &pt) override;
92
93 OutputType getResultSize() const override;
94};
95
96/**
97 \brief Get the Topological Torsion Generator object
98
99 \tparam OutputType determines the size of the bitIds and the result, can only
100 be 64 bit unsigned integer for this type
101 \param includeChirality includeChirality argument for both the default atom
102 invariants generator and the fingerprint arguments
103 \param torsionAtomCount the number of atoms to include in the "torsions"
104 \param atomInvariantsGenerator custom atom invariants generator to use
105 \param useCountSimulation if set, use count simulation while
106 generating the fingerprint
107 \param countBounds boundaries for count simulation, corresponding bit will
108 be set if the count is higher than the number provided for that spot
109 \param fpSize size of the generated fingerprint, does not affect the sparse
110 versions
111 \param ownsAtomInvGen if set atom invariants generator is destroyed with the
112 fingerprint generator
113
114 /return FingerprintGenerator<OutputType>* that generates topological-torsion
115 fingerprints
116
117 This generator supports the following \c AdditionalOutput types:
118 - \c atomToBits : which bits each atom is involved in
119 - \c atomCounts : how many bits each atom sets
120 - \c bitPaths : map from bitId to vectors of atom indices
121
122 */
123template <typename OutputType>
126 bool includeChirality = false, uint32_t torsionAtomCount = 4,
127 AtomInvariantsGenerator *atomInvariantsGenerator = nullptr,
128 bool countSimulation = true, std::uint32_t fpSize = 2048,
129 std::vector<std::uint32_t> countBounds = {1, 2, 4, 8},
130 bool ownsAtomInvGen = false);
131//! overload
132template <typename OutputType>
134 const TopologicalTorsionArguments &args,
135 AtomInvariantsGenerator *atomInvariantsGenerator = nullptr,
136 const bool ownsAtomInvGen = false);
137} // namespace TopologicalTorsion
138} // namespace RDKit
139
140#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...
FingerprintArguments(bool countSimulation, const std::vector< std::uint32_t > countBounds, std::uint32_t fpSize, std::uint32_t numBitsPerFeature=1, bool includeChirality=false)
class that generates same fingerprint style for different output formats
void fromJSON(const boost::property_tree::ptree &pt) override
TopologicalTorsionArguments(const bool includeChirality=false, const uint32_t torsionAtomCount=4, const bool countSimulation=true, const std::vector< std::uint32_t > countBounds={1, 2, 4, 8}, const std::uint32_t fpSize=2048)
Construct a new Topological Torsion Arguments object.
void toJSON(boost::property_tree::ptree &pt) const override
std::string infoString() const override
method that returns information string about the fingerprint specific argument set and the arguments ...
void updateAdditionalOutput(AdditionalOutput *output, size_t bitId) const override
TopologicalTorsionAtomEnv(OutputType bitId, INT_VECT atomPath)
Construct a new Topological Torsion Atom Env object.
OutputType getBitId(FingerprintArguments *arguments, const std::vector< std::uint32_t > *atomInvariants, const std::vector< std::uint32_t > *bondInvariants, 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
std::string infoString() const override
method that returns information about this /c AtomEnvironmentGenerator and its arguments if any
void fromJSON(const boost::property_tree::ptree &pt) override
void toJSON(boost::property_tree::ptree &pt) const override
OutputType getResultSize() const override
Returns the size of the fingerprint based on arguments.
std::vector< AtomEnvironment< OutputType > * > getEnvironments(const ROMol &mol, FingerprintArguments *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:193
RDKIT_FINGERPRINTS_EXPORT FingerprintGenerator< OutputType > * getTopologicalTorsionGenerator(bool includeChirality=false, uint32_t torsionAtomCount=4, AtomInvariantsGenerator *atomInvariantsGenerator=nullptr, bool countSimulation=true, std::uint32_t fpSize=2048, std::vector< std::uint32_t > countBounds={1, 2, 4, 8}, bool ownsAtomInvGen=false)
Get the Topological Torsion Generator object.
Std stuff.
std::vector< int > INT_VECT
Definition types.h:303