RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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#include <RDGeneral/export.h>
33#ifndef __RD_FILTER_MATCHER_H__
34#define __RD_FILTER_MATCHER_H__
35#include <utility>
36
37#include <GraphMol/RDKitBase.h>
39#include "FilterMatcherBase.h"
40#include <GraphMol/MolPickler.h>
41
42#ifdef RDK_USE_BOOST_SERIALIZATION
44#include <boost/serialization/shared_ptr.hpp>
46#endif
47
48namespace RDKit {
49
50namespace {
51std::string getArgName(const boost::shared_ptr<FilterMatcherBase> &arg) {
52 if (arg.get()) {
53 return arg->getName();
54 }
55 return "<nullmatcher>";
56}
57} // namespace
58
59namespace FilterMatchOps {
61 boost::shared_ptr<FilterMatcherBase> arg1;
62 boost::shared_ptr<FilterMatcherBase> arg2;
63
64 public:
65 // !Default Constructor for serialization
66 And() : FilterMatcherBase("And"), arg1(), arg2() {}
67
68 //! Constructs an Ander
69 //! True if arg1 and arg2 FilterMatchers are true
70
71 And(const FilterMatcherBase &arg1, const FilterMatcherBase &arg2)
72 : FilterMatcherBase("And"), arg1(arg1.copy()), arg2(arg2.copy()) {}
73
74 And(boost::shared_ptr<FilterMatcherBase> arg1,
75 boost::shared_ptr<FilterMatcherBase> arg2)
76 : FilterMatcherBase("And"),
77 arg1(std::move(arg1)),
78 arg2(std::move(arg2)) {}
79
80 And(const And &rhs)
81 : FilterMatcherBase(rhs), arg1(rhs.arg1), arg2(rhs.arg2) {}
82
83 std::string getName() const override {
84 return "(" + getArgName(arg1) + " " + FilterMatcherBase::getName() + " " +
85 getArgName(arg2) + ")";
86 }
87
88 bool isValid() const override {
89 return arg1.get() && arg2.get() && arg1->isValid() && arg2->isValid();
90 }
91
92 bool hasMatch(const ROMol &mol) const override {
93 PRECONDITION(isValid(),
94 "FilterMatchOps::And is not valid, null arg1 or arg2");
95 return arg1->hasMatch(mol) && arg2->hasMatch(mol);
96 }
97
98 bool getMatches(const ROMol &mol,
99 std::vector<FilterMatch> &matchVect) const override {
100 PRECONDITION(isValid(),
101 "FilterMatchOps::And is not valid, null arg1 or arg2");
102 std::vector<FilterMatch> matches;
103 if (arg1->getMatches(mol, matches) && arg2->getMatches(mol, matches)) {
104 matchVect = matches;
105 return true;
106 }
107 return false;
108 }
109
110 boost::shared_ptr<FilterMatcherBase> copy() const override {
111 return boost::shared_ptr<FilterMatcherBase>(new And(*this));
112 }
113
114 private:
115#ifdef RDK_USE_BOOST_SERIALIZATION
116 friend class boost::serialization::access;
117 template <class Archive>
118 void serialize(Archive &ar, const unsigned int version) {
119 RDUNUSED_PARAM(version);
120 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
121
122 ar & arg1;
123 ar & arg2;
124 }
125#endif
126};
127
129 boost::shared_ptr<FilterMatcherBase> arg1;
130 boost::shared_ptr<FilterMatcherBase> arg2;
131
132 public:
133 // !Default Constructor for serialization
134 Or() : FilterMatcherBase("Or"), arg1(), arg2() {}
135
136 //! Constructs or Ander
137 //! true if arg1 or arg2 are true
138 Or(const FilterMatcherBase &arg1, const FilterMatcherBase &arg2)
139 : FilterMatcherBase("Or"), arg1(arg1.copy()), arg2(arg2.copy()) {}
140
141 Or(boost::shared_ptr<FilterMatcherBase> arg1,
142 boost::shared_ptr<FilterMatcherBase> arg2)
143 : FilterMatcherBase("Or"), arg1(std::move(arg1)), arg2(std::move(arg2)) {}
144
145 Or(const Or &rhs) : FilterMatcherBase(rhs), arg1(rhs.arg1), arg2(rhs.arg2) {}
146
147 std::string getName() const override {
148 return "(" + getArgName(arg1) + " " + FilterMatcherBase::getName() + " " +
149 getArgName(arg2) + ")";
150 }
151
152 bool isValid() const override {
153 return arg1.get() && arg2.get() && arg1->isValid() && arg2->isValid();
154 }
155
156 bool hasMatch(const ROMol &mol) const override {
157 PRECONDITION(isValid(), "Or is not valid, null arg1 or arg2");
158 return arg1->hasMatch(mol) || arg2->hasMatch(mol);
159 }
160
161 bool getMatches(const ROMol &mol,
162 std::vector<FilterMatch> &matchVect) const override {
163 PRECONDITION(isValid(),
164 "FilterMatchOps::Or is not valid, null arg1 or arg2");
165 // we want both matches to run in order to accumulate all matches
166 // into matchVect, otherwise the or can be arbitrary...
167 bool res1 = arg1->getMatches(mol, matchVect);
168 bool res2 = arg2->getMatches(mol, matchVect);
169 return res1 || res2;
170 }
171
172 boost::shared_ptr<FilterMatcherBase> copy() const override {
173 return boost::shared_ptr<FilterMatcherBase>(new Or(*this));
174 }
175
176#ifdef RDK_USE_BOOST_SERIALIZATION
177 friend class boost::serialization::access;
178 template <class Archive>
179 void serialize(Archive &ar, const unsigned int version) {
180 RDUNUSED_PARAM(version);
181 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
182 ar & arg1;
183 ar & arg2;
184 }
185#endif
186};
187
189 boost::shared_ptr<FilterMatcherBase> arg1;
190
191 public:
192 // !Default Constructor for serialization
193 Not() : FilterMatcherBase("Not"), arg1() {}
194
195 //! Constructs a Noter
196 //! true if arg1 is false (note, never returns matches
197 /// from getMatches since a false internal match matches
198 /// nothing!
200 : FilterMatcherBase("Not"), arg1(arg1.copy()) {}
201
202 Not(boost::shared_ptr<FilterMatcherBase> arg1)
203 : FilterMatcherBase("Not"), arg1(std::move(arg1)) {}
204
205 Not(const Not &rhs) : FilterMatcherBase(rhs), arg1(rhs.arg1) {}
206
207 std::string getName() const override {
208 return "(" + FilterMatcherBase::getName() + " " + getArgName(arg1) + ")";
209 }
210
211 bool isValid() const override { return arg1.get() && arg1->isValid(); }
212
213 bool hasMatch(const ROMol &mol) const override {
214 PRECONDITION(isValid(), "FilterMatchOps::Not: arg1 is null");
215 return !arg1->hasMatch(mol);
216 }
217
218 bool getMatches(const ROMol &mol, std::vector<FilterMatch> &) const override {
219 PRECONDITION(isValid(), "FilterMatchOps::Not: arg1 is null");
220 // If we are a not, we really can't hold the match for
221 // this query since by definition it won't exist!
222 std::vector<FilterMatch> matchVect;
223 return !arg1->getMatches(mol, matchVect);
224 }
225
226 boost::shared_ptr<FilterMatcherBase> copy() const override {
227 return boost::shared_ptr<FilterMatcherBase>(new Not(*this));
228 }
229
230 private:
231#ifdef RDK_USE_BOOST_SERIALIZATION
232 friend class boost::serialization::access;
233 template <class Archive>
234 void serialize(Archive &ar, const unsigned int version) {
235 RDUNUSED_PARAM(version);
236 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
237 ar & arg1;
238 }
239#endif
240};
241} // namespace FilterMatchOps
242
245 ROMOL_SPTR d_pattern;
246 unsigned int d_min_count{0};
247 unsigned int d_max_count;
248
249 public:
250 //! Construct a SmartsMatcher
251 SmartsMatcher(const std::string &name = SMARTS_MATCH_NAME_DEFAULT)
252 : FilterMatcherBase(name),
253 d_pattern(),
254
255 d_max_count(UINT_MAX) {}
256
257 //! Construct a SmartsMatcher from a query molecule
258 /*
259 \param pattern query molecule used as the substructure search
260 \param unsigned int minCount minimum number of times the pattern needs to
261 appear
262 \param maxCount the maximum number of times the pattern should appear
263 a value of UINT_MAX indicates the pattern can exist any number of times.
264 [default UINT_MAX]
265
266 */
267 SmartsMatcher(const ROMol &pattern, unsigned int minCount = 1,
268 unsigned int maxCount = UINT_MAX);
269
270 //! Construct a SmartsMatcher
271 /*
272 \param name name for the smarts pattern
273 \param pattern query molecule used as the substructure search
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
282 SmartsMatcher(const std::string &name, const ROMol &pattern,
283 unsigned int minCount = 1, unsigned int maxCount = UINT_MAX);
284
285 //! Construct a SmartsMatcher from a smarts pattern
286 /*
287 \param name name for the smarts pattern
288 \param smarts smarts pattern to use for the filter
289 \param unsigned int minCount minimum number of times the pattern needs to
290 appear
291 \param maxCount the maximum number of times the pattern should appear
292 a value of UINT_MAX indicates the pattern can exist any number of times.
293 [default UINT_MAX]
294 */
295
296 SmartsMatcher(const std::string &name, const std::string &smarts,
297 unsigned int minCount = 1, unsigned int maxCount = UINT_MAX);
298
299 //! Construct a SmartsMatcher from a shared_ptr
300 /*
301 \param name name for the smarts pattern
302 \param pattern shared_ptr query molecule used as the substructure search
303 \param unsigned int minCount minimum number of times the pattern needs to
304 appear
305 \param maxCount the maximum number of times the pattern should appear
306 a value of UINT_MAX indicates the pattern can exist any number of times.
307 [default UINT_MAX]
308 */
309
310 SmartsMatcher(const std::string &name, ROMOL_SPTR onPattern,
311 unsigned int minCount = 1, unsigned int maxCount = UINT_MAX);
312
314
315 //! Returns True if the Smarts pattern is valid
316 bool isValid() const override { return d_pattern.get(); }
317
318 //! Return the shared_ptr to the underlying query molecule
319 const ROMOL_SPTR &getPattern() const { return d_pattern; }
320 //! Set the smarts pattern for the matcher
321 void setPattern(const std::string &smarts);
322 //! Set the query molecule for the matcher
323 void setPattern(const ROMol &mol);
324 //! Set the shared query molecule for the matcher
325 void setPattern(const ROMOL_SPTR &pat) { d_pattern = pat; }
326
327 //! Get the minimum match count for the pattern to be true
328 unsigned int getMinCount() const { return d_min_count; }
329 //! Set the minimum match count for the pattern to be true
330 void setMinCount(unsigned int val) { d_min_count = val; }
331 //! Get the maximum match count for the pattern to be true
332 unsigned int getMaxCount() const { return d_max_count; }
333 //! Set the maximum match count for the pattern to be true
334 void setMaxCount(unsigned int val) { d_max_count = val; }
335
336 bool getMatches(const ROMol &mol,
337 std::vector<FilterMatch> &matchVect) const override;
338 bool hasMatch(const ROMol &mol) const override;
339 boost::shared_ptr<FilterMatcherBase> copy() const override {
340 return boost::shared_ptr<FilterMatcherBase>(new SmartsMatcher(*this));
341 }
342
343 private:
344#ifdef RDK_USE_BOOST_SERIALIZATION
345 friend class boost::serialization::access;
346 template <class Archive>
347 void save(Archive &ar, const unsigned int version) const {
348 RDUNUSED_PARAM(version);
349 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
350 std::string res;
351 MolPickler::pickleMol(*d_pattern.get(), res);
352 ar & res;
353 ar & d_min_count;
354 ar & d_max_count;
355 }
356 template <class Archive>
357 void load(Archive &ar, const unsigned int version) {
358 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
359 RDUNUSED_PARAM(version);
360 std::string res;
361 ar & res;
362 d_pattern = boost::shared_ptr<ROMol>(new ROMol(res));
363 ar & d_min_count;
364 ar & d_max_count;
365 }
366 BOOST_SERIALIZATION_SPLIT_MEMBER();
367#endif
368};
369
370// ------------------------------------------------------------------
371// Syntactic sugar for the following style patterns
372// Add exclusion patterns
373// using FilterMatchOps;
374// And(new SmartsMatcher(pat1),
375// new Not(SmartsMatcher(pat2)))
376// The exclusion match never adds any FilterMatches when getMatches
377// is called, the main intent is for it to be used with an
378// And construct, such as:
379// And(SmartsMatcher(..), ExclusionList(...))
380//
381// which will return the SmartsMatcher FilterMatch only if no patterns
382// in the exclusion list are found.
384 std::vector<boost::shared_ptr<FilterMatcherBase>> d_offPatterns;
385
386 public:
387 ExclusionList() : FilterMatcherBase("Not any of"), d_offPatterns() {}
388
389 //! Constructs an ExclusionList
390 //! true if non of the FilterMatcherBases are true
391 //! Syntactic sugar for
392 //! using FilterMatchOps;
393 //! And(Not(SmartsMatcher(pat1),
394 //! And(Not(SmartsMatcher(pat2)),
395 //! And(Not(Single...
396
397 ExclusionList(std::vector<boost::shared_ptr<FilterMatcherBase>> offPatterns)
398 : FilterMatcherBase("Not any of"),
399 d_offPatterns(std::move(offPatterns)) {}
400
401 std::string getName() const override {
402 std::string res;
403 res = "(" + FilterMatcherBase::getName();
404 for (size_t i = 0; i < d_offPatterns.size(); ++i) {
405 res += " " + d_offPatterns[i]->getName();
406 }
407 res += ")";
408 return res;
409 }
410
411 bool isValid() const override {
412 for (size_t i = 0; i < d_offPatterns.size(); ++i) {
413 if (!d_offPatterns[i]->isValid()) {
414 return false;
415 }
416 }
417 return true;
418 }
419
420 void addPattern(const FilterMatcherBase &base) {
421 PRECONDITION(base.isValid(), "Invalid FilterMatcherBase");
422 d_offPatterns.push_back(base.copy());
423 }
424
426 const std::vector<boost::shared_ptr<FilterMatcherBase>> &offPatterns) {
427 d_offPatterns = offPatterns;
428 }
429
430 bool getMatches(const ROMol &mol, std::vector<FilterMatch> &) const override {
431 PRECONDITION(isValid(),
432 "ExclusionList: one of the exclusion pattens is invalid");
433 bool result = true;
434 for (size_t i = 0; i < d_offPatterns.size() && result; ++i) {
435 result &= !d_offPatterns[i]->hasMatch(mol);
436 }
437
438 return result;
439 }
440
441 bool hasMatch(const ROMol &mol) const override {
442 PRECONDITION(isValid(),
443 "ExclusionList: one of the exclusion pattens is invalid");
444 bool result = true;
445 for (size_t i = 0; i < d_offPatterns.size() && result; ++i) {
446 result &= !d_offPatterns[i]->hasMatch(mol);
447 }
448
449 return result;
450 }
451
452 boost::shared_ptr<FilterMatcherBase> copy() const override {
453 return boost::shared_ptr<FilterMatcherBase>(new ExclusionList(*this));
454 }
455
456 private:
457#ifdef RDK_USE_BOOST_SERIALIZATION
458 friend class boost::serialization::access;
459 template <class Archive>
460 void serialize(Archive &ar, const unsigned int version) {
461 RDUNUSED_PARAM(version);
462 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
463 ar & d_offPatterns;
464 }
465#endif
466};
467
469 : public FilterMatcherBase {
470 std::vector<boost::shared_ptr<FilterHierarchyMatcher>> d_children;
471 boost::shared_ptr<FilterMatcherBase> d_matcher;
472
473 public:
474 // !Default Constructor for serialization
476 //! Constructs a FilterHierarchyMatcher from a FilterMatchBase
477 //! A FilterHierarchyMatcher is a tree hierarchy where to
478 //! match a child node, one needs to match the parent first.
479 //! For each branch, the lowest nodes are returned when
480 //! getting the filter matches.
481 /*
482 \param matcher FilterMatcherBase to match this node against
483 */
485 : FilterMatcherBase(), d_matcher(matcher.copy()) {}
486
487 //! Return the name for this node (from the underlying FilterMatcherBase)
488 std::string getName() const override {
489 if (d_matcher.get()) {
490 return d_matcher->getName();
491 }
492 return "FilterMatcherHierarchy root";
493 }
494
495 //! returns true if this node has a valid matcher
496 bool isValid() const override { return d_matcher->isValid(); }
497
498 //! Set a new FilterMatcherBase for this node
499 /*
500 \param matcher The new FilterMatcherBase
501 */
502 void setPattern(const FilterMatcherBase &matcher) {
503 PRECONDITION(matcher.isValid(), "Adding invalid patterns is not allowed.");
504 d_matcher = matcher.copy();
505 PRECONDITION(getName() == d_matcher->getName(), "Opps");
506 }
507
508 //! add a FilterHierarchy as a child.
509 //! returns the FilterHierarchy pointer used in the tree (this is a
510 //! shallow copy of the original)
511 /*
512 \param hierarchy The new FilterHierarchyMatcher child for this node
513 */
514 boost::shared_ptr<FilterHierarchyMatcher> addChild(
515 const FilterHierarchyMatcher &hierarchy) {
516 PRECONDITION(hierarchy.d_matcher.get() && hierarchy.d_matcher->isValid(),
517 "Only one root node is allowed in a FilterHierarchyMatcher");
518
519 d_children.push_back(boost::shared_ptr<FilterHierarchyMatcher>(
520 new FilterHierarchyMatcher(hierarchy)));
521 return d_children.back();
522 }
523
524 //! returns the FilterMatches against the given molecule
525 /*
526 \param mol The molecule to match against
527 \param matches The vector of FilterMatch objects that match
528 */
529 bool getMatches(const ROMol &mol,
530 std::vector<FilterMatch> &matches) const override;
531
532 //! Does this node match the molecule
533 /*
534 \param mol The molecule to match against
535 */
536 bool hasMatch(const ROMol &mol) const override {
537 std::vector<FilterMatch> temp;
538 return getMatches(mol, temp);
539 }
540
541 //! copys the FilterHierarchyMatcher into a FilterMatcherBase
542 boost::shared_ptr<FilterMatcherBase> copy() const override {
543 return boost::shared_ptr<FilterMatcherBase>(
544 new FilterHierarchyMatcher(*this));
545 }
546
547 private:
548#ifdef RDK_USE_BOOST_SERIALIZATION
549 friend class boost::serialization::access;
550 template <class Archive>
551 void serialize(Archive &ar, const unsigned int version) {
552 RDUNUSED_PARAM(version);
553 ar &boost::serialization::base_object<FilterMatcherBase>(*this);
554 ar & d_children;
555 ar & d_matcher;
556 }
557#endif
558};
559
560#ifdef RDK_USE_BOOST_SERIALIZATION
561// Register all known filter matcher types for serialization
562template <class Archive>
564 ar.register_type(static_cast<FilterMatchOps::And *>(nullptr));
565 ar.register_type(static_cast<FilterMatchOps::Or *>(nullptr));
566 ar.register_type(static_cast<FilterMatchOps::Not *>(nullptr));
567 ar.register_type(static_cast<SmartsMatcher *>(nullptr));
568 ar.register_type(static_cast<ExclusionList *>(nullptr));
569 ar.register_type(static_cast<FilterHierarchyMatcher *>(nullptr));
570}
571#endif
572} // namespace RDKit
573
574#ifdef RDK_USE_BOOST_SERIALIZATION
575BOOST_CLASS_VERSION(RDKit::SmartsMatcher, 1)
576BOOST_CLASS_VERSION(RDKit::ExclusionList, 1)
577BOOST_CLASS_VERSION(RDKit::FilterHierarchyMatcher, 1)
578#endif
579
580#endif
#define RDUNUSED_PARAM(x)
Definition Invariant.h:196
#define PRECONDITION(expr, mess)
Definition Invariant.h:109
pulls in the core RDKit functionality
bool getMatches(const ROMol &mol, std::vector< FilterMatch > &) const override
getMatches
bool hasMatch(const ROMol &mol) const override
hasMatches
void setExclusionPatterns(const std::vector< boost::shared_ptr< FilterMatcherBase > > &offPatterns)
ExclusionList(std::vector< boost::shared_ptr< FilterMatcherBase > > offPatterns)
void addPattern(const FilterMatcherBase &base)
bool isValid() const override
std::string getName() const override
boost::shared_ptr< FilterMatcherBase > copy() const override
void setPattern(const FilterMatcherBase &matcher)
Set a new FilterMatcherBase for this node.
bool getMatches(const ROMol &mol, std::vector< FilterMatch > &matches) const override
returns the FilterMatches against the given molecule
bool isValid() const override
returns true if this node has a valid matcher
boost::shared_ptr< FilterMatcherBase > copy() const override
copys the FilterHierarchyMatcher into a FilterMatcherBase
std::string getName() const override
Return the name for this node (from the underlying FilterMatcherBase)
FilterHierarchyMatcher(const FilterMatcherBase &matcher)
boost::shared_ptr< FilterHierarchyMatcher > addChild(const FilterHierarchyMatcher &hierarchy)
bool hasMatch(const ROMol &mol) const override
Does this node match the molecule.
bool getMatches(const ROMol &mol, std::vector< FilterMatch > &matchVect) const override
getMatches
And(const FilterMatcherBase &arg1, const FilterMatcherBase &arg2)
std::string getName() const override
bool hasMatch(const ROMol &mol) const override
hasMatches
bool isValid() const override
boost::shared_ptr< FilterMatcherBase > copy() const override
And(boost::shared_ptr< FilterMatcherBase > arg1, boost::shared_ptr< FilterMatcherBase > arg2)
bool isValid() const override
bool hasMatch(const ROMol &mol) const override
hasMatches
std::string getName() const override
Not(const FilterMatcherBase &arg1)
boost::shared_ptr< FilterMatcherBase > copy() const override
Not(boost::shared_ptr< FilterMatcherBase > arg1)
bool getMatches(const ROMol &mol, std::vector< FilterMatch > &) const override
getMatches
Or(boost::shared_ptr< FilterMatcherBase > arg1, boost::shared_ptr< FilterMatcherBase > arg2)
bool hasMatch(const ROMol &mol) const override
hasMatches
bool isValid() const override
boost::shared_ptr< FilterMatcherBase > copy() const override
Or(const FilterMatcherBase &arg1, const FilterMatcherBase &arg2)
std::string getName() const override
bool getMatches(const ROMol &mol, std::vector< FilterMatch > &matchVect) const override
getMatches
virtual boost::shared_ptr< FilterMatcherBase > copy() const =0
virtual bool isValid() const =0
bool isValid() const override
Returns True if the Smarts pattern is valid.
void setPattern(const ROMol &mol)
Set the query molecule for the matcher.
unsigned int getMaxCount() const
Get the maximum match count for the pattern to be true.
unsigned int getMinCount() const
Get the minimum match count for the pattern to be true.
bool hasMatch(const ROMol &mol) const override
hasMatches
SmartsMatcher(const ROMol &pattern, unsigned int minCount=1, unsigned int maxCount=UINT_MAX)
Construct a SmartsMatcher from a query molecule.
void setPattern(const std::string &smarts)
Set the smarts pattern for the matcher.
const ROMOL_SPTR & getPattern() const
Return the shared_ptr to the underlying query molecule.
boost::shared_ptr< FilterMatcherBase > copy() const override
void setPattern(const ROMOL_SPTR &pat)
Set the shared query molecule for the matcher.
void setMinCount(unsigned int val)
Set the minimum match count for the pattern to be true.
bool getMatches(const ROMol &mol, std::vector< FilterMatch > &matchVect) const override
getMatches
void setMaxCount(unsigned int val)
Set the maximum match count for the pattern to be true.
SmartsMatcher(const std::string &name, ROMOL_SPTR onPattern, unsigned int minCount=1, unsigned int maxCount=UINT_MAX)
Construct a SmartsMatcher from a shared_ptr.
SmartsMatcher(const std::string &name=SMARTS_MATCH_NAME_DEFAULT)
Construct a SmartsMatcher.
SmartsMatcher(const std::string &name, const ROMol &pattern, unsigned int minCount=1, unsigned int maxCount=UINT_MAX)
Construct a SmartsMatcher.
SmartsMatcher(const SmartsMatcher &rhs)
SmartsMatcher(const std::string &name, const std::string &smarts, unsigned int minCount=1, unsigned int maxCount=UINT_MAX)
Construct a SmartsMatcher from a smarts pattern.
#define RDKIT_FILTERCATALOG_EXPORT
Definition export.h:169
Std stuff.
bool rdvalue_is(const RDValue_cast_t)
boost::shared_ptr< ROMol > ROMOL_SPTR
RDKIT_FILTERCATALOG_EXPORT const char * SMARTS_MATCH_NAME_DEFAULT