 |
RDKit
Open-source cheminformatics and machine learning.
|
Go to the documentation of this file.
31 #ifndef RDK_SUBSTRUCT_LIBRARY
32 #define RDK_SUBSTRUCT_LIBRARY
58 virtual unsigned int addMol(
const ROMol &m) = 0;
61 virtual boost::shared_ptr<ROMol> getMol(
unsigned int)
const = 0;
64 virtual unsigned int size()
const = 0;
73 std::vector<boost::shared_ptr<ROMol>> mols;
79 mols.push_back(boost::make_shared<ROMol>(m));
83 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
88 virtual unsigned int size()
const {
89 return rdcast<unsigned int>(mols.size());
92 std::vector<boost::shared_ptr<ROMol>> &
getMols() {
return mols; }
93 const std::vector<boost::shared_ptr<ROMol>> &
getMols()
const {
return mols; }
105 std::vector<std::string> mols;
111 mols.push_back(std::string());
123 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
125 boost::shared_ptr<ROMol> mol(
new ROMol);
130 virtual unsigned int size()
const {
131 return rdcast<unsigned int>(mols.size());
134 std::vector<std::string> &
getMols() {
return mols; }
135 const std::vector<std::string> &
getMols()
const {
return mols; }
149 std::vector<std::string> mols;
155 bool doIsomericSmiles =
true;
163 mols.push_back(smiles);
167 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
170 boost::shared_ptr<ROMol> mol(
SmilesToMol(mols[idx]));
174 virtual unsigned int size()
const {
175 return rdcast<unsigned int>(mols.size());
178 std::vector<std::string> &
getMols() {
return mols; }
179 const std::vector<std::string> &
getMols()
const {
return mols; }
198 std::vector<std::string> mols;
204 bool doIsomericSmiles =
true;
212 mols.push_back(smiles);
216 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
221 return boost::shared_ptr<ROMol>(m);
224 virtual unsigned int size()
const {
225 return rdcast<unsigned int>(mols.size());
228 std::vector<std::string> &
getMols() {
return mols; }
229 const std::vector<std::string> &
getMols()
const {
return mols; }
234 std::vector<ExplicitBitVect *> fps;
238 for (
size_t i = 0; i < fps.size(); ++i)
delete fps[i];
243 fps.push_back(makeFingerprint(m));
244 return rdcast<unsigned int>(fps.size() - 1);
250 return rdcast<unsigned int>(fps.size() - 1);
361 boost::shared_ptr<MolHolderBase> molholder;
362 boost::shared_ptr<FPHolderBase> fpholder;
370 mols(molholder.get()),
374 : molholder(molecules), fpholder(), mols(molholder.get()), fps(0) {}
377 boost::shared_ptr<FPHolderBase> fingerprints)
378 : molholder(molecules),
379 fpholder(fingerprints),
380 mols(molholder.get()),
381 fps(fpholder.get()) {}
386 mols(molholder.get()),
399 boost::shared_ptr<FPHolderBase> &
getFpHolder() {
return fpholder; }
407 PRECONDITION(mols,
"Molecule holder NULL in SubstructLibrary");
431 unsigned int addMol(
const ROMol &mol);
447 std::vector<unsigned int> getMatches(
const ROMol &query,
448 bool recursionPossible =
true,
449 bool useChirality =
true,
450 bool useQueryQueryMatches =
false,
452 int maxResults = -1);
469 std::vector<unsigned int> getMatches(
470 const ROMol &query,
unsigned int startIdx,
unsigned int endIdx,
471 bool recursionPossible =
true,
bool useChirality =
true,
472 bool useQueryQueryMatches =
false,
int numThreads = -1,
473 int maxResults = -1);
487 unsigned int countMatches(
const ROMol &query,
bool recursionPossible =
true,
488 bool useChirality =
true,
489 bool useQueryQueryMatches =
false,
490 int numThreads = -1);
505 unsigned int countMatches(
const ROMol &query,
unsigned int startIdx,
506 unsigned int endIdx,
bool recursionPossible =
true,
507 bool useChirality =
true,
508 bool useQueryQueryMatches =
false,
509 int numThreads = -1);
523 bool hasMatch(
const ROMol &query,
bool recursionPossible =
true,
524 bool useChirality =
true,
bool useQueryQueryMatches =
false,
525 int numThreads = -1);
541 bool hasMatch(
const ROMol &query,
unsigned int startIdx,
unsigned int endIdx,
542 bool recursionPossible =
true,
bool useChirality =
true,
543 bool useQueryQueryMatches =
false,
int numThreads = -1);
549 boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
551 PRECONDITION(mols,
"molholder is null in SubstructLibrary");
561 PRECONDITION(mols,
"molholder is null in SubstructLibrary");
567 PRECONDITION(mols,
"molholder is null in SubstructLibrary");
568 return rdcast<unsigned int>(molholder->size());
573 mols = molholder.get();
574 fps = fpholder.get();
578 void toStream(std::ostream &ss)
const;
580 std::string Serialize()
const;
582 void initFromStream(std::istream &ss);
584 void initFromString(
const std::string &text);
virtual unsigned int size() const
Get the current library size.
CachedTrustedSmilesMolHolder()
const std::vector< std::string > & getMols() const
virtual unsigned int size() const
Get the current library size.
const std::vector< ExplicitBitVect * > & getFingerprints() const
RDKIT_CHEMREACTIONS_EXPORT void pickle(const boost::shared_ptr< EnumerationStrategyBase > &enumerator, std::ostream &ss)
pickles a EnumerationStrategy and adds the results to a stream ss
virtual unsigned int size() const
Get the current library size.
Concrete class that holds trusted smiles strings in memory.
RDKIT_SUBSTRUCTLIBRARY_EXPORT bool SubstructLibraryCanSerialize()
Contains general bit-comparison and similarity operations.
std::vector< std::string > & getMols()
unsigned int addSmiles(const std::string &smiles)
RDKIT_SMILESPARSE_EXPORT std::string MolToSmiles(const ROMol &mol, bool doIsomericSmiles=true, bool doKekule=false, int rootedAtAtom=-1, bool canonical=true, bool allBondsExplicit=false, bool allHsExplicit=false, bool doRandom=false)
returns canonical SMILES for a molecule
RWMol is a molecule class that is intended to be edited.
virtual unsigned int addMol(const ROMol &m)
boost::shared_ptr< FPHolderBase > & getFpHolder()
Get the underlying molecule holder implementation.
Substructure Search a library of molecules.
Base FPI for the fingerprinter used to rule out impossible matches.
boost::shared_ptr< ROMol > operator[](unsigned int idx)
Returns the molecule at the given index.
const ExplicitBitVect & getFingerprint(unsigned int idx) const
virtual boost::shared_ptr< ROMol > getMol(unsigned int idx) const
virtual boost::shared_ptr< ROMol > getMol(unsigned int idx) const
boost::shared_ptr< MolHolderBase > & getMolHolder()
Get the underlying molecule holder implementation.
static void molFromPickle(const std::string &pickle, ROMol *mol)
constructs a molecule from a pickle stored in a string
virtual ExplicitBitVect * makeFingerprint(const ROMol &m) const
Caller owns the vector!
const std::vector< boost::shared_ptr< ROMol > > & getMols() const
RDKIT_SMILESPARSE_EXPORT RWMol * SmilesToMol(const std::string &smi, const SmilesParserParams ¶ms)
std::vector< ExplicitBitVect * > & getFingerprints()
virtual boost::shared_ptr< ROMol > getMol(unsigned int) const =0
Base class API for holding molecules to substructure search.
const FPHolderBase & getFingerprints() const
virtual boost::shared_ptr< ROMol > getMol(unsigned int idx) const
pulls in the core RDKit functionality
unsigned int addMol(const ROMol &m)
Adds a molecule to the fingerprinter.
const std::vector< std::string > & getMols() const
RDKIT_DATASTRUCTS_EXPORT bool AllProbeBitsMatch(const char *probe, const char *ref)
const std::vector< std::string > & getMols() const
Concrete class that holds smiles strings in memory.
const boost::shared_ptr< MolHolderBase > & getMolHolder() const
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
unsigned int size() const
return the number of molecules in the library
SubstructLibrary(const std::string &pickle)
Concrete class that holds molecules in memory.
virtual unsigned int addMol(const ROMol &m)
void updatePropertyCache(bool strict=true)
calculates any of our lazy properties
void resetHolders()
access required for serialization
virtual boost::shared_ptr< ROMol > getMol(unsigned int idx) const
static void pickleMol(const ROMol *mol, std::ostream &ss)
pickles a molecule and sends the results to stream ss
RDKIT_FINGERPRINTS_EXPORT ExplicitBitVect * PatternFingerprintMol(const ROMol &mol, unsigned int fpSize=2048, std::vector< unsigned int > *atomCounts=0, ExplicitBitVect *setOnlyBits=0)
Generates a topological fingerprint for a molecule using a series of pre-defined structural patterns.
Class to allow us to throw an IndexError from C++ and have it make it back to Python.
std::vector< std::string > & getMols()
Uses the pattern fingerprinter to rule out matches.
FPHolderBase & getFingerprints()
Get the underlying fingerprint implementation.
virtual unsigned int addMol(const ROMol &m)
bool passesFilter(unsigned int idx, const ExplicitBitVect &query) const
Return false if a substructure search can never match the molecule.
#define PRECONDITION(expr, mess)
SubstructLibrary(boost::shared_ptr< MolHolderBase > molecules, boost::shared_ptr< FPHolderBase > fingerprints)
const boost::shared_ptr< FPHolderBase > & getFpHolder() const
Get the underlying molecule holder implementation.
std::vector< boost::shared_ptr< ROMol > > & getMols()
RDKIT_RDGENERAL_EXPORT std::ostream & toStream(std::ostream &)
Concrete class that holds binary cached molecules in memory.
virtual unsigned int size() const
Get the current library size.
unsigned int addBinary(const std::string &pickle)
const MolHolderBase & getMolecules() const
boost::shared_ptr< ROMol > getMol(unsigned int idx) const
Returns the molecule at the given index.
unsigned int addFingerprint(const ExplicitBitVect &v)
Adds a raw bit vector to the fingerprinter.
std::vector< std::string > & getMols()
unsigned int addSmiles(const std::string &smiles)
virtual unsigned int addMol(const ROMol &m)
#define RDKIT_SUBSTRUCTLIBRARY_EXPORT
a class for bit vectors that are densely occupied
SubstructLibrary(boost::shared_ptr< MolHolderBase > molecules)