Package rdkit :: Package Chem :: Module SaltRemover :: Class SaltRemover
[hide private]
[frames] | no frames]

Class SaltRemover

source code

object --+
         |
        SaltRemover

Instance Methods [hide private]
 
__init__(self, defnFilename=None, defnData=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_initPatterns(self)
>>> remover = SaltRemover() >>> len(remover.salts)>0 True
source code
 
StripMol(self, mol, dontRemoveEverything=False)
>>> remover = SaltRemover(defnData="[Cl,Br]") >>> len(remover.salts) 1
source code
 
__call__(self, mol, dontRemoveEverything=False)
>>> remover = SaltRemover(defnData="[Cl,Br]") >>> len(remover.salts) 1
source code

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

Class Variables [hide private]
  defnFilename = '/scratch/RDKit_git/Data/Salts.txt'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, defnFilename=None, defnData=None)
(Constructor)

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

Overrides: object.__init__
(inherited documentation)

_initPatterns(self)

source code 


>>> remover = SaltRemover()
>>> len(remover.salts)>0
True

>>> remover = SaltRemover(defnData="[Cl,Br]")
>>> len(remover.salts)
1

>>> from rdkit import RDLogger
>>> RDLogger.DisableLog('rdApp.error')
>>> remover = SaltRemover(defnData="[Cl,fail]")
Traceback (most recent call last):
  ...
ValueError: [Cl,fail]

>>> RDLogger.EnableLog('rdApp.error')

StripMol(self, mol, dontRemoveEverything=False)

source code 


>>> remover = SaltRemover(defnData="[Cl,Br]")
>>> len(remover.salts)
1

>>> mol = Chem.MolFromSmiles('CN(C)C.Cl')
>>> res = remover.StripMol(mol)
>>> res is not None
True
>>> res.GetNumAtoms()
4

Notice that all salts are removed:
>>> mol = Chem.MolFromSmiles('CN(C)C.Cl.Cl.Br')
>>> res = remover.StripMol(mol)
>>> res.GetNumAtoms()
4

Matching (e.g. "salt-like") atoms in the molecule are unchanged:
>>> mol = Chem.MolFromSmiles('CN(Br)Cl')
>>> res = remover.StripMol(mol)
>>> res.GetNumAtoms()
4

>>> mol = Chem.MolFromSmiles('CN(Br)Cl.Cl')
>>> res = remover.StripMol(mol)
>>> res.GetNumAtoms()
4

Charged salts are handled reasonably:
>>> mol = Chem.MolFromSmiles('C[NH+](C)(C).[Cl-]')
>>> res = remover.StripMol(mol)
>>> res.GetNumAtoms()
4


Watch out for this case (everything removed):
>>> remover = SaltRemover()
>>> len(remover.salts)>1
True
>>> mol = Chem.MolFromSmiles('CC(=O)O.[Na]')
>>> res = remover.StripMol(mol)
>>> res.GetNumAtoms()
0

dontRemoveEverything helps with this by leaving the last salt:
>>> res = remover.StripMol(mol,dontRemoveEverything=True)
>>> res.GetNumAtoms()
4

but in cases where the last salts are the same, it can't choose
between them, so it returns all of them:
>>> mol = Chem.MolFromSmiles('Cl.Cl')
>>> res = remover.StripMol(mol,dontRemoveEverything=True)
>>> res.GetNumAtoms()
2

__call__(self, mol, dontRemoveEverything=False)
(Call operator)

source code 


>>> remover = SaltRemover(defnData="[Cl,Br]")
>>> len(remover.salts)
1

>>> mol = Chem.MolFromSmiles('CN(C)C.Cl')
>>> res = remover(mol)
>>> res is not None
True
>>> res.GetNumAtoms()
4