RDKit: TopologicalTorsionGenerator.h Source File

| 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
15#include <GraphMol/Fingerprints/FingerprintGenerator.h>
16#include <GraphMol/Fingerprints/FingerprintUtil.h>
17
18namespace RDKit {
19 namespace TopologicalTorsion {
20
21 class RDKIT_FINGERPRINTS_EXPORT TopologicalTorsionArguments
22 : public FingerprintArguments {
23 public:
24 uint32_t d_torsionAtomCount = 4;
25 bool df_onlyShortestPaths = false;
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 */
43 TopologicalTorsionArguments(
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>
51 class RDKIT_FINGERPRINTS_EXPORT TopologicalTorsionAtomEnv
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;
65 void updateAdditionalOutput(AdditionalOutput *output,
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>
77 class RDKIT_FINGERPRINTS_EXPORT TopologicalTorsionEnvGenerator
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>
124 RDKIT_FINGERPRINTS_EXPORT FingerprintGenerator<OutputType> *
125getTopologicalTorsionGenerator(
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>
133 FingerprintGenerator<OutputType> *getTopologicalTorsionGenerator(
134 const TopologicalTorsionArguments &args,
135 AtomInvariantsGenerator *atomInvariantsGenerator = nullptr,
136 const bool ownsAtomInvGen = false);
137} // namespace TopologicalTorsion
138} // namespace RDKit
139
140#endif
FingerprintGenerator.h
FingerprintUtil.h
RDKit::AtomEnvironmentGenerator
abstract base class that generates atom-environments from a molecule
Definition FingerprintGenerator.h:162
RDKit::AtomEnvironment
abstract base class that holds atom-environments that will be hashed to generate the fingerprint
Definition FingerprintGenerator.h:131
RDKit::AtomInvariantsGenerator
abstract base class for atom invariants generators
Definition FingerprintGenerator.h:227
RDKit::FingerprintArguments
Abstract base class that holds molecule independent arguments that are common amongst all fingerprint...
Definition FingerprintGenerator.h:90
RDKit::FingerprintArguments::FingerprintArguments
FingerprintArguments(bool countSimulation, const std::vector< std::uint32_t > countBounds, std::uint32_t fpSize, std::uint32_t numBitsPerFeature=1, bool includeChirality=false)
RDKit::FingerprintGenerator
class that generates same fingerprint style for different output formats
Definition FingerprintGenerator.h:321
RDKit::ROMol
Definition ROMol.h:199
RDKit::TopologicalTorsion::TopologicalTorsionArguments
Definition TopologicalTorsionGenerator.h:22
RDKit::TopologicalTorsion::TopologicalTorsionArguments::d_torsionAtomCount
uint32_t d_torsionAtomCount
Definition TopologicalTorsionGenerator.h:24
RDKit::TopologicalTorsion::TopologicalTorsionArguments::fromJSON
void fromJSON(const boost::property_tree::ptree &pt) override
RDKit::TopologicalTorsion::TopologicalTorsionArguments::TopologicalTorsionArguments
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.
RDKit::TopologicalTorsion::TopologicalTorsionArguments::toJSON
void toJSON(boost::property_tree::ptree &pt) const override
RDKit::TopologicalTorsion::TopologicalTorsionArguments::infoString
std::string infoString() const override
method that returns information string about the fingerprint specific argument set and the arguments ...
RDKit::TopologicalTorsion::TopologicalTorsionArguments::df_onlyShortestPaths
bool df_onlyShortestPaths
Definition TopologicalTorsionGenerator.h:25
RDKit::TopologicalTorsion::TopologicalTorsionAtomEnv::updateAdditionalOutput
void updateAdditionalOutput(AdditionalOutput *output, size_t bitId) const override
RDKit::TopologicalTorsion::TopologicalTorsionAtomEnv::TopologicalTorsionAtomEnv
TopologicalTorsionAtomEnv(OutputType bitId, INT_VECT atomPath)
Construct a new Topological Torsion Atom Env object.
Definition TopologicalTorsionGenerator.h:72
RDKit::TopologicalTorsion::TopologicalTorsionAtomEnv::getBitId
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
RDKit::TopologicalTorsion::TopologicalTorsionEnvGenerator
Definition TopologicalTorsionGenerator.h:78
RDKit::TopologicalTorsion::TopologicalTorsionEnvGenerator::infoString
std::string infoString() const override
method that returns information about this /c AtomEnvironmentGenerator and its arguments if any
RDKit::TopologicalTorsion::TopologicalTorsionEnvGenerator::fromJSON
void fromJSON(const boost::property_tree::ptree &pt) override
RDKit::TopologicalTorsion::TopologicalTorsionEnvGenerator::toJSON
void toJSON(boost::property_tree::ptree &pt) const override
RDKit::TopologicalTorsion::TopologicalTorsionEnvGenerator::getResultSize
OutputType getResultSize() const override
Returns the size of the fingerprint based on arguments.
RDKit::TopologicalTorsion::TopologicalTorsionEnvGenerator::getEnvironments
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
export.h
RDKIT_FINGERPRINTS_EXPORT
#define RDKIT_FINGERPRINTS_EXPORT
Definition export.h:193
RDKit::TopologicalTorsion
Definition TopologicalTorsionGenerator.h:19
RDKit::TopologicalTorsion::getTopologicalTorsionGenerator
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.
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::INT_VECT
std::vector< int > INT_VECT
Definition types.h:303
RDKit::AdditionalOutput
Definition FingerprintGenerator.h:27