RDKitFPGenerator.h
Go to the documentation of this file.
//
// Copyright (C) 2018 Boran Adas, Google Summer of Code
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <RDGeneral/export.h>
#ifndef RD_RDFINGERPRINTGEN_H_2018_07
#define RD_RDFINGERPRINTGEN_H_2018_07
#include <GraphMol/Fingerprints/FingerprintGenerator.h>
namespace RDKit {
namespace RDKitFP {
template <typename OutputType>
class RDKIT_FINGERPRINTS_EXPORT RDKitFPArguments
: public FingerprintArguments<OutputType> {
public:
const unsigned int d_minPath;
const unsigned int d_maxPath;
const bool df_useHs;
const bool df_branchedPaths;
const bool df_useBondOrder;
OutputType getResultSize() const override;
std::string infoString() const override;
/**
\brief Construct a new RDKitFPArguments object
\param minPath the minimum path length (in bonds) to be included
\param maxPath the maximum path length (in bonds) to be included
\param useHs toggles inclusion of Hs in paths (if the molecule has
explicit Hs)
\param branchedPaths toggles generation of branched subgraphs, not just
linear paths
\param useBondOrder toggles inclusion of bond orders in the path hashes
\param countSimulation if set, use count simulation while
generating the fingerprint
\param countBounds boundaries for count simulation, corresponding bit will
be set if the count is higher than the number provided for that spot
\param fpSize size of the generated fingerprint, does not affect the sparse
versions
\param numBitsPerFeature controls the number of bits that are set for each
path/subgraph found
*/
RDKitFPArguments(unsigned int minPath, unsigned int maxPath, bool useHs,
bool branchedPaths, bool useBondOrder, bool countSimulation,
const std::vector<std::uint32_t> countBounds,
std::uint32_t fpSize, std::uint32_t numBitsPerFeature);
};
class RDKIT_FINGERPRINTS_EXPORT RDKitFPAtomInvGenerator
: public AtomInvariantsGenerator {
public:
std::vector<std::uint32_t> *getAtomInvariants(
const ROMol &mol) const override;
std::string infoString() const override;
RDKitFPAtomInvGenerator *clone() const override;
};
template <typename OutputType>
class RDKIT_FINGERPRINTS_EXPORT RDKitFPAtomEnv
: public AtomEnvironment<OutputType> {
const OutputType d_bitId;
const boost::dynamic_bitset<> d_atomsInPath;
const INT_VECT d_bondPath;
public:
OutputType getBitId(FingerprintArguments<OutputType> *arguments,
const std::vector<std::uint32_t> *atomInvariants,
const std::vector<std::uint32_t> *bondInvariants,
const AdditionalOutput *additionalOutput,
bool hashResults = false,
const std::uint64_t fpSize = 0) const override;
/**
\brief Construct a new RDKitFPAtomEnv object
\param bitId bitId generated for this environment
\param atomsInPath holds atoms in this environment to set additional output
\param bondPath the bond path defining the environment
*/
RDKitFPAtomEnv(const OutputType bitId, boost::dynamic_bitset<> atomsInPath,
INT_VECT bondPath)
: d_bitId(bitId),
d_atomsInPath(std::move(atomsInPath)),
d_bondPath(std::move(bondPath)) {}
};
template <typename OutputType>
class RDKIT_FINGERPRINTS_EXPORT RDKitFPEnvGenerator
: public AtomEnvironmentGenerator<OutputType> {
public:
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, int confId,
const AdditionalOutput *additionalOutput,
const std::vector<std::uint32_t> *atomInvariants,
const std::vector<std::uint32_t> *bondInvariants,
bool hashResults = false) const override;
std::string infoString() const override;
};
/**
\brief Get a RDKit fingerprint generator with given parameters
\tparam OutputType determines the size of the bitIds and the result, can be 32
or 64 bit unsigned integer
\param minPath the minimum path length (in bonds) to be included
\param maxPath the maximum path length (in bonds) to be included
\param useHs toggles inclusion of Hs in paths (if the molecule has
explicit Hs)
\param branchedPaths toggles generation of branched subgraphs, not just
linear paths
\param useBondOrder toggles inclusion of bond orders in the path hashes
\param atomInvariantsGenerator custom atom invariants generator to use
\param countSimulation if set, use count simulation while
generating the fingerprint
\param countBounds boundaries for count simulation, corresponding bit will be
set if the count is higher than the number provided for that spot
\param fpSize size of the generated fingerprint, does not affect the sparse
versions
\param numBitsPerFeature controls the number of bits that are set for each
path/subgraph found
\param ownsAtomInvGen if set atom invariants generator is destroyed with the
fingerprint generator
/return FingerprintGenerator<OutputType>* that generates RDKit fingerprints
This generator supports the following \c AdditionalOutput types:
- \c atomToBits : which bits each atom is involved in
- \c atomCounts : how many bits each atom sets
- \c bitPaths : map from bitId to vectors of bond indices for the individual
subgraphs
*/
template <typename OutputType>
RDKIT_FINGERPRINTS_EXPORT FingerprintGenerator<OutputType> *getRDKitFPGenerator(
unsigned int minPath = 1, unsigned int maxPath = 7, bool useHs = true,
bool branchedPaths = true, bool useBondOrder = true,
AtomInvariantsGenerator *atomInvariantsGenerator = nullptr,
bool countSimulation = false,
const std::vector<std::uint32_t> countBounds = {1, 2, 4, 8},
std::uint32_t fpSize = 2048, std::uint32_t numBitsPerFeature = 2,
bool ownsAtomInvGen = false);
} // namespace RDKitFP
} // namespace RDKit
#endif
FingerprintGenerator.h
RDKit::AtomEnvironmentGenerator
abstract base class that generates atom-environments from a molecule
Definition: FingerprintGenerator.h:153
RDKit::AtomEnvironment
abstract base class that holds atom-environments that will be hashed to generate the fingerprint
Definition: FingerprintGenerator.h:124
RDKit::AtomInvariantsGenerator
abstract base class for atom invariants generators
Definition: FingerprintGenerator.h:207
RDKit::FingerprintArguments
Abstract base class that holds molecule independent arguments that are common amongst all fingerprint...
Definition: FingerprintGenerator.h:81
RDKit::FingerprintGenerator
class that generates same fingerprint style for different output formats
Definition: FingerprintGenerator.h:269
RDKit::RDKitFP::RDKitFPArguments
Definition: RDKitFPGenerator.h:22
RDKit::RDKitFP::RDKitFPArguments::df_useHs
const bool df_useHs
Definition: RDKitFPGenerator.h:26
RDKit::RDKitFP::RDKitFPArguments::infoString
std::string infoString() const override
method that returns information string about the fingerprint specific argument set and the arguments ...
RDKit::RDKitFP::RDKitFPArguments::d_minPath
const unsigned int d_minPath
Definition: RDKitFPGenerator.h:24
RDKit::RDKitFP::RDKitFPArguments::RDKitFPArguments
RDKitFPArguments(unsigned int minPath, unsigned int maxPath, bool useHs, bool branchedPaths, bool useBondOrder, bool countSimulation, const std::vector< std::uint32_t > countBounds, std::uint32_t fpSize, std::uint32_t numBitsPerFeature)
Construct a new RDKitFPArguments object.
RDKit::RDKitFP::RDKitFPArguments::getResultSize
OutputType getResultSize() const override
Returns the size of the fingerprint based on arguments.
RDKit::RDKitFP::RDKitFPArguments::df_useBondOrder
const bool df_useBondOrder
Definition: RDKitFPGenerator.h:28
RDKit::RDKitFP::RDKitFPArguments::df_branchedPaths
const bool df_branchedPaths
Definition: RDKitFPGenerator.h:27
RDKit::RDKitFP::RDKitFPArguments::d_maxPath
const unsigned int d_maxPath
Definition: RDKitFPGenerator.h:25
RDKit::RDKitFP::RDKitFPAtomEnv
Definition: RDKitFPGenerator.h:72
RDKit::RDKitFP::RDKitFPAtomEnv::RDKitFPAtomEnv
RDKitFPAtomEnv(const OutputType bitId, boost::dynamic_bitset<> atomsInPath, INT_VECT bondPath)
Construct a new RDKitFPAtomEnv object.
Definition: RDKitFPGenerator.h:93
RDKit::RDKitFP::RDKitFPAtomEnv::getBitId
OutputType getBitId(FingerprintArguments< OutputType > *arguments, const std::vector< std::uint32_t > *atomInvariants, const std::vector< std::uint32_t > *bondInvariants, const AdditionalOutput *additionalOutput, 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::RDKitFP::RDKitFPAtomInvGenerator
Definition: RDKitFPGenerator.h:61
RDKit::RDKitFP::RDKitFPAtomInvGenerator::clone
RDKitFPAtomInvGenerator * clone() const override
RDKit::RDKitFP::RDKitFPAtomInvGenerator::getAtomInvariants
std::vector< std::uint32_t > * getAtomInvariants(const ROMol &mol) const override
get atom invariants from a molecule
RDKit::RDKitFP::RDKitFPAtomInvGenerator::infoString
std::string infoString() const override
method that returns information about this /c AtomInvariantsGenerator and its arguments
RDKit::RDKitFP::RDKitFPEnvGenerator
Definition: RDKitFPGenerator.h:102
RDKit::RDKitFP::RDKitFPEnvGenerator::getEnvironments
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, int confId, const AdditionalOutput *additionalOutput, const std::vector< std::uint32_t > *atomInvariants, const std::vector< std::uint32_t > *bondInvariants, bool hashResults=false) const override
generate and return all atom-envorinments from a molecule
RDKit::RDKitFP::RDKitFPEnvGenerator::infoString
std::string infoString() const override
method that returns information about this /c AtomEnvironmentGenerator and its arguments if any
RDKit::ROMol
Definition: ROMol.h:178
export.h
RDKIT_FINGERPRINTS_EXPORT
#define RDKIT_FINGERPRINTS_EXPORT
Definition: export.h:169
RDKit::RDKitFP::getRDKitFPGenerator
RDKIT_FINGERPRINTS_EXPORT FingerprintGenerator< OutputType > * getRDKitFPGenerator(unsigned int minPath=1, unsigned int maxPath=7, bool useHs=true, bool branchedPaths=true, bool useBondOrder=true, AtomInvariantsGenerator *atomInvariantsGenerator=nullptr, bool countSimulation=false, const std::vector< std::uint32_t > countBounds={1, 2, 4, 8}, std::uint32_t fpSize=2048, std::uint32_t numBitsPerFeature=2, bool ownsAtomInvGen=false)
Get a RDKit fingerprint generator with given parameters.
RDKit
Std stuff.
Definition: Abbreviations.h:18
RDKit::INT_VECT
std::vector< int > INT_VECT
Definition: types.h:274
RDKit::RDKitFP
@ RDKitFP
Definition: ReactionFingerprints.h:47
RDKit::AdditionalOutput
Definition: FingerprintGenerator.h:26