RDKit: FingerprintGenerator.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
FingerprintGenerator.h
Go to the documentation of this file.
1//
2// Copyright (C) 2018-2025 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_FINGERPRINTGEN_H_2018_05
13#define RD_FINGERPRINTGEN_H_2018_05
14
15#include <DataStructs/SparseIntVect.h>
16#include <DataStructs/ExplicitBitVect.h>
17#include <DataStructs/SparseBitVect.h>
18#include <utility>
19#include <vector>
20#include <memory>
21#include <cstdint>
22#include <boost/property_tree/ptree_fwd.hpp>
23
24namespace RDKit {
25class ROMol;
26
27 struct RDKIT_FINGERPRINTS_EXPORT AdditionalOutput {
28 using atomToBitsType = std::vector<std::vector<std::uint64_t>>;
29 using bitInfoMapType =
30 std::map<std::uint64_t,
31 std::vector<std::pair<std::uint32_t, std::uint32_t>>>;
32 using bitPathsType = std::map<std::uint64_t, std::vector<std::vector<int>>>;
33 using atomCountsType = std::vector<unsigned int>;
34 using atomsPerBitType =
35 std::map<std::uint64_t, std::vector<std::vector<int>>>;
36
37 // numAtoms long
38 atomToBitsType *atomToBits = nullptr;
39
40 // bitId -> vector of (atomId, radius) for morgan
41 // bitId -> (atom1, atom2) for atom pairs
42 bitInfoMapType *bitInfoMap = nullptr;
43
44 // rdkit fp
45 // maps bitId -> vector of bond paths
46 bitPathsType *bitPaths = nullptr;
47
48 // number of paths that set bits for each atom, must have the same size as
49 // atom count for molecule.
50 atomCountsType *atomCounts = nullptr;
51
52 // maps bitId -> vector of atoms involved in setting that bit
53 atomsPerBitType *atomsPerBit = nullptr;
54
55 void allocateAtomToBits() {
56 atomToBitsHolder.reset(new atomToBitsType);
57 atomToBits = atomToBitsHolder.get();
58 }
59 void allocateBitInfoMap() {
60 bitInfoMapHolder.reset(new bitInfoMapType);
61 bitInfoMap = bitInfoMapHolder.get();
62 }
63 void allocateBitPaths() {
64 bitPathsHolder.reset(new bitPathsType);
65 bitPaths = bitPathsHolder.get();
66 }
67 void allocateAtomCounts() {
68 atomCountsHolder.reset(new atomCountsType);
69 atomCounts = atomCountsHolder.get();
70 }
71 void allocateAtomsPerBit() {
72 atomsPerBitHolder.reset(new atomsPerBitType);
73 atomsPerBit = atomsPerBitHolder.get();
74 }
75
76 private:
77 std::unique_ptr<atomToBitsType> atomToBitsHolder;
78 std::unique_ptr<bitInfoMapType> bitInfoMapHolder;
79 std::unique_ptr<bitPathsType> bitPathsHolder;
80 std::unique_ptr<atomCountsType> atomCountsHolder;
81 std::unique_ptr<atomsPerBitType> atomsPerBitHolder;
82};
83
84/*!
85 \brief Abstract base class that holds molecule independent arguments that are
86 common amongst all fingerprint types and classes inherited from this would
87 hold fingerprint type specific arguments
88
89 */
90 class RDKIT_FINGERPRINTS_EXPORT FingerprintArguments {
91 public:
92 FingerprintArguments(bool countSimulation,
93 const std::vector<std::uint32_t> countBounds,
94 std::uint32_t fpSize,
95 std::uint32_t numBitsPerFeature = 1,
96 bool includeChirality = false);
97 bool df_countSimulation = false;
98 bool df_includeChirality = false;
99 std::vector<std::uint32_t> d_countBounds;
100 std::uint32_t d_fpSize = 2048;
101 std::uint32_t d_numBitsPerFeature = 1;
102
103 /**
104 \brief method that returns information string about the fingerprint specific
105 argument set and the arguments themselves
106
107 \return std::string information string
108 */
109 virtual std::string infoString() const = 0;
110 virtual void toJSON(boost::property_tree::ptree &pt) const;
111 virtual void fromJSON(const boost::property_tree::ptree &pt);
112
113 /**
114 \brief method that returns information string about common fingerprinting
115 arguments' values
116
117 \return std::string information string
118 */
119 std::string commonArgumentsString() const;
120
121 virtual ~FingerprintArguments() {}
122 FingerprintArguments() = default;
123};
124
125/*!
126 \brief abstract base class that holds atom-environments that will be hashed to
127 generate the fingerprint
128
129 */
130template <typename OutputType>
131 class RDKIT_FINGERPRINTS_EXPORT AtomEnvironment : private boost::noncopyable {
132 public:
133 /*!
134 \brief calculates and returns the bit id to be set for this atom-environment
135
136 \param arguments Fingerprinting type specific molecule independent
137 arguments
138 \param atomInvariants Atom-invariants to be used during hashing
139 \param bondInvariants Bond-invariants to be used during hashing
140 \param hashResults if set results will be ready to be modded
141
142 \return OutputType calculated bit id for this environment
143 */
144 virtual OutputType getBitId(FingerprintArguments *arguments,
145 const std::vector<std::uint32_t> *atomInvariants,
146 const std::vector<std::uint32_t> *bondInvariants,
147 AdditionalOutput *AdditionalOutput,
148 const bool hashResults = false,
149 const std::uint64_t fpSize = 0) const = 0;
150 virtual void updateAdditionalOutput(AdditionalOutput *AdditionalOutput,
151 size_t bitId) const = 0;
152
153 virtual ~AtomEnvironment() {}
154};
155
156/*!
157 \brief abstract base class that generates atom-environments from a molecule
158
159 */
160template <typename OutputType>
161 class RDKIT_FINGERPRINTS_EXPORT AtomEnvironmentGenerator
162 : private boost::noncopyable {
163 public:
164 /*!
165 \brief generate and return all atom-envorinments from a molecule
166
167 \param mol molecule to generate the atom-environments from
168 \param arguments fingerprint type specific molecule independent
169 arguments
170 \param fromAtoms atoms to be used during environment generation,
171 usage of this parameter depends on the implementation of different
172 fingerprint types
173 \param ignoreAtoms atoms to be ignored during environment generation,
174 usage of this parameter depends on the implementation of different
175 fingerprint types
176 \param confId which conformation to use during environment
177 generation, needed for some fingerprint types
178 \param additionalOutput contains pointers for additional outputs of
179 fingerprinting operation, usage depends on implementation of the fingerprint
180 type
181 \param atomInvariants atom invariants to be used during environment
182 generation, in some cases some of the hashing can be done during environment
183 generation so it is also passed here
184 \param bondInvariants bond invariants to be used during environment
185 generation, same as atomInvariants it might be needed
186 \param hashResults if set results will be ready to be modded
187
188 \return std::vector<AtomEnvironment *> atom-environments generated from
189 this molecule
190 */
191 virtual std::vector<AtomEnvironment<OutputType> *> getEnvironments(
192 const ROMol &mol, FingerprintArguments *arguments,
193 const std::vector<std::uint32_t> *fromAtoms = nullptr,
194 const std::vector<std::uint32_t> *ignoreAtoms = nullptr,
195 const int confId = -1, const AdditionalOutput *additionalOutput = nullptr,
196 const std::vector<std::uint32_t> *atomInvariants = nullptr,
197 const std::vector<std::uint32_t> *bondInvariants = nullptr,
198 const bool hashResults = false) const = 0;
199
200 /**
201 \brief method that returns information about this /c AtomEnvironmentGenerator
202 and its arguments if any
203
204 \return std::string information string
205 */
206 virtual std::string infoString() const = 0;
207 virtual void toJSON(boost::property_tree::ptree &) const {};
208 virtual void fromJSON(const boost::property_tree::ptree &) {};
209
210 /*!
211 \brief Returns the size of the fingerprint based on arguments
212
213 \return OutputType size of the fingerprint
214 */
215 virtual OutputType getResultSize() const = 0;
216
217 const FingerprintArguments *dp_fingerprintArguments;
218
219 virtual ~AtomEnvironmentGenerator() {}
220};
221
222/*!
223 \brief abstract base class for atom invariants generators
224
225 */
226 class RDKIT_FINGERPRINTS_EXPORT AtomInvariantsGenerator
227 : private boost::noncopyable {
228 public:
229 /*!
230 \brief get atom invariants from a molecule
231
232 \param mol molecule to generate the atom invariants for
233
234 \return std::vector<std::uint32_t> atom invariants generated for the given
235 molecule
236 */
237 virtual std::vector<std::uint32_t> *getAtomInvariants(
238 const ROMol &mol) const = 0;
239
240 /**
241 \brief method that returns information about this /c AtomInvariantsGenerator
242 and its arguments
243
244 \return std::string information string
245 */
246 virtual std::string infoString() const = 0;
247 virtual void toJSON(boost::property_tree::ptree &) const {};
248 virtual void fromJSON(const boost::property_tree::ptree &) {};
249
250 virtual ~AtomInvariantsGenerator() {}
251 virtual AtomInvariantsGenerator *clone() const = 0;
252};
253
254/*!
255 \brief abstract base class for bond invariants generators
256
257 */
258 class RDKIT_FINGERPRINTS_EXPORT BondInvariantsGenerator
259 : private boost::noncopyable {
260 public:
261 /*!
262 \brief get bond invariants from a molecule
263
264 \param mol molecule to generate the bond invariants for
265
266 \return std::vector<std::uint32_t> bond invariants generated for the given
267 molecule
268 */
269 virtual std::vector<std::uint32_t> *getBondInvariants(
270 const ROMol &mol) const = 0;
271
272 /**
273 \brief method that returns information about this /c BondInvariantsGenerator
274 and its arguments
275
276 \return std::string information string
277 */
278 virtual std::string infoString() const = 0;
279 virtual void toJSON(boost::property_tree::ptree &) const {};
280 virtual void fromJSON(const boost::property_tree::ptree &) {};
281
282 virtual ~BondInvariantsGenerator() {}
283 virtual BondInvariantsGenerator *clone() const = 0;
284}; // namespace RDKit
285
286/*!
287 \brief struct that makes calling the fingerprint generation functions easier
288
289 FingerprintFuncArguments doesn't own any of the pointers it stores.
290
291 */
292 struct FingerprintFuncArguments {
293 const std::vector<std::uint32_t> *fromAtoms = nullptr;
294 const std::vector<std::uint32_t> *ignoreAtoms = nullptr;
295 int confId = -1;
296 AdditionalOutput *additionalOutput = nullptr;
297 const std::vector<std::uint32_t> *customAtomInvariants = nullptr;
298 const std::vector<std::uint32_t> *customBondInvariants = nullptr;
299 FingerprintFuncArguments() = default;
300 FingerprintFuncArguments(
301 const std::vector<std::uint32_t> *fromAtoms_arg,
302 const std::vector<std::uint32_t> *ignoreAtoms_arg, int confId_arg,
303 AdditionalOutput *additionalOutput_arg,
304 const std::vector<std::uint32_t> *customAtomInvariants_arg,
305 const std::vector<std::uint32_t> *customBondInvariants_arg)
306 : fromAtoms(fromAtoms_arg),
307 ignoreAtoms(ignoreAtoms_arg),
308 confId(confId_arg),
309 additionalOutput(additionalOutput_arg),
310 customAtomInvariants(customAtomInvariants_arg),
311 customBondInvariants(customBondInvariants_arg) {};
312};
313
314/*!
315 \brief class that generates same fingerprint style for different output
316 formats
317
318 */
319template <typename OutputType>
320 class RDKIT_FINGERPRINTS_EXPORT FingerprintGenerator
321 : private boost::noncopyable {
322 FingerprintArguments *dp_fingerprintArguments;
323 AtomEnvironmentGenerator<OutputType> *dp_atomEnvironmentGenerator;
324 AtomInvariantsGenerator *dp_atomInvariantsGenerator;
325 BondInvariantsGenerator *dp_bondInvariantsGenerator;
326 const bool df_ownsAtomInvGenerator;
327 const bool df_ownsBondInvGenerator;
328
329 std::unique_ptr<SparseIntVect<OutputType>> getFingerprintHelper(
330 const ROMol &mol, FingerprintFuncArguments &args,
331 const std::uint64_t fpSize = 0) const;
332
333 public:
334 FingerprintGenerator(
335 AtomEnvironmentGenerator<OutputType> *atomEnvironmentGenerator,
336 FingerprintArguments *fingerprintArguments,
337 AtomInvariantsGenerator *atomInvariantsGenerator = nullptr,
338 BondInvariantsGenerator *bondInvariantsGenerator = nullptr,
339 bool ownsAtomInvGenerator = false, bool ownsBondInvGenerator = false);
340
341 ~FingerprintGenerator();
342
343 FingerprintArguments *getOptions() { return dp_fingerprintArguments; };
344 const FingerprintArguments *getOptions() const {
345 return dp_fingerprintArguments;
346 };
347
348 std::unique_ptr<SparseIntVect<OutputType>> getSparseCountFingerprint(
349 const ROMol &mol, FingerprintFuncArguments &args) const;
350
351 std::unique_ptr<SparseBitVect> getSparseFingerprint(
352 const ROMol &mol, FingerprintFuncArguments &args) const;
353
354 std::unique_ptr<SparseIntVect<std::uint32_t>> getCountFingerprint(
355 const ROMol &mol, FingerprintFuncArguments &args) const;
356
357 std::unique_ptr<ExplicitBitVect> getFingerprint(
358 const ROMol &mol, FingerprintFuncArguments &args) const;
359
360 std::vector<std::unique_ptr<ExplicitBitVect>> getFingerprints(
361 const std::vector<const ROMol *> &mols, int numThreads = 1) const;
362
363 std::vector<std::unique_ptr<SparseBitVect>> getSparseFingerprints(
364 const std::vector<const ROMol *> &mols, int numThreads = 1) const;
365
366 std::vector<std::unique_ptr<SparseIntVect<std::uint32_t>>>
367 getCountFingerprints(const std::vector<const ROMol *> &mols,
368 int numThreads = 1) const;
369
370 std::vector<std::unique_ptr<SparseIntVect<OutputType>>>
371 getSparseCountFingerprints(const std::vector<const ROMol *> &mols,
372 int numThreads = 1) const;
373
374 SparseIntVect<OutputType> *getSparseCountFingerprint(
375 const ROMol &mol, const std::vector<std::uint32_t> *fromAtoms = nullptr,
376 const std::vector<std::uint32_t> *ignoreAtoms = nullptr, int confId = -1,
377 AdditionalOutput *additionalOutput = nullptr,
378 const std::vector<std::uint32_t> *customAtomInvariants = nullptr,
379 const std::vector<std::uint32_t> *customBondInvariants = nullptr) const {
380 FingerprintFuncArguments ffa(fromAtoms, ignoreAtoms, confId,
381 additionalOutput, customAtomInvariants,
382 customBondInvariants);
383 return getSparseCountFingerprint(mol, ffa).release();
384 };
385
386 SparseBitVect *getSparseFingerprint(
387 const ROMol &mol, const std::vector<std::uint32_t> *fromAtoms = nullptr,
388 const std::vector<std::uint32_t> *ignoreAtoms = nullptr, int confId = -1,
389 AdditionalOutput *additionalOutput = nullptr,
390 const std::vector<std::uint32_t> *customAtomInvariants = nullptr,
391 const std::vector<std::uint32_t> *customBondInvariants = nullptr) const {
392 FingerprintFuncArguments ffa(fromAtoms, ignoreAtoms, confId,
393 additionalOutput, customAtomInvariants,
394 customBondInvariants);
395 return getSparseFingerprint(mol, ffa).release();
396 };
397
398 SparseIntVect<std::uint32_t> *getCountFingerprint(
399 const ROMol &mol, const std::vector<std::uint32_t> *fromAtoms = nullptr,
400 const std::vector<std::uint32_t> *ignoreAtoms = nullptr, int confId = -1,
401 AdditionalOutput *additionalOutput = nullptr,
402 const std::vector<std::uint32_t> *customAtomInvariants = nullptr,
403 const std::vector<std::uint32_t> *customBondInvariants = nullptr) const {
404 FingerprintFuncArguments ffa(fromAtoms, ignoreAtoms, confId,
405 additionalOutput, customAtomInvariants,
406 customBondInvariants);
407 return getCountFingerprint(mol, ffa).release();
408 };
409
410 ExplicitBitVect *getFingerprint(
411 const ROMol &mol, const std::vector<std::uint32_t> *fromAtoms = nullptr,
412 const std::vector<std::uint32_t> *ignoreAtoms = nullptr, int confId = -1,
413 AdditionalOutput *additionalOutput = nullptr,
414 const std::vector<std::uint32_t> *customAtomInvariants = nullptr,
415 const std::vector<std::uint32_t> *customBondInvariants = nullptr) const {
416 FingerprintFuncArguments ffa(fromAtoms, ignoreAtoms, confId,
417 additionalOutput, customAtomInvariants,
418 customBondInvariants);
419 return getFingerprint(mol, ffa).release();
420 };
421
422 std::string infoString() const;
423 void toJSON(boost::property_tree::ptree &pt) const;
424 void fromJSON(const boost::property_tree::ptree &pt);
425};
426//! generate JSON representation of a FingerprintGenerator
427template <typename OutputType>
428 RDKIT_FINGERPRINTS_EXPORT std::string generatorToJSON(
429 const FingerprintGenerator<OutputType> &generator);
430
431//! create a FingerprintGenerator from its JSON representation
432/// note that the returned generator always uses std::uint64_t as OutputType.
433 RDKIT_FINGERPRINTS_EXPORT std::unique_ptr<FingerprintGenerator<std::uint64_t>>
434generatorFromJSON(const std::string &jsonStr);
435
436template RDKIT_FINGERPRINTS_EXPORT ExplicitBitVect *
437 FingerprintGenerator<std::uint32_t>::getFingerprint(
438 const ROMol &, const std::vector<std::uint32_t> *,
439 const std::vector<std::uint32_t> *, int, AdditionalOutput *,
440 const std::vector<std::uint32_t> *,
441 const std::vector<std::uint32_t> *) const;
442template RDKIT_FINGERPRINTS_EXPORT SparseBitVect *
443 FingerprintGenerator<std::uint32_t>::getSparseFingerprint(
444 const ROMol &, const std::vector<std::uint32_t> *,
445 const std::vector<std::uint32_t> *, int, AdditionalOutput *,
446 const std::vector<std::uint32_t> *,
447 const std::vector<std::uint32_t> *) const;
448template RDKIT_FINGERPRINTS_EXPORT SparseIntVect<std::uint32_t> *
449 FingerprintGenerator<std::uint32_t>::getCountFingerprint(
450 const ROMol &, const std::vector<std::uint32_t> *,
451 const std::vector<std::uint32_t> *, int, AdditionalOutput *,
452 const std::vector<std::uint32_t> *,
453 const std::vector<std::uint32_t> *) const;
454template RDKIT_FINGERPRINTS_EXPORT SparseIntVect<std::uint32_t> *
455 FingerprintGenerator<std::uint32_t>::getSparseCountFingerprint(
456 const ROMol &, const std::vector<std::uint32_t> *,
457 const std::vector<std::uint32_t> *, int, AdditionalOutput *,
458 const std::vector<std::uint32_t> *,
459 const std::vector<std::uint32_t> *) const;
460template RDKIT_FINGERPRINTS_EXPORT ExplicitBitVect *
461 FingerprintGenerator<std::uint64_t>::getFingerprint(
462 const ROMol &, const std::vector<std::uint32_t> *,
463 const std::vector<std::uint32_t> *, int, AdditionalOutput *,
464 const std::vector<std::uint32_t> *,
465 const std::vector<std::uint32_t> *) const;
466template RDKIT_FINGERPRINTS_EXPORT SparseBitVect *
467 FingerprintGenerator<std::uint64_t>::getSparseFingerprint(
468 const ROMol &, const std::vector<std::uint32_t> *,
469 const std::vector<std::uint32_t> *, int, AdditionalOutput *,
470 const std::vector<std::uint32_t> *,
471 const std::vector<std::uint32_t> *) const;
472template RDKIT_FINGERPRINTS_EXPORT SparseIntVect<std::uint32_t> *
473 FingerprintGenerator<std::uint64_t>::getCountFingerprint(
474 const ROMol &, const std::vector<std::uint32_t> *,
475 const std::vector<std::uint32_t> *, int, AdditionalOutput *,
476 const std::vector<std::uint32_t> *,
477 const std::vector<std::uint32_t> *) const;
478template RDKIT_FINGERPRINTS_EXPORT SparseIntVect<std::uint64_t> *
479 FingerprintGenerator<std::uint64_t>::getSparseCountFingerprint(
480 const ROMol &, const std::vector<std::uint32_t> *,
481 const std::vector<std::uint32_t> *, int, AdditionalOutput *,
482 const std::vector<std::uint32_t> *,
483 const std::vector<std::uint32_t> *) const;
484
485 enum class FPType {
486 AtomPairFP,
487 MorganFP,
488 RDKitFP,
489 TopologicalTorsionFP
490};
491
492//! used to indicate errors for unimplemented fp types in convenience
493//! functions
494 class RDKIT_FINGERPRINTS_EXPORT UnimplementedFPException
495 : public std::exception {
496 public:
497 //! construct with an error message
498 UnimplementedFPException(const char *msg) : _msg(msg) {}
499 //! construct with an error message
500 UnimplementedFPException(std::string msg) : _msg(std::move(msg)) {}
501 //! get the error message
502 const char *what() const noexcept override { return _msg.c_str(); }
503 ~UnimplementedFPException() noexcept override = default;
504
505 private:
506 std::string _msg;
507};
508
509// convenience functions, fingerprint generation with default values
510
511 RDKIT_FINGERPRINTS_EXPORT SparseIntVect<std::uint64_t> *getSparseCountFP(
512 const ROMol &mol, FPType fPType);
513
514 RDKIT_FINGERPRINTS_EXPORT SparseBitVect *getSparseFP(const ROMol &mol,
515 FPType fPType);
516
517 RDKIT_FINGERPRINTS_EXPORT SparseIntVect<std::uint32_t> *getCountFP(
518 const ROMol &mol, FPType fPType);
519
520 RDKIT_FINGERPRINTS_EXPORT ExplicitBitVect *getFP(const ROMol &mol,
521 FPType fPType);
522
523 RDKIT_FINGERPRINTS_EXPORT std::vector<SparseIntVect<std::uint64_t> *> *
524getSparseCountFPBulk(const std::vector<const ROMol *> molVector, FPType fPType);
525
526 RDKIT_FINGERPRINTS_EXPORT std::vector<SparseBitVect *> *getSparseFPBulk(
527 const std::vector<const ROMol *> molVector, FPType fPType);
528
529 RDKIT_FINGERPRINTS_EXPORT std::vector<SparseIntVect<std::uint32_t> *> *
530getCountFPBulk(const std::vector<const ROMol *> molVector, FPType fPType);
531
532 RDKIT_FINGERPRINTS_EXPORT std::vector<ExplicitBitVect *> *getFPBulk(
533 const std::vector<const ROMol *> molVector, FPType fPType);
534
535} // namespace RDKit
536
537#endif
ExplicitBitVect.h
SparseBitVect.h
SparseIntVect.h
ExplicitBitVect
a class for bit vectors that are densely occupied
Definition ExplicitBitVect.h:29
RDKit::AtomEnvironmentGenerator
abstract base class that generates atom-environments from a molecule
Definition FingerprintGenerator.h:162
RDKit::AtomEnvironmentGenerator::~AtomEnvironmentGenerator
virtual ~AtomEnvironmentGenerator()
Definition FingerprintGenerator.h:219
RDKit::AtomEnvironmentGenerator::toJSON
virtual void toJSON(boost::property_tree::ptree &) const
Definition FingerprintGenerator.h:207
RDKit::AtomEnvironmentGenerator::fromJSON
virtual void fromJSON(const boost::property_tree::ptree &)
Definition FingerprintGenerator.h:208
RDKit::AtomEnvironmentGenerator::getEnvironments
virtual std::vector< AtomEnvironment< OutputType > * > getEnvironments(const ROMol &mol, FingerprintArguments *arguments, const std::vector< std::uint32_t > *fromAtoms=nullptr, const std::vector< std::uint32_t > *ignoreAtoms=nullptr, const int confId=-1, const AdditionalOutput *additionalOutput=nullptr, const std::vector< std::uint32_t > *atomInvariants=nullptr, const std::vector< std::uint32_t > *bondInvariants=nullptr, const bool hashResults=false) const =0
generate and return all atom-envorinments from a molecule
RDKit::AtomEnvironmentGenerator::dp_fingerprintArguments
const FingerprintArguments * dp_fingerprintArguments
Definition FingerprintGenerator.h:217
RDKit::AtomEnvironmentGenerator::infoString
virtual std::string infoString() const =0
method that returns information about this /c AtomEnvironmentGenerator and its arguments if any
RDKit::AtomEnvironmentGenerator::getResultSize
virtual OutputType getResultSize() const =0
Returns the size of the fingerprint based on arguments.
RDKit::AtomEnvironment
abstract base class that holds atom-environments that will be hashed to generate the fingerprint
Definition FingerprintGenerator.h:131
RDKit::AtomEnvironment::~AtomEnvironment
virtual ~AtomEnvironment()
Definition FingerprintGenerator.h:153
RDKit::AtomEnvironment::updateAdditionalOutput
virtual void updateAdditionalOutput(AdditionalOutput *AdditionalOutput, size_t bitId) const =0
RDKit::AtomEnvironment::getBitId
virtual 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 =0
calculates and returns the bit id to be set for this atom-environment
RDKit::AtomInvariantsGenerator
abstract base class for atom invariants generators
Definition FingerprintGenerator.h:227
RDKit::AtomInvariantsGenerator::toJSON
virtual void toJSON(boost::property_tree::ptree &) const
Definition FingerprintGenerator.h:247
RDKit::AtomInvariantsGenerator::~AtomInvariantsGenerator
virtual ~AtomInvariantsGenerator()
Definition FingerprintGenerator.h:250
RDKit::AtomInvariantsGenerator::infoString
virtual std::string infoString() const =0
method that returns information about this /c AtomInvariantsGenerator and its arguments
RDKit::AtomInvariantsGenerator::clone
virtual AtomInvariantsGenerator * clone() const =0
RDKit::AtomInvariantsGenerator::fromJSON
virtual void fromJSON(const boost::property_tree::ptree &)
Definition FingerprintGenerator.h:248
RDKit::AtomInvariantsGenerator::getAtomInvariants
virtual std::vector< std::uint32_t > * getAtomInvariants(const ROMol &mol) const =0
get atom invariants from a molecule
RDKit::BondInvariantsGenerator
abstract base class for bond invariants generators
Definition FingerprintGenerator.h:259
RDKit::BondInvariantsGenerator::infoString
virtual std::string infoString() const =0
method that returns information about this /c BondInvariantsGenerator and its arguments
RDKit::BondInvariantsGenerator::~BondInvariantsGenerator
virtual ~BondInvariantsGenerator()
Definition FingerprintGenerator.h:282
RDKit::BondInvariantsGenerator::clone
virtual BondInvariantsGenerator * clone() const =0
RDKit::BondInvariantsGenerator::toJSON
virtual void toJSON(boost::property_tree::ptree &) const
Definition FingerprintGenerator.h:279
RDKit::BondInvariantsGenerator::getBondInvariants
virtual std::vector< std::uint32_t > * getBondInvariants(const ROMol &mol) const =0
get bond invariants from a molecule
RDKit::BondInvariantsGenerator::fromJSON
virtual void fromJSON(const boost::property_tree::ptree &)
Definition FingerprintGenerator.h:280
RDKit::FingerprintArguments
Abstract base class that holds molecule independent arguments that are common amongst all fingerprint...
Definition FingerprintGenerator.h:90
RDKit::FingerprintArguments::toJSON
virtual void toJSON(boost::property_tree::ptree &pt) const
RDKit::FingerprintArguments::df_includeChirality
bool df_includeChirality
Definition FingerprintGenerator.h:98
RDKit::FingerprintArguments::~FingerprintArguments
virtual ~FingerprintArguments()
Definition FingerprintGenerator.h:121
RDKit::FingerprintArguments::df_countSimulation
bool df_countSimulation
Definition FingerprintGenerator.h:97
RDKit::FingerprintArguments::infoString
virtual std::string infoString() const =0
method that returns information string about the fingerprint specific argument set and the arguments ...
RDKit::FingerprintArguments::FingerprintArguments
FingerprintArguments()=default
RDKit::FingerprintArguments::fromJSON
virtual void fromJSON(const boost::property_tree::ptree &pt)
RDKit::FingerprintArguments::d_fpSize
std::uint32_t d_fpSize
Definition FingerprintGenerator.h:100
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::FingerprintArguments::d_numBitsPerFeature
std::uint32_t d_numBitsPerFeature
Definition FingerprintGenerator.h:101
RDKit::FingerprintArguments::commonArgumentsString
std::string commonArgumentsString() const
method that returns information string about common fingerprinting arguments' values
RDKit::FingerprintArguments::d_countBounds
std::vector< std::uint32_t > d_countBounds
Definition FingerprintGenerator.h:99
RDKit::FingerprintGenerator
class that generates same fingerprint style for different output formats
Definition FingerprintGenerator.h:321
RDKit::FingerprintGenerator::getSparseFingerprint
std::unique_ptr< SparseBitVect > getSparseFingerprint(const ROMol &mol, FingerprintFuncArguments &args) const
RDKit::FingerprintGenerator::FingerprintGenerator
FingerprintGenerator(AtomEnvironmentGenerator< OutputType > *atomEnvironmentGenerator, FingerprintArguments *fingerprintArguments, AtomInvariantsGenerator *atomInvariantsGenerator=nullptr, BondInvariantsGenerator *bondInvariantsGenerator=nullptr, bool ownsAtomInvGenerator=false, bool ownsBondInvGenerator=false)
RDKit::FingerprintGenerator::getFingerprint
std::unique_ptr< ExplicitBitVect > getFingerprint(const ROMol &mol, FingerprintFuncArguments &args) const
RDKit::FingerprintGenerator::infoString
std::string infoString() const
RDKit::FingerprintGenerator::getCountFingerprint
std::unique_ptr< SparseIntVect< std::uint32_t > > getCountFingerprint(const ROMol &mol, FingerprintFuncArguments &args) const
RDKit::FingerprintGenerator::getFingerprints
std::vector< std::unique_ptr< ExplicitBitVect > > getFingerprints(const std::vector< const ROMol * > &mols, int numThreads=1) const
RDKit::FingerprintGenerator::fromJSON
void fromJSON(const boost::property_tree::ptree &pt)
RDKit::FingerprintGenerator::getSparseCountFingerprints
std::vector< std::unique_ptr< SparseIntVect< OutputType > > > getSparseCountFingerprints(const std::vector< const ROMol * > &mols, int numThreads=1) const
RDKit::FingerprintGenerator::getCountFingerprints
std::vector< std::unique_ptr< SparseIntVect< std::uint32_t > > > getCountFingerprints(const std::vector< const ROMol * > &mols, int numThreads=1) const
RDKit::FingerprintGenerator::getSparseFingerprints
std::vector< std::unique_ptr< SparseBitVect > > getSparseFingerprints(const std::vector< const ROMol * > &mols, int numThreads=1) const
RDKit::FingerprintGenerator::getSparseCountFingerprint
std::unique_ptr< SparseIntVect< OutputType > > getSparseCountFingerprint(const ROMol &mol, FingerprintFuncArguments &args) const
RDKit::FingerprintGenerator::getCountFingerprint
SparseIntVect< std::uint32_t > * getCountFingerprint(const ROMol &mol, const std::vector< std::uint32_t > *fromAtoms=nullptr, const std::vector< std::uint32_t > *ignoreAtoms=nullptr, int confId=-1, AdditionalOutput *additionalOutput=nullptr, const std::vector< std::uint32_t > *customAtomInvariants=nullptr, const std::vector< std::uint32_t > *customBondInvariants=nullptr) const
Definition FingerprintGenerator.h:398
RDKit::FingerprintGenerator::getSparseFingerprint
SparseBitVect * getSparseFingerprint(const ROMol &mol, const std::vector< std::uint32_t > *fromAtoms=nullptr, const std::vector< std::uint32_t > *ignoreAtoms=nullptr, int confId=-1, AdditionalOutput *additionalOutput=nullptr, const std::vector< std::uint32_t > *customAtomInvariants=nullptr, const std::vector< std::uint32_t > *customBondInvariants=nullptr) const
Definition FingerprintGenerator.h:386
RDKit::FingerprintGenerator::toJSON
void toJSON(boost::property_tree::ptree &pt) const
RDKit::FingerprintGenerator::~FingerprintGenerator
~FingerprintGenerator()
RDKit::FingerprintGenerator::getFingerprint
ExplicitBitVect * getFingerprint(const ROMol &mol, const std::vector< std::uint32_t > *fromAtoms=nullptr, const std::vector< std::uint32_t > *ignoreAtoms=nullptr, int confId=-1, AdditionalOutput *additionalOutput=nullptr, const std::vector< std::uint32_t > *customAtomInvariants=nullptr, const std::vector< std::uint32_t > *customBondInvariants=nullptr) const
Definition FingerprintGenerator.h:410
RDKit::FingerprintGenerator::getOptions
FingerprintArguments * getOptions()
Definition FingerprintGenerator.h:343
RDKit::FingerprintGenerator::getSparseCountFingerprint
SparseIntVect< OutputType > * getSparseCountFingerprint(const ROMol &mol, const std::vector< std::uint32_t > *fromAtoms=nullptr, const std::vector< std::uint32_t > *ignoreAtoms=nullptr, int confId=-1, AdditionalOutput *additionalOutput=nullptr, const std::vector< std::uint32_t > *customAtomInvariants=nullptr, const std::vector< std::uint32_t > *customBondInvariants=nullptr) const
Definition FingerprintGenerator.h:374
RDKit::FingerprintGenerator::getOptions
const FingerprintArguments * getOptions() const
Definition FingerprintGenerator.h:344
RDKit::ROMol
Definition ROMol.h:199
RDKit::SparseIntVect
a class for efficiently storing sparse vectors of ints
Definition SparseIntVect.h:28
RDKit::UnimplementedFPException::UnimplementedFPException
UnimplementedFPException(const char *msg)
construct with an error message
Definition FingerprintGenerator.h:498
RDKit::UnimplementedFPException::~UnimplementedFPException
~UnimplementedFPException() noexcept override=default
RDKit::UnimplementedFPException::UnimplementedFPException
UnimplementedFPException(std::string msg)
construct with an error message
Definition FingerprintGenerator.h:500
RDKit::UnimplementedFPException::what
const char * what() const noexcept override
get the error message
Definition FingerprintGenerator.h:502
SparseBitVect
a class for bit vectors that are sparsely occupied.
Definition SparseBitVect.h:35
export.h
RDKIT_FINGERPRINTS_EXPORT
#define RDKIT_FINGERPRINTS_EXPORT
Definition export.h:193
RDKit::RDKitFP
Definition RDKitFPGenerator.h:18
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::getSparseFP
RDKIT_FINGERPRINTS_EXPORT SparseBitVect * getSparseFP(const ROMol &mol, FPType fPType)
RDKit::getSparseFPBulk
RDKIT_FINGERPRINTS_EXPORT std::vector< SparseBitVect * > * getSparseFPBulk(const std::vector< const ROMol * > molVector, FPType fPType)
RDKit::getFPBulk
RDKIT_FINGERPRINTS_EXPORT std::vector< ExplicitBitVect * > * getFPBulk(const std::vector< const ROMol * > molVector, FPType fPType)
RDKit::generatorToJSON
RDKIT_FINGERPRINTS_EXPORT std::string generatorToJSON(const FingerprintGenerator< OutputType > &generator)
generate JSON representation of a FingerprintGenerator
RDKit::getSparseCountFP
RDKIT_FINGERPRINTS_EXPORT SparseIntVect< std::uint64_t > * getSparseCountFP(const ROMol &mol, FPType fPType)
RDKit::getCountFPBulk
RDKIT_FINGERPRINTS_EXPORT std::vector< SparseIntVect< std::uint32_t > * > * getCountFPBulk(const std::vector< const ROMol * > molVector, FPType fPType)
RDKit::generatorFromJSON
RDKIT_FINGERPRINTS_EXPORT std::unique_ptr< FingerprintGenerator< std::uint64_t > > generatorFromJSON(const std::string &jsonStr)
RDKit::getSparseCountFPBulk
RDKIT_FINGERPRINTS_EXPORT std::vector< SparseIntVect< std::uint64_t > * > * getSparseCountFPBulk(const std::vector< const ROMol * > molVector, FPType fPType)
RDKit::getCountFP
RDKIT_FINGERPRINTS_EXPORT SparseIntVect< std::uint32_t > * getCountFP(const ROMol &mol, FPType fPType)
RDKit::FPType
FPType
Definition FingerprintGenerator.h:485
RDKit::getFP
RDKIT_FINGERPRINTS_EXPORT ExplicitBitVect * getFP(const ROMol &mol, FPType fPType)
RDKit::FingerprintType::TopologicalTorsionFP
@ TopologicalTorsionFP
Definition ReactionFingerprints.h:45
RDKit::FingerprintType::MorganFP
@ MorganFP
Definition ReactionFingerprints.h:46
RDKit::FingerprintType::AtomPairFP
@ AtomPairFP
Definition ReactionFingerprints.h:44
RDKit::AdditionalOutput
Definition FingerprintGenerator.h:27
RDKit::AdditionalOutput::atomToBitsType
std::vector< std::vector< std::uint64_t > > atomToBitsType
Definition FingerprintGenerator.h:28
RDKit::AdditionalOutput::allocateAtomCounts
void allocateAtomCounts()
Definition FingerprintGenerator.h:67
RDKit::AdditionalOutput::bitPaths
bitPathsType * bitPaths
Definition FingerprintGenerator.h:46
RDKit::AdditionalOutput::atomCountsType
std::vector< unsigned int > atomCountsType
Definition FingerprintGenerator.h:33
RDKit::AdditionalOutput::bitInfoMap
bitInfoMapType * bitInfoMap
Definition FingerprintGenerator.h:42
RDKit::AdditionalOutput::atomToBits
atomToBitsType * atomToBits
Definition FingerprintGenerator.h:38
RDKit::AdditionalOutput::atomsPerBitType
std::map< std::uint64_t, std::vector< std::vector< int > > > atomsPerBitType
Definition FingerprintGenerator.h:34
RDKit::AdditionalOutput::allocateBitInfoMap
void allocateBitInfoMap()
Definition FingerprintGenerator.h:59
RDKit::AdditionalOutput::allocateAtomToBits
void allocateAtomToBits()
Definition FingerprintGenerator.h:55
RDKit::AdditionalOutput::allocateBitPaths
void allocateBitPaths()
Definition FingerprintGenerator.h:63
RDKit::AdditionalOutput::bitPathsType
std::map< std::uint64_t, std::vector< std::vector< int > > > bitPathsType
Definition FingerprintGenerator.h:32
RDKit::AdditionalOutput::bitInfoMapType
std::map< std::uint64_t, std::vector< std::pair< std::uint32_t, std::uint32_t > > > bitInfoMapType
Definition FingerprintGenerator.h:29
RDKit::AdditionalOutput::atomCounts
atomCountsType * atomCounts
Definition FingerprintGenerator.h:50
RDKit::AdditionalOutput::allocateAtomsPerBit
void allocateAtomsPerBit()
Definition FingerprintGenerator.h:71
RDKit::AdditionalOutput::atomsPerBit
atomsPerBitType * atomsPerBit
Definition FingerprintGenerator.h:53
RDKit::FingerprintFuncArguments
struct that makes calling the fingerprint generation functions easier
Definition FingerprintGenerator.h:292
RDKit::FingerprintFuncArguments::customAtomInvariants
const std::vector< std::uint32_t > * customAtomInvariants
Definition FingerprintGenerator.h:297
RDKit::FingerprintFuncArguments::additionalOutput
AdditionalOutput * additionalOutput
Definition FingerprintGenerator.h:296
RDKit::FingerprintFuncArguments::customBondInvariants
const std::vector< std::uint32_t > * customBondInvariants
Definition FingerprintGenerator.h:298
RDKit::FingerprintFuncArguments::fromAtoms
const std::vector< std::uint32_t > * fromAtoms
Definition FingerprintGenerator.h:293
RDKit::FingerprintFuncArguments::confId
int confId
Definition FingerprintGenerator.h:295
RDKit::FingerprintFuncArguments::ignoreAtoms
const std::vector< std::uint32_t > * ignoreAtoms
Definition FingerprintGenerator.h:294
RDKit::FingerprintFuncArguments::FingerprintFuncArguments
FingerprintFuncArguments(const std::vector< std::uint32_t > *fromAtoms_arg, const std::vector< std::uint32_t > *ignoreAtoms_arg, int confId_arg, AdditionalOutput *additionalOutput_arg, const std::vector< std::uint32_t > *customAtomInvariants_arg, const std::vector< std::uint32_t > *customBondInvariants_arg)
Definition FingerprintGenerator.h:300
RDKit::FingerprintFuncArguments::FingerprintFuncArguments
FingerprintFuncArguments()=default