15 #ifndef _RD_QUERY_OPS_H 16 #define _RD_QUERY_OPS_H 22 #ifdef RDK_THREADSAFE_SSS 23 #include <boost/thread/mutex.hpp> 81 return static_cast<int>(
round(massIntegerConversionFactor*at->
getMass()));
114 while(atomBonds.first != atomBonds.second){
137 while(atomBonds.first != atomBonds.second){
169 res->setDataFunc(func);
170 res->setDescription(description);
267 return makeAtomSimpleQuery<T>(massIntegerConversionFactor*what,
queryAtomMass,descr);
389 virtual bool Match(
const ConstAtomPtr what)
const {
432 d_serialNumber(serialNumber)
450 dp_queryMol.reset(query);
460 res->dp_queryMol.reset(
new ROMol(*dp_queryMol,
true));
462 std::set<int>::const_iterator i;
463 for(i=d_set.begin();i!=d_set.end();i++){
468 res->d_serialNumber=d_serialNumber;
473 #ifdef RDK_THREADSAFE_SSS 474 boost::mutex d_mutex;
477 boost::shared_ptr<const ROMol>dp_queryMol;
478 unsigned int d_serialNumber;
481 template <
typename T>
483 template <
typename T>
489 template<
class TargetPtr>
491 int, TargetPtr, true> {
493 std::string propname;
510 virtual bool Match(
const TargetPtr what)
const {
511 bool res = what->hasProp(propname);
534 template<
class Target>
536 const std::string &property)
542 template<
class TargetPtr,
class T>
544 int, TargetPtr, true> {
545 std::string propname;
567 virtual bool Match(
const TargetPtr what)
const {
568 bool res = what->hasProp(propname);
572 T atom_val = what->template getProp<T>(propname);
578 catch (boost::bad_any_cast)
594 this->propname, this->val, this->tolerance);
601 template<
class TargetPtr>
604 std::string propname;
615 const std::string &v,
616 const std::string &tol=
"") :
625 virtual bool Match(
const TargetPtr what)
const {
626 bool res = what->hasProp(propname);
630 std::string atom_val = what->template getProp<std::string>(propname);
631 res = atom_val == this->val;
636 catch (boost::bad_any_cast)
652 this->propname, this->val);
660 template<
class Target,
class T>
662 const std::string &propname,
664 const T&tolerance=T())
667 propname, val, tolerance);
ROMol & getOwningMol() const
returns a reference to the ROMol that owns this Atom
HasPropQuery(const std::string &v)
bool getNegation() const
returns whether or not we are negated
T * makeAtomTotalValenceQuery(int what, const std::string &descr)
returns a Query for matching total valence
T * makeAtomInRingQuery(const std::string &descr)
returns a Query for matching ring atoms
Queries::SetQuery< int, Bond const *, true > BOND_SET_QUERY
static int queryAtomTotalDegree(Atom const *at)
int queryCmp(const T1 v1, const T2 v2, const T1 tol)
T * makeAtomHybridizationQuery(int what, const std::string &descr)
returns a Query for matching hybridization
static int queryAtomHybridization(Atom const *at)
T * makeAtomMassQuery(int what, const std::string &descr)
returns a Query for matching atoms with a particular mass
double round(double v)
rounds a value to the closest int
Queries::Query< int, Atom const *, true > ATOM_NULL_QUERY
Queries::Query< bool, Atom const *, true > ATOM_BOOL_QUERY
Queries::Query< int, TargetPtr, true > * copy() const
returns a copy of this query
bool isBondInRingOfSize(unsigned int idx, unsigned int size) const
returns whether or not the bond with index idx is in a size - ring.
Queries::LessEqualQuery< int, Atom const *, true > ATOM_LESSEQUAL_QUERY
Queries::EqualityQuery< int, Bond const *, true > BOND_EQUALS_QUERY
Queries::Query< int, TargetPtr, true > * copy() const
returns a copy of this query
void setNegation(bool what)
sets whether or not we are negated
virtual bool Match(const TargetPtr what) const
returns whether or not we match the argument
ATOM_NULL_QUERY * makeAtomNullQuery()
returns a Query for matching any atom
ROMol const * getQueryMol() const
returns a pointer to our query molecule
a Query implementing AND: requires all children to be true
T * makeAtomImplicitValenceQuery(int what, const std::string &descr)
returns a Query for matching implicit valence
Queries::LessEqualQuery< int, Bond const *, true > BOND_LESSEQUAL_QUERY
Queries::Query< int, Bond const *, true > BOND_NULL_QUERY
void setTol(MatchFuncArgType what)
sets our tolerance
Atom const * ConstAtomPtr
BOND_EQUALS_QUERY * makeBondOrderEqualsQuery(Bond::BondType what)
returns a Query for matching bond orders
unsigned int getTotalNumHs(bool includeNeighbors=false) const
returns the total number of Hs (implicit and explicit) that this Atom is bound to ...
a Query implementing AND: requires any child to be true
unsigned int getIsotope() const
returns our isotope number
BondDir getBondDir() const
returns our direction
double getMass() const
returns our mass
unsigned int queryAtomAllBondProduct(Atom const *at)
T * makeAtomMinRingSizeQuery(int tgt, const std::string &descr)
returns a Query for matching an atom's minimum ring size
Queries::GreaterEqualQuery< int, Bond const *, true > BOND_GREATEREQUAL_QUERY
static int massIntegerConversionFactor
Queries::EqualityQuery< int, Atom const *, true > ATOM_PROP_QUERY
static int queryAtomExplicitDegree(Atom const *at)
static int queryBondOrder(Bond const *bond)
Queries::LessQuery< int, Bond const *, true > BOND_LESS_QUERY
int TypeConvert(intwhat, Int2Type< false >) const
calls our dataFunc (if it's set) on what and returns the result, otherwise returns what ...
static int queryAtomImplicitHCount(Atom const *at)
unsigned int getIdx() const
returns our index within the ROMol
static int getAtIdx(Atom const *at)
returns the index of an atom
T * makeAtomImplicitHCountQuery(int what, const std::string &descr)
returns a Query for matching implicit hydrogen count
static int queryAtomMass(Atom const *at)
Queries::EqualityQuery< int, const Target *, true > * makePropQuery(const std::string &propname, const T &val, const T &tolerance=T())
pulls in the core RDKit functionality
static int queryIsBondInRing(Bond const *bond)
ROMol is a molecule class that is intended to have a fixed topology.
unsigned int minAtomRingSize(unsigned int idx) const
returns the size of the smallest ring atom idx is involved in
virtual bool Match(const ConstAtomPtr what) const
unsigned int getDegree() const
Queries::EqualityQuery< int, Bond const *, true > BOND_PROP_QUERY
Queries::LessQuery< int, Atom const *, true > ATOM_LESS_QUERY
T * makeAtomExplicitDegreeQuery(int what, const std::string &descr)
returns a Query for matching explicit degree
static int queryBondDir(Bond const *bond)
static int queryAtomUnsaturated(Atom const *at)
virtual bool Match(const TargetPtr what) const
returns whether or not we match the argument
virtual bool Match(const TargetPtr what) const
returns whether or not we match the argument
a Query implementing a range: arguments must fall in a particular range of values.
unsigned int getTotalDegree() const
int queryAtomIsInRingOfSize(Atom const *at)
Queries::EqualityQuery< int, const Target *, true > * makeHasPropQuery(const std::string &property)
returns a Query for matching atoms that have a particular property
Queries::RangeQuery< int, Bond const *, true > BOND_RANGE_QUERY
T * makeAtomIsotopeQuery(int what, const std::string &descr)
returns a Query for matching atoms with a particular isotope
T * makeAtomAliphaticQuery(const std::string &descr)
returns a Query for matching aliphatic atoms
BOND_EQUALS_QUERY * makeBondInNRingsQuery(int tgt)
returns a Query for matching bonds in a particular number of rings
Queries::GreaterQuery< int, Bond const *, true > BOND_GREATER_QUERY
Queries::GreaterEqualQuery< int, Atom const *, true > ATOM_GREATEREQUAL_QUERY
int getAtomicNum() const
returns our atomic number
T * makeAtomUnsaturatedQuery(const std::string &descr)
returns a Query for matching atoms with unsaturation:
unsigned int numAtomRings(unsigned int idx) const
returns the number of rings atom idx is involved in
Queries::Query< int, ConstAtomPtr, true > * copy() const
returns a copy of this query
class to allow integer values to pick templates
static int queryAtomIsotope(Atom const *at)
int getExplicitValence() const
returns the explicit valence (including Hs) of this atom
MolGraph const & getTopology() const
brief returns a pointer to our underlying BGL object
BOND_NULL_QUERY * makeBondNullQuery()
returns a Query for matching any bond
allows use of recursive structure queries (e.g. recursive SMARTS)
RecursiveStructureQuery()
Bond const * ConstBondPtr
static int queryAtomExplicitValence(Atom const *at)
static int queryIsAtomInRing(Atom const *at)
a Query implementing <= using a particular value (and an optional tolerance)
HasPropWithValueQuery(const std::string &prop, const std::string &v, const std::string &tol="")
static int queryAtomAromatic(Atom const *at)
unsigned int getNumExplicitHs() const
returns our number of explict Hs
Includes a bunch of functionality for handling Atom and Bond queries.
static int queryBondMinRingSize(Bond const *bond)
static int queryAtomNum(Atom const *at)
MatchFuncArgType(* d_dataFunc)(DataFuncArgType)
Queries::RangeQuery< int, Atom const *, true > ATOM_RANGE_QUERY
T * makeAtomRingBondCountQuery(int what, const std::string &descr)
returns a Query for matching atoms with a particular number of ring bonds
T * makeAtomAromaticQuery(const std::string &descr)
returns a Query for matching the isAromatic flag
static int queryAtomFormalCharge(Atom const *at)
a Query implementing < using a particular value (and an optional tolerance)
a Query implementing ==: arguments must match a particular value (within an optional tolerance) ...
T * makeAtomNumQuery(int what, const std::string &descr)
returns a Query for matching atomic number
T * makeAtomFormalChargeQuery(int what, const std::string &descr)
returns a Query for matching formal charge
class for representing a bond
static int queryAtomHeavyAtomDegree(Atom const *at)
T * makeAtomExplicitValenceQuery(int what, const std::string &descr)
returns a Query for matching explicit valence
int getImplicitValence() const
returns the implicit valence for this Atom
RingInfo * getRingInfo() const
void insert(const MatchFuncArgType what)
insert an entry into our set
void setDataFunc(int(*what)(ConstAtomPtr))
sets our data function
bool isAtomInRingOfSize(unsigned int idx, unsigned int size) const
returns whether or not the atom with index idx is in a size - ring.
BondDir
the bond's direction (for chirality)
Queries::SetQuery< int, Atom const *, true > ATOM_SET_QUERY
static int queryIsAtomInNRings(Atom const *at)
void setQueryMol(ROMol const *query)
sets the molecule we'll use recursively
unsigned int getSerialNumber() const
Queries::AndQuery< int, Bond const *, true > BOND_AND_QUERY
Queries::GreaterQuery< int, Atom const *, true > ATOM_GREATER_QUERY
RecursiveStructureQuery(ROMol const *query, unsigned int serialNumber=0)
initialize from an ROMol pointer
static int queryAtomHasImplicitH(Atom const *at)
#define PRECONDITION(expr, mess)
static int queryAtomMinRingSize(Atom const *at)
Queries::AndQuery< int, Atom const *, true > ATOM_AND_QUERY
unsigned int numBondRings(unsigned int idx) const
returns the number of rings bond idx is involved in
HybridizationType getHybridization() const
returns our hybridization
T * makeAtomHasRingBondQuery(const std::string &descr)
returns a Query for matching atoms with a particular number of ring bonds
std::string d_description
Queries::OrQuery< int, Bond const *, true > BOND_OR_QUERY
T * makeAtomHasImplicitHQuery(const std::string &descr)
returns a Query for matching ring atoms
Queries::OrQuery< int, Atom const *, true > ATOM_OR_QUERY
T * makeAtomInNRingsQuery(int what, const std::string &descr)
returns a Query for matching atoms in a particular number of rings
static int queryAtomAliphatic(Atom const *at)
HasPropWithValueQuery(const std::string &prop, const T &v, const T &tol=0.0)
a Query implementing > using a particular value (and an optional tolerance)
BOND_EQUALS_QUERY * makeBondMinRingSizeQuery(int what)
returns a Query for matching a bond's minimum ring size
ATOM_EQUALS_QUERY * makeAtomInRingOfSizeQuery(int tgt)
returns a Query for matching atoms in rings of a particular size
static int queryAtomRingBondCount(Atom const *at)
a Query implementing >= using a particular value (and an optional tolerance)
Pulls in all the query types.
BOND_EQUALS_QUERY * makeBondDirEqualsQuery(Bond::BondDir what)
returns a Query for matching bond directions
Queries::Query< int, Atom const *, true > * copy() const
returns a copy of this query
T * makeAtomSimpleQuery(int what, int func(Atom const *), const std::string &description="Atom Simple")
int getFormalCharge() const
returns the formal charge of this atom
int queryBondIsInRingOfSize(Bond const *bond)
unsigned int getIdx() const
returns our index within the ROMol
Queries::Query< int, TargetPtr, true > * copy() const
returns a copy of this query
static int queryAtomHasRingBond(Atom const *at)
BOND_EQUALS_QUERY * makeBondInRingOfSizeQuery(int what)
returns a Query for matching bonds in rings of a particular size
OBOND_ITER_PAIR getAtomBonds(Atom const *at) const
provides access to all Bond objects connected to an Atom
ROMol & getOwningMol() const
returns a reference to the ROMol that owns this Bond
Queries::Query< bool, Bond const *, true > BOND_BOOL_QUERY
static int queryAtomRingMembership(Atom const *at)
Base class for all queries.
static int queryAtomHCount(Atom const *at)
unsigned int queryAtomBondProduct(Atom const *at)
static int queryAtomTotalValence(Atom const *at)
BOND_EQUALS_QUERY * makeBondIsInRingQuery()
returns a Query for matching ring bonds
unsigned int minBondRingSize(unsigned int idx) const
returns the size of the smallest ring bond idx is involved in
The class for representing atoms.
Queries::XOrQuery< int, Bond const *, true > BOND_XOR_QUERY
BondType getBondType() const
returns our bondType
a Query implementing XOR: requires exactly one child to be true
Queries::EqualityQuery< int, Atom const *, true > ATOM_EQUALS_QUERY
void setDescription(const std::string &descr)
sets our text description
bool getIsAromatic() const
returns our isAromatic flag
static int queryAtomImplicitValence(Atom const *at)
Class to allow us to throw a KeyError from C++ and have it make it back to Python.
Queries::XOrQuery< int, Atom const *, true > ATOM_XOR_QUERY
T * makeAtomHCountQuery(int what, const std::string &descr)
returns a Query for matching hydrogen count
T * makeAtomTotalDegreeQuery(int what, const std::string &descr)
returns a Query for matching atomic degree
const int getTol() const
returns out tolerance
static int queryIsBondInNRings(Bond const *at)