31 #ifndef RDKIT_SUBSTRUCT_LIBRARY 32 #define RDKIT_SUBSTRUCT_LIBRARY 59 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int)
const = 0;
62 virtual unsigned int size()
const = 0;
71 std::vector<boost::shared_ptr<ROMol> > mols;
77 mols.push_back(boost::make_shared<ROMol>(m));
81 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
82 if(idx >= mols.size())
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 {
120 if(idx >= mols.size())
122 boost::shared_ptr<ROMol> mol(
new ROMol);
127 virtual unsigned int size()
const {
128 return rdcast<unsigned int>(mols.size());
142 std::vector<std::string> mols;
148 bool doIsomericSmiles =
true;
156 mols.push_back(smiles);
160 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
161 if(idx >= mols.size())
164 boost::shared_ptr<ROMol> mol(
SmilesToMol(mols[idx]));
168 virtual unsigned int size()
const {
169 return rdcast<unsigned int>(mols.size());
188 std::vector<std::string> mols;
194 bool doIsomericSmiles =
true;
202 mols.push_back(smiles);
206 virtual boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
207 if(idx >= mols.size())
212 return boost::shared_ptr<ROMol>(m);
215 virtual unsigned int size()
const {
216 return rdcast<unsigned int>(mols.size());
222 std::vector<ExplicitBitVect *> fps;
226 for (
size_t i = 0; i < fps.size(); ++i)
delete fps[i];
232 fps.push_back(makeFingerprint(m));
233 return rdcast<unsigned int>(fps.size() - 1);
239 return rdcast<unsigned int>(fps.size() - 1);
244 if(idx >= fps.size())
252 if(idx >= fps.size())
280 boost::shared_ptr<MolHolderBase> molholder;
281 boost::shared_ptr<FPHolderBase> fpholder;
289 mols(molholder.get()),
293 : molholder(molecules), fpholder(), mols(molholder.get()), fps(0) {}
296 boost::shared_ptr<FPHolderBase> fingerprints)
297 : molholder(molecules),
298 fpholder(fingerprints),
299 mols(molholder.get()),
300 fps(fpholder.get()) {}
304 PRECONDITION(mols,
"Molecule holder NULL in SubstructLibrary");
309 PRECONDITION(mols,
"Molecule holder NULL in SubstructLibrary");
346 std::vector<unsigned int> getMatches(
const ROMol &query,
347 bool recursionPossible=
true,
348 bool useChirality=
true,
349 bool useQueryQueryMatches=
false,
365 std::vector<unsigned int> getMatches(
const ROMol &query,
366 unsigned int startIdx,
unsigned int endIdx,
367 bool recursionPossible=
true,
368 bool useChirality=
true,
369 bool useQueryQueryMatches=
false,
382 unsigned int countMatches(
const ROMol &query,
383 bool recursionPossible=
true,
384 bool useChirality=
true,
385 bool useQueryQueryMatches=
false,
398 unsigned int countMatches(
const ROMol &query,
399 unsigned int startIdx,
unsigned int endIdx,
400 bool recursionPossible=
true,
401 bool useChirality=
true,
402 bool useQueryQueryMatches=
false,
414 bool hasMatch(
const ROMol &query,
415 bool recursionPossible=
true,
416 bool useChirality=
true,
417 bool useQueryQueryMatches=
false,
430 bool hasMatch(
const ROMol &query,
431 unsigned int startIdx,
unsigned int endIdx,
432 bool recursionPossible=
true,
433 bool useChirality=
true,
434 bool useQueryQueryMatches=
false,
441 boost::shared_ptr<ROMol>
getMol(
unsigned int idx)
const {
443 PRECONDITION(mols,
"molholder is null in SubstructLibrary");
451 boost::shared_ptr<ROMol> operator[] (
unsigned int idx) {
453 PRECONDITION(mols,
"molholder is null in SubstructLibrary");
459 PRECONDITION(mols,
"molholder is null in SubstructLibrary");
460 return rdcast<unsigned int>(molholder->size());
SubstructLibrary(boost::shared_ptr< MolHolderBase > molecules, boost::shared_ptr< FPHolderBase > fingerprints)
boost::shared_ptr< ROMol > getMol(unsigned int idx) const
Returns the molecule at the given index.
const ExplicitBitVect & getFingerprint(unsigned int idx) const
Get the bit vector at the specified index (throws IndexError if out of range)
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.
RWMol is a molecule class that is intended to be edited.
std::string MolToSmiles(const ROMol &mol, bool doIsomericSmiles=false, bool doKekule=false, int rootedAtAtom=-1, bool canonical=true, bool allBondsExplicit=false, bool allHsExplicit=false)
returns canonical SMILES for a molecule
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
Concrete class that holds molecules in memory.
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.
pulls in the core RDKit functionality
ROMol is a molecule class that is intended to have a fixed topology.
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
RWMol * SmilesToMol(const std::string &smi, const SmilesParserParams ¶ms)
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...
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 so substructure search.
bool passesFilter(unsigned int idx, const ExplicitBitVect &query) const
Return false if a substructure search can never match the molecule.
virtual unsigned int addMol(const ROMol &m)=0
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.
bool AllProbeBitsMatch(const char *probe, const char *ref)
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 unsigned int size() const =0
Get the current library size.
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.
Substtructure Search a library of molecules.
void pickle(const boost::shared_ptr< EnumerationStrategyBase > &enumerator, std::ostream &ss)
pickles a EnumerationStrategy and adds the results to a stream ss