RDKit: FilterMatchers.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

FilterMatchers.h
Go to the documentation of this file.
1 // Copyright (c) 2015, Novartis Institutes for BioMedical Research Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following
12 // disclaimer in the documentation and/or other materials provided
13 // with the distribution.
14 // * Neither the name of Novartis Institutes for BioMedical Research Inc.
15 // nor the names of its contributors may be used to endorse or promote
16 // products derived from this software without specific prior written
17 // permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 //
31
32 #ifndef __RD_FILTER_MATCHER_H__
33 #define __RD_FILTER_MATCHER_H__
34 #include <GraphMol/RDKitBase.h>
35 #include <GraphMol/Substruct/SubstructMatch.h>
36 #include "FilterMatcherBase.h"
37 #include <GraphMol/MolPickler.h>
38
39 namespace RDKit {
40
41 namespace {
42 std::string getArgName(const boost::shared_ptr<FilterMatcherBase> &arg) {
43 if (arg.get()) return arg->getName();
44 return "<nullmatcher>";
45 }
46 }
47
48 namespace FilterMatchOps {
49 class And : public FilterMatcherBase {
50 boost::shared_ptr<FilterMatcherBase> arg1;
51 boost::shared_ptr<FilterMatcherBase> arg2;
52
53 public:
54 // !Default Constructor for serialization
55 And() : FilterMatcherBase("And"), arg1(), arg2() {}
56
57 //! Constructs an Ander
58 //! True if arg1 and arg2 FilterMatchers are true
59
60 And(const FilterMatcherBase &arg1, const FilterMatcherBase &arg2)
61 : FilterMatcherBase("And"), arg1(arg1.copy()), arg2(arg2.copy()) {}
62
63 And(const boost::shared_ptr<FilterMatcherBase> &arg1,
64 const boost::shared_ptr<FilterMatcherBase> &arg2)
65 : FilterMatcherBase("And"), arg1(arg1), arg2(arg2) {}
66
67 And(const And &rhs)
68 : FilterMatcherBase(rhs), arg1(rhs.arg1), arg2(rhs.arg2) {}
69
70 virtual std::string getName() const {
71 return "(" + getArgName(arg1) + " " + FilterMatcherBase::getName() + " " +
72 getArgName(arg2) + ")";
73 }
74
75 bool isValid() const {
76 return arg1.get() && arg2.get() && arg1->isValid() && arg2->isValid();
77 }
78
79 bool hasMatch(const ROMol &mol) const {
80 PRECONDITION(isValid(),
81 "FilterMatchOps::And is not valid, null arg1 or arg2");
82 return arg1->hasMatch(mol) && arg2->hasMatch(mol);
83 }
84
85 bool getMatches(const ROMol &mol, std::vector<FilterMatch> &matchVect) const {
86 PRECONDITION(isValid(),
87 "FilterMatchOps::And is not valid, null arg1 or arg2");
88 std::vector<FilterMatch> matches;
89 if (arg1->getMatches(mol, matches) && arg2->getMatches(mol, matches)) {
90 matchVect = matches;
91 return true;
92 }
93 return false;
94 }
95
96 boost::shared_ptr<FilterMatcherBase> copy() const {
97 return boost::shared_ptr<FilterMatcherBase>(new And(*this));
98 }
99
100 private:
101 #ifdef RDK_USE_BOOST_SERIALIZATION
102 friend class boost::serialization::access;
103 template <class Archive>
104 void serialize(Archive &ar, const unsigned int version) {
105 RDUNUSED_PARAM(version);
106 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
107
108 ar &arg1;
109 ar &arg2;
110 }
111 #endif
112 };
113
114 class Or : public FilterMatcherBase {
115 boost::shared_ptr<FilterMatcherBase> arg1;
116 boost::shared_ptr<FilterMatcherBase> arg2;
117
118 public:
119 // !Default Constructor for serialization
120 Or() : FilterMatcherBase("Or"), arg1(), arg2() {}
121
122 //! Constructs or Ander
123 //! true if arg1 or arg2 are true
124 Or(const FilterMatcherBase &arg1, const FilterMatcherBase &arg2)
125 : FilterMatcherBase("Or"), arg1(arg1.copy()), arg2(arg2.copy()) {}
126
127 Or(const boost::shared_ptr<FilterMatcherBase> &arg1,
128 const boost::shared_ptr<FilterMatcherBase> &arg2)
129 : FilterMatcherBase("Or"), arg1(arg1), arg2(arg2) {}
130
131 Or(const Or &rhs) : FilterMatcherBase(rhs), arg1(rhs.arg1), arg2(rhs.arg2) {}
132
133 virtual std::string getName() const {
134 return "(" + getArgName(arg1) + " " + FilterMatcherBase::getName() + " " +
135 getArgName(arg2) + ")";
136 }
137
138 bool isValid() const {
139 return arg1.get() && arg2.get() && arg1->isValid() && arg2->isValid();
140 }
141
142 bool hasMatch(const ROMol &mol) const {
143 PRECONDITION(isValid(), "Or is not valid, null arg1 or arg2");
144 return arg1->hasMatch(mol) || arg2->hasMatch(mol);
145 }
146
147 bool getMatches(const ROMol &mol, std::vector<FilterMatch> &matchVect) const {
148 PRECONDITION(isValid(),
149 "FilterMatchOps::Or is not valid, null arg1 or arg2");
150 // we want both matches to run in order to accumulate all matches
151 // into matchVect, otherwise the or can be arbitrary...
152 bool res1 = arg1->getMatches(mol, matchVect);
153 bool res2 = arg2->getMatches(mol, matchVect);
154 return res1 || res2;
155 }
156
157 boost::shared_ptr<FilterMatcherBase> copy() const {
158 return boost::shared_ptr<FilterMatcherBase>(new Or(*this));
159 }
160
161 #ifdef RDK_USE_BOOST_SERIALIZATION
162 friend class boost::serialization::access;
163 template <class Archive>
164 void serialize(Archive &ar, const unsigned int version) {
165 RDUNUSED_PARAM(version);
166 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
167 ar &arg1;
168 ar &arg2;
169 }
170 #endif
171 };
172
173 class Not : public FilterMatcherBase {
174 boost::shared_ptr<FilterMatcherBase> arg1;
175
176 public:
177 // !Default Constructor for serialization
178 Not() : FilterMatcherBase("Not"), arg1() {}
179
180 //! Constructs a Noter
181 //! true if arg1 is false (note, never returns matches
182 // from getMatches since a false internal match matches
183 // nothing!
184 Not(const FilterMatcherBase &arg1)
185 : FilterMatcherBase("Not"), arg1(arg1.copy()) {}
186
187 Not(const boost::shared_ptr<FilterMatcherBase> &arg1)
188 : FilterMatcherBase("Not"), arg1(arg1) {}
189
190 Not(const Not &rhs) : FilterMatcherBase(rhs), arg1(rhs.arg1) {}
191
192 virtual std::string getName() const {
193 return "(" + FilterMatcherBase::getName() + " " + getArgName(arg1) + ")";
194 }
195
196 bool isValid() const { return arg1.get() && arg1->isValid(); }
197
198 bool hasMatch(const ROMol &mol) const {
199 PRECONDITION(isValid(), "FilterMatchOps::Not: arg1 is null");
200 return !arg1->hasMatch(mol);
201 }
202
203 bool getMatches(const ROMol &mol, std::vector<FilterMatch> &) const {
204 PRECONDITION(isValid(), "FilterMatchOps::Not: arg1 is null");
205 // If we are a not, we really can't hold the match for
206 // this query since by definition it won't exist!
207 std::vector<FilterMatch> matchVect;
208 return !arg1->getMatches(mol, matchVect);
209 }
210
211 boost::shared_ptr<FilterMatcherBase> copy() const {
212 return boost::shared_ptr<FilterMatcherBase>(new Not(*this));
213 }
214
215 private:
216 #ifdef RDK_USE_BOOST_SERIALIZATION
217 friend class boost::serialization::access;
218 template <class Archive>
219 void serialize(Archive &ar, const unsigned int version) {
220 RDUNUSED_PARAM(version);
221 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
222 ar &arg1;
223 }
224 #endif
225 };
226 }
227
228 extern const char *SMARTS_MATCH_NAME_DEFAULT;
229 class SmartsMatcher : public FilterMatcherBase {
230 ROMOL_SPTR d_pattern;
231 unsigned int d_min_count;
232 unsigned int d_max_count;
233
234 public:
235 //! Construct a SmartsMatcher
236 SmartsMatcher(const std::string &name = SMARTS_MATCH_NAME_DEFAULT)
237 : FilterMatcherBase(name),
238 d_pattern(),
239 d_min_count(0),
240 d_max_count(UINT_MAX) {}
241
242 //! Construct a SmartsMatcher from a query molecule
243 /*
244 \param pattern query molecule used as the substructure search
245 \param unsigned int minCount minimum number of times the pattern needs to
246 appear
247 \param maxCount the maximum number of times the pattern should appear
248 a value of UINT_MAX indicates the pattern can exist any number of times.
249 [default UINT_MAX]
250
251 */
252 SmartsMatcher(const ROMol &pattern, unsigned int minCount = 1,
253 unsigned int maxCount = UINT_MAX);
254
255 //! Construct a SmartsMatcher
256 /*
257 \param name name for the smarts pattern
258 \param pattern query molecule used as the substructure search
259 \param unsigned int minCount minimum number of times the pattern needs to
260 appear
261 \param maxCount the maximum number of times the pattern should appear
262 a value of UINT_MAX indicates the pattern can exist any number of times.
263 [default UINT_MAX]
264
265 */
266
267 SmartsMatcher(const std::string &name, const ROMol &pattern,
268 unsigned int minCount = 1, unsigned int maxCount = UINT_MAX);
269
270 //! Construct a SmartsMatcher from a smarts pattern
271 /*
272 \param name name for the smarts pattern
273 \param smarts smarts pattern to use for the filter
274 \param unsigned int minCount minimum number of times the pattern needs to
275 appear
276 \param maxCount the maximum number of times the pattern should appear
277 a value of UINT_MAX indicates the pattern can exist any number of times.
278 [default UINT_MAX]
279 */
280
281 SmartsMatcher(const std::string &name, const std::string &smarts,
282 unsigned int minCount = 1, unsigned int maxCount = UINT_MAX);
283
284 //! Construct a SmartsMatcher from a shared_ptr
285 /*
286 \param name name for the smarts pattern
287 \param pattern shared_ptr query molecule used as the substructure search
288 \param unsigned int minCount minimum number of times the pattern needs to
289 appear
290 \param maxCount the maximum number of times the pattern should appear
291 a value of UINT_MAX indicates the pattern can exist any number of times.
292 [default UINT_MAX]
293 */
294
295 SmartsMatcher(const std::string &name, ROMOL_SPTR onPattern,
296 unsigned int minCount = 1, unsigned int maxCount = UINT_MAX);
297
298 SmartsMatcher(const SmartsMatcher &rhs);
299
300 //! Returns True if the Smarts pattern is valid
301 bool isValid() const { return d_pattern.get(); }
302
303 //! Return the shared_ptr to the underlying query molecule
304 const ROMOL_SPTR &getPattern() const { return d_pattern; }
305 //! Set the smarts pattern for the matcher
306 void setPattern(const std::string &smarts);
307 //! Set the query molecule for the matcher
308 void setPattern(const ROMol &mol);
309 //! Set the shared query molecule for the matcher
310 void setPattern(const ROMOL_SPTR &pat) { d_pattern = pat; }
311
312 //! Get the minimum match count for the pattern to be true
313 unsigned int getMinCount() const { return d_min_count; }
314 //! Set the minimum match count for the pattern to be true
315 void setMinCount(unsigned int val) { d_min_count = val; }
316 //! Get the maximum match count for the pattern to be true
317 unsigned int getMaxCount() const { return d_max_count; }
318 //! Set the maximum match count for the pattern to be true
319 void setMaxCount(unsigned int val) { d_max_count = val; }
320
321 virtual bool getMatches(const ROMol &mol,
322 std::vector<FilterMatch> &matchVect) const;
323 virtual bool hasMatch(const ROMol &mol) const;
324 virtual boost::shared_ptr<FilterMatcherBase> copy() const {
325 return boost::shared_ptr<FilterMatcherBase>(new SmartsMatcher(*this));
326 }
327
328 private:
329 #ifdef RDK_USE_BOOST_SERIALIZATION
330 friend class boost::serialization::access;
331 template <class Archive>
332 void save(Archive &ar, const unsigned int version) const {
333 RDUNUSED_PARAM(version);
334 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
335 std::string res;
336 MolPickler::pickleMol(*d_pattern.get(), res);
337 ar &res;
338 ar &d_min_count;
339 ar &d_max_count;
340 }
341 template <class Archive>
342 void load(Archive &ar, const unsigned int version) {
343 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
344 {
345 RDUNUSED_PARAM(version);
346 std::string res;
347 ar &res;
348 d_pattern = boost::shared_ptr<ROMol>(new ROMol(res));
349 }
350 ar &d_min_count;
351 ar &d_max_count;
352 }
353 BOOST_SERIALIZATION_SPLIT_MEMBER();
354 #endif
355 };
356
357 // ------------------------------------------------------------------
358 // Syntactic sugar for the following style patterns
359 // Add exclusion patterns
360 // using FilterMatchOps;
361 // And(new SmartsMatcher(pat1),
362 // new Not(SmartsMatcher(pat2)))
363 // The exclusion match never adds any FilterMatches when getMatches
364 // is called, the main intent is for it to be used with an
365 // And construct, such as:
366 // And(SmartsMatcher(..), ExclusionList(...))
367 //
368 // which will return the SmartsMatcher FilterMatch only if no patterns
369 // in the exclusion list are found.
370 class ExclusionList : public FilterMatcherBase {
371 std::vector<boost::shared_ptr<FilterMatcherBase> > d_offPatterns;
372
373 public:
374 ExclusionList() : FilterMatcherBase("Not any of"), d_offPatterns() {}
375
376 //! Constructs an ExclusionList
377 //! true if non of the FilterMatcherBases are true
378 //! Syntactic sugar for
379 //! using FilterMatchOps;
380 //! And(Not(SmartsMatcher(pat1),
381 //! And(Not(SmartsMatcher(pat2)),
382 //! And(Not(Single...
383
384 ExclusionList(
385 const std::vector<boost::shared_ptr<FilterMatcherBase> > &offPatterns)
386 : FilterMatcherBase("Not any of"), d_offPatterns(offPatterns) {}
387
388 virtual std::string getName() const {
389 std::string res;
390 res = "(" + FilterMatcherBase::getName();
391 for (size_t i = 0; i < d_offPatterns.size(); ++i) {
392 res += " " + d_offPatterns[i]->getName();
393 }
394 res += ")";
395 return res;
396 }
397
398 bool isValid() const {
399 for (size_t i = 0; i < d_offPatterns.size(); ++i)
400 if (!d_offPatterns[i]->isValid()) return false;
401 return true;
402 }
403
404 void addPattern(const FilterMatcherBase &base) {
405 PRECONDITION(base.isValid(), "Invalid FilterMatcherBase");
406 d_offPatterns.push_back(base.copy());
407 }
408
409 void setExclusionPatterns(
410 const std::vector<boost::shared_ptr<FilterMatcherBase> > &offPatterns) {
411 d_offPatterns = offPatterns;
412 }
413
414 virtual bool getMatches(const ROMol &mol, std::vector<FilterMatch> &) const {
415 PRECONDITION(isValid(),
416 "ExclusionList: one of the exclusion pattens is invalid");
417 bool result = true;
418 for (size_t i = 0; i < d_offPatterns.size() && result; ++i) {
419 result &= !d_offPatterns[i]->hasMatch(mol);
420 }
421
422 return result;
423 }
424
425 virtual bool hasMatch(const ROMol &mol) const {
426 PRECONDITION(isValid(),
427 "ExclusionList: one of the exclusion pattens is invalid");
428 bool result = true;
429 for (size_t i = 0; i < d_offPatterns.size() && result; ++i) {
430 result &= !d_offPatterns[i]->hasMatch(mol);
431 }
432
433 return result;
434 }
435
436 virtual boost::shared_ptr<FilterMatcherBase> copy() const {
437 return boost::shared_ptr<FilterMatcherBase>(new ExclusionList(*this));
438 }
439
440 private:
441 #ifdef RDK_USE_BOOST_SERIALIZATION
442 friend class boost::serialization::access;
443 template <class Archive>
444 void serialize(Archive &ar, const unsigned int version) {
445 RDUNUSED_PARAM(version);
446 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
447 ar &d_offPatterns;
448 }
449 #endif
450 };
451
452 class FilterHierarchyMatcher : public FilterMatcherBase {
453 std::vector<boost::shared_ptr<FilterHierarchyMatcher> > d_children;
454 boost::shared_ptr<FilterMatcherBase> d_matcher;
455
456 public:
457 // !Default Constructor for serialization
458 FilterHierarchyMatcher() :
459 FilterMatcherBase(),
460 d_matcher() {
461 }
462 //! Constructs a FilterHierarchyMatcher from a FilterMatchBase
463 //! A FilterHierarchyMatcher is a tree hierarchy where to
464 //! match a child node, one needs to match the parent first.
465 //! For each branch, the lowest nodes are returned when
466 //! getting the filter matches.
467 /*
468 \param matcher FilterMatcherBase to match this node against
469 */
470 FilterHierarchyMatcher(const FilterMatcherBase &matcher) :
471 FilterMatcherBase(),
472 d_matcher(matcher.copy()) {
473 }
474
475 //! Return the name for this node (from the underlying FilterMatcherBase)
476 virtual std::string getName() const {
477 if (d_matcher.get()) {
478 return d_matcher->getName();
479 }
480 return "FilterMatcherHierarchy root";
481 }
482
483 //! returns true if this node has a valid matcher
484 bool isValid() const {
485 return d_matcher->isValid();
486 }
487
488 //! Set a new FilterMatcherBase for this node
489 /*
490 \param matcher The new FilterMatcherBase
491 */
492 void setPattern(const FilterMatcherBase & matcher) {
493 PRECONDITION(matcher.isValid(), "Adding invalid patterns is not allowed.");
494 d_matcher = matcher.copy();
495 PRECONDITION(getName() == d_matcher->getName(), "Opps");
496 }
497
498 //! add a FilterHierarchy as a child.
499 //! returns the FilterHierarchy pointer used in the tree (this is a
500 //! shallow copy of the original)
501 /*
502 \param hierarchy The new FilterHierarchyMatcher child for this node
503 */
504 boost::shared_ptr<FilterHierarchyMatcher> addChild(
505 const FilterHierarchyMatcher &hierarchy) {
506 PRECONDITION(hierarchy.d_matcher.get() && hierarchy.d_matcher->isValid(),
507 "Only one root node is allowed in a FilterHierarchyMatcher");
508
509 d_children.push_back( boost::shared_ptr<FilterHierarchyMatcher>(
510 new FilterHierarchyMatcher(hierarchy) ));
511 return d_children.back();
512 }
513
514 //! returns the FilterMatches against the given molecule
515 /*
516 \param mol The molecule to match against
517 \param matches The vector of FilterMatch objects that match
518 */
519 virtual bool getMatches(const ROMol &mol, std::vector<FilterMatch> &matches) const;
520
521 //! Does this node match the molecule
522 /*
523 \param mol The molecule to match against
524 */
525 virtual bool hasMatch(const ROMol &mol) const {
526 std::vector<FilterMatch> temp;
527 return getMatches(mol, temp);
528 }
529
530 //! copys the FilterHierarchyMatcher into a FilterMatcherBase
531 virtual boost::shared_ptr<FilterMatcherBase> copy() const {
532 return boost::shared_ptr<FilterMatcherBase>(new FilterHierarchyMatcher(*this));
533 }
534 private:
535 #ifdef RDK_USE_BOOST_SERIALIZATION
536 friend class boost::serialization::access;
537 template <class Archive>
538 void serialize(Archive &ar, const unsigned int version) {
539 RDUNUSED_PARAM(version);
540 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
541 ar &d_children;
542 ar &d_matcher;
543 }
544 #endif
545
546 };
547
548 #ifdef RDK_USE_BOOST_SERIALIZATION
549 // Register all known filter matcher types for serialization
550 template <class Archive>
551 void registerFilterMatcherTypes(Archive &ar) {
552 ar.register_type(static_cast<FilterMatchOps::And *>(NULL));
553 ar.register_type(static_cast<FilterMatchOps::Or *>(NULL));
554 ar.register_type(static_cast<FilterMatchOps::Not *>(NULL));
555 ar.register_type(static_cast<SmartsMatcher *>(NULL));
556 ar.register_type(static_cast<ExclusionList *>(NULL));
557 ar.register_type(static_cast<FilterHierarchyMatcher *>(NULL));
558 }
559 #endif
560 }
561
562 #ifdef RDK_USE_BOOST_SERIALIZATION
563 BOOST_CLASS_VERSION(RDKit::SmartsMatcher, 1)
564 BOOST_CLASS_VERSION(RDKit::ExclusionList, 1)
565 BOOST_CLASS_VERSION(RDKit::FilterHierarchyMatcher, 1)
566 #endif
567
568 #endif
RDKit::FilterMatcherBase::getName
virtual std::string getName() const
Definition: FilterMatcherBase.h:95
RDKit::ExclusionList::hasMatch
virtual bool hasMatch(const ROMol &mol) const
hasMatches
Definition: FilterMatchers.h:425
RDKit::FilterMatcherBase::isValid
virtual bool isValid() const =0
RDKit::FilterMatchOps::Or::copy
boost::shared_ptr< FilterMatcherBase > copy() const
copy
Definition: FilterMatchers.h:157
RDKit::SmartsMatcher::getMaxCount
unsigned int getMaxCount() const
Get the maximum match count for the pattern to be true.
Definition: FilterMatchers.h:317
RDKit::MolPickler::pickleMol
static void pickleMol(const ROMol *mol, std::ostream &ss)
pickles a molecule and sends the results to stream ss
RDKit::ExclusionList::ExclusionList
ExclusionList()
Definition: FilterMatchers.h:374
RDKit::FilterMatchOps::Or::getMatches
bool getMatches(const ROMol &mol, std::vector< FilterMatch > &matchVect) const
getMatches
Definition: FilterMatchers.h:147
RDKit::FilterMatchOps::And::getMatches
bool getMatches(const ROMol &mol, std::vector< FilterMatch > &matchVect) const
getMatches
Definition: FilterMatchers.h:85
RDKit::FilterHierarchyMatcher::FilterHierarchyMatcher
FilterHierarchyMatcher(const FilterMatcherBase &matcher)
Definition: FilterMatchers.h:470
RDKit::SmartsMatcher::setPattern
void setPattern(const ROMOL_SPTR &pat)
Set the shared query molecule for the matcher.
Definition: FilterMatchers.h:310
RDKit::FilterHierarchyMatcher::addChild
boost::shared_ptr< FilterHierarchyMatcher > addChild(const FilterHierarchyMatcher &hierarchy)
Definition: FilterMatchers.h:504
RDKit::FilterMatchOps::And::And
And(const FilterMatcherBase &arg1, const FilterMatcherBase &arg2)
Definition: FilterMatchers.h:60
RDKit::FilterMatchOps::Not::isValid
bool isValid() const
Definition: FilterMatchers.h:196
RDKit::FilterMatchOps::And::And
And()
Definition: FilterMatchers.h:55
RDKit::FilterMatchOps::Not::Not
Not(const Not &rhs)
Definition: FilterMatchers.h:190
RDKit::ExclusionList::addPattern
void addPattern(const FilterMatcherBase &base)
Definition: FilterMatchers.h:404
RDKit::SmartsMatcher::copy
virtual boost::shared_ptr< FilterMatcherBase > copy() const
copy
Definition: FilterMatchers.h:324
SubstructMatch.h
RDKit::FilterMatchOps::Or
Definition: FilterMatchers.h:114
RDKit::FilterMatchOps::Not::copy
boost::shared_ptr< FilterMatcherBase > copy() const
copy
Definition: FilterMatchers.h:211
RDKitBase.h
pulls in the core RDKit functionality
RDKit::ROMol
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:103
RDKit::FilterHierarchyMatcher::setPattern
void setPattern(const FilterMatcherBase &matcher)
Set a new FilterMatcherBase for this node.
Definition: FilterMatchers.h:492
RDKit::FilterHierarchyMatcher::FilterHierarchyMatcher
FilterHierarchyMatcher()
Definition: FilterMatchers.h:458
RDKit::FilterHierarchyMatcher::isValid
bool isValid() const
returns true if this node has a valid matcher
Definition: FilterMatchers.h:484
RDKit::ExclusionList
Definition: FilterMatchers.h:370
RDKit::FilterMatchOps::Not::Not
Not(const FilterMatcherBase &arg1)
Definition: FilterMatchers.h:184
RDKit::FilterMatcherBase
Definition: FilterMatcherBase.h:76
RDKit::SmartsMatcher::setMaxCount
void setMaxCount(unsigned int val)
Set the maximum match count for the pattern to be true.
Definition: FilterMatchers.h:319
RDKit::SmartsMatcher::getPattern
const ROMOL_SPTR & getPattern() const
Return the shared_ptr to the underlying query molecule.
Definition: FilterMatchers.h:304
RDKit::FilterMatchOps::And
Definition: FilterMatchers.h:49
RDKit::FilterMatchOps::And::isValid
bool isValid() const
Definition: FilterMatchers.h:75
RDKit::FilterHierarchyMatcher::getName
virtual std::string getName() const
Return the name for this node (from the underlying FilterMatcherBase)
Definition: FilterMatchers.h:476
RDKit::FilterMatchOps::Not::getMatches
bool getMatches(const ROMol &mol, std::vector< FilterMatch > &) const
getMatches
Definition: FilterMatchers.h:203
RDKit::FilterMatchOps::Or::Or
Or(const Or &rhs)
Definition: FilterMatchers.h:131
RDKit::FilterMatchOps::Not::getName
virtual std::string getName() const
Definition: FilterMatchers.h:192
RDKit::ROMOL_SPTR
boost::shared_ptr< ROMol > ROMOL_SPTR
Definition: ChemTransforms.h:21
RDKit
Std stuff.
Definition: Atom.h:29
RDKit::SmartsMatcher::isValid
bool isValid() const
Returns True if the Smarts pattern is valid.
Definition: FilterMatchers.h:301
RDKit::FilterMatchOps::Not::hasMatch
bool hasMatch(const ROMol &mol) const
hasMatches
Definition: FilterMatchers.h:198
FilterMatcherBase.h
RDKit::ExclusionList::copy
virtual boost::shared_ptr< FilterMatcherBase > copy() const
copy
Definition: FilterMatchers.h:436
RDKit::ExclusionList::ExclusionList
ExclusionList(const std::vector< boost::shared_ptr< FilterMatcherBase > > &offPatterns)
Definition: FilterMatchers.h:384
RDKit::FilterMatchOps::Or::Or
Or(const FilterMatcherBase &arg1, const FilterMatcherBase &arg2)
Definition: FilterMatchers.h:124
RDKit::ExclusionList::getName
virtual std::string getName() const
Definition: FilterMatchers.h:388
RDUNUSED_PARAM
#define RDUNUSED_PARAM(x)
Definition: Invariant.h:194
RDKit::FilterMatchOps::Or::hasMatch
bool hasMatch(const ROMol &mol) const
hasMatches
Definition: FilterMatchers.h:142
RDKit::ExclusionList::isValid
bool isValid() const
Definition: FilterMatchers.h:398
MolPickler.h
RDKit::FilterMatchOps::Not::Not
Not(const boost::shared_ptr< FilterMatcherBase > &arg1)
Definition: FilterMatchers.h:187
RDKit::FilterHierarchyMatcher::hasMatch
virtual bool hasMatch(const ROMol &mol) const
Does this node match the molecule.
Definition: FilterMatchers.h:525
RDKit::FilterMatchOps::Or::Or
Or()
Definition: FilterMatchers.h:120
RDKit::SmartsMatcher
Definition: FilterMatchers.h:229
RDKit::SmartsMatcher::setMinCount
void setMinCount(unsigned int val)
Set the minimum match count for the pattern to be true.
Definition: FilterMatchers.h:315
RDKit::FilterMatchOps::Not
Definition: FilterMatchers.h:173
RDKit::FilterMatcherBase::copy
virtual boost::shared_ptr< FilterMatcherBase > copy() const =0
copy
RDKit::SMARTS_MATCH_NAME_DEFAULT
const char * SMARTS_MATCH_NAME_DEFAULT
RDKit::FilterMatchOps::And::And
And(const And &rhs)
Definition: FilterMatchers.h:67
RDKit::FilterMatchOps::Or::Or
Or(const boost::shared_ptr< FilterMatcherBase > &arg1, const boost::shared_ptr< FilterMatcherBase > &arg2)
Definition: FilterMatchers.h:127
PRECONDITION
#define PRECONDITION(expr, mess)
Definition: Invariant.h:107
RDKit::FilterHierarchyMatcher::copy
virtual boost::shared_ptr< FilterMatcherBase > copy() const
copys the FilterHierarchyMatcher into a FilterMatcherBase
Definition: FilterMatchers.h:531
RDKit::FilterMatchOps::And::copy
boost::shared_ptr< FilterMatcherBase > copy() const
copy
Definition: FilterMatchers.h:96
RDKit::FilterMatchOps::Or::isValid
bool isValid() const
Definition: FilterMatchers.h:138
RDKit::FilterMatchOps::Not::Not
Not()
Definition: FilterMatchers.h:178
RDKit::FilterHierarchyMatcher
Definition: FilterMatchers.h:452
RDKit::FilterMatchOps::And::And
And(const boost::shared_ptr< FilterMatcherBase > &arg1, const boost::shared_ptr< FilterMatcherBase > &arg2)
Definition: FilterMatchers.h:63
RDKit::SmartsMatcher::SmartsMatcher
SmartsMatcher(const std::string &name=SMARTS_MATCH_NAME_DEFAULT)
Construct a SmartsMatcher.
Definition: FilterMatchers.h:236
RDKit::SmartsMatcher::getMinCount
unsigned int getMinCount() const
Get the minimum match count for the pattern to be true.
Definition: FilterMatchers.h:313
RDKit::ExclusionList::setExclusionPatterns
void setExclusionPatterns(const std::vector< boost::shared_ptr< FilterMatcherBase > > &offPatterns)
Definition: FilterMatchers.h:409
RDKit::FilterMatchOps::And::getName
virtual std::string getName() const
Definition: FilterMatchers.h:70
RDKit::FilterMatchOps::Or::getName
virtual std::string getName() const
Definition: FilterMatchers.h:133
RDKit::FilterMatchOps::And::hasMatch
bool hasMatch(const ROMol &mol) const
hasMatches
Definition: FilterMatchers.h:79
RDKit::ExclusionList::getMatches
virtual bool getMatches(const ROMol &mol, std::vector< FilterMatch > &) const
getMatches
Definition: FilterMatchers.h:414