Package rdkit :: Package VLib :: Package NodeLib :: Module SmartsRemover :: Class SmartsRemover

[hide private]
[frames] | no frames]

# Class SmartsRemover

source code

             object --+
                      |
          Node.VLibNode --+
                          |
    Transform.TransformNode --+
                              |
                             SmartsRemover

    transforms molecules by removing atoms matching smarts patterns

    Assumptions:

      - inputs are molecules

    Sample Usage:
      >>> smis = ['C1CCC1.C=O','C1CCC1C=O','CCC=O.C=O','NCC=O.C=O.CN']
      >>> 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)
      4

      We can pass in SMARTS strings:
      >>> smas = ['C=O','CN']
      >>> tform = SmartsRemover(patterns=smas)
      >>> tform.AddParent(suppl)
      >>> ms = [x for x in tform]
      >>> len(ms)
      4
      >>> Chem.MolToSmiles(ms[0])
      'C1CCC1'
      >>> Chem.MolToSmiles(ms[1])
      'O=CC1CCC1'
      >>> Chem.MolToSmiles(ms[2])
      'CCC=O'
      >>> Chem.MolToSmiles(ms[3])
      'NCC=O'

      We can also remove pieces of the molecule that are not complete
      fragments:
      >>> tform.Destroy()
      >>> smas = ['C=O','CN']
      >>> smas = [Chem.MolFromSmarts(x) for x in smas]
      >>> tform = SmartsRemover(patterns=smas,wholeFragments=0)
      >>> tform.AddParent(suppl)
      >>> ms = [x for x in tform]
      >>> len(ms)
      4
      >>> Chem.MolToSmiles(ms[0])
      'C1CCC1'
      >>> Chem.MolToSmiles(ms[1])
      'C1CCC1'
      >>> Chem.MolToSmiles(ms[3])
      ''

      Or patterns themselves:
      >>> tform.Destroy()
      >>> smas = ['C=O','CN']
      >>> smas = [Chem.MolFromSmarts(x) for x in smas]
      >>> tform = SmartsRemover(patterns=smas)
      >>> tform.AddParent(suppl)
      >>> ms = [x for x in tform]
      >>> len(ms)
      4
      >>> Chem.MolToSmiles(ms[0])
      'C1CCC1'
      >>> Chem.MolToSmiles(ms[3])
      'NCC=O'

Instance Methods | [hide private]

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

_initPatterns(self, patterns) | source code

transform(self, cmpd) | source code

Inherited from `Transform.TransformNode`: `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=[], wholeFragments=1, **kwargs)
(Constructor)

source code

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

Overrides: object.__init__
  (inherited documentation)