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