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());
119 mols.push_back(pickle);
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; }
148 std::vector<std::string> mols;
154 bool doIsomericSmiles =
true;
162 mols.push_back(smiles);
166 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
169 boost::shared_ptr<ROMol> mol(
SmilesToMol(mols[idx]));
173 virtual unsigned int size()
const {
174 return rdcast<unsigned int>(mols.size());
177 std::vector<std::string> &
getMols() {
return mols; }
178 const std::vector<std::string> &
getMols()
const {
return mols; }
196 std::vector<std::string> mols;
202 bool doIsomericSmiles =
true;
210 mols.push_back(smiles);
214 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
219 return boost::shared_ptr<ROMol>(m);
222 virtual unsigned int size()
const {
223 return rdcast<unsigned int>(mols.size());
226 std::vector<std::string> &
getMols() {
return mols; }
227 const std::vector<std::string> &
getMols()
const {
return mols; }
232 std::vector<ExplicitBitVect *> fps;
236 for (
size_t i = 0; i < fps.size(); ++i)
delete fps[i];
241 fps.push_back(makeFingerprint(m));
242 return rdcast<unsigned int>(fps.size() - 1);
248 return rdcast<unsigned int>(fps.size() - 1);
359 boost::shared_ptr<MolHolderBase> molholder;
360 boost::shared_ptr<FPHolderBase> fpholder;
368 mols(molholder.get()),
372 : molholder(molecules), fpholder(), mols(molholder.get()), fps(0) {}
375 boost::shared_ptr<FPHolderBase> fingerprints)
376 : molholder(molecules),
377 fpholder(fingerprints),
378 mols(molholder.get()),
379 fps(fpholder.get()) {}
382 : molholder(new
MolHolder), fpholder(), mols(molholder.get()),
384 initFromString(pickle);
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());
574 mols = molholder.get();
575 fps = fpholder.get();
579 void toStream(std::ostream &ss)
const;
581 std::string Serialize()
const;
583 void initFromStream(std::istream &ss);
585 void initFromString(
const std::string &text);
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...
const boost::shared_ptr< FPHolderBase > & getFpHolder() const
Get the underlying molecule holder implementation.
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
SubstructLibrary(const std::string &pickle)
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)
boost::shared_ptr< MolHolderBase > & getMolHolder()
Get the underlying molecule holder implementation.
const std::vector< std::string > & getMols() const
Concrete class that holds trusted smiles strings in memory.
const std::vector< boost::shared_ptr< ROMol > > & getMols() const
virtual unsigned int size() const
Get the current library size.
std::vector< std::string > & getMols()
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)
RDKIT_SUBSTRUCTLIBRARY_EXPORT bool SubstructLibraryCanSerialize()
virtual unsigned int addMol(const ROMol &m)
const std::vector< std::string > & getMols() const
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)
boost::shared_ptr< FPHolderBase > & getFpHolder()
Get the underlying molecule holder implementation.
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
const boost::shared_ptr< MolHolderBase > & getMolHolder() const
Base class API for holding molecules to substructure search.
std::vector< ExplicitBitVect * > & getFingerprints()
bool passesFilter(unsigned int idx, const ExplicitBitVect &query) const
Return false if a substructure search can never match the molecule.
std::vector< std::string > & getMols()
CachedTrustedSmilesMolHolder()
std::vector< boost::shared_ptr< ROMol > > & getMols()
virtual ExplicitBitVect * makeFingerprint(const ROMol &m) const
Caller owns the vector!
unsigned int addSmiles(const std::string &smiles)
const std::vector< ExplicitBitVect * > & getFingerprints() const
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.
RDKIT_RDGENERAL_EXPORT std::ostream & toStream(std::ostream &)
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
std::vector< std::string > & getMols()
void resetHolders()
access required for serialization
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.
const std::vector< std::string > & getMols() const