RDKit: QueryOps.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
QueryOps.h
Go to the documentation of this file.
1//
2// Copyright (C) 2003-2021 Greg Landrum and other RDKit contributors
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#include <RDGeneral/export.h>
16#include <RDGeneral/Dict.h>
17#ifndef RD_QUERY_OPS_H
18#define RD_QUERY_OPS_H
19
20#include <GraphMol/RDKitBase.h>
21#include <Query/QueryObjects.h>
22#include <Query/Query.h>
23#include <DataStructs/BitVects.h>
24#include <DataStructs/BitOps.h>
25
26#ifdef RDK_BUILD_THREADSAFE_SSS
27#include <mutex>
28#include <utility>
29#endif
30
31namespace RDKit {
32 typedef Queries::Query<bool, Atom const *, true> ATOM_BOOL_QUERY;
33 typedef Queries::Query<bool, Bond const *, true> BOND_BOOL_QUERY;
34
35 typedef Queries::AndQuery<int, Atom const *, true> ATOM_AND_QUERY;
36 typedef Queries::AndQuery<int, Bond const *, true> BOND_AND_QUERY;
37
38 typedef Queries::OrQuery<int, Atom const *, true> ATOM_OR_QUERY;
39 typedef Queries::OrQuery<int, Bond const *, true> BOND_OR_QUERY;
40
41 typedef Queries::XOrQuery<int, Atom const *, true> ATOM_XOR_QUERY;
42 typedef Queries::XOrQuery<int, Bond const *, true> BOND_XOR_QUERY;
43
44 typedef Queries::EqualityQuery<int, Atom const *, true> ATOM_EQUALS_QUERY;
45 typedef Queries::EqualityQuery<int, Bond const *, true> BOND_EQUALS_QUERY;
46
47 typedef Queries::GreaterQuery<int, Atom const *, true> ATOM_GREATER_QUERY;
48 typedef Queries::GreaterQuery<int, Bond const *, true> BOND_GREATER_QUERY;
49
50typedef Queries::GreaterEqualQuery<int, Atom const *, true>
51 ATOM_GREATEREQUAL_QUERY;
52typedef Queries::GreaterEqualQuery<int, Bond const *, true>
53 BOND_GREATEREQUAL_QUERY;
54
55 typedef Queries::LessQuery<int, Atom const *, true> ATOM_LESS_QUERY;
56 typedef Queries::LessQuery<int, Bond const *, true> BOND_LESS_QUERY;
57
58 typedef Queries::LessEqualQuery<int, Atom const *, true> ATOM_LESSEQUAL_QUERY;
59 typedef Queries::LessEqualQuery<int, Bond const *, true> BOND_LESSEQUAL_QUERY;
60
61 typedef Queries::RangeQuery<int, Atom const *, true> ATOM_RANGE_QUERY;
62 typedef Queries::RangeQuery<int, Bond const *, true> BOND_RANGE_QUERY;
63
64 typedef Queries::SetQuery<int, Atom const *, true> ATOM_SET_QUERY;
65 typedef Queries::SetQuery<int, Bond const *, true> BOND_SET_QUERY;
66
67 typedef Queries::Query<int, Bond const *, true> BOND_NULL_QUERY;
68 typedef Queries::Query<int, Atom const *, true> ATOM_NULL_QUERY;
69
70// -------------------------------------------------
71// common atom queries
72
73 static inline int queryAtomAromatic(Atom const *at) {
74 return at->getIsAromatic();
75};
76 static inline int queryAtomAliphatic(Atom const *at) {
77 return !(at->getIsAromatic());
78};
79 static inline int queryAtomExplicitDegree(Atom const *at) {
80 return at->getDegree();
81};
82 static inline int queryAtomTotalDegree(Atom const *at) {
83 return at->getTotalDegree();
84};
85//! D and T are treated as "non-hydrogen" here
86 static inline int queryAtomNonHydrogenDegree(Atom const *at) {
87 int res = 0;
88 for (const auto nbri :
89 boost::make_iterator_range(at->getOwningMol().getAtomNeighbors(at))) {
90 const auto nbr = at->getOwningMol()[nbri];
91 if (nbr->getAtomicNum() != 1 || nbr->getIsotope() > 1) {
92 res++;
93 }
94 }
95
96 return res;
97};
98//! D and T are not treated as heavy atoms here
99 static inline int queryAtomHeavyAtomDegree(Atom const *at) {
100 int heavyDegree = 0;
101 for (const auto nbri :
102 boost::make_iterator_range(at->getOwningMol().getAtomNeighbors(at))) {
103 const auto nbr = at->getOwningMol()[nbri];
104 if (nbr->getAtomicNum() > 1) {
105 heavyDegree++;
106 }
107 }
108
109 return heavyDegree;
110};
111 static inline int queryAtomHCount(Atom const *at) {
112 return at->getTotalNumHs(true);
113};
114 static inline int queryAtomImplicitHCount(Atom const *at) {
115 return at->getTotalNumHs(false);
116};
117 static inline int queryAtomHasImplicitH(Atom const *at) {
118 return int(at->getTotalNumHs(false) > 0);
119};
120 static inline int queryAtomImplicitValence(Atom const *at) {
121 return at->getValence(Atom::ValenceType::IMPLICIT);
122};
123 static inline int queryAtomExplicitValence(Atom const *at) {
124 return at->getValence(Atom::ValenceType::EXPLICIT) - at->getNumExplicitHs();
125};
126 static inline int queryAtomTotalValence(Atom const *at) {
127 return at->getTotalValence();
128};
129 static inline int queryAtomUnsaturated(Atom const *at) {
130 return at->getTotalDegree() < at->getTotalValence();
131};
132 static inline int queryAtomNum(Atom const *at) { return at->getAtomicNum(); }
133 static inline int makeAtomType(int atomic_num, bool aromatic) {
134 return atomic_num + 1000 * static_cast<int>(aromatic);
135}
136 static inline void parseAtomType(int val, int &atomic_num, bool &aromatic) {
137 if (val > 1000) {
138 aromatic = true;
139 atomic_num = val - 1000;
140 } else {
141 aromatic = false;
142 atomic_num = val;
143 }
144}
145 static inline bool getAtomTypeIsAromatic(int val) { return val > 1000; }
146 static inline int getAtomTypeAtomicNum(int val) {
147 if (val > 1000) {
148 return val - 1000;
149 }
150 return val;
151}
152
153 static inline int queryAtomType(Atom const *at) {
154 return makeAtomType(at->getAtomicNum(), at->getIsAromatic());
155};
156 const int massIntegerConversionFactor = 1000;
157 static inline int queryAtomMass(Atom const *at) {
158 return static_cast<int>(
159 std::round(massIntegerConversionFactor * at->getMass()));
160};
161 static inline int queryAtomIsotope(Atom const *at) {
162 return static_cast<int>(at->getIsotope());
163};
164 static inline int queryAtomFormalCharge(Atom const *at) {
165 return static_cast<int>(at->getFormalCharge());
166};
167 static inline int queryAtomNegativeFormalCharge(Atom const *at) {
168 return static_cast<int>(-1 * at->getFormalCharge());
169};
170 static inline int queryAtomHybridization(Atom const *at) {
171 return at->getHybridization();
172};
173 static inline int queryAtomNumRadicalElectrons(Atom const *at) {
174 return at->getNumRadicalElectrons();
175};
176 static inline int queryAtomHasChiralTag(Atom const *at) {
177 return at->getChiralTag() != Atom::CHI_UNSPECIFIED;
178};
179 static inline int queryAtomMissingChiralTag(Atom const *at) {
180 return at->getChiralTag() == Atom::CHI_UNSPECIFIED &&
181 at->hasProp(common_properties::_ChiralityPossible);
182};
183
184 static inline int queryAtomHasHeteroatomNbrs(Atom const *at) {
185 ROMol::ADJ_ITER nbrIdx, endNbrs;
186 boost::tie(nbrIdx, endNbrs) = at->getOwningMol().getAtomNeighbors(at);
187 while (nbrIdx != endNbrs) {
188 const Atom *nbr = at->getOwningMol()[*nbrIdx];
189 if (nbr->getAtomicNum() != 6 && nbr->getAtomicNum() != 1) {
190 return 1;
191 }
192 ++nbrIdx;
193 }
194 return 0;
195};
196
197 static inline int queryAtomNumHeteroatomNbrs(Atom const *at) {
198 int res = 0;
199 ROMol::ADJ_ITER nbrIdx, endNbrs;
200 boost::tie(nbrIdx, endNbrs) = at->getOwningMol().getAtomNeighbors(at);
201 while (nbrIdx != endNbrs) {
202 const Atom *nbr = at->getOwningMol()[*nbrIdx];
203 if (nbr->getAtomicNum() != 6 && nbr->getAtomicNum() != 1) {
204 ++res;
205 }
206 ++nbrIdx;
207 }
208 return res;
209};
210
211 static inline int queryAtomHasAliphaticHeteroatomNbrs(Atom const *at) {
212 ROMol::ADJ_ITER nbrIdx, endNbrs;
213 boost::tie(nbrIdx, endNbrs) = at->getOwningMol().getAtomNeighbors(at);
214 while (nbrIdx != endNbrs) {
215 const Atom *nbr = at->getOwningMol()[*nbrIdx];
216 if ((!nbr->getIsAromatic()) && nbr->getAtomicNum() != 6 &&
217 nbr->getAtomicNum() != 1) {
218 return 1;
219 }
220 ++nbrIdx;
221 }
222 return 0;
223};
224
225 static inline int queryAtomNumAliphaticHeteroatomNbrs(Atom const *at) {
226 int res = 0;
227 ROMol::ADJ_ITER nbrIdx, endNbrs;
228 boost::tie(nbrIdx, endNbrs) = at->getOwningMol().getAtomNeighbors(at);
229 while (nbrIdx != endNbrs) {
230 const Atom *nbr = at->getOwningMol()[*nbrIdx];
231 if ((!nbr->getIsAromatic()) && nbr->getAtomicNum() != 6 &&
232 nbr->getAtomicNum() != 1) {
233 ++res;
234 }
235 ++nbrIdx;
236 }
237 return res;
238};
239
240 RDKIT_GRAPHMOL_EXPORT unsigned int queryAtomBondProduct(Atom const *at);
241 RDKIT_GRAPHMOL_EXPORT unsigned int queryAtomAllBondProduct(Atom const *at);
242
243// -------------------------------------------------
244// common bond queries
245
246 static inline int queryBondOrder(Bond const *bond) {
247 return static_cast<int>(bond->getBondType());
248};
249 static inline int queryBondIsSingleOrAromatic(Bond const *bond) {
250 return static_cast<int>(bond->getBondType() == Bond::SINGLE ||
251 bond->getBondType() == Bond::AROMATIC);
252};
253 static inline int queryBondIsDoubleOrAromatic(Bond const *bond) {
254 return static_cast<int>(bond->getBondType() == Bond::DOUBLE ||
255 bond->getBondType() == Bond::AROMATIC);
256};
257 static inline int queryBondIsSingleOrDouble(Bond const *bond) {
258 return static_cast<int>(bond->getBondType() == Bond::SINGLE ||
259 bond->getBondType() == Bond::DOUBLE);
260};
261 static inline int queryBondIsSingleOrDoubleOrAromatic(Bond const *bond) {
262 return static_cast<int>(bond->getBondType() == Bond::SINGLE ||
263 bond->getBondType() == Bond::DOUBLE ||
264 bond->getBondType() == Bond::AROMATIC);
265};
266 static inline int queryBondDir(Bond const *bond) {
267 return static_cast<int>(bond->getBondDir());
268};
269 static inline int queryIsBondInNRings(Bond const *at) {
270 return at->getOwningMol().getRingInfo()->numBondRings(at->getIdx());
271};
272 static inline int queryBondHasStereo(Bond const *bnd) {
273 return bnd->getStereo() > Bond::STEREONONE;
274};
275
276// -------------------------------------------------
277// ring queries
278
279 static inline int queryIsAtomInNRings(Atom const *at) {
280 return at->getOwningMol().getRingInfo()->numAtomRings(at->getIdx());
281};
282 static inline int queryIsAtomInRing(Atom const *at) {
283 return at->getOwningMol().getRingInfo()->numAtomRings(at->getIdx()) != 0;
284};
285 static inline int queryAtomHasRingBond(Atom const *at) {
286 ROMol::OBOND_ITER_PAIR atomBonds = at->getOwningMol().getAtomBonds(at);
287 while (atomBonds.first != atomBonds.second) {
288 unsigned int bondIdx =
289 at->getOwningMol().getTopology()[*atomBonds.first]->getIdx();
290 if (at->getOwningMol().getRingInfo()->numBondRings(bondIdx)) {
291 return 1;
292 }
293 ++atomBonds.first;
294 }
295 return 0;
296};
297 RDKIT_GRAPHMOL_EXPORT int queryIsAtomBridgehead(Atom const *at);
298
299 static inline int queryIsBondInRing(Bond const *bond) {
300 return bond->getOwningMol().getRingInfo()->numBondRings(bond->getIdx()) != 0;
301};
302 static inline int queryAtomMinRingSize(Atom const *at) {
303 return at->getOwningMol().getRingInfo()->minAtomRingSize(at->getIdx());
304};
305 static inline int queryBondMinRingSize(Bond const *bond) {
306 return bond->getOwningMol().getRingInfo()->minBondRingSize(bond->getIdx());
307};
308
309 static inline int queryAtomRingBondCount(Atom const *at) {
310 // EFF: cache this result
311 int res = 0;
312 ROMol::OBOND_ITER_PAIR atomBonds = at->getOwningMol().getAtomBonds(at);
313 while (atomBonds.first != atomBonds.second) {
314 unsigned int bondIdx =
315 at->getOwningMol().getTopology()[*atomBonds.first]->getIdx();
316 if (at->getOwningMol().getRingInfo()->numBondRings(bondIdx)) {
317 res++;
318 }
319 ++atomBonds.first;
320 }
321 return res;
322}
323
324template <int tgt>
325 int queryAtomIsInRingOfSize(Atom const *at) {
326 if (at->getOwningMol().getRingInfo()->isAtomInRingOfSize(at->getIdx(), tgt)) {
327 return tgt;
328 } else {
329 return 0;
330 }
331};
332template <int tgt>
333 int queryBondIsInRingOfSize(Bond const *bond) {
334 if (bond->getOwningMol().getRingInfo()->isBondInRingOfSize(bond->getIdx(),
335 tgt)) {
336 return tgt;
337 } else {
338 return 0;
339 }
340};
341
342template <class T>
343T *makeAtomSimpleQuery(int what, int func(Atom const *),
344 const std::string &description = "Atom Simple") {
345 T *res = new T;
346 res->setVal(what);
347 res->setDataFunc(func);
348 res->setDescription(description);
349 return res;
350}
351
352 static inline ATOM_RANGE_QUERY *makeAtomRangeQuery(
353 int lower, int upper, bool lowerOpen, bool upperOpen,
354 int func(Atom const *), const std::string &description = "Atom Range") {
355 ATOM_RANGE_QUERY *res = new ATOM_RANGE_QUERY(lower, upper);
356 res->setDataFunc(func);
357 res->setDescription(description);
358 res->setEndsOpen(lowerOpen, upperOpen);
359 return res;
360}
361
362//! returns a Query for matching atomic number
363template <class T>
364T *makeAtomNumQuery(int what, const std::string &descr) {
365 return makeAtomSimpleQuery<T>(what, queryAtomNum, descr);
366}
367//! \overload
368 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomNumQuery(int what);
369
370//! returns a Query for matching atomic number and aromaticity
371template <class T>
372T *makeAtomTypeQuery(int num, int aromatic, const std::string &descr) {
373 return makeAtomSimpleQuery<T>(makeAtomType(num, aromatic), queryAtomType,
374 descr);
375}
376//! \overload
377 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomTypeQuery(int num,
378 int aromatic);
379
380//! returns a Query for matching implicit valence
381template <class T>
382T *makeAtomImplicitValenceQuery(int what, const std::string &descr) {
383 return makeAtomSimpleQuery<T>(what, queryAtomImplicitValence, descr);
384}
385//! \overload
386 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomImplicitValenceQuery(int what);
387
388//! returns a Query for matching explicit valence
389template <class T>
390T *makeAtomExplicitValenceQuery(int what, const std::string &descr) {
391 return makeAtomSimpleQuery<T>(what, queryAtomExplicitValence, descr);
392}
393//! \overload
394 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomExplicitValenceQuery(int what);
395
396//! returns a Query for matching total valence
397template <class T>
398T *makeAtomTotalValenceQuery(int what, const std::string &descr) {
399 return makeAtomSimpleQuery<T>(what, queryAtomTotalValence, descr);
400}
401//! \overload
402 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomTotalValenceQuery(int what);
403
404//! returns a Query for matching explicit degree
405template <class T>
406T *makeAtomExplicitDegreeQuery(int what, const std::string &descr) {
407 return makeAtomSimpleQuery<T>(what, queryAtomExplicitDegree, descr);
408}
409//! \overload
410 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomExplicitDegreeQuery(int what);
411
412//! returns a Query for matching atomic degree
413template <class T>
414T *makeAtomTotalDegreeQuery(int what, const std::string &descr) {
415 return makeAtomSimpleQuery<T>(what, queryAtomTotalDegree, descr);
416}
417//! \overload
418 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomTotalDegreeQuery(int what);
419
420//! returns a Query for matching heavy atom degree
421template <class T>
422T *makeAtomHeavyAtomDegreeQuery(int what, const std::string &descr) {
423 return makeAtomSimpleQuery<T>(what, queryAtomHeavyAtomDegree, descr);
424}
425//! \overload
426 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomHeavyAtomDegreeQuery(int what);
427
428//! returns a Query for matching hydrogen count
429template <class T>
430T *makeAtomHCountQuery(int what, const std::string &descr) {
431 return makeAtomSimpleQuery<T>(what, queryAtomHCount, descr);
432}
433//! \overload
434 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomHCountQuery(int what);
435
436//! returns a Query for matching ring atoms
437template <class T>
438T *makeAtomHasImplicitHQuery(const std::string &descr) {
439 return makeAtomSimpleQuery<T>(true, queryAtomHasImplicitH, descr);
440}
441//! \overload
442 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomHasImplicitHQuery();
443
444//! returns a Query for matching implicit hydrogen count
445template <class T>
446T *makeAtomImplicitHCountQuery(int what, const std::string &descr) {
447 return makeAtomSimpleQuery<T>(what, queryAtomImplicitHCount, descr);
448}
449//! \overload
450 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomImplicitHCountQuery(int what);
451
452//! returns a Query for matching the \c isAromatic flag
453template <class T>
454T *makeAtomAromaticQuery(const std::string &descr) {
455 return makeAtomSimpleQuery<T>(true, queryAtomAromatic, descr);
456}
457//! \overload
458 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomAromaticQuery();
459
460//! returns a Query for matching aliphatic atoms
461template <class T>
462T *makeAtomAliphaticQuery(const std::string &descr) {
463 return makeAtomSimpleQuery<T>(true, queryAtomAliphatic, descr);
464}
465//! \overload
466 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomAliphaticQuery();
467
468//! returns a Query for matching atoms with a particular mass
469template <class T>
470T *makeAtomMassQuery(int what, const std::string &descr) {
471 return makeAtomSimpleQuery<T>(massIntegerConversionFactor * what,
472 queryAtomMass, descr);
473}
474//! \overload
475 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomMassQuery(int what);
476
477//! returns a Query for matching atoms with a particular isotope
478template <class T>
479T *makeAtomIsotopeQuery(int what, const std::string &descr) {
480 return makeAtomSimpleQuery<T>(what, queryAtomIsotope, descr);
481}
482//! \overload
483 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomIsotopeQuery(int what);
484
485//! returns a Query for matching formal charge
486template <class T>
487T *makeAtomFormalChargeQuery(int what, const std::string &descr) {
488 return makeAtomSimpleQuery<T>(what, queryAtomFormalCharge, descr);
489}
490//! \overload
491 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomFormalChargeQuery(int what);
492
493//! returns a Query for matching negative formal charges (i.e. a query val of 1
494//! matches a formal charge of -1)
495template <class T>
496T *makeAtomNegativeFormalChargeQuery(int what, const std::string &descr) {
497 return makeAtomSimpleQuery<T>(what, queryAtomNegativeFormalCharge, descr);
498}
499//! \overload
500 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomNegativeFormalChargeQuery(
501 int what);
502
503//! returns a Query for matching hybridization
504template <class T>
505T *makeAtomHybridizationQuery(int what, const std::string &descr) {
506 return makeAtomSimpleQuery<T>(what, queryAtomHybridization, descr);
507}
508//! \overload
509 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomHybridizationQuery(int what);
510
511//! returns a Query for matching the number of radical electrons
512template <class T>
513T *makeAtomNumRadicalElectronsQuery(int what, const std::string &descr) {
514 return makeAtomSimpleQuery<T>(what, queryAtomNumRadicalElectrons, descr);
515}
516//! \overload
517 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomNumRadicalElectronsQuery(
518 int what);
519
520//! returns a Query for matching whether or not chirality has been set on the
521//! atom
522template <class T>
523T *makeAtomHasChiralTagQuery(const std::string &descr) {
524 return makeAtomSimpleQuery<T>(true, queryAtomHasChiralTag, descr);
525}
526//! \overloadquery
527 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomHasChiralTagQuery();
528
529//! returns a Query for matching whether or not a potentially chiral atom is
530//! missing a chiral tag
531template <class T>
532T *makeAtomMissingChiralTagQuery(const std::string &descr) {
533 return makeAtomSimpleQuery<T>(true, queryAtomMissingChiralTag, descr);
534}
535//! \overloadquery
536 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomMissingChiralTagQuery();
537
538//! returns a Query for matching atoms with unsaturation:
539template <class T>
540T *makeAtomUnsaturatedQuery(const std::string &descr) {
541 return makeAtomSimpleQuery<T>(true, queryAtomUnsaturated, descr);
542}
543//! \overload
544 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomUnsaturatedQuery();
545
546//! returns a Query for matching ring atoms
547template <class T>
548T *makeAtomInRingQuery(const std::string &descr) {
549 return makeAtomSimpleQuery<T>(true, queryIsAtomInRing, descr);
550}
551//! \overload
552 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomInRingQuery();
553
554//! returns a Query for matching atoms in a particular number of rings
555template <class T>
556T *makeAtomInNRingsQuery(int what, const std::string &descr) {
557 return makeAtomSimpleQuery<T>(what, queryIsAtomInNRings, descr);
558}
559//! \overload
560 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomInNRingsQuery(int what);
561
562//! returns a Query for matching atoms in rings of a particular size
563 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomInRingOfSizeQuery(int tgt);
564
565//! returns a Query for matching an atom's minimum ring size
566template <class T>
567T *makeAtomMinRingSizeQuery(int tgt, const std::string &descr) {
568 return makeAtomSimpleQuery<T>(tgt, queryAtomMinRingSize, descr);
569}
570//! \overload
571 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomMinRingSizeQuery(int tgt);
572
573//! returns a Query for matching atoms with a particular number of ring bonds
574template <class T>
575T *makeAtomRingBondCountQuery(int what, const std::string &descr) {
576 return makeAtomSimpleQuery<T>(what, queryAtomRingBondCount, descr);
577}
578//! \overload
579 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomRingBondCountQuery(int what);
580
581//! returns a Query for matching generic A atoms (heavy atoms)
582 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAAtomQuery();
583//! returns a Query for matching generic AH atoms (any atom)
584 RDKIT_GRAPHMOL_EXPORT ATOM_NULL_QUERY *makeAHAtomQuery();
585//! returns a Query for matching generic Q atoms (heteroatoms)
586 RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY *makeQAtomQuery();
587//! returns a Query for matching generic QH atoms (heteroatom or H)
588 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeQHAtomQuery();
589//! returns a Query for matching generic X atoms (halogens)
590 RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY *makeXAtomQuery();
591//! returns a Query for matching generic XH atoms (halogen or H)
592 RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY *makeXHAtomQuery();
593//! returns a Query for matching generic M atoms (metals)
594 RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY *makeMAtomQuery();
595//! returns a Query for matching generic MH atoms (metals or H)
596 RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY *makeMHAtomQuery();
597
598// We support the same special atom queries that we can read from
599// CXSMILES
600 const std::vector<std::string> complexQueries = {"A", "AH", "Q", "QH",
601 "X", "XH", "M", "MH"};
602 RDKIT_GRAPHMOL_EXPORT void convertComplexNameToQuery(Atom *query,
603 std::string_view symb);
604
605//! returns a Query for matching atoms that have ring bonds
606template <class T>
607T *makeAtomHasRingBondQuery(const std::string &descr) {
608 return makeAtomSimpleQuery<T>(1, queryAtomHasRingBond, descr);
609}
610//! \overload
611 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomHasRingBondQuery();
612
613//! returns a Query for matching the number of heteroatom neighbors
614template <class T>
615T *makeAtomNumHeteroatomNbrsQuery(int what, const std::string &descr) {
616 return makeAtomSimpleQuery<T>(what, queryAtomNumHeteroatomNbrs, descr);
617}
618//! \overload
619 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomNumHeteroatomNbrsQuery(
620 int what);
621
622//! returns a Query for matching atoms that have heteroatom neighbors
623template <class T>
624T *makeAtomHasHeteroatomNbrsQuery(const std::string &descr) {
625 return makeAtomSimpleQuery<T>(1, queryAtomHasHeteroatomNbrs, descr);
626}
627//! \overload
628 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomHasHeteroatomNbrsQuery();
629
630//! returns a Query for matching the number of aliphatic heteroatom neighbors
631template <class T>
632T *makeAtomNumAliphaticHeteroatomNbrsQuery(int what, const std::string &descr) {
633 return makeAtomSimpleQuery<T>(what, queryAtomNumAliphaticHeteroatomNbrs,
634 descr);
635}
636//! \overload
637 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *
638 makeAtomNumAliphaticHeteroatomNbrsQuery(int what);
639
640//! returns a Query for matching atoms that have heteroatom neighbors
641template <class T>
642T *makeAtomHasAliphaticHeteroatomNbrsQuery(const std::string &descr) {
643 return makeAtomSimpleQuery<T>(1, queryAtomHasAliphaticHeteroatomNbrs, descr);
644}
645//! \overload
646 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *
647makeAtomHasAliphaticHeteroatomNbrsQuery();
648
649//! returns a Query for matching the number of non-hydrogen neighbors
650template <class T>
651T *makeAtomNonHydrogenDegreeQuery(int what, const std::string &descr) {
652 return makeAtomSimpleQuery<T>(what, queryAtomNonHydrogenDegree, descr);
653}
654//! \overload
655 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomNonHydrogenDegreeQuery(
656 int what);
657
658//! returns a Query for matching bridgehead atoms
659template <class T>
660T *makeAtomIsBridgeheadQuery(const std::string &descr) {
661 return makeAtomSimpleQuery<T>(true, queryIsAtomBridgehead, descr);
662}
663//! \overload
664 RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY *makeAtomIsBridgeheadQuery();
665
666//! returns a Query for matching bond orders
667 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeBondOrderEqualsQuery(
668 Bond::BondType what);
669//! returns a Query for unspecified SMARTS bonds
670 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeSingleOrAromaticBondQuery();
671//! returns a Query for double|aromatic bonds
672 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeDoubleOrAromaticBondQuery();
673//! returns a Query for single|double bonds
674 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeSingleOrDoubleBondQuery();
675//! returns a Query for tautomeric bonds
676 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *
677makeSingleOrDoubleOrAromaticBondQuery();
678
679//! returns a Query for matching bond directions
680 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeBondDirEqualsQuery(
681 Bond::BondDir what);
682//! returns a Query for matching bonds with stereo set
683 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeBondHasStereoQuery();
684//! returns a Query for matching ring bonds
685 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeBondIsInRingQuery();
686//! returns a Query for matching bonds in rings of a particular size
687 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeBondInRingOfSizeQuery(int what);
688//! returns a Query for matching a bond's minimum ring size
689 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeBondMinRingSizeQuery(int what);
690//! returns a Query for matching bonds in a particular number of rings
691 RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY *makeBondInNRingsQuery(int tgt);
692
693//! returns a Query for matching any bond
694 RDKIT_GRAPHMOL_EXPORT BOND_NULL_QUERY *makeBondNullQuery();
695//! returns a Query for matching any atom
696 RDKIT_GRAPHMOL_EXPORT ATOM_NULL_QUERY *makeAtomNullQuery();
697
698 static inline int queryAtomRingMembership(Atom const *at) {
699 return static_cast<int>(
700 at->getOwningMol().getRingInfo()->numAtomRings(at->getIdx()));
701}
702// I'm pretty sure that this typedef shouldn't be necessary,
703// but VC++ generates a warning about const Atom const * in
704// the definition of Match, then complains about an override
705// that differs only by const/volatile (c4301), then generates
706// incorrect code if we don't do this... so let's do it.
707 typedef Atom const *ConstAtomPtr;
708
709 class RDKIT_GRAPHMOL_EXPORT AtomRingQuery
710 : public Queries::EqualityQuery<int, ConstAtomPtr, true> {
711 public:
712 AtomRingQuery() : Queries::EqualityQuery<int, ConstAtomPtr, true>(-1) {
713 // default is to just do a number of rings query:
714 this->setDescription("AtomInNRings");
715 this->setDataFunc(queryAtomRingMembership);
716 }
717 explicit AtomRingQuery(int v)
718 : Queries::EqualityQuery<int, ConstAtomPtr, true>(v) {
719 // default is to just do a number of rings query:
720 this->setDescription("AtomInNRings");
721 this->setDataFunc(queryAtomRingMembership);
722 }
723
724 bool Match(const ConstAtomPtr what) const override {
725 int v = this->TypeConvert(what, Queries::Int2Type<true>());
726 bool res;
727 if (this->d_val < 0) {
728 res = v != 0;
729 } else {
730 res = !Queries::queryCmp(v, this->d_val, this->d_tol);
731 }
732 if (this->getNegation()) {
733 res = !res;
734 }
735 return res;
736 }
737
738 //! returns a copy of this query
739 Queries::Query<int, ConstAtomPtr, true> *copy() const override {
740 AtomRingQuery *res = new AtomRingQuery(this->d_val);
741 res->setNegation(getNegation());
742 res->setTol(this->getTol());
743 res->d_description = this->d_description;
744 res->d_dataFunc = this->d_dataFunc;
745 return res;
746 }
747};
748
749//! allows use of recursive structure queries (e.g. recursive SMARTS)
750 class RDKIT_GRAPHMOL_EXPORT RecursiveStructureQuery
751 : public Queries::SetQuery<int, Atom const *, true> {
752 public:
753 RecursiveStructureQuery() : Queries::SetQuery<int, Atom const *, true>() {
754 setDataFunc(getAtIdx);
755 setDescription("RecursiveStructure");
756 }
757 //! initialize from an ROMol pointer
758 /*!
759 <b>Notes</b>
760 - this takes over ownership of the pointer
761 */
762 RecursiveStructureQuery(ROMol const *query, unsigned int serialNumber = 0)
763 : Queries::SetQuery<int, Atom const *, true>(),
764 d_serialNumber(serialNumber) {
765 setQueryMol(query);
766 setDataFunc(getAtIdx);
767 setDescription("RecursiveStructure");
768 }
769 //! returns the index of an atom
770 static inline int getAtIdx(Atom const *at) {
771 PRECONDITION(at, "bad atom argument");
772 return at->getIdx();
773 }
774
775 //! sets the molecule we'll use recursively
776 /*!
777 <b>Notes</b>
778 - this takes over ownership of the pointer
779 */
780 void setQueryMol(ROMol const *query) { dp_queryMol.reset(query); }
781 //! returns a pointer to our query molecule
782 ROMol const *getQueryMol() const { return dp_queryMol.get(); }
783
784 //! returns a copy of this query
785 Queries::Query<int, Atom const *, true> *copy() const override {
786 RecursiveStructureQuery *res = new RecursiveStructureQuery();
787 res->dp_queryMol.reset(new ROMol(*dp_queryMol, true));
788
789 std::set<int>::const_iterator i;
790 for (i = d_set.begin(); i != d_set.end(); i++) {
791 res->insert(*i);
792 }
793 res->setNegation(getNegation());
794 res->d_description = d_description;
795 res->d_serialNumber = d_serialNumber;
796 return res;
797 }
798 unsigned int getSerialNumber() const { return d_serialNumber; }
799
800#ifdef RDK_BUILD_THREADSAFE_SSS
801 std::mutex d_mutex;
802#endif
803 private:
804 boost::shared_ptr<const ROMol> dp_queryMol;
805 unsigned int d_serialNumber{0};
806};
807
808template <typename T>
809 int nullDataFun(T) {
810 return 1;
811}
812template <typename T>
813 bool nullQueryFun(T) {
814 return true;
815}
816
817 typedef Bond const *ConstBondPtr;
818
819// ! Query whether an atom has a property
820template <class TargetPtr>
821 class HasPropQuery : public Queries::EqualityQuery<int, TargetPtr, true> {
822 std::string propname;
823
824 public:
825 HasPropQuery() : Queries::EqualityQuery<int, TargetPtr, true>(), propname() {
826 this->setDescription("HasProp");
827 this->setDataFunc(nullptr);
828 }
829 explicit HasPropQuery(std::string v)
830 : Queries::EqualityQuery<int, TargetPtr, true>(), propname(std::move(v)) {
831 this->setDescription("HasProp");
832 this->setDataFunc(nullptr);
833 }
834
835 bool Match(const TargetPtr what) const override {
836 bool res = what->hasProp(propname);
837 if (this->getNegation()) {
838 res = !res;
839 }
840 return res;
841 }
842
843 //! returns a copy of this query
844 Queries::Query<int, TargetPtr, true> *copy() const override {
845 HasPropQuery *res = new HasPropQuery(this->propname);
846 res->setNegation(this->getNegation());
847 res->d_description = this->d_description;
848 return res;
849 }
850
851 const std::string &getPropName() const { return propname; }
852};
853
854 typedef Queries::EqualityQuery<int, Atom const *, true> ATOM_PROP_QUERY;
855 typedef Queries::EqualityQuery<int, Bond const *, true> BOND_PROP_QUERY;
856
857//! returns a Query for matching atoms that have a particular property
858template <class Target>
859 Queries::EqualityQuery<int, const Target *, true> *makeHasPropQuery(
860 const std::string &property) {
861 return new HasPropQuery<const Target *>(property);
862}
863
864// ! Query whether an atom has a property with a value
865 class HasPropWithValueQueryBase {
866 public:
867 HasPropWithValueQueryBase() = default;
868 virtual ~HasPropWithValueQueryBase() = default;
869 virtual PairHolder getPair() const = 0;
870 virtual double getTolerance() const = 0;
871};
872
873template <class TargetPtr, class T>
874 class HasPropWithValueQuery
875 : public HasPropWithValueQueryBase,
876 public Queries::EqualityQuery<int, TargetPtr, true> {
877 std::string propname;
878 T val;
879 double tolerance{0.0};
880
881 public:
882 HasPropWithValueQuery()
883 : Queries::EqualityQuery<int, TargetPtr, true>(), propname(), val() {
884 // default is to just do a number of rings query:
885 this->setDescription("HasPropWithValue");
886 this->setDataFunc(0);
887 }
888
889 PairHolder getPair() const override {
890 return PairHolder(Dict::Pair(propname, val));
891 }
892
893 double getTolerance() const override { return tolerance; }
894
895 explicit HasPropWithValueQuery(std::string prop, const T &v,
896 const T &tol = 0.0)
897 : Queries::EqualityQuery<int, TargetPtr, true>(),
898 propname(std::move(prop)),
899 val(v),
900 tolerance(tol) {
901 // default is to just do a number of rings query:
902 this->setDescription("HasPropWithValue");
903 this->setDataFunc(nullptr);
904 }
905
906 bool Match(const TargetPtr what) const override {
907 bool res = what->hasProp(propname);
908 if (res) {
909 try {
910 T atom_val = what->template getProp<T>(propname);
911 res = Queries::queryCmp(atom_val, this->val,
912 static_cast<T>(this->tolerance)) == 0;
913 } catch (KeyErrorException &) {
914 res = false;
915 } catch (std::bad_any_cast &) {
916 res = false;
917 }
918#ifdef __GNUC__
919#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
920 catch (...) {
921 // catch all -- this is currently necessary to
922 // trap some bugs in boost+gcc configurations
923 // Normally, this is not the correct thing to
924 // do, but the only exception above is due
925 // to the boost any_cast which is trapped
926 // by the Boost python wrapper when it shouldn't
927 // be.
928 res = false;
929 }
930#endif
931#endif
932 }
933 if (this->getNegation()) {
934 res = !res;
935 }
936 return res;
937 }
938
939 //! returns a copy of this query
940 Queries::Query<int, TargetPtr, true> *copy() const override {
941 HasPropWithValueQuery *res =
942 new HasPropWithValueQuery(this->propname, this->val, this->tolerance);
943 res->setNegation(this->getNegation());
944 res->d_description = this->d_description;
945 return res;
946 }
947};
948
949template <class TargetPtr>
950 class HasPropWithValueQuery<TargetPtr, std::string>
951 : public HasPropWithValueQueryBase,
952 public Queries::EqualityQuery<int, TargetPtr, true> {
953 std::string propname;
954 std::string val;
955
956 public:
957 HasPropWithValueQuery()
958 : Queries::EqualityQuery<int, TargetPtr, true>(), propname(), val() {
959 // default is to just do a number of rings query:
960 this->setDescription("HasPropWithValue");
961 this->setDataFunc(0);
962 }
963 explicit HasPropWithValueQuery(std::string prop, std::string v,
964 const double /*tol*/ = 0.0)
965 : Queries::EqualityQuery<int, TargetPtr, true>(),
966 propname(std::move(prop)),
967 val(std::move(v)) {
968 // default is to just do a number of rings query:
969 this->setDescription("HasPropWithValue");
970 this->setDataFunc(nullptr);
971 }
972
973 PairHolder getPair() const override {
974 return PairHolder(Dict::Pair(propname, val));
975 }
976
977 double getTolerance() const override { return 0.0; }
978
979 bool Match(const TargetPtr what) const override {
980 bool res = what->hasProp(propname);
981 if (res) {
982 try {
983 std::string atom_val = what->template getProp<std::string>(propname);
984 res = atom_val == this->val;
985 } catch (KeyErrorException &) {
986 res = false;
987 } catch (std::bad_any_cast &) {
988 res = false;
989 }
990#ifdef __GNUC__
991#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
992 catch (...) {
993 // catch all -- this is currently necessary to
994 // trap some bugs in boost+gcc configurations
995 // Normally, this is not the correct thing to
996 // do, but the only exception above is due
997 // to the boost any_cast which is trapped
998 // by the Boost python wrapper when it shouldn't
999 // be.
1000 res = false;
1001 }
1002#endif
1003#endif
1004 }
1005 if (this->getNegation()) {
1006 res = !res;
1007 }
1008 return res;
1009 }
1010
1011 //! returns a copy of this query
1012 Queries::Query<int, TargetPtr, true> *copy() const override {
1013 HasPropWithValueQuery<TargetPtr, std::string> *res =
1014 new HasPropWithValueQuery<TargetPtr, std::string>(this->propname,
1015 this->val);
1016 res->setNegation(this->getNegation());
1017 res->d_description = this->d_description;
1018 return res;
1019 }
1020};
1021
1022template <class TargetPtr>
1023 class HasPropWithValueQuery<TargetPtr, ExplicitBitVect>
1024 : public HasPropWithValueQueryBase,
1025 public Queries::EqualityQuery<int, TargetPtr, true> {
1026 std::string propname;
1027 ExplicitBitVect val;
1028 double tol{0.0};
1029
1030 public:
1031 HasPropWithValueQuery()
1032 : Queries::EqualityQuery<int, TargetPtr, true>(), propname(), val() {
1033 this->setDescription("HasPropWithValue");
1034 this->setDataFunc(0);
1035 }
1036
1037 explicit HasPropWithValueQuery(std::string prop, const ExplicitBitVect &v,
1038 double tol = 0.0)
1039 : Queries::EqualityQuery<int, TargetPtr, true>(),
1040 propname(std::move(prop)),
1041 val(v),
1042 tol(tol) {
1043 this->setDescription("HasPropWithValue");
1044 this->setDataFunc(nullptr);
1045 }
1046
1047 PairHolder getPair() const override {
1048 return PairHolder(Dict::Pair(propname, val));
1049 }
1050
1051 double getTolerance() const override { return tol; }
1052
1053 bool Match(const TargetPtr what) const override {
1054 bool res = what->hasProp(propname);
1055 if (res) {
1056 try {
1057 const ExplicitBitVect &bv =
1058 what->template getProp<const ExplicitBitVect &>(propname);
1059 const double tani = TanimotoSimilarity(val, bv);
1060 res = (1.0 - tani) <= tol;
1061 } catch (KeyErrorException &) {
1062 res = false;
1063 } catch (std::bad_any_cast &) {
1064 res = false;
1065 }
1066#ifdef __GNUC__
1067#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
1068 catch (...) {
1069 // catch all -- this is currently necessary to
1070 // trap some bugs in boost+gcc configurations
1071 // Normally, this is not the correct thing to
1072 // do, but the only exception above is due
1073 // to the boost any_cast which is trapped
1074 // by the Boost python wrapper when it shouldn't
1075 // be.
1076 res = false;
1077 }
1078#endif
1079#endif
1080 }
1081 if (this->getNegation()) {
1082 res = !res;
1083 }
1084 return res;
1085 }
1086
1087 //! returns a copy of this query
1088 Queries::Query<int, TargetPtr, true> *copy() const override {
1089 HasPropWithValueQuery<TargetPtr, ExplicitBitVect> *res =
1090 new HasPropWithValueQuery<TargetPtr, ExplicitBitVect>(
1091 this->propname, this->val, this->tol);
1092 res->setNegation(this->getNegation());
1093 res->d_description = this->d_description;
1094 return res;
1095 }
1096};
1097
1098template <class Target, class T>
1099 Queries::EqualityQuery<int, const Target *, true> *makePropQuery(
1100 const std::string &propname, const T &val, double tolerance = 0.0) {
1101 return new HasPropWithValueQuery<const Target *, T>(propname, val, tolerance);
1102}
1103
1104template <class Target>
1105 Queries::EqualityQuery<int, const Target *, true> *makePropQuery(
1106 const std::string &propname, const ExplicitBitVect &val,
1107 double tolerance = 0.0) {
1108 return new HasPropWithValueQuery<const Target *, ExplicitBitVect>(
1109 propname, val, tolerance);
1110}
1111
1112 RDKIT_GRAPHMOL_EXPORT bool isComplexQuery(const Bond *b);
1113 RDKIT_GRAPHMOL_EXPORT bool isComplexQuery(const Atom *a);
1114 RDKIT_GRAPHMOL_EXPORT bool isAtomAromatic(const Atom *a);
1115 RDKIT_GRAPHMOL_EXPORT bool isAtomListQuery(const Atom *a);
1116 RDKIT_GRAPHMOL_EXPORT void getAtomListQueryVals(const Atom::QUERYATOM_QUERY *q,
1117 std::vector<int> &vals);
1118
1119// Checks if an atom is dummy or not.
1120// 1. A dummy non-query atom (e.g., "*" in SMILES) is defined by its zero atomic
1121// number. This rule breaks for query atoms because a COMPOSITE_OR query atom
1122// also has a zero atomic number (#6349).
1123// 2. A dummy query atom (e.g., "*" in SMARTS) is defined by its explicit
1124// description: "AtomNull".
1125 inline bool isAtomDummy(const Atom *a) {
1126 return (!a->hasQuery() && a->getAtomicNum() == 0) ||
1127 (a->hasQuery() && !a->getQuery()->getNegation() &&
1128 a->getQuery()->getDescription() == "AtomNull");
1129}
1130
1131 namespace QueryOps {
1132 RDKIT_GRAPHMOL_EXPORT void completeMolQueries(
1133 RWMol *mol, unsigned int magicVal = 0xDEADBEEF);
1134// Replaces the given atom in the molecule with a QueryAtom that is otherwise
1135// a copy of the given atom. Returns a pointer to that atom.
1136// if the atom already has a query, nothing will be changed
1137 RDKIT_GRAPHMOL_EXPORT Atom *replaceAtomWithQueryAtom(RWMol *mol, Atom *atom);
1138
1139 RDKIT_GRAPHMOL_EXPORT void finalizeQueryFromDescription(
1140 Queries::Query<int, Atom const *, true> *query, Atom const *owner);
1141 RDKIT_GRAPHMOL_EXPORT void finalizeQueryFromDescription(
1142 Queries::Query<int, Bond const *, true> *query, Bond const *owner);
1143
1144 RDKIT_GRAPHMOL_EXPORT bool hasBondTypeQuery(
1145 const Queries::Query<int, Bond const *, true> &qry);
1146 inline bool hasBondTypeQuery(const Bond &bond) {
1147 if (!bond.hasQuery()) {
1148 return false;
1149 }
1150 return hasBondTypeQuery(*bond.getQuery());
1151}
1152 RDKIT_GRAPHMOL_EXPORT bool hasComplexBondTypeQuery(
1153 const Queries::Query<int, Bond const *, true> &qry);
1154 inline bool hasComplexBondTypeQuery(const Bond &bond) {
1155 if (!bond.hasQuery()) {
1156 return false;
1157 }
1158 return hasComplexBondTypeQuery(*bond.getQuery());
1159}
1160
1161 RDKIT_GRAPHMOL_EXPORT bool isMetal(const Atom &atom);
1162} // namespace QueryOps
1163} // namespace RDKit
1164#endif
BitOps.h
Contains general bit-comparison and similarity operations.
BitVects.h
Pulls in all the BitVect classes.
Dict.h
Defines the Dict class.
PRECONDITION
#define PRECONDITION(expr, mess)
Definition Invariant.h:108
QueryObjects.h
Pulls in all the query types.
Query.h
RDKitBase.h
pulls in the core RDKit functionality
ExplicitBitVect
a class for bit vectors that are densely occupied
Definition ExplicitBitVect.h:29
KeyErrorException
Class to allow us to throw a KeyError from C++ and have it make it back to Python.
Definition Exceptions.h:56
Queries::AndQuery
a Query implementing AND: requires all children to be true
Definition AndQuery.h:22
Queries::EqualityQuery
a Query implementing ==: arguments must match a particular value (within an optional tolerance)
Definition EqualityQuery.h:24
Queries::EqualityQuery::setTol
void setTol(MatchFuncArgType what)
sets our tolerance
Definition EqualityQuery.h:47
Queries::EqualityQuery< int, ConstAtomPtr, true >::EqualityQuery
EqualityQuery()
Definition EqualityQuery.h:26
Queries::EqualityQuery< int, ConstAtomPtr, true >::getTol
const int getTol() const
Definition EqualityQuery.h:49
Queries::GreaterEqualQuery
a Query implementing >= using a particular value (and an optional tolerance)
Definition GreaterEqualQuery.h:22
Queries::GreaterQuery
a Query implementing > using a particular value (and an optional tolerance)
Definition GreaterQuery.h:22
Queries::Int2Type
class to allow integer values to pick templates
Definition Query.h:26
Queries::LessEqualQuery
a Query implementing <= using a particular value (and an optional tolerance)
Definition LessEqualQuery.h:22
Queries::LessQuery
a Query implementing < using a particular value (and an optional tolerance)
Definition LessQuery.h:22
Queries::OrQuery
a Query implementing AND: requires any child to be true
Definition OrQuery.h:21
Queries::Query
Base class for all queries.
Definition Query.h:45
Queries::Query::d_dataFunc
MatchFuncArgType(* d_dataFunc)(DataFuncArgType)
Definition Query.h:164
Queries::Query< int, ConstAtomPtr, needsConversion >::TypeConvert
int TypeConvert(int what, Int2Type< false >) const
Definition Query.h:169
Queries::Query::setDataFunc
void setDataFunc(MatchFuncArgType(*what)(DataFuncArgType))
sets our data function
Definition Query.h:94
Queries::Query< int, ConstAtomPtr, needsConversion >::getNegation
bool getNegation() const
Definition Query.h:61
Queries::Query::setNegation
void setNegation(bool what)
sets whether or not we are negated
Definition Query.h:59
Queries::Query::getDescription
const std::string & getDescription() const
returns our text description
Definition Query.h:70
Queries::Query< int, ConstAtomPtr, needsConversion >::d_tol
int d_tol
Definition Query.h:151
Queries::Query< int, ConstAtomPtr, needsConversion >::d_val
int d_val
Definition Query.h:150
Queries::Query::setDescription
void setDescription(const std::string &descr)
sets our text description
Definition Query.h:64
Queries::Query::d_description
std::string d_description
Definition Query.h:152
Queries::RangeQuery
a Query implementing a range: arguments must fall in a particular range of values.
Definition RangeQuery.h:28
Queries::RangeQuery::setEndsOpen
void setEndsOpen(bool lower, bool upper)
sets whether or not the ends of the range are open
Definition RangeQuery.h:47
Queries::SetQuery
a Query implementing a set: arguments must one of a set of values
Definition SetQuery.h:26
Queries::SetQuery::insert
void insert(const MatchFuncArgType what)
insert an entry into our set
Definition SetQuery.h:33
Queries::SetQuery< int, Atom const *, true >::d_set
CONTAINER_TYPE d_set
Definition SetQuery.h:84
Queries::SetQuery< int, Atom const *, true >::SetQuery
SetQuery()
Definition SetQuery.h:30
Queries::XOrQuery
a Query implementing XOR: requires exactly one child to be true
Definition XOrQuery.h:22
RDKit::AtomRingQuery::Match
bool Match(const ConstAtomPtr what) const override
Definition QueryOps.h:724
RDKit::AtomRingQuery::AtomRingQuery
AtomRingQuery(int v)
Definition QueryOps.h:717
RDKit::AtomRingQuery::AtomRingQuery
AtomRingQuery()
Definition QueryOps.h:712
RDKit::AtomRingQuery::copy
Queries::Query< int, ConstAtomPtr, true > * copy() const override
returns a copy of this query
Definition QueryOps.h:739
RDKit::Atom
The class for representing atoms.
Definition Atom.h:74
RDKit::Atom::getChiralTag
ChiralType getChiralTag() const
returns our chiralTag
Definition Atom.h:244
RDKit::Atom::getOwningMol
ROMol & getOwningMol() const
returns a reference to the ROMol that owns this instance
Definition Atom.h:156
RDKit::Atom::QUERYATOM_QUERY
Queries::Query< int, Atom const *, true > QUERYATOM_QUERY
Definition Atom.h:89
RDKit::Atom::getIdx
unsigned int getIdx() const
returns our index within the ROMol
Definition Atom.h:162
RDKit::Atom::getValence
unsigned int getValence(ValenceType which) const
returns the valence (explicit or implicit) of this atom
RDKit::Atom::getNumExplicitHs
unsigned int getNumExplicitHs() const
returns our number of explicit Hs
Definition Atom.h:224
RDKit::Atom::getNumRadicalElectrons
unsigned int getNumRadicalElectrons() const
returns the number of radical electrons for this Atom
Definition Atom.h:207
RDKit::Atom::ValenceType::IMPLICIT
@ IMPLICIT
Definition Atom.h:119
RDKit::Atom::ValenceType::EXPLICIT
@ EXPLICIT
Definition Atom.h:120
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::Atom::getAtomicNum
int getAtomicNum() const
returns our atomic number
Definition Atom.h:145
RDKit::Atom::CHI_UNSPECIFIED
@ CHI_UNSPECIFIED
chirality that hasn't been specified
Definition Atom.h:106
RDKit::Atom::hasQuery
virtual bool hasQuery() const
Definition Atom.h:268
RDKit::Atom::getHybridization
HybridizationType getHybridization() const
returns our hybridization
Definition Atom.h:251
RDKit::Atom::getIsAromatic
bool getIsAromatic() const
returns our isAromatic flag
Definition Atom.h:229
RDKit::Atom::getTotalValence
unsigned int getTotalValence() const
returns the total valence (implicit and explicit) for an atom
RDKit::Atom::getFormalCharge
int getFormalCharge() const
returns the formal charge of this atom
Definition Atom.h:211
RDKit::Atom::getMass
double getMass() const
returns our mass
RDKit::Atom::getIsotope
unsigned int getIsotope() const
returns our isotope number
Definition Atom.h:237
RDKit::Atom::getTotalDegree
unsigned int getTotalDegree() const
RDKit::Atom::getQuery
virtual QUERYATOM_QUERY * getQuery() const
NOT CALLABLE.
RDKit::Atom::getDegree
unsigned int getDegree() const
RDKit::Bond
class for representing a bond
Definition Bond.h:46
RDKit::Bond::BondType
BondType
the type of Bond
Definition Bond.h:55
RDKit::Bond::AROMATIC
@ AROMATIC
Definition Bond.h:68
RDKit::Bond::DOUBLE
@ DOUBLE
Definition Bond.h:58
RDKit::Bond::SINGLE
@ SINGLE
Definition Bond.h:57
RDKit::Bond::getIdx
unsigned int getIdx() const
returns our index within the ROMol
Definition Bond.h:205
RDKit::Bond::getQuery
virtual QUERYBOND_QUERY * getQuery() const
NOT CALLABLE.
RDKit::Bond::hasQuery
virtual bool hasQuery() const
Definition Bond.h:286
RDKit::Bond::getBondType
BondType getBondType() const
returns our bondType
Definition Bond.h:159
RDKit::Bond::getOwningMol
ROMol & getOwningMol() const
returns a reference to the ROMol that owns this instance
Definition Bond.h:187
RDKit::Bond::BondDir
BondDir
the bond's direction (for chirality)
Definition Bond.h:82
RDKit::Bond::getStereo
BondStereo getStereo() const
returns our stereo code
Definition Bond.h:334
RDKit::Bond::STEREONONE
@ STEREONONE
Definition Bond.h:95
RDKit::Bond::getBondDir
BondDir getBondDir() const
returns our direction
Definition Bond.h:312
RDKit::HasPropQuery
Definition QueryOps.h:821
RDKit::HasPropQuery::copy
Queries::Query< int, TargetPtr, true > * copy() const override
returns a copy of this query
Definition QueryOps.h:844
RDKit::HasPropQuery::getPropName
const std::string & getPropName() const
Definition QueryOps.h:851
RDKit::HasPropQuery::HasPropQuery
HasPropQuery()
Definition QueryOps.h:825
RDKit::HasPropQuery::HasPropQuery
HasPropQuery(std::string v)
Definition QueryOps.h:829
RDKit::HasPropQuery::Match
bool Match(const TargetPtr what) const override
returns whether or not we match the argument
Definition QueryOps.h:835
RDKit::HasPropWithValueQueryBase::~HasPropWithValueQueryBase
virtual ~HasPropWithValueQueryBase()=default
RDKit::HasPropWithValueQueryBase::getPair
virtual PairHolder getPair() const =0
RDKit::HasPropWithValueQueryBase::HasPropWithValueQueryBase
HasPropWithValueQueryBase()=default
RDKit::HasPropWithValueQueryBase::getTolerance
virtual double getTolerance() const =0
RDKit::HasPropWithValueQuery< TargetPtr, ExplicitBitVect >::getPair
PairHolder getPair() const override
Definition QueryOps.h:1047
RDKit::HasPropWithValueQuery< TargetPtr, ExplicitBitVect >::HasPropWithValueQuery
HasPropWithValueQuery(std::string prop, const ExplicitBitVect &v, double tol=0.0)
Definition QueryOps.h:1037
RDKit::HasPropWithValueQuery< TargetPtr, ExplicitBitVect >::Match
bool Match(const TargetPtr what) const override
returns whether or not we match the argument
Definition QueryOps.h:1053
RDKit::HasPropWithValueQuery< TargetPtr, ExplicitBitVect >::copy
Queries::Query< int, TargetPtr, true > * copy() const override
returns a copy of this query
Definition QueryOps.h:1088
RDKit::HasPropWithValueQuery< TargetPtr, ExplicitBitVect >::getTolerance
double getTolerance() const override
Definition QueryOps.h:1051
RDKit::HasPropWithValueQuery< TargetPtr, ExplicitBitVect >::HasPropWithValueQuery
HasPropWithValueQuery()
Definition QueryOps.h:1031
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::copy
Queries::Query< int, TargetPtr, true > * copy() const override
returns a copy of this query
Definition QueryOps.h:1012
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::HasPropWithValueQuery
HasPropWithValueQuery()
Definition QueryOps.h:957
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::Match
bool Match(const TargetPtr what) const override
returns whether or not we match the argument
Definition QueryOps.h:979
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::HasPropWithValueQuery
HasPropWithValueQuery(std::string prop, std::string v, const double=0.0)
Definition QueryOps.h:963
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::getPair
PairHolder getPair() const override
Definition QueryOps.h:973
RDKit::HasPropWithValueQuery< TargetPtr, std::string >::getTolerance
double getTolerance() const override
Definition QueryOps.h:977
RDKit::HasPropWithValueQuery
Definition QueryOps.h:876
RDKit::HasPropWithValueQuery::HasPropWithValueQuery
HasPropWithValueQuery(std::string prop, const T &v, const T &tol=0.0)
Definition QueryOps.h:895
RDKit::HasPropWithValueQuery::getPair
PairHolder getPair() const override
Definition QueryOps.h:889
RDKit::HasPropWithValueQuery::Match
bool Match(const TargetPtr what) const override
returns whether or not we match the argument
Definition QueryOps.h:906
RDKit::HasPropWithValueQuery::HasPropWithValueQuery
HasPropWithValueQuery()
Definition QueryOps.h:882
RDKit::HasPropWithValueQuery::getTolerance
double getTolerance() const override
Definition QueryOps.h:893
RDKit::HasPropWithValueQuery::copy
Queries::Query< int, TargetPtr, true > * copy() const override
returns a copy of this query
Definition QueryOps.h:940
RDKit::PairHolder
Definition Dict.h:358
RDKit::RDProps::hasProp
bool hasProp(const std::string &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition RDProps.h:126
RDKit::ROMol
Definition ROMol.h:199
RDKit::ROMol::getAtomNeighbors
ADJ_ITER_PAIR getAtomNeighbors(Atom const *at) const
provides access to all neighbors around an Atom
RDKit::ROMol::getAtomBonds
OBOND_ITER_PAIR getAtomBonds(Atom const *at) const
provides access to all Bond objects connected to an Atom
RDKit::ROMol::getRingInfo
RingInfo * getRingInfo() const
Definition ROMol.h:577
RDKit::ROMol::getTopology
MolGraph const & getTopology() const
brief returns a pointer to our underlying BGL object
Definition ROMol.h:680
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
RDKit::RecursiveStructureQuery::RecursiveStructureQuery
RecursiveStructureQuery(ROMol const *query, unsigned int serialNumber=0)
initialize from an ROMol pointer
Definition QueryOps.h:762
RDKit::RecursiveStructureQuery::RecursiveStructureQuery
RecursiveStructureQuery()
Definition QueryOps.h:753
RDKit::RecursiveStructureQuery::getSerialNumber
unsigned int getSerialNumber() const
Definition QueryOps.h:798
RDKit::RecursiveStructureQuery::copy
Queries::Query< int, Atom const *, true > * copy() const override
returns a copy of this query
Definition QueryOps.h:785
RDKit::RecursiveStructureQuery::getQueryMol
ROMol const * getQueryMol() const
returns a pointer to our query molecule
Definition QueryOps.h:782
RDKit::RecursiveStructureQuery::getAtIdx
static int getAtIdx(Atom const *at)
returns the index of an atom
Definition QueryOps.h:770
RDKit::RecursiveStructureQuery::setQueryMol
void setQueryMol(ROMol const *query)
sets the molecule we'll use recursively
Definition QueryOps.h:780
RDKit::RingInfo::numBondRings
unsigned int numBondRings(unsigned int idx) const
returns the number of rings bond idx is involved in
RDKit::RingInfo::minBondRingSize
unsigned int minBondRingSize(unsigned int idx) const
returns the size of the smallest ring bond idx is involved in
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::RingInfo::numAtomRings
unsigned int numAtomRings(unsigned int idx) const
returns the number of rings atom idx is involved in
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.
RDKit::RingInfo::minAtomRingSize
unsigned int minAtomRingSize(unsigned int idx) const
returns the size of the smallest ring atom idx is involved in
export.h
RDKIT_GRAPHMOL_EXPORT
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:249
Queries
Definition AndQuery.h:16
Queries::queryCmp
int queryCmp(const T1 v1, const T2 v2, const T1 tol)
Definition Query.h:197
RDKit::QueryOps
Definition QueryOps.h:1131
RDKit::QueryOps::completeMolQueries
RDKIT_GRAPHMOL_EXPORT void completeMolQueries(RWMol *mol, unsigned int magicVal=0xDEADBEEF)
RDKit::QueryOps::isMetal
RDKIT_GRAPHMOL_EXPORT bool isMetal(const Atom &atom)
RDKit::QueryOps::hasComplexBondTypeQuery
RDKIT_GRAPHMOL_EXPORT bool hasComplexBondTypeQuery(const Queries::Query< int, Bond const *, true > &qry)
RDKit::QueryOps::finalizeQueryFromDescription
RDKIT_GRAPHMOL_EXPORT void finalizeQueryFromDescription(Queries::Query< int, Atom const *, true > *query, Atom const *owner)
RDKit::QueryOps::hasBondTypeQuery
RDKIT_GRAPHMOL_EXPORT bool hasBondTypeQuery(const Queries::Query< int, Bond const *, true > &qry)
RDKit::QueryOps::replaceAtomWithQueryAtom
RDKIT_GRAPHMOL_EXPORT Atom * replaceAtomWithQueryAtom(RWMol *mol, Atom *atom)
RDKit::common_properties::_ChiralityPossible
RDKIT_RDGENERAL_EXPORT const std::string _ChiralityPossible
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::BOND_LESS_QUERY
Queries::LessQuery< int, Bond const *, true > BOND_LESS_QUERY
Definition QueryOps.h:56
RDKit::queryAtomNumRadicalElectrons
static int queryAtomNumRadicalElectrons(Atom const *at)
Definition QueryOps.h:173
RDKit::makeAtomHeavyAtomDegreeQuery
T * makeAtomHeavyAtomDegreeQuery(int what, const std::string &descr)
returns a Query for matching heavy atom degree
Definition QueryOps.h:422
RDKit::makeAtomUnsaturatedQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomUnsaturatedQuery()
This is an overloaded member function, provided for convenience. It differs from the above function o...
RDKit::ATOM_LESS_QUERY
Queries::LessQuery< int, Atom const *, true > ATOM_LESS_QUERY
Definition QueryOps.h:55
RDKit::queryAtomHybridization
static int queryAtomHybridization(Atom const *at)
Definition QueryOps.h:170
RDKit::queryAtomMinRingSize
static int queryAtomMinRingSize(Atom const *at)
Definition QueryOps.h:302
RDKit::makeAtomTotalDegreeQuery
T * makeAtomTotalDegreeQuery(int what, const std::string &descr)
returns a Query for matching atomic degree
Definition QueryOps.h:414
RDKit::BOND_LESSEQUAL_QUERY
Queries::LessEqualQuery< int, Bond const *, true > BOND_LESSEQUAL_QUERY
Definition QueryOps.h:59
RDKit::makeAtomHasHeteroatomNbrsQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomHasHeteroatomNbrsQuery()
This is an overloaded member function, provided for convenience. It differs from the above function o...
RDKit::queryAtomExplicitDegree
static int queryAtomExplicitDegree(Atom const *at)
Definition QueryOps.h:79
RDKit::queryAtomHasRingBond
static int queryAtomHasRingBond(Atom const *at)
Definition QueryOps.h:285
RDKit::ConstBondPtr
Bond const * ConstBondPtr
Definition QueryOps.h:817
RDKit::makeSingleOrDoubleBondQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeSingleOrDoubleBondQuery()
returns a Query for single|double bonds
RDKit::queryBondHasStereo
static int queryBondHasStereo(Bond const *bnd)
Definition QueryOps.h:272
RDKit::queryAtomUnsaturated
static int queryAtomUnsaturated(Atom const *at)
Definition QueryOps.h:129
RDKit::makeSingleOrAromaticBondQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeSingleOrAromaticBondQuery()
returns a Query for unspecified SMARTS bonds
RDKit::queryAtomAromatic
static int queryAtomAromatic(Atom const *at)
Definition QueryOps.h:73
RDKit::ATOM_RANGE_QUERY
Queries::RangeQuery< int, Atom const *, true > ATOM_RANGE_QUERY
Definition QueryOps.h:61
RDKit::BOND_BOOL_QUERY
Queries::Query< bool, Bond const *, true > BOND_BOOL_QUERY
Definition QueryOps.h:33
RDKit::queryAtomType
static int queryAtomType(Atom const *at)
Definition QueryOps.h:153
RDKit::makeAtomHasAliphaticHeteroatomNbrsQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomHasAliphaticHeteroatomNbrsQuery()
This is an overloaded member function, provided for convenience. It differs from the above function o...
RDKit::ATOM_AND_QUERY
Queries::AndQuery< int, Atom const *, true > ATOM_AND_QUERY
Definition QueryOps.h:35
RDKit::makeMHAtomQuery
RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY * makeMHAtomQuery()
returns a Query for matching generic MH atoms (metals or H)
RDKit::makeAtomHasImplicitHQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomHasImplicitHQuery()
This is an overloaded member function, provided for convenience. It differs from the above function o...
RDKit::queryAtomBondProduct
RDKIT_GRAPHMOL_EXPORT unsigned int queryAtomBondProduct(Atom const *at)
RDKit::queryBondIsDoubleOrAromatic
static int queryBondIsDoubleOrAromatic(Bond const *bond)
Definition QueryOps.h:253
RDKit::queryAtomHasImplicitH
static int queryAtomHasImplicitH(Atom const *at)
Definition QueryOps.h:117
RDKit::ATOM_LESSEQUAL_QUERY
Queries::LessEqualQuery< int, Atom const *, true > ATOM_LESSEQUAL_QUERY
Definition QueryOps.h:58
RDKit::makePropQuery
Queries::EqualityQuery< int, const Target *, true > * makePropQuery(const std::string &propname, const T &val, double tolerance=0.0)
Definition QueryOps.h:1099
RDKit::makeBondInRingOfSizeQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeBondInRingOfSizeQuery(int what)
returns a Query for matching bonds in rings of a particular size
RDKit::makeDoubleOrAromaticBondQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeDoubleOrAromaticBondQuery()
returns a Query for double|aromatic bonds
RDKit::makeAtomNullQuery
RDKIT_GRAPHMOL_EXPORT ATOM_NULL_QUERY * makeAtomNullQuery()
returns a Query for matching any atom
RDKit::queryAtomAllBondProduct
RDKIT_GRAPHMOL_EXPORT unsigned int queryAtomAllBondProduct(Atom const *at)
RDKit::TanimotoSimilarity
double TanimotoSimilarity(const SparseIntVect< IndexType > &v1, const SparseIntVect< IndexType > &v2, bool returnDistance=false, double bounds=0.0)
Definition SparseIntVect.h:571
RDKit::nullQueryFun
bool nullQueryFun(T)
Definition QueryOps.h:813
RDKit::queryAtomNegativeFormalCharge
static int queryAtomNegativeFormalCharge(Atom const *at)
Definition QueryOps.h:167
RDKit::ATOM_SET_QUERY
Queries::SetQuery< int, Atom const *, true > ATOM_SET_QUERY
Definition QueryOps.h:64
RDKit::queryAtomHasHeteroatomNbrs
static int queryAtomHasHeteroatomNbrs(Atom const *at)
Definition QueryOps.h:184
RDKit::makeSingleOrDoubleOrAromaticBondQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeSingleOrDoubleOrAromaticBondQuery()
returns a Query for tautomeric bonds
RDKit::makeAtomTotalValenceQuery
T * makeAtomTotalValenceQuery(int what, const std::string &descr)
returns a Query for matching total valence
Definition QueryOps.h:398
RDKit::makeAtomIsBridgeheadQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomIsBridgeheadQuery()
This is an overloaded member function, provided for convenience. It differs from the above function o...
RDKit::isAtomAromatic
RDKIT_GRAPHMOL_EXPORT bool isAtomAromatic(const Atom *a)
RDKit::ATOM_XOR_QUERY
Queries::XOrQuery< int, Atom const *, true > ATOM_XOR_QUERY
Definition QueryOps.h:41
RDKit::isAtomDummy
bool isAtomDummy(const Atom *a)
Definition QueryOps.h:1125
RDKit::makeXAtomQuery
RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY * makeXAtomQuery()
returns a Query for matching generic X atoms (halogens)
RDKit::makeAHAtomQuery
RDKIT_GRAPHMOL_EXPORT ATOM_NULL_QUERY * makeAHAtomQuery()
returns a Query for matching generic AH atoms (any atom)
RDKit::makeAtomHasRingBondQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomHasRingBondQuery()
This is an overloaded member function, provided for convenience. It differs from the above function o...
RDKit::BOND_SET_QUERY
Queries::SetQuery< int, Bond const *, true > BOND_SET_QUERY
Definition QueryOps.h:65
RDKit::queryBondIsSingleOrAromatic
static int queryBondIsSingleOrAromatic(Bond const *bond)
Definition QueryOps.h:249
RDKit::makeAtomFormalChargeQuery
T * makeAtomFormalChargeQuery(int what, const std::string &descr)
returns a Query for matching formal charge
Definition QueryOps.h:487
RDKit::BOND_OR_QUERY
Queries::OrQuery< int, Bond const *, true > BOND_OR_QUERY
Definition QueryOps.h:39
RDKit::queryBondMinRingSize
static int queryBondMinRingSize(Bond const *bond)
Definition QueryOps.h:305
RDKit::massIntegerConversionFactor
const int massIntegerConversionFactor
Definition QueryOps.h:156
RDKit::makeAtomNumRadicalElectronsQuery
T * makeAtomNumRadicalElectronsQuery(int what, const std::string &descr)
returns a Query for matching the number of radical electrons
Definition QueryOps.h:513
RDKit::queryAtomTotalValence
static int queryAtomTotalValence(Atom const *at)
Definition QueryOps.h:126
RDKit::queryAtomNonHydrogenDegree
static int queryAtomNonHydrogenDegree(Atom const *at)
D and T are treated as "non-hydrogen" here.
Definition QueryOps.h:86
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:575
RDKit::makeAtomType
static int makeAtomType(int atomic_num, bool aromatic)
Definition QueryOps.h:133
RDKit::convertComplexNameToQuery
RDKIT_GRAPHMOL_EXPORT void convertComplexNameToQuery(Atom *query, std::string_view symb)
RDKit::makeAtomMinRingSizeQuery
T * makeAtomMinRingSizeQuery(int tgt, const std::string &descr)
returns a Query for matching an atom's minimum ring size
Definition QueryOps.h:567
RDKit::queryAtomHeavyAtomDegree
static int queryAtomHeavyAtomDegree(Atom const *at)
D and T are not treated as heavy atoms here.
Definition QueryOps.h:99
RDKit::queryAtomRingBondCount
static int queryAtomRingBondCount(Atom const *at)
Definition QueryOps.h:309
RDKit::makeBondNullQuery
RDKIT_GRAPHMOL_EXPORT BOND_NULL_QUERY * makeBondNullQuery()
returns a Query for matching any bond
RDKit::makeBondDirEqualsQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeBondDirEqualsQuery(Bond::BondDir what)
returns a Query for matching bond directions
RDKit::makeAtomImplicitHCountQuery
T * makeAtomImplicitHCountQuery(int what, const std::string &descr)
returns a Query for matching implicit hydrogen count
Definition QueryOps.h:446
RDKit::makeAtomAromaticQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomAromaticQuery()
This is an overloaded member function, provided for convenience. It differs from the above function o...
RDKit::makeAtomMassQuery
T * makeAtomMassQuery(int what, const std::string &descr)
returns a Query for matching atoms with a particular mass
Definition QueryOps.h:470
RDKit::makeAtomNumAliphaticHeteroatomNbrsQuery
T * makeAtomNumAliphaticHeteroatomNbrsQuery(int what, const std::string &descr)
returns a Query for matching the number of aliphatic heteroatom neighbors
Definition QueryOps.h:632
RDKit::BOND_XOR_QUERY
Queries::XOrQuery< int, Bond const *, true > BOND_XOR_QUERY
Definition QueryOps.h:42
RDKit::makeAtomSimpleQuery
T * makeAtomSimpleQuery(int what, int func(Atom const *), const std::string &description="Atom Simple")
Definition QueryOps.h:343
RDKit::ATOM_NULL_QUERY
Queries::Query< int, Atom const *, true > ATOM_NULL_QUERY
Definition QueryOps.h:68
RDKit::makeAtomMissingChiralTagQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomMissingChiralTagQuery()
\overloadquery
RDKit::queryAtomAliphatic
static int queryAtomAliphatic(Atom const *at)
Definition QueryOps.h:76
RDKit::queryAtomNumHeteroatomNbrs
static int queryAtomNumHeteroatomNbrs(Atom const *at)
Definition QueryOps.h:197
RDKit::getAtomTypeIsAromatic
static bool getAtomTypeIsAromatic(int val)
Definition QueryOps.h:145
RDKit::queryIsAtomInNRings
static int queryIsAtomInNRings(Atom const *at)
Definition QueryOps.h:279
RDKit::makeMAtomQuery
RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY * makeMAtomQuery()
returns a Query for matching generic M atoms (metals)
RDKit::queryAtomHasChiralTag
static int queryAtomHasChiralTag(Atom const *at)
Definition QueryOps.h:176
RDKit::BOND_PROP_QUERY
Queries::EqualityQuery< int, Bond const *, true > BOND_PROP_QUERY
Definition QueryOps.h:855
RDKit::ATOM_OR_QUERY
Queries::OrQuery< int, Atom const *, true > ATOM_OR_QUERY
Definition QueryOps.h:38
RDKit::queryAtomImplicitHCount
static int queryAtomImplicitHCount(Atom const *at)
Definition QueryOps.h:114
RDKit::queryAtomFormalCharge
static int queryAtomFormalCharge(Atom const *at)
Definition QueryOps.h:164
RDKit::makeAtomNonHydrogenDegreeQuery
T * makeAtomNonHydrogenDegreeQuery(int what, const std::string &descr)
returns a Query for matching the number of non-hydrogen neighbors
Definition QueryOps.h:651
RDKit::queryIsAtomBridgehead
RDKIT_GRAPHMOL_EXPORT int queryIsAtomBridgehead(Atom const *at)
RDKit::queryAtomNum
static int queryAtomNum(Atom const *at)
Definition QueryOps.h:132
RDKit::BOND_GREATEREQUAL_QUERY
Queries::GreaterEqualQuery< int, Bond const *, true > BOND_GREATEREQUAL_QUERY
Definition QueryOps.h:53
RDKit::queryIsAtomInRing
static int queryIsAtomInRing(Atom const *at)
Definition QueryOps.h:282
RDKit::queryAtomHCount
static int queryAtomHCount(Atom const *at)
Definition QueryOps.h:111
RDKit::makeAtomImplicitValenceQuery
T * makeAtomImplicitValenceQuery(int what, const std::string &descr)
returns a Query for matching implicit valence
Definition QueryOps.h:382
RDKit::queryAtomExplicitValence
static int queryAtomExplicitValence(Atom const *at)
Definition QueryOps.h:123
RDKit::isAtomListQuery
RDKIT_GRAPHMOL_EXPORT bool isAtomListQuery(const Atom *a)
RDKit::makeAtomHasChiralTagQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomHasChiralTagQuery()
\overloadquery
RDKit::queryAtomMass
static int queryAtomMass(Atom const *at)
Definition QueryOps.h:157
RDKit::queryAtomHasAliphaticHeteroatomNbrs
static int queryAtomHasAliphaticHeteroatomNbrs(Atom const *at)
Definition QueryOps.h:211
RDKit::makeBondOrderEqualsQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeBondOrderEqualsQuery(Bond::BondType what)
returns a Query for matching bond orders
RDKit::queryAtomNumAliphaticHeteroatomNbrs
static int queryAtomNumAliphaticHeteroatomNbrs(Atom const *at)
Definition QueryOps.h:225
RDKit::BOND_EQUALS_QUERY
Queries::EqualityQuery< int, Bond const *, true > BOND_EQUALS_QUERY
Definition QueryOps.h:45
RDKit::queryAtomIsInRingOfSize
int queryAtomIsInRingOfSize(Atom const *at)
Definition QueryOps.h:325
RDKit::ATOM_GREATER_QUERY
Queries::GreaterQuery< int, Atom const *, true > ATOM_GREATER_QUERY
Definition QueryOps.h:47
RDKit::makeAtomExplicitValenceQuery
T * makeAtomExplicitValenceQuery(int what, const std::string &descr)
returns a Query for matching explicit valence
Definition QueryOps.h:390
RDKit::makeAAtomQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAAtomQuery()
returns a Query for matching generic A atoms (heavy atoms)
RDKit::queryBondIsInRingOfSize
int queryBondIsInRingOfSize(Bond const *bond)
Definition QueryOps.h:333
RDKit::BOND_AND_QUERY
Queries::AndQuery< int, Bond const *, true > BOND_AND_QUERY
Definition QueryOps.h:36
RDKit::makeAtomAliphaticQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomAliphaticQuery()
This is an overloaded member function, provided for convenience. It differs from the above function o...
RDKit::queryBondIsSingleOrDoubleOrAromatic
static int queryBondIsSingleOrDoubleOrAromatic(Bond const *bond)
Definition QueryOps.h:261
RDKit::makeBondMinRingSizeQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeBondMinRingSizeQuery(int what)
returns a Query for matching a bond's minimum ring size
RDKit::getAtomListQueryVals
RDKIT_GRAPHMOL_EXPORT void getAtomListQueryVals(const Atom::QUERYATOM_QUERY *q, std::vector< int > &vals)
RDKit::makeAtomExplicitDegreeQuery
T * makeAtomExplicitDegreeQuery(int what, const std::string &descr)
returns a Query for matching explicit degree
Definition QueryOps.h:406
RDKit::makeAtomInRingQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomInRingQuery()
This is an overloaded member function, provided for convenience. It differs from the above function o...
RDKit::ATOM_EQUALS_QUERY
Queries::EqualityQuery< int, Atom const *, true > ATOM_EQUALS_QUERY
Definition QueryOps.h:44
RDKit::queryIsBondInNRings
static int queryIsBondInNRings(Bond const *at)
Definition QueryOps.h:269
RDKit::queryAtomTotalDegree
static int queryAtomTotalDegree(Atom const *at)
Definition QueryOps.h:82
RDKit::BOND_NULL_QUERY
Queries::Query< int, Bond const *, true > BOND_NULL_QUERY
Definition QueryOps.h:67
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:556
RDKit::isComplexQuery
RDKIT_GRAPHMOL_EXPORT bool isComplexQuery(const Bond *b)
RDKit::ATOM_PROP_QUERY
Queries::EqualityQuery< int, Atom const *, true > ATOM_PROP_QUERY
Definition QueryOps.h:854
RDKit::makeBondInNRingsQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeBondInNRingsQuery(int tgt)
returns a Query for matching bonds in a particular number of rings
RDKit::queryBondDir
static int queryBondDir(Bond const *bond)
Definition QueryOps.h:266
RDKit::makeAtomIsotopeQuery
T * makeAtomIsotopeQuery(int what, const std::string &descr)
returns a Query for matching atoms with a particular isotope
Definition QueryOps.h:479
RDKit::makeAtomInRingOfSizeQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeAtomInRingOfSizeQuery(int tgt)
returns a Query for matching atoms in rings of a particular size
RDKit::getAtomTypeAtomicNum
static int getAtomTypeAtomicNum(int val)
Definition QueryOps.h:146
RDKit::makeXHAtomQuery
RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY * makeXHAtomQuery()
returns a Query for matching generic XH atoms (halogen or H)
RDKit::makeQHAtomQuery
RDKIT_GRAPHMOL_EXPORT ATOM_EQUALS_QUERY * makeQHAtomQuery()
returns a Query for matching generic QH atoms (heteroatom or H)
RDKit::nullDataFun
int nullDataFun(T)
Definition QueryOps.h:809
RDKit::complexQueries
const std::vector< std::string > complexQueries
Definition QueryOps.h:600
RDKit::makeAtomNegativeFormalChargeQuery
T * makeAtomNegativeFormalChargeQuery(int what, const std::string &descr)
Definition QueryOps.h:496
RDKit::makeAtomNumQuery
T * makeAtomNumQuery(int what, const std::string &descr)
returns a Query for matching atomic number
Definition QueryOps.h:364
RDKit::queryBondIsSingleOrDouble
static int queryBondIsSingleOrDouble(Bond const *bond)
Definition QueryOps.h:257
RDKit::ConstAtomPtr
Atom const * ConstAtomPtr
Definition QueryOps.h:707
RDKit::makeAtomHCountQuery
T * makeAtomHCountQuery(int what, const std::string &descr)
returns a Query for matching hydrogen count
Definition QueryOps.h:430
RDKit::makeAtomRangeQuery
static ATOM_RANGE_QUERY * makeAtomRangeQuery(int lower, int upper, bool lowerOpen, bool upperOpen, int func(Atom const *), const std::string &description="Atom Range")
Definition QueryOps.h:352
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:859
RDKit::makeBondHasStereoQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeBondHasStereoQuery()
returns a Query for matching bonds with stereo set
RDKit::ATOM_GREATEREQUAL_QUERY
Queries::GreaterEqualQuery< int, Atom const *, true > ATOM_GREATEREQUAL_QUERY
Definition QueryOps.h:51
RDKit::queryAtomIsotope
static int queryAtomIsotope(Atom const *at)
Definition QueryOps.h:161
RDKit::makeBondIsInRingQuery
RDKIT_GRAPHMOL_EXPORT BOND_EQUALS_QUERY * makeBondIsInRingQuery()
returns a Query for matching ring bonds
RDKit::makeAtomTypeQuery
T * makeAtomTypeQuery(int num, int aromatic, const std::string &descr)
returns a Query for matching atomic number and aromaticity
Definition QueryOps.h:372
RDKit::BOND_RANGE_QUERY
Queries::RangeQuery< int, Bond const *, true > BOND_RANGE_QUERY
Definition QueryOps.h:62
RDKit::queryAtomImplicitValence
static int queryAtomImplicitValence(Atom const *at)
Definition QueryOps.h:120
RDKit::makeAtomNumHeteroatomNbrsQuery
T * makeAtomNumHeteroatomNbrsQuery(int what, const std::string &descr)
returns a Query for matching the number of heteroatom neighbors
Definition QueryOps.h:615
RDKit::queryIsBondInRing
static int queryIsBondInRing(Bond const *bond)
Definition QueryOps.h:299
RDKit::makeQAtomQuery
RDKIT_GRAPHMOL_EXPORT ATOM_OR_QUERY * makeQAtomQuery()
returns a Query for matching generic Q atoms (heteroatoms)
RDKit::queryBondOrder
static int queryBondOrder(Bond const *bond)
Definition QueryOps.h:246
RDKit::queryAtomRingMembership
static int queryAtomRingMembership(Atom const *at)
Definition QueryOps.h:698
RDKit::parseAtomType
static void parseAtomType(int val, int &atomic_num, bool &aromatic)
Definition QueryOps.h:136
RDKit::makeAtomHybridizationQuery
T * makeAtomHybridizationQuery(int what, const std::string &descr)
returns a Query for matching hybridization
Definition QueryOps.h:505
RDKit::BOND_GREATER_QUERY
Queries::GreaterQuery< int, Bond const *, true > BOND_GREATER_QUERY
Definition QueryOps.h:48
RDKit::queryAtomMissingChiralTag
static int queryAtomMissingChiralTag(Atom const *at)
Definition QueryOps.h:179
RDKit::ATOM_BOOL_QUERY
Queries::Query< bool, Atom const *, true > ATOM_BOOL_QUERY
Definition QueryOps.h:32
RDKit::Dict::Pair
Definition Dict.h:38