RDKit: QueryOps.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

QueryOps.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2010 Greg Landrum and Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10
11 //! \file QueryOps.h
12 /*!
13 \brief Includes a bunch of functionality for handling Atom and Bond queries.
14 */
15 #ifndef _RD_QUERY_OPS_H
16 #define _RD_QUERY_OPS_H
17
18 #include <GraphMol/RDKitBase.h>
19 #include <Query/QueryObjects.h>
20 #include <Query/Query.h>
21
22 #ifdef RDK_THREADSAFE_SSS
23 #include <boost/thread/mutex.hpp>
24 #endif
25
26 namespace RDKit {
27 typedef Queries::Query<bool, Atom const *, true> ATOM_BOOL_QUERY;
28 typedef Queries::Query<bool, Bond const *, true> BOND_BOOL_QUERY;
29
30 typedef Queries::AndQuery<int, Atom const *, true> ATOM_AND_QUERY;
31 typedef Queries::AndQuery<int, Bond const *, true> BOND_AND_QUERY;
32
33 typedef Queries::OrQuery<int, Atom const *, true> ATOM_OR_QUERY;
34 typedef Queries::OrQuery<int, Bond const *, true> BOND_OR_QUERY;
35
36 typedef Queries::XOrQuery<int, Atom const *, true> ATOM_XOR_QUERY;
37 typedef Queries::XOrQuery<int, Bond const *, true> BOND_XOR_QUERY;
38
39 typedef Queries::EqualityQuery<int, Atom const *, true> ATOM_EQUALS_QUERY;
40 typedef Queries::EqualityQuery<int, Bond const *, true> BOND_EQUALS_QUERY;
41
42 typedef Queries::GreaterQuery<int, Atom const *, true> ATOM_GREATER_QUERY;
43 typedef Queries::GreaterQuery<int, Bond const *, true> BOND_GREATER_QUERY;
44
45 typedef Queries::GreaterEqualQuery<int, Atom const *, true>
46 ATOM_GREATEREQUAL_QUERY;
47 typedef Queries::GreaterEqualQuery<int, Bond const *, true>
48 BOND_GREATEREQUAL_QUERY;
49
50 typedef Queries::LessQuery<int, Atom const *, true> ATOM_LESS_QUERY;
51 typedef Queries::LessQuery<int, Bond const *, true> BOND_LESS_QUERY;
52
53 typedef Queries::LessEqualQuery<int, Atom const *, true> ATOM_LESSEQUAL_QUERY;
54 typedef Queries::LessEqualQuery<int, Bond const *, true> BOND_LESSEQUAL_QUERY;
55
56 typedef Queries::RangeQuery<int, Atom const *, true> ATOM_RANGE_QUERY;
57 typedef Queries::RangeQuery<int, Bond const *, true> BOND_RANGE_QUERY;
58
59 typedef Queries::SetQuery<int, Atom const *, true> ATOM_SET_QUERY;
60 typedef Queries::SetQuery<int, Bond const *, true> BOND_SET_QUERY;
61
62 typedef Queries::Query<int, Bond const *, true> BOND_NULL_QUERY;
63 typedef Queries::Query<int, Atom const *, true> ATOM_NULL_QUERY;
64
65 // -------------------------------------------------
66 // common atom queries
67
68 static inline int queryAtomAromatic(Atom const *at) {
69 return at->getIsAromatic();
70 };
71 static inline int queryAtomAliphatic(Atom const *at) {
72 return !(at->getIsAromatic());
73 };
74 static inline int queryAtomExplicitDegree(Atom const *at) {
75 return at->getDegree();
76 };
77 static inline int queryAtomTotalDegree(Atom const *at) {
78 return at->getTotalDegree();
79 };
80 static inline int queryAtomHeavyAtomDegree(Atom const *at) {
81 return at->getTotalDegree() - at->getTotalNumHs(true);
82 };
83 static inline int queryAtomHCount(Atom const *at) {
84 return at->getTotalNumHs(true);
85 };
86 static inline int queryAtomImplicitHCount(Atom const *at) {
87 return at->getTotalNumHs(false);
88 };
89 static inline int queryAtomHasImplicitH(Atom const *at) {
90 return int(at->getTotalNumHs(false) > 0);
91 };
92 static inline int queryAtomImplicitValence(Atom const *at) {
93 return at->getImplicitValence();
94 };
95 static inline int queryAtomExplicitValence(Atom const *at) {
96 return at->getExplicitValence() - at->getNumExplicitHs();
97 };
98 static inline int queryAtomTotalValence(Atom const *at) {
99 return at->getExplicitValence() + at->getImplicitValence();
100 };
101 static inline int queryAtomUnsaturated(Atom const *at) {
102 return static_cast<int>(at->getDegree()) < at->getExplicitValence();
103 };
104 static inline int queryAtomNum(Atom const *at) { return at->getAtomicNum(); };
105 const int massIntegerConversionFactor = 1000;
106 static inline int queryAtomMass(Atom const *at) {
107 return static_cast<int>(round(massIntegerConversionFactor * at->getMass()));
108 };
109 static inline int queryAtomIsotope(Atom const *at) {
110 return static_cast<int>(at->getIsotope());
111 };
112 static inline int queryAtomFormalCharge(Atom const *at) {
113 return static_cast<int>(at->getFormalCharge());
114 };
115 static inline int queryAtomHybridization(Atom const *at) {
116 return at->getHybridization();
117 };
118 unsigned int queryAtomBondProduct(Atom const *at);
119 unsigned int queryAtomAllBondProduct(Atom const *at);
120
121 // -------------------------------------------------
122 // common bond queries
123
124 static inline int queryBondOrder(Bond const *bond) {
125 return static_cast<int>(bond->getBondType());
126 };
127 static inline int queryBondDir(Bond const *bond) {
128 return static_cast<int>(bond->getBondDir());
129 };
130 static inline int queryIsBondInNRings(Bond const *at) {
131 return at->getOwningMol().getRingInfo()->numBondRings(at->getIdx());
132 };
133
134 // -------------------------------------------------
135 // ring queries
136
137 static inline int queryIsAtomInNRings(Atom const *at) {
138 return at->getOwningMol().getRingInfo()->numAtomRings(at->getIdx());
139 };
140 static inline int queryIsAtomInRing(Atom const *at) {
141 return at->getOwningMol().getRingInfo()->numAtomRings(at->getIdx()) != 0;
142 };
143 static inline int queryAtomHasRingBond(Atom const *at) {
144 ROMol::OBOND_ITER_PAIR atomBonds = at->getOwningMol().getAtomBonds(at);
145 while (atomBonds.first != atomBonds.second) {
146 unsigned int bondIdx =
147 at->getOwningMol().getTopology()[*atomBonds.first]->getIdx();
148 if (at->getOwningMol().getRingInfo()->numBondRings(bondIdx)) {
149 return 1;
150 }
151 ++atomBonds.first;
152 }
153 return 0;
154 };
155 static inline int queryIsBondInRing(Bond const *bond) {
156 return bond->getOwningMol().getRingInfo()->numBondRings(bond->getIdx()) != 0;
157 };
158 static inline int queryAtomMinRingSize(Atom const *at) {
159 return at->getOwningMol().getRingInfo()->minAtomRingSize(at->getIdx());
160 };
161 static inline int queryBondMinRingSize(Bond const *bond) {
162 return bond->getOwningMol().getRingInfo()->minBondRingSize(bond->getIdx());
163 };
164
165 static inline int queryAtomRingBondCount(Atom const *at) {
166 // EFF: cache this result
167 int res = 0;
168 ROMol::OBOND_ITER_PAIR atomBonds = at->getOwningMol().getAtomBonds(at);
169 while (atomBonds.first != atomBonds.second) {
170 unsigned int bondIdx =
171 at->getOwningMol().getTopology()[*atomBonds.first]->getIdx();
172 if (at->getOwningMol().getRingInfo()->numBondRings(bondIdx)) {
173 res++;
174 }
175 ++atomBonds.first;
176 }
177 return res;
178 }
179
180 template <int tgt>
181 int queryAtomIsInRingOfSize(Atom const *at) {
182 if (at->getOwningMol().getRingInfo()->isAtomInRingOfSize(at->getIdx(), tgt)) {
183 return tgt;
184 } else {
185 return 0;
186 }
187 };
188 template <int tgt>
189 int queryBondIsInRingOfSize(Bond const *bond) {
190 if (bond->getOwningMol().getRingInfo()->isBondInRingOfSize(bond->getIdx(),
191 tgt)) {
192 return tgt;
193 } else {
194 return 0;
195 }
196 };
197
198 template <class T>
199 T *makeAtomSimpleQuery(int what, int func(Atom const *),
200 const std::string &description = "Atom Simple") {
201 T *res = new T;
202 res->setVal(what);
203 res->setDataFunc(func);
204 res->setDescription(description);
205 return res;
206 }
207
208 //! returns a Query for matching atomic number
209 template <class T>
210 T *makeAtomNumQuery(int what, const std::string &descr) {
211 return makeAtomSimpleQuery<T>(what, queryAtomNum, descr);
212 }
213 //! \overload
214 ATOM_EQUALS_QUERY *makeAtomNumQuery(int what);
215
216 //! returns a Query for matching implicit valence
217 template <class T>
218 T *makeAtomImplicitValenceQuery(int what, const std::string &descr) {
219 return makeAtomSimpleQuery<T>(what, queryAtomImplicitValence, descr);
220 }
221 //! \overload
222 ATOM_EQUALS_QUERY *makeAtomImplicitValenceQuery(int what);
223
224 //! returns a Query for matching explicit valence
225 template <class T>
226 T *makeAtomExplicitValenceQuery(int what, const std::string &descr) {
227 return makeAtomSimpleQuery<T>(what, queryAtomExplicitValence, descr);
228 }
229 //! \overload
230 ATOM_EQUALS_QUERY *makeAtomExplicitValenceQuery(int what);
231
232 //! returns a Query for matching total valence
233 template <class T>
234 T *makeAtomTotalValenceQuery(int what, const std::string &descr) {
235 return makeAtomSimpleQuery<T>(what, queryAtomTotalValence, descr);
236 }
237 //! \overload
238 ATOM_EQUALS_QUERY *makeAtomTotalValenceQuery(int what);
239
240 //! returns a Query for matching explicit degree
241 template <class T>
242 T *makeAtomExplicitDegreeQuery(int what, const std::string &descr) {
243 return makeAtomSimpleQuery<T>(what, queryAtomExplicitDegree, descr);
244 }
245 //! \overload
246 ATOM_EQUALS_QUERY *makeAtomExplicitDegreeQuery(int what);
247
248 //! returns a Query for matching atomic degree
249 template <class T>
250 T *makeAtomTotalDegreeQuery(int what, const std::string &descr) {
251 return makeAtomSimpleQuery<T>(what, queryAtomTotalDegree, descr);
252 }
253 //! \overload
254 ATOM_EQUALS_QUERY *makeAtomTotalDegreeQuery(int what);
255
256 //! returns a Query for matching hydrogen count
257 template <class T>
258 T *makeAtomHCountQuery(int what, const std::string &descr) {
259 return makeAtomSimpleQuery<T>(what, queryAtomHCount, descr);
260 }
261 //! \overload
262 ATOM_EQUALS_QUERY *makeAtomHCountQuery(int what);
263
264 //! returns a Query for matching ring atoms
265 template <class T>
266 T *makeAtomHasImplicitHQuery(const std::string &descr) {
267 return makeAtomSimpleQuery<T>(true, queryAtomHasImplicitH, descr);
268 }
269 //! \overload
270 ATOM_EQUALS_QUERY *makeAtomHasImplicitHQuery();
271
272 //! returns a Query for matching implicit hydrogen count
273 template <class T>
274 T *makeAtomImplicitHCountQuery(int what, const std::string &descr) {
275 return makeAtomSimpleQuery<T>(what, queryAtomImplicitHCount, descr);
276 }
277 //! \overload
278 ATOM_EQUALS_QUERY *makeAtomImplicitHCountQuery(int what);
279
280 //! returns a Query for matching the \c isAromatic flag
281 template <class T>
282 T *makeAtomAromaticQuery(const std::string &descr) {
283 return makeAtomSimpleQuery<T>(true, queryAtomAromatic, descr);
284 }
285 //! \overload
286 ATOM_EQUALS_QUERY *makeAtomAromaticQuery();
287
288 //! returns a Query for matching aliphatic atoms
289 template <class T>
290 T *makeAtomAliphaticQuery(const std::string &descr) {
291 return makeAtomSimpleQuery<T>(true, queryAtomAliphatic, descr);
292 }
293 //! \overload
294 ATOM_EQUALS_QUERY *makeAtomAliphaticQuery();
295
296 //! returns a Query for matching atoms with a particular mass
297 template <class T>
298 T *makeAtomMassQuery(int what, const std::string &descr) {
299 return makeAtomSimpleQuery<T>(massIntegerConversionFactor * what,
300 queryAtomMass, descr);
301 }
302 //! \overload
303 ATOM_EQUALS_QUERY *makeAtomMassQuery(int what);
304
305 //! returns a Query for matching atoms with a particular isotope
306 template <class T>
307 T *makeAtomIsotopeQuery(int what, const std::string &descr) {
308 return makeAtomSimpleQuery<T>(what, queryAtomIsotope, descr);
309 }
310 //! \overload
311 ATOM_EQUALS_QUERY *makeAtomIsotopeQuery(int what);
312
313 //! returns a Query for matching formal charge
314 template <class T>
315 T *makeAtomFormalChargeQuery(int what, const std::string &descr) {
316 return makeAtomSimpleQuery<T>(what, queryAtomFormalCharge, descr);
317 }
318 //! \overload
319 ATOM_EQUALS_QUERY *makeAtomFormalChargeQuery(int what);
320
321 //! returns a Query for matching hybridization
322 template <class T>
323 T *makeAtomHybridizationQuery(int what, const std::string &descr) {
324 return makeAtomSimpleQuery<T>(what, queryAtomHybridization, descr);
325 }
326 //! \overload
327 ATOM_EQUALS_QUERY *makeAtomHybridizationQuery(int what);
328
329 //! returns a Query for matching atoms with unsaturation:
330 template <class T>
331 T *makeAtomUnsaturatedQuery(const std::string &descr) {
332 return makeAtomSimpleQuery<T>(true, queryAtomUnsaturated, descr);
333 }
334 //! \overload
335 ATOM_EQUALS_QUERY *makeAtomUnsaturatedQuery();
336
337 //! returns a Query for matching ring atoms
338 template <class T>
339 T *makeAtomInRingQuery(const std::string &descr) {
340 return makeAtomSimpleQuery<T>(true, queryIsAtomInRing, descr);
341 }
342 //! \overload
343 ATOM_EQUALS_QUERY *makeAtomInRingQuery();
344
345 //! returns a Query for matching atoms in a particular number of rings
346 template <class T>
347 T *makeAtomInNRingsQuery(int what, const std::string &descr) {
348 return makeAtomSimpleQuery<T>(what, queryIsAtomInNRings, descr);
349 }
350 //! \overload
351 ATOM_EQUALS_QUERY *makeAtomInNRingsQuery(int what);
352
353 //! returns a Query for matching atoms in rings of a particular size
354 ATOM_EQUALS_QUERY *makeAtomInRingOfSizeQuery(int tgt);
355
356 //! returns a Query for matching an atom's minimum ring size
357 template <class T>
358 T *makeAtomMinRingSizeQuery(int tgt, const std::string &descr) {
359 return makeAtomSimpleQuery<T>(tgt, queryAtomMinRingSize, descr);
360 }
361 //! \overload
362 ATOM_EQUALS_QUERY *makeAtomMinRingSizeQuery(int tgt);
363
364 //! returns a Query for matching atoms with a particular number of ring bonds
365 template <class T>
366 T *makeAtomRingBondCountQuery(int what, const std::string &descr) {
367 return makeAtomSimpleQuery<T>(what, queryAtomRingBondCount, descr);
368 }
369 //! \overload
370 ATOM_EQUALS_QUERY *makeAtomRingBondCountQuery(int what);
371
372 //! returns a Query for matching atoms with a particular number of ring bonds
373 template <class T>
374 T *makeAtomHasRingBondQuery(const std::string &descr) {
375 return makeAtomSimpleQuery<T>(1, queryAtomHasRingBond, descr);
376 }
377 //! \overload
378 ATOM_EQUALS_QUERY *makeAtomHasRingBondQuery();
379
380 //! returns a Query for matching bond orders
381 BOND_EQUALS_QUERY *makeBondOrderEqualsQuery(Bond::BondType what);
382 //! returns a Query for matching bond directions
383 BOND_EQUALS_QUERY *makeBondDirEqualsQuery(Bond::BondDir what);
384 //! returns a Query for matching ring bonds
385 BOND_EQUALS_QUERY *makeBondIsInRingQuery();
386 //! returns a Query for matching bonds in rings of a particular size
387 BOND_EQUALS_QUERY *makeBondInRingOfSizeQuery(int what);
388 //! returns a Query for matching a bond's minimum ring size
389 BOND_EQUALS_QUERY *makeBondMinRingSizeQuery(int what);
390 //! returns a Query for matching bonds in a particular number of rings
391 BOND_EQUALS_QUERY *makeBondInNRingsQuery(int tgt);
392
393 //! returns a Query for matching any bond
394 BOND_NULL_QUERY *makeBondNullQuery();
395 //! returns a Query for matching any atom
396 ATOM_NULL_QUERY *makeAtomNullQuery();
397
398 static inline int queryAtomRingMembership(Atom const *at) {
399 return static_cast<int>(
400 at->getOwningMol().getRingInfo()->numAtomRings(at->getIdx()));
401 }
402 // I'm pretty sure that this typedef shouldn't be necessary,
403 // but VC++ generates a warning about const Atom const * in
404 // the definition of Match, then complains about an override
405 // that differs only by const/volatile (c4301), then generates
406 // incorrect code if we don't do this... so let's do it.
407 typedef Atom const *ConstAtomPtr;
408
409 class AtomRingQuery : public Queries::EqualityQuery<int, ConstAtomPtr, true> {
410 public:
411 AtomRingQuery() : Queries::EqualityQuery<int, ConstAtomPtr, true>(-1) {
412 // default is to just do a number of rings query:
413 this->setDescription("AtomInNRings");
414 this->setDataFunc(queryAtomRingMembership);
415 };
416 explicit AtomRingQuery(int v)
417 : Queries::EqualityQuery<int, ConstAtomPtr, true>(v) {
418 // default is to just do a number of rings query:
419 this->setDescription("AtomInNRings");
420 this->setDataFunc(queryAtomRingMembership);
421 };
422
423 virtual bool Match(const ConstAtomPtr what) const {
424 int v = this->TypeConvert(what, Queries::Int2Type<true>());
425 bool res;
426 if (this->d_val < 0) {
427 res = v != 0;
428 } else {
429 res = !Queries::queryCmp(v, this->d_val, this->d_tol);
430 }
431 if (this->getNegation()) {
432 res = !res;
433 }
434 return res;
435 }
436
437 //! returns a copy of this query
438 Queries::Query<int, ConstAtomPtr, true> *copy() const {
439 AtomRingQuery *res = new AtomRingQuery(this->d_val);
440 res->setNegation(getNegation());
441 res->setTol(this->getTol());
442 res->d_description = this->d_description;
443 res->d_dataFunc = this->d_dataFunc;
444 return res;
445 }
446 };
447
448 //! allows use of recursive structure queries (e.g. recursive SMARTS)
449 class RecursiveStructureQuery
450 : public Queries::SetQuery<int, Atom const *, true> {
451 public:
452 RecursiveStructureQuery()
453 : Queries::SetQuery<int, Atom const *, true>(), d_serialNumber(0) {
454 setDataFunc(getAtIdx);
455 setDescription("RecursiveStructure");
456 };
457 //! initialize from an ROMol pointer
458 /*!
459 <b>Notes</b>
460 - this takes over ownership of the pointer
461 */
462 RecursiveStructureQuery(ROMol const *query, unsigned int serialNumber = 0)
463 : Queries::SetQuery<int, Atom const *, true>(),
464 d_serialNumber(serialNumber) {
465 setQueryMol(query);
466 setDataFunc(getAtIdx);
467 setDescription("RecursiveStructure");
468 };
469 //! returns the index of an atom
470 static inline int getAtIdx(Atom const *at) {
471 PRECONDITION(at, "bad atom argument");
472 return at->getIdx();
473 };
474
475 //! sets the molecule we'll use recursively
476 /*!
477 <b>Notes</b>
478 - this takes over ownership of the pointer
479 */
480 void setQueryMol(ROMol const *query) { dp_queryMol.reset(query); }
481 //! returns a pointer to our query molecule
482 ROMol const *getQueryMol() const { return dp_queryMol.get(); };
483
484 //! returns a copy of this query
485 Queries::Query<int, Atom const *, true> *copy() const {
486 RecursiveStructureQuery *res = new RecursiveStructureQuery();
487 res->dp_queryMol.reset(new ROMol(*dp_queryMol, true));
488
489 std::set<int>::const_iterator i;
490 for (i = d_set.begin(); i != d_set.end(); i++) {
491 res->insert(*i);
492 }
493 res->setNegation(getNegation());
494 res->d_description = d_description;
495 res->d_serialNumber = d_serialNumber;
496 return res;
497 }
498 unsigned int getSerialNumber() const { return d_serialNumber; };
499
500 #ifdef RDK_THREADSAFE_SSS
501 boost::mutex d_mutex;
502 #endif
503 private:
504 boost::shared_ptr<const ROMol> dp_queryMol;
505 unsigned int d_serialNumber;
506 };
507
508 template <typename T>
509 int nullDataFun(T) {
510 return 1;
511 }
512 template <typename T>
513 bool nullQueryFun(T) {
514 return true;
515 }
516
517 typedef Bond const *ConstBondPtr;
518
519 // ! Query whether an atom has a property
520 template <class TargetPtr>
521 class HasPropQuery : public Queries::EqualityQuery<int, TargetPtr, true> {
522 std::string propname;
523
524 public:
525 HasPropQuery() : Queries::EqualityQuery<int, TargetPtr, true>(), propname() {
526 // default is to just do a number of rings query:
527 this->setDescription("AtomHasProp");
528 this->setDataFunc(0);
529 };
530 explicit HasPropQuery(const std::string &v)
531 : Queries::EqualityQuery<int, TargetPtr, true>(), propname(v) {
532 // default is to just do a number of rings query:
533 this->setDescription("AtomHasProp");
534 this->setDataFunc(0);
535 };
536
537 virtual bool Match(const TargetPtr what) const {
538 bool res = what->hasProp(propname);
539 if (this->getNegation()) {
540 res = !res;
541 }
542 return res;
543 }
544
545 //! returns a copy of this query
546 Queries::Query<int, TargetPtr, true> *copy() const {
547 HasPropQuery *res = new HasPropQuery(this->propname);
548 res->setNegation(this->getNegation());
549 res->d_description = this->d_description;
550 return res;
551 }
552 };
553
554 typedef Queries::EqualityQuery<int, Atom const *, true> ATOM_PROP_QUERY;
555 typedef Queries::EqualityQuery<int, Bond const *, true> BOND_PROP_QUERY;
556
557 //! returns a Query for matching atoms that have a particular property
558 template <class Target>
559 Queries::EqualityQuery<int, const Target *, true> *makeHasPropQuery(
560 const std::string &property) {
561 return new HasPropQuery<const Target *>(property);
562 }
563
564 // ! Query whether an atom has a property with a value
565 template <class TargetPtr, class T>
566 class HasPropWithValueQuery
567 : public Queries::EqualityQuery<int, TargetPtr, true> {
568 std::string propname;
569 T val;
570 T tolerance;
571
572 public:
573 HasPropWithValueQuery()
574 : Queries::EqualityQuery<int, TargetPtr, true>(), propname(), val() {
575 // default is to just do a number of rings query:
576 this->setDescription("HasPropWithValue");
577 this->setDataFunc(0);
578 };
579 explicit HasPropWithValueQuery(const std::string &prop, const T &v,
580 const T &tol = 0.0)
581 : Queries::EqualityQuery<int, TargetPtr, true>(),
582 propname(prop),
583 val(v),
584 tolerance(tol) {
585 // default is to just do a number of rings query:
586 this->setDescription("HasPropWithValue");
587 this->setDataFunc(0);
588 };
589
590 virtual bool Match(const TargetPtr what) const {
591 bool res = what->hasProp(propname);
592 if (res) {
593 try {
594 T atom_val = what->template getProp<T>(propname);
595 res = Queries::queryCmp(atom_val, this->val, this->tolerance) == 0;
596 } catch (KeyErrorException e) {
597 res = false;
598 }
599 catch (boost::bad_any_cast) {
600 res = false;
601 }
602 #ifdef __GNUC__
603 #if (__GNUC__ < 4 || \
604 (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
605 catch (...) {
606 // catch all -- this is currently necessary to
607 // trap some bugs in boost+gcc configurations
608 // Normally, this is not the correct thing to
609 // do, but the only exception above is due
610 // to the boost any_cast which is trapped
611 // by the Boost python wrapper when it shouldn't
612 // be.
613 res = false;
614 }
615 #endif
616 #endif
617 }
618 if (this->getNegation()) {
619 res = !res;
620 }
621 return res;
622 }
623
624 //! returns a copy of this query
625 Queries::Query<int, TargetPtr, true> *copy() const {
626 HasPropWithValueQuery *res =
627 new HasPropWithValueQuery(this->propname, this->val, this->tolerance);
628 res->setNegation(this->getNegation());
629 res->d_description = this->d_description;
630 return res;
631 }
632 };
633
634 template <class TargetPtr>
635 class HasPropWithValueQuery<TargetPtr, std::string>
636 : public Queries::EqualityQuery<int, TargetPtr, true> {
637 std::string propname;
638 std::string val;
639
640 public:
641 HasPropWithValueQuery()
642 : Queries::EqualityQuery<int, TargetPtr, true>(), propname(), val() {
643 // default is to just do a number of rings query:
644 this->setDescription("HasPropWithValue");
645 this->setDataFunc(0);
646 };
647 explicit HasPropWithValueQuery(const std::string &prop, const std::string &v,
648 const std::string &tol = "")
649 : Queries::EqualityQuery<int, TargetPtr, true>(), propname(prop), val(v) {
650 RDUNUSED_PARAM(tol);
651 // default is to just do a number of rings query:
652 this->setDescription("HasPropWithValue");
653 this->setDataFunc(0);
654 };
655
656 virtual bool Match(const TargetPtr what) const {
657 bool res = what->hasProp(propname);
658 if (res) {
659 try {
660 std::string atom_val = what->template getProp<std::string>(propname);
661 res = atom_val == this->val;
662 } catch (KeyErrorException) {
663 res = false;
664 } catch (boost::bad_any_cast) {
665 res = false;
666 }
667 #ifdef __GNUC__
668 #if (__GNUC__ < 4 || \
669 (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
670 catch (...) {
671 // catch all -- this is currently necessary to
672 // trap some bugs in boost+gcc configurations
673 // Normally, this is not the correct thing to
674 // do, but the only exception above is due
675 // to the boost any_cast which is trapped
676 // by the Boost python wrapper when it shouldn't
677 // be.
678 res = false;
679 }
680 #endif
681 #endif
682 }
683 if (this->getNegation()) {
684 res = !res;
685 }
686 return res;
687 }
688
689 //! returns a copy of this query
690 Queries::Query<int, TargetPtr, true> *copy() const {
691 HasPropWithValueQuery<TargetPtr, std::string> *res =
692 new HasPropWithValueQuery<TargetPtr, std::string>(this->propname,
693 this->val);
694 res->setNegation(this->getNegation());
695 res->d_description = this->d_description;
696 return res;
697 }
698 };
699
700 template <class Target, class T>
701 Queries::EqualityQuery<int, const Target *, true> *makePropQuery(
702 const std::string &propname, const T &val, const T &tolerance = T()) {
703 return new HasPropWithValueQuery<const Target *, T>(propname, val, tolerance);
704 }
705
706 bool isComplexQuery(const Bond *b);
707 bool isComplexQuery(const Atom *a);
708 bool isAtomAromatic(const Atom *a);
709 };
710
711 #endif
RDKit::Atom::getOwningMol
ROMol & getOwningMol() const
returns a reference to the ROMol that owns this Atom
Definition: Atom.h:123
RDKit::HasPropQuery::HasPropQuery
HasPropQuery(const std::string &v)
Definition: QueryOps.h:530
Queries::Query< int, ConstAtomPtr, needsConversion >::getNegation
bool getNegation() const
returns whether or not we are negated
Definition: Query.h:63
RDKit::HasPropWithValueQuery::HasPropWithValueQuery
HasPropWithValueQuery()
Definition: QueryOps.h:573
RDKit::ATOM_XOR_QUERY
Queries::XOrQuery< int, Atom const *, true > ATOM_XOR_QUERY
Definition: QueryOps.h:36
RDKit::makeAtomTotalValenceQuery
T * makeAtomTotalValenceQuery(int what, const std::string &descr)
returns a Query for matching total valence
Definition: QueryOps.h:234
RDKit::makeAtomInRingQuery
T * makeAtomInRingQuery(const std::string &descr)
returns a Query for matching ring atoms
Definition: QueryOps.h:339
Queries
Definition: AndQuery.h:15
RDKit::queryAtomTotalDegree
static int queryAtomTotalDegree(Atom const *at)
Definition: QueryOps.h:77
Queries::queryCmp
int queryCmp(const T1 v1, const T2 v2, const T1 tol)
Definition: Query.h:177
RDKit::makeAtomHybridizationQuery
T * makeAtomHybridizationQuery(int what, const std::string &descr)
returns a Query for matching hybridization
Definition: QueryOps.h:323
RDKit::queryAtomHybridization
static int queryAtomHybridization(Atom const *at)
Definition: QueryOps.h:115
RDKit::makeAtomMassQuery
T * makeAtomMassQuery(int what, const std::string &descr)
returns a Query for matching atoms with a particular mass
Definition: QueryOps.h:298
RDKit::BOND_OR_QUERY
Queries::OrQuery< int, Bond const *, true > BOND_OR_QUERY
Definition: QueryOps.h:34
RDKit::round
double round(double v)
rounds a value to the closest int
RDKit::ATOM_LESS_QUERY
Queries::LessQuery< int, Atom const *, true > ATOM_LESS_QUERY
Definition: QueryOps.h:50
RDKit::RingInfo::isBondInRingOfSize
bool isBondInRingOfSize(unsigned int idx, unsigned int size) const
returns whether or not the bond with index idx is in a size - ring.
Queries::EqualityQuery< int, ConstAtomPtr, true >::EqualityQuery
EqualityQuery()
Definition: EqualityQuery.h:25
RDKit::AtomRingQuery::copy
Queries::Query< int, ConstAtomPtr, true > * copy() const
returns a copy of this query
Definition: QueryOps.h:438
Queries::Query::setNegation
void setNegation(bool what)
sets whether or not we are negated
Definition: Query.h:61
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::Match
virtual bool Match(const TargetPtr what) const
returns whether or not we match the argument
Definition: QueryOps.h:656
RDKit::ATOM_NULL_QUERY
Queries::Query< int, Atom const *, true > ATOM_NULL_QUERY
Definition: QueryOps.h:63
RDKit::makeAtomNullQuery
ATOM_NULL_QUERY * makeAtomNullQuery()
returns a Query for matching any atom
RDKit::RecursiveStructureQuery::getQueryMol
ROMol const * getQueryMol() const
returns a pointer to our query molecule
Definition: QueryOps.h:482
Queries::AndQuery
a Query implementing AND: requires all children to be true
Definition: AndQuery.h:20
RDKit::makeAtomImplicitValenceQuery
T * makeAtomImplicitValenceQuery(int what, const std::string &descr)
returns a Query for matching implicit valence
Definition: QueryOps.h:218
Queries::EqualityQuery::setTol
void setTol(MatchFuncArgType what)
sets our tolerance
Definition: EqualityQuery.h:43
RDKit::ConstAtomPtr
Atom const * ConstAtomPtr
Definition: QueryOps.h:407
RDKit::makeBondOrderEqualsQuery
BOND_EQUALS_QUERY * makeBondOrderEqualsQuery(Bond::BondType what)
returns a Query for matching bond orders
RDKit::Atom::getTotalNumHs
unsigned int getTotalNumHs(bool includeNeighbors=false) const
returns the total number of Hs (implicit and explicit) that this Atom is bound to ...
RDKit::BOND_PROP_QUERY
Queries::EqualityQuery< int, Bond const *, true > BOND_PROP_QUERY
Definition: QueryOps.h:555
Queries::OrQuery
a Query implementing AND: requires any child to be true
Definition: OrQuery.h:19
RDKit::Atom::getIsotope
unsigned int getIsotope() const
returns our isotope number
Definition: Atom.h:225
RDKit::Bond::getBondDir
BondDir getBondDir() const
returns our direction
Definition: Bond.h:271
RDKit::Atom::getMass
double getMass() const
returns our mass
RDKit::queryAtomAllBondProduct
unsigned int queryAtomAllBondProduct(Atom const *at)
RDKit::makeAtomMinRingSizeQuery
T * makeAtomMinRingSizeQuery(int tgt, const std::string &descr)
returns a Query for matching an atom's minimum ring size
Definition: QueryOps.h:358
std
STL namespace.
RDKit::BOND_NULL_QUERY
Queries::Query< int, Bond const *, true > BOND_NULL_QUERY
Definition: QueryOps.h:62
RDKit::queryAtomExplicitDegree
static int queryAtomExplicitDegree(Atom const *at)
Definition: QueryOps.h:74
RDKit::BOND_GREATER_QUERY
Queries::GreaterQuery< int, Bond const *, true > BOND_GREATER_QUERY
Definition: QueryOps.h:43
RDKit::queryBondOrder
static int queryBondOrder(Bond const *bond)
Definition: QueryOps.h:124
Queries::Query< int, ConstAtomPtr, needsConversion >::TypeConvert
int TypeConvert(intwhat, Int2Type< false >) const
calls our dataFunc (if it's set) on what and returns the result, otherwise returns what ...
Definition: Query.h:150
RDKit::queryAtomImplicitHCount
static int queryAtomImplicitHCount(Atom const *at)
Definition: QueryOps.h:86
Queries::SetQuery< int, Atom const *, true >::d_set
CONTAINER_TYPE d_set
Definition: SetQuery.h:80
RDKit::Atom::getIdx
unsigned int getIdx() const
returns our index within the ROMol
Definition: Atom.h:126
RDKit::BOND_BOOL_QUERY
Queries::Query< bool, Bond const *, true > BOND_BOOL_QUERY
Definition: QueryOps.h:28
RDKit::RecursiveStructureQuery::getAtIdx
static int getAtIdx(Atom const *at)
returns the index of an atom
Definition: QueryOps.h:470
RDKit::BOND_SET_QUERY
Queries::SetQuery< int, Bond const *, true > BOND_SET_QUERY
Definition: QueryOps.h:60
RDKit::makeAtomImplicitHCountQuery
T * makeAtomImplicitHCountQuery(int what, const std::string &descr)
returns a Query for matching implicit hydrogen count
Definition: QueryOps.h:274
RDKit::queryAtomMass
static int queryAtomMass(Atom const *at)
Definition: QueryOps.h:106
RDKit::makePropQuery
Queries::EqualityQuery< int, const Target *, true > * makePropQuery(const std::string &propname, const T &val, const T &tolerance=T())
Definition: QueryOps.h:701
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::copy
Queries::Query< int, TargetPtr, true > * copy() const
returns a copy of this query
Definition: QueryOps.h:690
Query.h
RDKit::Bond::BondType
BondType
the type of Bond
Definition: Bond.h:56
RDKit::nullQueryFun
bool nullQueryFun(T)
Definition: QueryOps.h:513
RDKitBase.h
pulls in the core RDKit functionality
RDKit::ATOM_GREATEREQUAL_QUERY
Queries::GreaterEqualQuery< int, Atom const *, true > ATOM_GREATEREQUAL_QUERY
Definition: QueryOps.h:46
RDKit::queryIsBondInRing
static int queryIsBondInRing(Bond const *bond)
Definition: QueryOps.h:155
RDKit::ROMol
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:102
RDKit::BOND_GREATEREQUAL_QUERY
Queries::GreaterEqualQuery< int, Bond const *, true > BOND_GREATEREQUAL_QUERY
Definition: QueryOps.h:48
RDKit::RingInfo::minAtomRingSize
unsigned int minAtomRingSize(unsigned int idx) const
returns the size of the smallest ring atom idx is involved in
RDKit::AtomRingQuery::Match
virtual bool Match(const ConstAtomPtr what) const
Definition: QueryOps.h:423
RDKit::Atom::getDegree
unsigned int getDegree() const
RDKit::AtomRingQuery::AtomRingQuery
AtomRingQuery()
Definition: QueryOps.h:411
RDKit::makeAtomExplicitDegreeQuery
T * makeAtomExplicitDegreeQuery(int what, const std::string &descr)
returns a Query for matching explicit degree
Definition: QueryOps.h:242
RDKit::HasPropQuery
Definition: QueryOps.h:521
RDKit::ATOM_LESSEQUAL_QUERY
Queries::LessEqualQuery< int, Atom const *, true > ATOM_LESSEQUAL_QUERY
Definition: QueryOps.h:53
RDKit::queryBondDir
static int queryBondDir(Bond const *bond)
Definition: QueryOps.h:127
RDKit::queryAtomUnsaturated
static int queryAtomUnsaturated(Atom const *at)
Definition: QueryOps.h:101
RDKit::HasPropWithValueQuery::Match
virtual bool Match(const TargetPtr what) const
returns whether or not we match the argument
Definition: QueryOps.h:590
RDKit::BOND_LESSEQUAL_QUERY
Queries::LessEqualQuery< int, Bond const *, true > BOND_LESSEQUAL_QUERY
Definition: QueryOps.h:54
RDKit::HasPropQuery::Match
virtual bool Match(const TargetPtr what) const
returns whether or not we match the argument
Definition: QueryOps.h:537
Queries::RangeQuery
a Query implementing a range: arguments must fall in a particular range of values.
Definition: RangeQuery.h:26
RDKit::Atom::getTotalDegree
unsigned int getTotalDegree() const
RDKit::queryAtomIsInRingOfSize
int queryAtomIsInRingOfSize(Atom const *at)
Definition: QueryOps.h:181
RDKit::isComplexQuery
bool isComplexQuery(const Bond *b)
RDKit::makeAtomIsotopeQuery
T * makeAtomIsotopeQuery(int what, const std::string &descr)
returns a Query for matching atoms with a particular isotope
Definition: QueryOps.h:307
RDKit::makeAtomAliphaticQuery
T * makeAtomAliphaticQuery(const std::string &descr)
returns a Query for matching aliphatic atoms
Definition: QueryOps.h:290
RDKit::makeBondInNRingsQuery
BOND_EQUALS_QUERY * makeBondInNRingsQuery(int tgt)
returns a Query for matching bonds in a particular number of rings
RDKit::massIntegerConversionFactor
const int massIntegerConversionFactor
Definition: QueryOps.h:105
RDKit::Atom::getAtomicNum
int getAtomicNum() const
returns our atomic number
Definition: Atom.h:115
RDKit::makeAtomUnsaturatedQuery
T * makeAtomUnsaturatedQuery(const std::string &descr)
returns a Query for matching atoms with unsaturation:
Definition: QueryOps.h:331
RDKit::RingInfo::numAtomRings
unsigned int numAtomRings(unsigned int idx) const
returns the number of rings atom idx is involved in
Queries::Int2Type
class to allow integer values to pick templates
Definition: Query.h:26
RDKit::queryAtomIsotope
static int queryAtomIsotope(Atom const *at)
Definition: QueryOps.h:109
RDKit::Atom::getExplicitValence
int getExplicitValence() const
returns the explicit valence (including Hs) of this atom
RDKit::BOND_LESS_QUERY
Queries::LessQuery< int, Bond const *, true > BOND_LESS_QUERY
Definition: QueryOps.h:51
RDKit::ROMol::getTopology
MolGraph const & getTopology() const
brief returns a pointer to our underlying BGL object
Definition: ROMol.h:481
RDKit::HasPropQuery::HasPropQuery
HasPropQuery()
Definition: QueryOps.h:525
RDKit::makeBondNullQuery
BOND_NULL_QUERY * makeBondNullQuery()
returns a Query for matching any bond
RDKit::RecursiveStructureQuery
allows use of recursive structure queries (e.g. recursive SMARTS)
Definition: QueryOps.h:449
RDKit::isAtomAromatic
bool isAtomAromatic(const Atom *a)
RDKit::RecursiveStructureQuery::RecursiveStructureQuery
RecursiveStructureQuery()
Definition: QueryOps.h:452
RDKit::ConstBondPtr
Bond const * ConstBondPtr
Definition: QueryOps.h:517
RDKit::queryAtomExplicitValence
static int queryAtomExplicitValence(Atom const *at)
Definition: QueryOps.h:95
RDKit::queryIsAtomInRing
static int queryIsAtomInRing(Atom const *at)
Definition: QueryOps.h:140
Queries::LessEqualQuery
a Query implementing <= using a particular value (and an optional tolerance)
Definition: LessEqualQuery.h:20
RDKit::ATOM_BOOL_QUERY
Queries::Query< bool, Atom const *, true > ATOM_BOOL_QUERY
Definition: QueryOps.h:27
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::HasPropWithValueQuery
HasPropWithValueQuery(const std::string &prop, const std::string &v, const std::string &tol="")
Definition: QueryOps.h:647
RDKit::HasPropWithValueQuery< TargetPtr, std::string >
Definition: QueryOps.h:635
RDKit::queryAtomAromatic
static int queryAtomAromatic(Atom const *at)
Definition: QueryOps.h:68
RDKit::Atom::getNumExplicitHs
unsigned int getNumExplicitHs() const
returns our number of explict Hs
Definition: Atom.h:212
RDKit
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
RDKit::queryBondMinRingSize
static int queryBondMinRingSize(Bond const *bond)
Definition: QueryOps.h:161
Queries::EqualityQuery< int, ConstAtomPtr, true >::d_tol
int d_tol
Definition: EqualityQuery.h:91
RDKit::queryAtomNum
static int queryAtomNum(Atom const *at)
Definition: QueryOps.h:104
RDKit::BOND_EQUALS_QUERY
Queries::EqualityQuery< int, Bond const *, true > BOND_EQUALS_QUERY
Definition: QueryOps.h:40
RDKit::BOND_XOR_QUERY
Queries::XOrQuery< int, Bond const *, true > BOND_XOR_QUERY
Definition: QueryOps.h:37
Queries::Query::d_dataFunc
MatchFuncArgType(* d_dataFunc)(DataFuncArgType)
Definition: Query.h:146
RDKit::makeAtomRingBondCountQuery
T * makeAtomRingBondCountQuery(int what, const std::string &descr)
returns a Query for matching atoms with a particular number of ring bonds
Definition: QueryOps.h:366
RDKit::makeAtomAromaticQuery
T * makeAtomAromaticQuery(const std::string &descr)
returns a Query for matching the isAromatic flag
Definition: QueryOps.h:282
RDKit::AtomRingQuery
Definition: QueryOps.h:409
RDKit::queryAtomFormalCharge
static int queryAtomFormalCharge(Atom const *at)
Definition: QueryOps.h:112
Queries::LessQuery
a Query implementing < using a particular value (and an optional tolerance)
Definition: LessQuery.h:20
Queries::EqualityQuery
a Query implementing ==: arguments must match a particular value (within an optional tolerance) ...
Definition: EqualityQuery.h:22
RDKit::makeAtomNumQuery
T * makeAtomNumQuery(int what, const std::string &descr)
returns a Query for matching atomic number
Definition: QueryOps.h:210
RDKit::makeAtomFormalChargeQuery
T * makeAtomFormalChargeQuery(int what, const std::string &descr)
returns a Query for matching formal charge
Definition: QueryOps.h:315
RDKit::Bond
class for representing a bond
Definition: Bond.h:46
RDUNUSED_PARAM
#define RDUNUSED_PARAM(x)
Definition: Invariant.h:190
RDKit::queryAtomHeavyAtomDegree
static int queryAtomHeavyAtomDegree(Atom const *at)
Definition: QueryOps.h:80
RDKit::makeAtomExplicitValenceQuery
T * makeAtomExplicitValenceQuery(int what, const std::string &descr)
returns a Query for matching explicit valence
Definition: QueryOps.h:226
RDKit::HasPropWithValueQuery::copy
Queries::Query< int, TargetPtr, true > * copy() const
returns a copy of this query
Definition: QueryOps.h:625
RDKit::HasPropWithValueQuery
Definition: QueryOps.h:566
RDKit::Atom::getImplicitValence
int getImplicitValence() const
returns the implicit valence for this Atom
RDKit::ROMol::getRingInfo
RingInfo * getRingInfo() const
Definition: ROMol.h:374
Queries::SetQuery::insert
void insert(const MatchFuncArgType what)
insert an entry into our set
Definition: SetQuery.h:32
Queries::Query< int, ConstAtomPtr, needsConversion >::setDataFunc
void setDataFunc(int(*what)(ConstAtomPtr))
sets our data function
Definition: Query.h:90
RDKit::RingInfo::isAtomInRingOfSize
bool isAtomInRingOfSize(unsigned int idx, unsigned int size) const
returns whether or not the atom with index idx is in a size - ring.
RDKit::BOND_AND_QUERY
Queries::AndQuery< int, Bond const *, true > BOND_AND_QUERY
Definition: QueryOps.h:31
RDKit::Bond::BondDir
BondDir
the bond's direction (for chirality)
Definition: Bond.h:83
RDKit::queryIsAtomInNRings
static int queryIsAtomInNRings(Atom const *at)
Definition: QueryOps.h:137
RDKit::RecursiveStructureQuery::setQueryMol
void setQueryMol(ROMol const *query)
sets the molecule we'll use recursively
Definition: QueryOps.h:480
RDKit::RecursiveStructureQuery::getSerialNumber
unsigned int getSerialNumber() const
Definition: QueryOps.h:498
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::HasPropWithValueQuery
HasPropWithValueQuery()
Definition: QueryOps.h:641
RDKit::RecursiveStructureQuery::RecursiveStructureQuery
RecursiveStructureQuery(ROMol const *query, unsigned int serialNumber=0)
initialize from an ROMol pointer
Definition: QueryOps.h:462
RDKit::queryAtomHasImplicitH
static int queryAtomHasImplicitH(Atom const *at)
Definition: QueryOps.h:89
PRECONDITION
#define PRECONDITION(expr, mess)
Definition: Invariant.h:103
RDKit::queryAtomMinRingSize
static int queryAtomMinRingSize(Atom const *at)
Definition: QueryOps.h:158
RDKit::RingInfo::numBondRings
unsigned int numBondRings(unsigned int idx) const
returns the number of rings bond idx is involved in
RDKit::Atom::getHybridization
HybridizationType getHybridization() const
returns our hybridization
Definition: Atom.h:239
RDKit::ATOM_AND_QUERY
Queries::AndQuery< int, Atom const *, true > ATOM_AND_QUERY
Definition: QueryOps.h:30
RDKit::makeAtomHasRingBondQuery
T * makeAtomHasRingBondQuery(const std::string &descr)
returns a Query for matching atoms with a particular number of ring bonds
Definition: QueryOps.h:374
RDKit::ATOM_EQUALS_QUERY
Queries::EqualityQuery< int, Atom const *, true > ATOM_EQUALS_QUERY
Definition: QueryOps.h:39
Queries::Query::d_description
std::string d_description
Definition: Query.h:139
Queries::SetQuery< int, Atom const *, true >::SetQuery
SetQuery()
Definition: SetQuery.h:29
RDKit::makeAtomHasImplicitHQuery
T * makeAtomHasImplicitHQuery(const std::string &descr)
returns a Query for matching ring atoms
Definition: QueryOps.h:266
RDKit::HasPropQuery::copy
Queries::Query< int, TargetPtr, true > * copy() const
returns a copy of this query
Definition: QueryOps.h:546
RDKit::makeAtomInNRingsQuery
T * makeAtomInNRingsQuery(int what, const std::string &descr)
returns a Query for matching atoms in a particular number of rings
Definition: QueryOps.h:347
RDKit::queryAtomAliphatic
static int queryAtomAliphatic(Atom const *at)
Definition: QueryOps.h:71
RDKit::ATOM_RANGE_QUERY
Queries::RangeQuery< int, Atom const *, true > ATOM_RANGE_QUERY
Definition: QueryOps.h:56
RDKit::HasPropWithValueQuery::HasPropWithValueQuery
HasPropWithValueQuery(const std::string &prop, const T &v, const T &tol=0.0)
Definition: QueryOps.h:579
Queries::GreaterQuery
a Query implementing > using a particular value (and an optional tolerance)
Definition: GreaterQuery.h:20
RDKit::makeBondMinRingSizeQuery
BOND_EQUALS_QUERY * makeBondMinRingSizeQuery(int what)
returns a Query for matching a bond's minimum ring size
RDKit::makeAtomInRingOfSizeQuery
ATOM_EQUALS_QUERY * makeAtomInRingOfSizeQuery(int tgt)
returns a Query for matching atoms in rings of a particular size
RDKit::queryAtomRingBondCount
static int queryAtomRingBondCount(Atom const *at)
Definition: QueryOps.h:165
Queries::GreaterEqualQuery
a Query implementing >= using a particular value (and an optional tolerance)
Definition: GreaterEqualQuery.h:20
QueryObjects.h
Pulls in all the query types.
RDKit::ATOM_GREATER_QUERY
Queries::GreaterQuery< int, Atom const *, true > ATOM_GREATER_QUERY
Definition: QueryOps.h:42
RDKit::makeBondDirEqualsQuery
BOND_EQUALS_QUERY * makeBondDirEqualsQuery(Bond::BondDir what)
returns a Query for matching bond directions
RDKit::ATOM_OR_QUERY
Queries::OrQuery< int, Atom const *, true > ATOM_OR_QUERY
Definition: QueryOps.h:33
RDKit::makeAtomSimpleQuery
T * makeAtomSimpleQuery(int what, int func(Atom const *), const std::string &description="Atom Simple")
Definition: QueryOps.h:199
RDKit::Atom::getFormalCharge
int getFormalCharge() const
returns the formal charge of this atom
Definition: Atom.h:199
RDKit::queryBondIsInRingOfSize
int queryBondIsInRingOfSize(Bond const *bond)
Definition: QueryOps.h:189
RDKit::Bond::getIdx
unsigned int getIdx() const
returns our index within the ROMol
Definition: Bond.h:158
RDKit::nullDataFun
int nullDataFun(T)
Definition: QueryOps.h:509
RDKit::queryAtomHasRingBond
static int queryAtomHasRingBond(Atom const *at)
Definition: QueryOps.h:143
RDKit::makeBondInRingOfSizeQuery
BOND_EQUALS_QUERY * makeBondInRingOfSizeQuery(int what)
returns a Query for matching bonds in rings of a particular size
RDKit::ROMol::getAtomBonds
OBOND_ITER_PAIR getAtomBonds(Atom const *at) const
provides access to all Bond objects connected to an Atom
RDKit::Bond::getOwningMol
ROMol & getOwningMol() const
returns a reference to the ROMol that owns this Bond
Definition: Bond.h:146
RDKit::queryAtomRingMembership
static int queryAtomRingMembership(Atom const *at)
Definition: QueryOps.h:398
RDKit::ATOM_PROP_QUERY
Queries::EqualityQuery< int, Atom const *, true > ATOM_PROP_QUERY
Definition: QueryOps.h:554
Queries::Query
Base class for all queries.
Definition: Query.h:45
RDKit::queryAtomHCount
static int queryAtomHCount(Atom const *at)
Definition: QueryOps.h:83
RDKit::BOND_RANGE_QUERY
Queries::RangeQuery< int, Bond const *, true > BOND_RANGE_QUERY
Definition: QueryOps.h:57
RDKit::queryAtomBondProduct
unsigned int queryAtomBondProduct(Atom const *at)
RDKit::queryAtomTotalValence
static int queryAtomTotalValence(Atom const *at)
Definition: QueryOps.h:98
RDKit::makeBondIsInRingQuery
BOND_EQUALS_QUERY * makeBondIsInRingQuery()
returns a Query for matching ring bonds
RDKit::RingInfo::minBondRingSize
unsigned int minBondRingSize(unsigned int idx) const
returns the size of the smallest ring bond idx is involved in
RDKit::AtomRingQuery::AtomRingQuery
AtomRingQuery(int v)
Definition: QueryOps.h:416
Queries::EqualityQuery< int, ConstAtomPtr, true >::d_val
int d_val
Definition: EqualityQuery.h:90
RDKit::Atom
The class for representing atoms.
Definition: Atom.h:67
RDKit::Bond::getBondType
BondType getBondType() const
returns our bondType
Definition: Bond.h:119
Queries::XOrQuery
a Query implementing XOR: requires exactly one child to be true
Definition: XOrQuery.h:20
Queries::Query< int, ConstAtomPtr, needsConversion >::setDescription
void setDescription(const std::string &descr)
sets our text description
Definition: Query.h:66
RDKit::makeHasPropQuery
Queries::EqualityQuery< int, const Target *, true > * makeHasPropQuery(const std::string &property)
returns a Query for matching atoms that have a particular property
Definition: QueryOps.h:559
RDKit::Atom::getIsAromatic
bool getIsAromatic() const
returns our isAromatic flag
Definition: Atom.h:217
RDKit::queryAtomImplicitValence
static int queryAtomImplicitValence(Atom const *at)
Definition: QueryOps.h:92
KeyErrorException
Class to allow us to throw a KeyError from C++ and have it make it back to Python.
Definition: Exceptions.h:48
RDKit::RecursiveStructureQuery::copy
Queries::Query< int, Atom const *, true > * copy() const
returns a copy of this query
Definition: QueryOps.h:485
RDKit::makeAtomHCountQuery
T * makeAtomHCountQuery(int what, const std::string &descr)
returns a Query for matching hydrogen count
Definition: QueryOps.h:258
RDKit::makeAtomTotalDegreeQuery
T * makeAtomTotalDegreeQuery(int what, const std::string &descr)
returns a Query for matching atomic degree
Definition: QueryOps.h:250
Queries::SetQuery< int, Atom const *, true >
RDKit::ATOM_SET_QUERY
Queries::SetQuery< int, Atom const *, true > ATOM_SET_QUERY
Definition: QueryOps.h:59
Queries::EqualityQuery< int, ConstAtomPtr, true >::getTol
const int getTol() const
returns out tolerance
Definition: EqualityQuery.h:45
RDKit::queryIsBondInNRings
static int queryIsBondInNRings(Bond const *at)
Definition: QueryOps.h:130