Loading...
Searching...
No Matches
SubstructLibrary.h
Go to the documentation of this file.
// Copyright (c) 2017-2021, Novartis Institutes for BioMedical Research Inc.
// and other RDKit contributors
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Novartis Institutes for BioMedical Research Inc.
// nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#ifndef RDK_SUBSTRUCT_LIBRARY
#define RDK_SUBSTRUCT_LIBRARY
#include <utility>
#include <RDGeneral/export.h>
#include <GraphMol/RDKitBase.h>
#include <GraphMol/MolPickler.h>
#include <GraphMol/MolBundle.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/SmilesParse/SmilesWrite.h>
#include <GraphMol/Fingerprints/Fingerprints.h>
#include <GraphMol/Substruct/SubstructMatch.h>
#include <DataStructs/ExplicitBitVect.h>
#include <DataStructs/BitOps.h>
#include <GraphMol/MolOps.h>
#include <GraphMol/TautomerQuery/TautomerQuery.h>
#include <GraphMol/GeneralizedSubstruct/XQMol.h>
#include <algorithm>
#include <string>
#include <boost/lexical_cast.hpp>
namespace RDKit {
using GeneralizedSubstruct::ExtendedQueryMol;
RDKIT_SUBSTRUCTLIBRARY_EXPORT bool SubstructLibraryCanSerialize();
//! Base class API for holding molecules to substructure search.
/*!
This is an API that hides the implementation details used for
indexing molecules for substructure searching. It simply
provides an API for adding and getting molecules from a set.
*/
class RDKIT_SUBSTRUCTLIBRARY_EXPORT MolHolderBase {
public:
virtual ~MolHolderBase() {}
//! Add a new molecule to the substructure search library
//! Returns the molecules index in the library
virtual unsigned int addMol(const ROMol &m) = 0;
// implementations should throw IndexError on out of range
virtual boost::shared_ptr<ROMol> getMol(unsigned int) const = 0;
//! Get the current library size
virtual unsigned int size() const = 0;
};
//! Concrete class that holds molecules in memory
/*!
This is currently one of the faster implementations.
However it is very memory intensive.
*/
class RDKIT_SUBSTRUCTLIBRARY_EXPORT MolHolder : public MolHolderBase {
std::vector<boost::shared_ptr<ROMol>> mols;
public:
MolHolder() : MolHolderBase(), mols() {}
unsigned int addMol(const ROMol &m) override {
mols.push_back(boost::make_shared<ROMol>(m));
return size() - 1;
}
boost::shared_ptr<ROMol> getMol(unsigned int idx) const override {
if (idx >= mols.size()) {
throw IndexErrorException(idx);
}
return mols[idx];
}
unsigned int size() const override {
return rdcast<unsigned int>(mols.size());
}
std::vector<boost::shared_ptr<ROMol>> &getMols() { return mols; }
const std::vector<boost::shared_ptr<ROMol>> &getMols() const { return mols; }
};
//! Concrete class that holds binary cached molecules in memory
/*!
This implementation uses quite a bit less memory than the
non cached implementation. However, due to the reduced speed
it should be used in conjunction with a pattern fingerprinter.
See RDKit::FPHolder
*/
class RDKIT_SUBSTRUCTLIBRARY_EXPORT CachedMolHolder : public MolHolderBase {
std::vector<std::string> mols;
public:
CachedMolHolder() : MolHolderBase(), mols() {}
unsigned int addMol(const ROMol &m) override {
mols.emplace_back();
MolPickler::pickleMol(m, mols.back());
return size() - 1;
}
//! Adds a pickled binary molecule, no validity checking of the input
//! is done.
unsigned int addBinary(const std::string &pickle) {
mols.push_back(pickle);
return size() - 1;
}
boost::shared_ptr<ROMol> getMol(unsigned int idx) const override {
if (idx >= mols.size()) {
throw IndexErrorException(idx);
}
boost::shared_ptr<ROMol> mol(new ROMol);
MolPickler::molFromPickle(mols[idx], mol.get());
return mol;
}
unsigned int size() const override {
return rdcast<unsigned int>(mols.size());
}
std::vector<std::string> &getMols() { return mols; }
const std::vector<std::string> &getMols() const { return mols; }
};
//! Concrete class that holds smiles strings in memory
/*!
This implementation uses quite a bit less memory than the
cached binary or uncached implementation. However, due to the
reduced speed it should be used in conjunction with a pattern
fingerprinter.
See RDKit::FPHolder
*/
class RDKIT_SUBSTRUCTLIBRARY_EXPORT CachedSmilesMolHolder
: public MolHolderBase {
std::vector<std::string> mols;
public:
CachedSmilesMolHolder() : MolHolderBase(), mols() {}
unsigned int addMol(const ROMol &m) override {
bool doIsomericSmiles = true;
mols.push_back(MolToSmiles(m, doIsomericSmiles));
return size() - 1;
}
//! Add a smiles to the dataset, no validation is done
//! to the inputs.
unsigned int addSmiles(const std::string &smiles) {
mols.push_back(smiles);
return size() - 1;
}
boost::shared_ptr<ROMol> getMol(unsigned int idx) const override {
if (idx >= mols.size()) {
throw IndexErrorException(idx);
}
boost::shared_ptr<ROMol> mol(SmilesToMol(mols[idx]));
return mol;
}
unsigned int size() const override {
return rdcast<unsigned int>(mols.size());
}
std::vector<std::string> &getMols() { return mols; }
const std::vector<std::string> &getMols() const { return mols; }
};
//! Concrete class that holds trusted smiles strings in memory
/*!
A trusted smiles is essentially a smiles string that
RDKit has generated. This indicates that fewer
sanitization steps are required. See
http://rdkit.blogspot.com/2016/09/avoiding-unnecessary-work-and.html
This implementation uses quite a bit less memory than the
cached binary or uncached implementation. However, due to the
reduced speed it should be used in conjunction with a pattern
fingerprinter.
See RDKit::FPHolder
*/
class RDKIT_SUBSTRUCTLIBRARY_EXPORT CachedTrustedSmilesMolHolder
: public MolHolderBase {
std::vector<std::string> mols;
public:
CachedTrustedSmilesMolHolder() : MolHolderBase(), mols() {}
unsigned int addMol(const ROMol &m) override {
bool doIsomericSmiles = true;
mols.push_back(MolToSmiles(m, doIsomericSmiles));
return size() - 1;
}
//! Add a smiles to the dataset, no validation is done
//! to the inputs.
unsigned int addSmiles(const std::string &smiles) {
mols.push_back(smiles);
return size() - 1;
}
boost::shared_ptr<ROMol> getMol(unsigned int idx) const override {
if (idx >= mols.size()) {
throw IndexErrorException(idx);
}
RWMol *m = SmilesToMol(mols[idx], 0, false);
if (m) {
m->updatePropertyCache();
}
return boost::shared_ptr<ROMol>(m);
}
unsigned int size() const override {
return rdcast<unsigned int>(mols.size());
}
std::vector<std::string> &getMols() { return mols; }
const std::vector<std::string> &getMols() const { return mols; }
};
//! Base FPI for the fingerprinter used to rule out impossible matches
class RDKIT_SUBSTRUCTLIBRARY_EXPORT FPHolderBase {
std::vector<ExplicitBitVect *> fps;
public:
virtual ~FPHolderBase() {
for (size_t i = 0; i < fps.size(); ++i) {
delete fps[i];
}
}
virtual unsigned int size() const { return rdcast<unsigned int>(fps.size()); }
//! Adds a molecule to the fingerprinter
unsigned int addMol(const ROMol &m) {
fps.push_back(makeFingerprint(m));
return rdcast<unsigned int>(fps.size() - 1);
}
//! Adds a raw bit vector pointer to the fingerprinter, which takes ownership
//! PLEASE NOTE: make sure that the passed ExplicitBitVect
//! is compatible with the one generated by makeFingerprint()
unsigned int addFingerprint(ExplicitBitVect *v) {
fps.push_back(v);
return rdcast<unsigned int>(fps.size() - 1);
}
//! Adds a raw bit vector to the fingerprinter
//! PLEASE NOTE: make sure that the passed ExplicitBitVect
//! is compatible with the one generated by makeFingerprint()
unsigned int addFingerprint(const ExplicitBitVect &v) {
return addFingerprint(new ExplicitBitVect(v));
}
//! Return false if a substructure search can never match the molecule
bool passesFilter(unsigned int idx, const ExplicitBitVect &query) const {
if (idx >= fps.size()) {
throw IndexErrorException(idx);
}
return AllProbeBitsMatch(query, *fps[idx]);
}
//! Get the bit vector at the specified index (throws IndexError if out of
//! range)
const ExplicitBitVect &getFingerprint(unsigned int idx) const {
if (idx >= fps.size()) {
throw IndexErrorException(idx);
}
return *fps[idx];
}
//! make the query vector
//! Caller owns the vector!
virtual ExplicitBitVect *makeFingerprint(const ROMol &m) const = 0;
std::vector<ExplicitBitVect *> &getFingerprints() { return fps; }
const std::vector<ExplicitBitVect *> &getFingerprints() const { return fps; }
};
//! Uses the pattern fingerprinter with a user-defined number of bits (default:
//! 2048) to rule out matches
class RDKIT_SUBSTRUCTLIBRARY_EXPORT PatternHolder : public FPHolderBase {
unsigned int numBits;
public:
PatternHolder() : FPHolderBase(), numBits(defaultNumBits()) {}
PatternHolder(unsigned int numBits) : FPHolderBase(), numBits(numBits) {}
//! Caller owns the vector!
ExplicitBitVect *makeFingerprint(const ROMol &m) const override {
return PatternFingerprintMol(m, numBits);
}
const unsigned int &getNumBits() const { return numBits; };
unsigned int &getNumBits() { return numBits; };
static unsigned int defaultNumBits() {
static const unsigned int DEFAULT_NUM_BITS = 2048;
return DEFAULT_NUM_BITS;
};
};
class RDKIT_SUBSTRUCTLIBRARY_EXPORT TautomerPatternHolder
: public PatternHolder {
public:
TautomerPatternHolder() : PatternHolder() {}
TautomerPatternHolder(unsigned int numBits) : PatternHolder(numBits) {}
ExplicitBitVect *makeFingerprint(const ROMol &m) const override {
std::vector<unsigned int> *atomCounts = nullptr;
ExplicitBitVect *setOnlyBits = nullptr;
const bool tautomericFingerprint = true;
return PatternFingerprintMol(m, getNumBits(), atomCounts, setOnlyBits,
tautomericFingerprint);
}
};
class RDKIT_SUBSTRUCTLIBRARY_EXPORT KeyHolderBase {
public:
virtual ~KeyHolderBase() {}
//! Add a key to the database getting it from the molecule
virtual unsigned int addMol(const ROMol &m) = 0;
//! Add a key to the database, this needs to be in the same order
//! as the molecule, no validation is done
virtual unsigned int addKey(const std::string &) = 0;
// !get the key at the requested index
// implementations should throw IndexError on out of range
virtual const std::string &getKey(unsigned int) const = 0;
// !get keys from a bunch of indices
virtual std::vector<std::string> getKeys(
const std::vector<unsigned int> &indices) const = 0;
//! Get the current keeyholder size
virtual unsigned int size() const = 0;
};
class RDKIT_SUBSTRUCTLIBRARY_EXPORT KeyFromPropHolder : public KeyHolderBase {
std::string propname;
std::vector<std::string> keys;
const std::string empty_string = {};
public:
KeyFromPropHolder(const std::string &propname = "_Name")
: propname(propname) {}
std::string &getPropName() { return propname; }
const std::string &getPropName() const { return propname; }
std::vector<std::string> &getKeys() { return keys; }
const std::vector<std::string> &getKeys() const { return keys; }
unsigned int addMol(const ROMol &m) override {
std::string key;
if (m.getPropIfPresent(propname, key)) {
keys.push_back(std::move(key));
} else {
// XXX is this a warning? it could be verbose. Should we push back the
// string repr of the
// numeric index?
const static std::string prefix("LIBIDX-");
keys.emplace_back(prefix + boost::lexical_cast<std::string>(keys.size()));
}
return keys.size() - 1u;
};
unsigned int addKey(const std::string &key) override {
keys.push_back(key);
return keys.size() - 1u;
}
const std::string &getKey(unsigned int idx) const override {
if (idx >= keys.size()) {
throw IndexErrorException(idx);
}
return keys[idx];
}
std::vector<std::string> getKeys(
const std::vector<unsigned int> &indices) const override {
std::vector<std::string> res;
std::transform(indices.begin(), indices.end(), std::back_inserter(res),
[=](unsigned idx) { return keys.at(idx); });
return res;
}
unsigned int size() const override { return keys.size(); }
};
//! Substructure Search a library of molecules
/*! This class allows for multithreaded substructure searches of
large datasets.
The implementations can use fingerprints to speed up searches
and have molecules cached as binary forms to reduce memory
usage.
basic usage:
\code
SubstructLibrary lib;
lib.addMol(mol);
std::vector<unsigned int> results = lib.getMatches(query);
for(std::vector<unsigned int>::const_iterator matchIndex=results.begin();
matchIndex != results.end();
++matchIndex) {
boost::shared_ptr<ROMol> match = lib.getMol(*matchIndex);
}
\endcode
Using different mol holders and pattern fingerprints.
\code
boost::shared_ptr<CachedTrustedSmilesMolHolder> molHolder = \
boost::make_shared<CachedTrustedSmilesMolHolder>();
boost::shared_ptr<PatternHolder> patternHolder = \
boost::make_shared<PatternHolder>();
SubstructLibrary lib(molHolder, patternHolder);
lib.addMol(mol);
\endcode
Cached molecule holders create molecules on demand. There are currently
three styles of cached molecules.
CachedMolHolder: stores molecules in the rdkit binary format.
CachedSmilesMolHolder: stores molecules in smiles format.
CachedTrustedSmilesMolHolder: stores molecules in smiles format.
The CachedTrustedSmilesMolHolder is made to add molecules from
a trusted source. This makes the basic assumption that RDKit was
used to sanitize and canonicalize the smiles string. In practice
this is considerably faster than using arbitrary smiles strings since
certain assumptions can be made. Molecules generated from trusted
smiles do not have ring information (although this is created
in the molecule being searched if necessary).
When loading from external data, as opposed to using the "addMol" API,
care must be taken to ensure that the pattern fingerprints and smiles
are synchronized.
Each pattern holder has an API point for making its fingerprint. This
is useful to ensure that the pattern stored in the database will be
compatible with the patterns made when analyzing queries.
\code
boost::shared_ptr<CachedTrustedSmilesMolHolder> molHolder = \
boost::make_shared<CachedTrustedSmilesMolHolder>();
boost::shared_ptr<PatternHolder> patternHolder = \
boost::make_shared<PatternHolder>();
// the PatternHolder instance is able to make fingerprints.
// These, of course, can be read from a file. For demonstration
// purposes we construct them here.
const std::string trustedSmiles = "c1ccccc1";
ROMol *m = SmilesToMol(trustedSmiles);
const ExplicitBitVect *bitVector = patternHolder->makeFingerprint(*m);
// The trusted smiles and bitVector can be read from any source.
// This is the fastest way to load a substruct library.
molHolder->addSmiles( trustedSmiles );
patternHolder->addFingerprint( *bitVector );
SubstructLibrary lib(molHolder, patternHolder);
delete m;
delete bitVector;
\endcode
Finally, using the KeyFromPropHolder will store user ids or keys.
By default, it uses RDKit's default _Name prop, but can be changed
to any property.
\code
boost::shared_ptr<CachedTrustedSmilesMolHolder> molHolder = \
boost::make_shared<CachedTrustedSmilesMolHolder>();
boost::shared_ptr<KeyFromPropHolder> keyHolder = \
boost::make_shared<KeyFromPropHolder>();
SubstructLibrary lib(molHolder, keyHolder);
...
You can get the keys in multiple through the use of the keyholder
auto key = lib.getKeys().getKey(idx);
auto keys = lib.getKeys().getKeys(lib.GetMatch(query));
\endcode
*/
class RDKIT_SUBSTRUCTLIBRARY_EXPORT SubstructLibrary {
boost::shared_ptr<MolHolderBase> molholder;
boost::shared_ptr<FPHolderBase> fpholder;
boost::shared_ptr<KeyHolderBase> keyholder;
MolHolderBase *mols; // used for a small optimization
FPHolderBase *fps{nullptr};
bool is_tautomerquery = false;
std::vector<unsigned int> searchOrder;
public:
SubstructLibrary()
: molholder(new MolHolder),
fpholder(),
keyholder(),
mols(molholder.get()) {}
SubstructLibrary(boost::shared_ptr<MolHolderBase> molecules)
: molholder(std::move(molecules)),
fpholder(),
keyholder(),
mols(molholder.get()),
fps(nullptr) {}
SubstructLibrary(boost::shared_ptr<MolHolderBase> molecules,
boost::shared_ptr<FPHolderBase> fingerprints)
: molholder(std::move(molecules)),
fpholder(std::move(fingerprints)),
keyholder(),
mols(molholder.get()),
fps(fpholder.get()) {
if (fpholder.get() &&
dynamic_cast<TautomerPatternHolder *>(fpholder.get()) != nullptr) {
is_tautomerquery = true;
}
}
SubstructLibrary(boost::shared_ptr<MolHolderBase> molecules,
boost::shared_ptr<KeyHolderBase> keys)
: molholder(std::move(molecules)),
fpholder(),
keyholder(std::move(keys)),
mols(molholder.get()),
fps(nullptr) {
if (fpholder.get() &&
dynamic_cast<TautomerPatternHolder *>(fpholder.get()) != nullptr) {
is_tautomerquery = true;
}
}
SubstructLibrary(boost::shared_ptr<MolHolderBase> molecules,
boost::shared_ptr<FPHolderBase> fingerprints,
boost::shared_ptr<KeyHolderBase> keys)
: molholder(std::move(molecules)),
fpholder(std::move(fingerprints)),
keyholder(std::move(keys)),
mols(molholder.get()),
fps(fpholder.get()) {
if (fpholder.get() &&
dynamic_cast<TautomerPatternHolder *>(fpholder.get()) != nullptr) {
is_tautomerquery = true;
}
}
SubstructLibrary(const std::string &pickle)
: molholder(new MolHolder),
fpholder(),
mols(molholder.get()),
fps(nullptr) {
initFromString(pickle);
if (fpholder.get() &&
dynamic_cast<TautomerPatternHolder *>(fpholder.get()) != nullptr) {
is_tautomerquery = true;
}
}
//! Get the underlying molecule holder implementation
boost::shared_ptr<MolHolderBase> &getMolHolder() { return molholder; }
const boost::shared_ptr<MolHolderBase> &getMolHolder() const {
return molholder;
}
//! Get the underlying molecule holder implementation
boost::shared_ptr<FPHolderBase> &getFpHolder() { return fpholder; }
//! Get the underlying molecule holder implementation
const boost::shared_ptr<FPHolderBase> &getFpHolder() const {
return fpholder;
}
//! Get the underlying molecule holder implementation
boost::shared_ptr<KeyHolderBase> &getKeyHolder() { return keyholder; }
//! Get the underlying molecule holder implementation
const boost::shared_ptr<KeyHolderBase> &getKeyHolder() const {
return keyholder;
}
const MolHolderBase &getMolecules() const {
PRECONDITION(mols, "Molecule holder NULL in SubstructLibrary");
return *mols;
}
//! Get the underlying fingerprint implementation.
/*! Throws a value error if no fingerprints have been set */
FPHolderBase &getFingerprints() {
if (!fps) {
throw ValueErrorException("Substruct Library does not have fingerprints");
}
return *fps;
}
const FPHolderBase &getFingerprints() const {
if (!fps) {
throw ValueErrorException("Substruct Library does not have fingerprints");
}
return *fps;
}
//! Get the underlying key holder implementation.
/*! Throws a value error if no keyholder have been set */
KeyHolderBase &getKeys() {
if (!keyholder.get()) {
throw ValueErrorException("Substruct Library does not have fingerprints");
}
return *keyholder.get();
}
//! Get the underlying key holder implementation.
/*! Throws a value error if no keyholder have been set */
const KeyHolderBase &getKeys() const {
if (!keyholder.get()) {
throw ValueErrorException("Substruct Library does not have fingerprints");
}
return *keyholder.get();
}
//! Add a molecule to the library
/*!
\param mol Molecule to add
returns index for the molecule in the library
*/
unsigned int addMol(const ROMol &mol);
//! Get the matching indices for the query
/*!
\param query Query or Tautomer Query to match against molecules
\param recursionPossible flags whether or not recursive matches are allowed
[default true]
\param useChirality use atomic CIP codes as part of the comparison
[default true]
\param useQueryQueryMatches if set, the contents of atom and bond queries
will be used as part of the matching
[default false]
\param numThreads If -1 use all available processors [default -1]
\param maxResults Maximum results to return, -1 means return all
[default -1]
*/
template <class Query>
std::vector<unsigned int> getMatches(const Query &query,
bool recursionPossible = true,
bool useChirality = true,
bool useQueryQueryMatches = false,
int numThreads = -1,
int maxResults = -1) const {
SubstructMatchParameters params;
params.recursionPossible = recursionPossible;
params.useChirality = useChirality;
params.useQueryQueryMatches = useQueryQueryMatches;
return getMatches(query, 0, size(), params, numThreads, maxResults);
}
//! overload
template <class Query>
std::vector<unsigned int> getMatches(const Query &query,
const SubstructMatchParameters &params,
int numThreads = -1,
int maxResults = -1) const {
return getMatches(query, 0, size(), params, numThreads, maxResults);
}
//! Get the matching indices for the query between the given indices
/*!
\param query Query to match against molecules
\param startIdx Start index of the search
\param endIdx Ending idx (non-inclusive) of the search.
\param recursionPossible flags whether or not recursive matches are allowed
[default true]
\param useChirality use atomic CIP codes as part of the comparison
[default true]
\param useQueryQueryMatches if set, the contents of atom and bond queries
will be used as part of the matching
[default false]
\param numThreads If -1 use all available processors [default -1]
\param maxResults Maximum results to return, -1 means return all
[default -1]
*/
template <class Query>
std::vector<unsigned int> getMatches(
const Query &query, unsigned int startIdx, unsigned int endIdx,
bool recursionPossible = true, bool useChirality = true,
bool useQueryQueryMatches = false, int numThreads = -1,
int maxResults = -1) const {
SubstructMatchParameters params;
params.recursionPossible = recursionPossible;
params.useChirality = useChirality;
params.useQueryQueryMatches = useQueryQueryMatches;
return getMatches(query, startIdx, endIdx, params, numThreads, maxResults);
};
//! overload
std::vector<unsigned int> getMatches(const ROMol &query,
unsigned int startIdx,
unsigned int endIdx,
const SubstructMatchParameters &params,
int numThreads = -1,
int maxResults = -1) const;
//! overload
std::vector<unsigned int> getMatches(const MolBundle &query,
unsigned int startIdx,
unsigned int endIdx,
const SubstructMatchParameters &params,
int numThreads = -1,
int maxResults = -1) const;
//! overload
std::vector<unsigned int> getMatches(const TautomerQuery &query,
unsigned int startIdx,
unsigned int endIdx,
const SubstructMatchParameters &params,
int numThreads = -1,
int maxResults = -1) const;
//! overload
std::vector<unsigned int> getMatches(const ExtendedQueryMol &query,
unsigned int startIdx,
unsigned int endIdx,
const SubstructMatchParameters &params,
int numThreads = -1,
int maxResults = -1) const;
//! Return the number of matches for the query
/*!
\param query Molecule or Tautomer Query to match against molecules
\param recursionPossible flags whether or not recursive matches are allowed
[default true]
\param useChirality use atomic CIP codes as part of the comparison
[default true]
\param useQueryQueryMatches if set, the contents of atom and bond queries
will be used as part of the matching
[default false]
\param numThreads If -1 use all available processors [default -1]
*/
template <class Query>
unsigned int countMatches(const Query &query, bool recursionPossible = true,
bool useChirality = true,
bool useQueryQueryMatches = false,
int numThreads = -1) const {
SubstructMatchParameters params;
params.recursionPossible = recursionPossible;
params.useChirality = useChirality;
params.useQueryQueryMatches = useQueryQueryMatches;
return countMatches(query, 0, size(), params, numThreads);
}
//! overload
template <class Query>
unsigned int countMatches(const Query &query,
const SubstructMatchParameters &params,
int numThreads = -1) const {
return countMatches(query, 0, size(), params, numThreads);
}
//! Return the number of matches for the query
//! Return the number of matches for the query between the given indices
/*!
\param query Query to match against molecules
\param startIdx Start index of the search
\param endIdx Ending idx (non-inclusive) of the search.
\param recursionPossible flags whether or not recursive matches are allowed
[default true]
\param useChirality use atomic CIP codes as part of the comparison
[default true]
\param useQueryQueryMatches if set, the contents of atom and bond queries
will be used as part of the matching
[default false]
\param numThreads If -1 use all available processors [default -1]
*/
template <class Query>
unsigned int countMatches(const Query &query, unsigned int startIdx,
unsigned int endIdx, bool recursionPossible = true,
bool useChirality = true,
bool useQueryQueryMatches = false,
int numThreads = -1) const {
SubstructMatchParameters params;
params.recursionPossible = recursionPossible;
params.useChirality = useChirality;
params.useQueryQueryMatches = useQueryQueryMatches;
return countMatches(query, startIdx, endIdx, params, numThreads);
};
//! overload
unsigned int countMatches(const ROMol &query, unsigned int startIdx,
unsigned int endIdx,
const SubstructMatchParameters &params,
int numThreads = -1) const;
//! overload
unsigned int countMatches(const TautomerQuery &query, unsigned int startIdx,
unsigned int endIdx,
const SubstructMatchParameters &params,
int numThreads = -1) const;
//! overload
unsigned int countMatches(const MolBundle &query, unsigned int startIdx,
unsigned int endIdx,
const SubstructMatchParameters &params,
int numThreads = -1) const;
//! overload
unsigned int countMatches(const ExtendedQueryMol &query,
unsigned int startIdx, unsigned int endIdx,
const SubstructMatchParameters &params,
int numThreads = -1) const;
//! Returns true if any match exists for the query
/*!
\param query Molecule or Tautomer Query to match against molecules
\param recursionPossible flags whether or not recursive matches are allowed
[default true]
\param useChirality use atomic CIP codes as part of the comparison
[default true]
\param useQueryQueryMatches if set, the contents of atom and bond queries
will be used as part of the matching
[default false]
\param numThreads If -1 use all available processors [default -1]
*/
template <class Query>
bool hasMatch(const Query &query, bool recursionPossible = true,
bool useChirality = true, bool useQueryQueryMatches = false,
int numThreads = -1) const {
SubstructMatchParameters params;
params.recursionPossible = recursionPossible;
params.useChirality = useChirality;
params.useQueryQueryMatches = useQueryQueryMatches;
return hasMatch(query, 0, size(), params, numThreads);
}
//! overload
template <class Query>
bool hasMatch(const Query &query, const SubstructMatchParameters &params,
int numThreads = -1) const {
return hasMatch(query, 0, size(), params, numThreads);
}
//! Returns true if any match exists for the query between the specified
//! indices
/*!
\param query Query to match against molecules
\param startIdx Start index of the search
\param endIdx Ending idx (inclusive) of the search.
\param recursionPossible flags whether or not recursive matches are
allowed [default true] \param useChirality use atomic CIP codes as part
of the comparison [default true] \param useQueryQueryMatches if set, the
contents of atom and bond queries will be used as part of the matching
[default false]
\param numThreads If -1 use all available processors [default -1]
*/
template <class Query>
bool hasMatch(const Query &query, unsigned int startIdx, unsigned int endIdx,
bool recursionPossible = true, bool useChirality = true,
bool useQueryQueryMatches = false, int numThreads = -1) const {
SubstructMatchParameters params;
params.recursionPossible = recursionPossible;
params.useChirality = useChirality;
params.useQueryQueryMatches = useQueryQueryMatches;
return hasMatch(query, startIdx, endIdx, params, numThreads);
};
//! overload
bool hasMatch(const ROMol &query, unsigned int startIdx, unsigned int endIdx,
const SubstructMatchParameters &params,
int numThreads = -1) const;
//! overload
bool hasMatch(const TautomerQuery &query, unsigned int startIdx,
unsigned int endIdx, const SubstructMatchParameters &params,
int numThreads = -1) const;
//! overload
bool hasMatch(const MolBundle &query, unsigned int startIdx,
unsigned int endIdx, const SubstructMatchParameters &params,
int numThreads = -1) const;
//! overload
bool hasMatch(const ExtendedQueryMol &query, unsigned int startIdx,
unsigned int endIdx, const SubstructMatchParameters &params,
int numThreads = -1) const;
//! Returns the molecule at the given index
/*!
\param idx Index of the molecule in the library (n.b. could contain
null)
*/
boost::shared_ptr<ROMol> getMol(unsigned int idx) const {
// expects implementation to throw IndexError if out of range
PRECONDITION(mols, "molholder is null in SubstructLibrary");
return mols->getMol(idx);
}
//! Returns the molecule at the given index
/*!
\param idx Index of the molecule in the library (n.b. could contain
null)
*/
boost::shared_ptr<ROMol> operator[](unsigned int idx) {
// expects implementation to throw IndexError if out of range
PRECONDITION(mols, "molholder is null in SubstructLibrary");
return mols->getMol(idx);
}
//! return the number of molecules in the library
unsigned int size() const {
PRECONDITION(mols, "molholder is null in SubstructLibrary");
return rdcast<unsigned int>(molholder->size());
}
//! does error checking
void setSearchOrder(const std::vector<unsigned int> &order) {
for (const auto idx : order) {
if (idx >= mols->size()) {
throw IndexErrorException(idx);
}
}
searchOrder = order;
}
const std::vector<unsigned int> &getSearchOrder() const {
return searchOrder;
}
std::vector<unsigned int> &getSearchOrder() { return searchOrder; }
//! access required for serialization
void resetHolders() {
is_tautomerquery = false;
mols = molholder.get();
fps = fpholder.get();
if (fps && dynamic_cast<TautomerPatternHolder *>(fps) != nullptr) {
is_tautomerquery = true;
}
}
//! serializes (pickles) to a stream
void toStream(std::ostream &ss) const;
//! returns a string with a serialized (pickled) representation
std::string Serialize() const;
//! initializes from a stream pickle
void initFromStream(std::istream &ss);
//! initializes from a string pickle
void initFromString(const std::string &text);
};
} // namespace RDKit
#include "SubstructLibrarySerialization.h"
#endif
BitOps.h
Contains general bit-comparison and similarity operations.
AllProbeBitsMatch
RDKIT_DATASTRUCTS_EXPORT bool AllProbeBitsMatch(const char *probe, const char *ref)
ExplicitBitVect.h
Fingerprints.h
PRECONDITION
#define PRECONDITION(expr, mess)
Definition Invariant.h:109
MolBundle.h
Defines a class for managing bundles of molecules.
MolOps.h
MolPickler.h
RDKitBase.h
pulls in the core RDKit functionality
SmilesParse.h
SmilesWrite.h
SubstructLibrarySerialization.h
SubstructMatch.h
TautomerQuery.h
XQMol.h
ExplicitBitVect
a class for bit vectors that are densely occupied
Definition ExplicitBitVect.h:29
IndexErrorException
Class to allow us to throw an IndexError from C++ and have it make it back to Python.
Definition Exceptions.h:20
RDKit::CachedMolHolder
Concrete class that holds binary cached molecules in memory.
Definition SubstructLibrary.h:121
RDKit::CachedMolHolder::getMols
std::vector< std::string > & getMols()
Definition SubstructLibrary.h:153
RDKit::CachedMolHolder::size
unsigned int size() const override
Get the current library size.
Definition SubstructLibrary.h:149
RDKit::CachedMolHolder::addMol
unsigned int addMol(const ROMol &m) override
Definition SubstructLibrary.h:127
RDKit::CachedMolHolder::CachedMolHolder
CachedMolHolder()
Definition SubstructLibrary.h:125
RDKit::CachedMolHolder::getMol
boost::shared_ptr< ROMol > getMol(unsigned int idx) const override
Definition SubstructLibrary.h:140
RDKit::CachedMolHolder::getMols
const std::vector< std::string > & getMols() const
Definition SubstructLibrary.h:154
RDKit::CachedMolHolder::addBinary
unsigned int addBinary(const std::string &pickle)
Definition SubstructLibrary.h:135
RDKit::CachedSmilesMolHolder
Concrete class that holds smiles strings in memory.
Definition SubstructLibrary.h:167
RDKit::CachedSmilesMolHolder::CachedSmilesMolHolder
CachedSmilesMolHolder()
Definition SubstructLibrary.h:171
RDKit::CachedSmilesMolHolder::getMols
std::vector< std::string > & getMols()
Definition SubstructLibrary.h:199
RDKit::CachedSmilesMolHolder::addSmiles
unsigned int addSmiles(const std::string &smiles)
Definition SubstructLibrary.h:181
RDKit::CachedSmilesMolHolder::getMols
const std::vector< std::string > & getMols() const
Definition SubstructLibrary.h:200
RDKit::CachedSmilesMolHolder::addMol
unsigned int addMol(const ROMol &m) override
Definition SubstructLibrary.h:173
RDKit::CachedSmilesMolHolder::getMol
boost::shared_ptr< ROMol > getMol(unsigned int idx) const override
Definition SubstructLibrary.h:186
RDKit::CachedSmilesMolHolder::size
unsigned int size() const override
Get the current library size.
Definition SubstructLibrary.h:195
RDKit::CachedTrustedSmilesMolHolder
Concrete class that holds trusted smiles strings in memory.
Definition SubstructLibrary.h:218
RDKit::CachedTrustedSmilesMolHolder::getMols
std::vector< std::string > & getMols()
Definition SubstructLibrary.h:253
RDKit::CachedTrustedSmilesMolHolder::addSmiles
unsigned int addSmiles(const std::string &smiles)
Definition SubstructLibrary.h:232
RDKit::CachedTrustedSmilesMolHolder::addMol
unsigned int addMol(const ROMol &m) override
Definition SubstructLibrary.h:224
RDKit::CachedTrustedSmilesMolHolder::getMols
const std::vector< std::string > & getMols() const
Definition SubstructLibrary.h:254
RDKit::CachedTrustedSmilesMolHolder::getMol
boost::shared_ptr< ROMol > getMol(unsigned int idx) const override
Definition SubstructLibrary.h:237
RDKit::CachedTrustedSmilesMolHolder::size
unsigned int size() const override
Get the current library size.
Definition SubstructLibrary.h:249
RDKit::CachedTrustedSmilesMolHolder::CachedTrustedSmilesMolHolder
CachedTrustedSmilesMolHolder()
Definition SubstructLibrary.h:222
RDKit::FPHolderBase
Base FPI for the fingerprinter used to rule out impossible matches.
Definition SubstructLibrary.h:258
RDKit::FPHolderBase::getFingerprints
std::vector< ExplicitBitVect * > & getFingerprints()
Definition SubstructLibrary.h:313
RDKit::FPHolderBase::addMol
unsigned int addMol(const ROMol &m)
Adds a molecule to the fingerprinter.
Definition SubstructLibrary.h:271
RDKit::FPHolderBase::size
virtual unsigned int size() const
Definition SubstructLibrary.h:268
RDKit::FPHolderBase::getFingerprints
const std::vector< ExplicitBitVect * > & getFingerprints() const
Definition SubstructLibrary.h:314
RDKit::FPHolderBase::~FPHolderBase
virtual ~FPHolderBase()
Definition SubstructLibrary.h:262
RDKit::FPHolderBase::passesFilter
bool passesFilter(unsigned int idx, const ExplicitBitVect &query) const
Return false if a substructure search can never match the molecule.
Definition SubstructLibrary.h:292
RDKit::FPHolderBase::addFingerprint
unsigned int addFingerprint(ExplicitBitVect *v)
Definition SubstructLibrary.h:279
RDKit::FPHolderBase::getFingerprint
const ExplicitBitVect & getFingerprint(unsigned int idx) const
Definition SubstructLibrary.h:302
RDKit::FPHolderBase::addFingerprint
unsigned int addFingerprint(const ExplicitBitVect &v)
Definition SubstructLibrary.h:287
RDKit::FPHolderBase::makeFingerprint
virtual ExplicitBitVect * makeFingerprint(const ROMol &m) const =0
RDKit::KeyFromPropHolder
Definition SubstructLibrary.h:373
RDKit::KeyFromPropHolder::KeyFromPropHolder
KeyFromPropHolder(const std::string &propname="_Name")
Definition SubstructLibrary.h:379
RDKit::KeyFromPropHolder::getKey
const std::string & getKey(unsigned int idx) const override
Definition SubstructLibrary.h:407
RDKit::KeyFromPropHolder::addKey
unsigned int addKey(const std::string &key) override
Definition SubstructLibrary.h:402
RDKit::KeyFromPropHolder::size
unsigned int size() const override
Get the current keeyholder size.
Definition SubstructLibrary.h:421
RDKit::KeyFromPropHolder::getKeys
const std::vector< std::string > & getKeys() const
Definition SubstructLibrary.h:386
RDKit::KeyFromPropHolder::getKeys
std::vector< std::string > & getKeys()
Definition SubstructLibrary.h:385
RDKit::KeyFromPropHolder::getKeys
std::vector< std::string > getKeys(const std::vector< unsigned int > &indices) const override
Definition SubstructLibrary.h:414
RDKit::KeyFromPropHolder::getPropName
const std::string & getPropName() const
Definition SubstructLibrary.h:383
RDKit::KeyFromPropHolder::addMol
unsigned int addMol(const ROMol &m) override
Add a key to the database getting it from the molecule.
Definition SubstructLibrary.h:388
RDKit::KeyFromPropHolder::getPropName
std::string & getPropName()
Definition SubstructLibrary.h:382
RDKit::KeyHolderBase
Definition SubstructLibrary.h:351
RDKit::KeyHolderBase::getKeys
virtual std::vector< std::string > getKeys(const std::vector< unsigned int > &indices) const =0
RDKit::KeyHolderBase::getKey
virtual const std::string & getKey(unsigned int) const =0
RDKit::KeyHolderBase::~KeyHolderBase
virtual ~KeyHolderBase()
Definition SubstructLibrary.h:353
RDKit::KeyHolderBase::addMol
virtual unsigned int addMol(const ROMol &m)=0
Add a key to the database getting it from the molecule.
RDKit::KeyHolderBase::size
virtual unsigned int size() const =0
Get the current keeyholder size.
RDKit::KeyHolderBase::addKey
virtual unsigned int addKey(const std::string &)=0
RDKit::MolBundle
MolBundle contains a collection of related ROMols.
Definition MolBundle.h:59
RDKit::MolHolderBase
Base class API for holding molecules to substructure search.
Definition SubstructLibrary.h:67
RDKit::MolHolderBase::addMol
virtual unsigned int addMol(const ROMol &m)=0
RDKit::MolHolderBase::size
virtual unsigned int size() const =0
Get the current library size.
RDKit::MolHolderBase::getMol
virtual boost::shared_ptr< ROMol > getMol(unsigned int) const =0
RDKit::MolHolderBase::~MolHolderBase
virtual ~MolHolderBase()
Definition SubstructLibrary.h:69
RDKit::MolHolder
Concrete class that holds molecules in memory.
Definition SubstructLibrary.h:87
RDKit::MolHolder::MolHolder
MolHolder()
Definition SubstructLibrary.h:91
RDKit::MolHolder::addMol
unsigned int addMol(const ROMol &m) override
Definition SubstructLibrary.h:93
RDKit::MolHolder::getMols
const std::vector< boost::shared_ptr< ROMol > > & getMols() const
Definition SubstructLibrary.h:110
RDKit::MolHolder::size
unsigned int size() const override
Get the current library size.
Definition SubstructLibrary.h:105
RDKit::MolHolder::getMol
boost::shared_ptr< ROMol > getMol(unsigned int idx) const override
Definition SubstructLibrary.h:98
RDKit::MolHolder::getMols
std::vector< boost::shared_ptr< ROMol > > & getMols()
Definition SubstructLibrary.h:109
RDKit::PatternHolder
Definition SubstructLibrary.h:319
RDKit::PatternHolder::PatternHolder
PatternHolder(unsigned int numBits)
Definition SubstructLibrary.h:324
RDKit::PatternHolder::getNumBits
const unsigned int & getNumBits() const
Definition SubstructLibrary.h:329
RDKit::PatternHolder::getNumBits
unsigned int & getNumBits()
Definition SubstructLibrary.h:330
RDKit::PatternHolder::defaultNumBits
static unsigned int defaultNumBits()
Definition SubstructLibrary.h:331
RDKit::PatternHolder::PatternHolder
PatternHolder()
Definition SubstructLibrary.h:323
RDKit::PatternHolder::makeFingerprint
ExplicitBitVect * makeFingerprint(const ROMol &m) const override
Caller owns the vector!
Definition SubstructLibrary.h:326
RDKit::ROMol
Definition ROMol.h:199
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
RDKit::SubstructLibrary
Substructure Search a library of molecules.
Definition SubstructLibrary.h:519
RDKit::SubstructLibrary::countMatches
unsigned int countMatches(const Query &query, bool recursionPossible=true, bool useChirality=true, bool useQueryQueryMatches=false, int numThreads=-1) const
Return the number of matches for the query.
Definition SubstructLibrary.h:770
RDKit::SubstructLibrary::countMatches
unsigned int countMatches(const ExtendedQueryMol &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1) const
overload
RDKit::SubstructLibrary::addMol
unsigned int addMol(const ROMol &mol)
Add a molecule to the library.
RDKit::SubstructLibrary::getMatches
std::vector< unsigned int > getMatches(const ROMol &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1, int maxResults=-1) const
overload
RDKit::SubstructLibrary::initFromStream
void initFromStream(std::istream &ss)
initializes from a stream pickle
RDKit::SubstructLibrary::getKeys
KeyHolderBase & getKeys()
Get the underlying key holder implementation.
Definition SubstructLibrary.h:641
RDKit::SubstructLibrary::getMatches
std::vector< unsigned int > getMatches(const ExtendedQueryMol &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1, int maxResults=-1) const
overload
RDKit::SubstructLibrary::getMol
boost::shared_ptr< ROMol > getMol(unsigned int idx) const
Returns the molecule at the given index.
Definition SubstructLibrary.h:910
RDKit::SubstructLibrary::getMolHolder
boost::shared_ptr< MolHolderBase > & getMolHolder()
Get the underlying molecule holder implementation.
Definition SubstructLibrary.h:596
RDKit::SubstructLibrary::hasMatch
bool hasMatch(const Query &query, bool recursionPossible=true, bool useChirality=true, bool useQueryQueryMatches=false, int numThreads=-1) const
Returns true if any match exists for the query.
Definition SubstructLibrary.h:851
RDKit::SubstructLibrary::SubstructLibrary
SubstructLibrary(boost::shared_ptr< MolHolderBase > molecules, boost::shared_ptr< FPHolderBase > fingerprints, boost::shared_ptr< KeyHolderBase > keys)
Definition SubstructLibrary.h:569
RDKit::SubstructLibrary::SubstructLibrary
SubstructLibrary()
Definition SubstructLibrary.h:530
RDKit::SubstructLibrary::countMatches
unsigned int countMatches(const Query &query, unsigned int startIdx, unsigned int endIdx, bool recursionPossible=true, bool useChirality=true, bool useQueryQueryMatches=false, int numThreads=-1) const
Return the number of matches for the query.
Definition SubstructLibrary.h:805
RDKit::SubstructLibrary::getMatches
std::vector< unsigned int > getMatches(const MolBundle &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1, int maxResults=-1) const
overload
RDKit::SubstructLibrary::getMatches
std::vector< unsigned int > getMatches(const Query &query, const SubstructMatchParameters &params, int numThreads=-1, int maxResults=-1) const
overload
Definition SubstructLibrary.h:694
RDKit::SubstructLibrary::getFpHolder
boost::shared_ptr< FPHolderBase > & getFpHolder()
Get the underlying molecule holder implementation.
Definition SubstructLibrary.h:603
RDKit::SubstructLibrary::getMatches
std::vector< unsigned int > getMatches(const Query &query, bool recursionPossible=true, bool useChirality=true, bool useQueryQueryMatches=false, int numThreads=-1, int maxResults=-1) const
Get the matching indices for the query.
Definition SubstructLibrary.h:680
RDKit::SubstructLibrary::getMolecules
const MolHolderBase & getMolecules() const
Definition SubstructLibrary.h:618
RDKit::SubstructLibrary::initFromString
void initFromString(const std::string &text)
initializes from a string pickle
RDKit::SubstructLibrary::countMatches
unsigned int countMatches(const Query &query, const SubstructMatchParameters &params, int numThreads=-1) const
overload
Definition SubstructLibrary.h:782
RDKit::SubstructLibrary::getKeys
const KeyHolderBase & getKeys() const
Get the underlying key holder implementation.
Definition SubstructLibrary.h:650
RDKit::SubstructLibrary::getKeyHolder
const boost::shared_ptr< KeyHolderBase > & getKeyHolder() const
Get the underlying molecule holder implementation.
Definition SubstructLibrary.h:614
RDKit::SubstructLibrary::hasMatch
bool hasMatch(const ExtendedQueryMol &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1) const
overload
RDKit::SubstructLibrary::hasMatch
bool hasMatch(const ROMol &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1) const
overload
RDKit::SubstructLibrary::countMatches
unsigned int countMatches(const MolBundle &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1) const
overload
RDKit::SubstructLibrary::getFingerprints
FPHolderBase & getFingerprints()
Get the underlying fingerprint implementation.
Definition SubstructLibrary.h:625
RDKit::SubstructLibrary::setSearchOrder
void setSearchOrder(const std::vector< unsigned int > &order)
does error checking
Definition SubstructLibrary.h:934
RDKit::SubstructLibrary::hasMatch
bool hasMatch(const Query &query, unsigned int startIdx, unsigned int endIdx, bool recursionPossible=true, bool useChirality=true, bool useQueryQueryMatches=false, int numThreads=-1) const
Definition SubstructLibrary.h:880
RDKit::SubstructLibrary::getFingerprints
const FPHolderBase & getFingerprints() const
Definition SubstructLibrary.h:632
RDKit::SubstructLibrary::SubstructLibrary
SubstructLibrary(boost::shared_ptr< MolHolderBase > molecules, boost::shared_ptr< KeyHolderBase > keys)
Definition SubstructLibrary.h:556
RDKit::SubstructLibrary::hasMatch
bool hasMatch(const MolBundle &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1) const
overload
RDKit::SubstructLibrary::countMatches
unsigned int countMatches(const ROMol &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1) const
overload
RDKit::SubstructLibrary::hasMatch
bool hasMatch(const Query &query, const SubstructMatchParameters &params, int numThreads=-1) const
overload
Definition SubstructLibrary.h:862
RDKit::SubstructLibrary::SubstructLibrary
SubstructLibrary(boost::shared_ptr< MolHolderBase > molecules, boost::shared_ptr< FPHolderBase > fingerprints)
Definition SubstructLibrary.h:543
RDKit::SubstructLibrary::getKeyHolder
boost::shared_ptr< KeyHolderBase > & getKeyHolder()
Get the underlying molecule holder implementation.
Definition SubstructLibrary.h:611
RDKit::SubstructLibrary::hasMatch
bool hasMatch(const TautomerQuery &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1) const
overload
RDKit::SubstructLibrary::getSearchOrder
const std::vector< unsigned int > & getSearchOrder() const
Definition SubstructLibrary.h:943
RDKit::SubstructLibrary::resetHolders
void resetHolders()
access required for serialization
Definition SubstructLibrary.h:949
RDKit::SubstructLibrary::size
unsigned int size() const
return the number of molecules in the library
Definition SubstructLibrary.h:928
RDKit::SubstructLibrary::getMatches
std::vector< unsigned int > getMatches(const Query &query, unsigned int startIdx, unsigned int endIdx, bool recursionPossible=true, bool useChirality=true, bool useQueryQueryMatches=false, int numThreads=-1, int maxResults=-1) const
Get the matching indices for the query between the given indices.
Definition SubstructLibrary.h:717
RDKit::SubstructLibrary::SubstructLibrary
SubstructLibrary(boost::shared_ptr< MolHolderBase > molecules)
Definition SubstructLibrary.h:536
RDKit::SubstructLibrary::SubstructLibrary
SubstructLibrary(const std::string &pickle)
Definition SubstructLibrary.h:583
RDKit::SubstructLibrary::Serialize
std::string Serialize() const
returns a string with a serialized (pickled) representation
RDKit::SubstructLibrary::countMatches
unsigned int countMatches(const TautomerQuery &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1) const
overload
RDKit::SubstructLibrary::getMatches
std::vector< unsigned int > getMatches(const TautomerQuery &query, unsigned int startIdx, unsigned int endIdx, const SubstructMatchParameters &params, int numThreads=-1, int maxResults=-1) const
overload
RDKit::SubstructLibrary::toStream
void toStream(std::ostream &ss) const
serializes (pickles) to a stream
RDKit::SubstructLibrary::operator[]
boost::shared_ptr< ROMol > operator[](unsigned int idx)
Returns the molecule at the given index.
Definition SubstructLibrary.h:921
RDKit::SubstructLibrary::getFpHolder
const boost::shared_ptr< FPHolderBase > & getFpHolder() const
Get the underlying molecule holder implementation.
Definition SubstructLibrary.h:606
RDKit::SubstructLibrary::getMolHolder
const boost::shared_ptr< MolHolderBase > & getMolHolder() const
Definition SubstructLibrary.h:598
RDKit::SubstructLibrary::getSearchOrder
std::vector< unsigned int > & getSearchOrder()
Definition SubstructLibrary.h:947
RDKit::TautomerPatternHolder
Definition SubstructLibrary.h:338
RDKit::TautomerPatternHolder::makeFingerprint
ExplicitBitVect * makeFingerprint(const ROMol &m) const override
Caller owns the vector!
Definition SubstructLibrary.h:342
RDKit::TautomerPatternHolder::TautomerPatternHolder
TautomerPatternHolder()
Definition SubstructLibrary.h:340
RDKit::TautomerPatternHolder::TautomerPatternHolder
TautomerPatternHolder(unsigned int numBits)
Definition SubstructLibrary.h:341
RDKit::TautomerQuery
Definition TautomerQuery.h:36
ValueErrorException
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
Definition Exceptions.h:40
export.h
RDKIT_SUBSTRUCTLIBRARY_EXPORT
#define RDKIT_SUBSTRUCTLIBRARY_EXPORT
Definition export.h:529
RDKit::v1::SmilesToMol
RDKit::RWMol * SmilesToMol(const std::string &smi, const SmilesParserParams &ps)
Definition SmilesParse.h:118
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::PatternFingerprintMol
RDKIT_FINGERPRINTS_EXPORT ExplicitBitVect * PatternFingerprintMol(const ROMol &mol, unsigned int fpSize=2048, std::vector< unsigned int > *atomCounts=nullptr, ExplicitBitVect *setOnlyBits=nullptr, bool tautomericFingerprint=false)
Generates a topological fingerprint for a molecule using a series of pre-defined structural patterns.
RDKit::SubstructLibraryCanSerialize
RDKIT_SUBSTRUCTLIBRARY_EXPORT bool SubstructLibraryCanSerialize()
RDKit::GeneralizedSubstruct::ExtendedQueryMol
Definition XQMol.h:31
RDKit::SubstructMatchParameters
Definition SubstructMatch.h:41
RDKit::SubstructMatchParameters::useChirality
bool useChirality
Definition SubstructMatch.h:42
RDKit::SubstructMatchParameters::recursionPossible
bool recursionPossible
Allow recursive queries.
Definition SubstructMatch.h:52
RDKit::SubstructMatchParameters::useQueryQueryMatches
bool useQueryQueryMatches
Definition SubstructMatch.h:48