Package rdkit :: Package VLib :: Package NodeLib :: Module SmartsMolFilter :: Class SmartsFilter

[hide private]
[frames] | no frames]

# Class SmartsFilter

source code

       object --+
                |
    Node.VLibNode --+
                    |
    Filter.FilterNode --+
                        |
                       SmartsFilter

    filter out molecules matching one or more SMARTS patterns

    There is a count associated with each pattern. Molecules are
    allowed to match the pattern up to this number of times.

    Assumptions:

      - inputs are molecules

    Sample Usage:
      >>> smis = ['C1CCC1','C1CCC1C=O','CCCC','CCC=O','CC(=O)C','CCN','NCCN','NCC=O']
      >>> mols = [Chem.MolFromSmiles(x) for x in smis]
      >>> from rdkit.VLib.Supply import SupplyNode
      >>> suppl = SupplyNode(contents=mols)
      >>> ms = [x for x in suppl]
      >>> len(ms)
      8

      We can pass in SMARTS strings:
      >>> smas = ['C=O','CN']
      >>> counts = [1,2]
      >>> filt = SmartsFilter(patterns=smas,counts=counts)
      >>> filt.AddParent(suppl)
      >>> ms = [x for x in filt]
      >>> len(ms)
      5

      Alternatively, we can pass in molecule objects:
      >>> mols =[Chem.MolFromSmarts(x) for x in smas]
      >>> counts = [1,2]
      >>> filt.Destroy()
      >>> filt = SmartsFilter(patterns=mols,counts=counts)
      >>> filt.AddParent(suppl)
      >>> ms = [x for x in filt]
      >>> len(ms)
      5

      Negation does what you'd expect:
      >>> filt.SetNegate(1)
      >>> ms = [x for x in filt]
      >>> len(ms)
      3

Instance Methods | [hide private]

__init__(self, patterns=[], counts=[], **kwargs) x.__init__(...) initializes x; see help(type(x)) for signature | source code

_initPatterns(self, patterns, counts) | source code

filter(self, cmpd) | source code

Inherited from `Filter.FilterNode`: `Negate`, `SetNegate`, `next`

Inherited from `Node.VLibNode`: `AddChild`, `AddParent`, `Destroy`, `GetChildren`, `GetParents`, `RemoveChild`, `RemoveParent`, `__iter__`, `reset`

Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, patterns=[], counts=[], **kwargs)
(Constructor)

source code

    x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
  (inherited documentation)