32 #ifndef RDKIT_SUBSTRUCT_LIBRARY 33 #define RDKIT_SUBSTRUCT_LIBRARY 57 virtual unsigned int addMol(
const ROMol &m) = 0;
60 virtual boost::shared_ptr<ROMol> getMol(
unsigned int)
const = 0;
63 virtual unsigned int size()
const = 0;
72 std::vector<boost::shared_ptr<ROMol>> mols;
78 mols.push_back(boost::make_shared<ROMol>(m));
82 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
87 virtual unsigned int size()
const {
88 return rdcast<unsigned int>(mols.size());
101 std::vector<std::string> mols;
107 mols.push_back(std::string());
115 mols.push_back(pickle);
119 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
121 boost::shared_ptr<ROMol> mol(
new ROMol);
126 virtual unsigned int size()
const {
127 return rdcast<unsigned int>(mols.size());
141 std::vector<std::string> mols;
147 bool doIsomericSmiles =
true;
155 mols.push_back(smiles);
159 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
162 boost::shared_ptr<ROMol> mol(
SmilesToMol(mols[idx]));
166 virtual unsigned int size()
const {
167 return rdcast<unsigned int>(mols.size());
186 std::vector<std::string> mols;
192 bool doIsomericSmiles =
true;
200 mols.push_back(smiles);
204 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
209 return boost::shared_ptr<ROMol>(m);
212 virtual unsigned int size()
const {
213 return rdcast<unsigned int>(mols.size());
219 std::vector<ExplicitBitVect *> fps;
223 for (
size_t i = 0; i < fps.size(); ++i)
delete fps[i];
228 fps.push_back(makeFingerprint(m));
229 return rdcast<unsigned int>(fps.size() - 1);
235 return rdcast<unsigned int>(fps.size() - 1);
343 boost::shared_ptr<MolHolderBase> molholder;
344 boost::shared_ptr<FPHolderBase> fpholder;
352 mols(molholder.get()),
356 : molholder(molecules), fpholder(), mols(molholder.get()), fps(0) {}
359 boost::shared_ptr<FPHolderBase> fingerprints)
360 : molholder(molecules),
361 fpholder(fingerprints),
362 mols(molholder.get()),
363 fps(fpholder.get()) {}
367 PRECONDITION(mols,
"Molecule holder NULL in SubstructLibrary");
372 PRECONDITION(mols,
"Molecule holder NULL in SubstructLibrary");
396 unsigned int addMol(
const ROMol &mol);
412 std::vector<unsigned int> getMatches(
const ROMol &query,
413 bool recursionPossible =
true,
414 bool useChirality =
true,
415 bool useQueryQueryMatches =
false,
417 int maxResults = -1);
434 std::vector<unsigned int> getMatches(
435 const ROMol &query,
unsigned int startIdx,
unsigned int endIdx,
436 bool recursionPossible =
true,
bool useChirality =
true,
437 bool useQueryQueryMatches =
false,
int numThreads = -1,
438 int maxResults = -1);
452 unsigned int countMatches(
const ROMol &query,
bool recursionPossible =
true,
453 bool useChirality =
true,
454 bool useQueryQueryMatches =
false,
455 int numThreads = -1);
470 unsigned int countMatches(
const ROMol &query,
unsigned int startIdx,
471 unsigned int endIdx,
bool recursionPossible =
true,
472 bool useChirality =
true,
473 bool useQueryQueryMatches =
false,
474 int numThreads = -1);
488 bool hasMatch(
const ROMol &query,
bool recursionPossible =
true,
489 bool useChirality =
true,
bool useQueryQueryMatches =
false,
490 int numThreads = -1);
506 bool hasMatch(
const ROMol &query,
unsigned int startIdx,
unsigned int endIdx,
507 bool recursionPossible =
true,
bool useChirality =
true,
508 bool useQueryQueryMatches =
false,
int numThreads = -1);
514 boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
516 PRECONDITION(mols,
"molholder is null in SubstructLibrary");
526 PRECONDITION(mols,
"molholder is null in SubstructLibrary");
532 PRECONDITION(mols,
"molholder is null in SubstructLibrary");
533 return rdcast<unsigned int>(molholder->size());
SubstructLibrary(boost::shared_ptr< MolHolderBase > molecules, boost::shared_ptr< FPHolderBase > fingerprints)
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...
boost::shared_ptr< ROMol > getMol(unsigned int idx) const
Returns the molecule at the given index.
const ExplicitBitVect & getFingerprint(unsigned int idx) const
static void pickleMol(const ROMol *mol, std::ostream &ss)
pickles a molecule and sends the results to stream ss
MolHolderBase & getMolHolder()
Get the underlying molecule holder implementation.
RDKIT_SMILESPARSE_EXPORT RWMol * SmilesToMol(const std::string &smi, const SmilesParserParams ¶ms)
RWMol is a molecule class that is intended to be edited.
boost::shared_ptr< ROMol > operator[](unsigned int idx)
Returns the molecule at the given index.
virtual boost::shared_ptr< ROMol > getMol(unsigned int idx) const
virtual unsigned int size() const
Get the current library size.
virtual boost::shared_ptr< ROMol > getMol(unsigned int idx) const
unsigned int size() const
return the number of molecules in the library
#define RDKIT_SUBSTRUCTLIBRARY_EXPORT
Concrete class that holds molecules in memory.
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
virtual unsigned int addMol(const ROMol &m)
Concrete class that holds trusted smiles strings in memory.
virtual unsigned int size() const
Get the current library size.
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
pulls in the core RDKit functionality
RDKIT_DATASTRUCTS_EXPORT bool AllProbeBitsMatch(const char *probe, const char *ref)
virtual unsigned int addMol(const ROMol &m)
unsigned int addMol(const ROMol &m)
Adds a molecule to the fingerprinter.
Base FPI for the fingerprinter used to rule out impossible matches.
virtual boost::shared_ptr< ROMol > getMol(unsigned int) const =0
virtual unsigned int addMol(const ROMol &m)
virtual unsigned int size() const
Get the current library size.
void updatePropertyCache(bool strict=true)
calculates any of our lazy properties
const MolHolderBase & getMolecules() const
SubstructLibrary(boost::shared_ptr< MolHolderBase > molecules)
Class to allow us to throw an IndexError from C++ and have it make it back to Python.
virtual boost::shared_ptr< ROMol > getMol(unsigned int idx) const
const FPHolderBase & getFingerprints() const
Base class API for holding molecules to substructure search.
bool passesFilter(unsigned int idx, const ExplicitBitVect &query) const
Return false if a substructure search can never match the molecule.
CachedTrustedSmilesMolHolder()
virtual ExplicitBitVect * makeFingerprint(const ROMol &m) const
Caller owns the vector!
unsigned int addSmiles(const std::string &smiles)
Contains general bit-comparison and similarity operations.
unsigned int addSmiles(const std::string &smiles)
static void molFromPickle(const std::string &pickle, ROMol *mol)
constructs a molecule from a pickle stored in a string
unsigned int addBinary(const std::string &pickle)
Concrete class that holds binary cached molecules in memory.
#define PRECONDITION(expr, mess)
Uses the pattern fingerprinter to rule out matches.
virtual unsigned int addMol(const ROMol &m)
unsigned int addFingerprint(const ExplicitBitVect &v)
Adds a raw bit vector to the fingerprinter.
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
a class for bit vectors that are densely occupied
virtual boost::shared_ptr< ROMol > getMol(unsigned int idx) const
FPHolderBase & getFingerprints()
Get the underlying fingerprint implementation.
Concrete class that holds smiles strings in memory.
virtual unsigned int size() const
Get the current library size.
Substructure Search a library of molecules.