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