Skip to content

Commit

Permalink
Go To CR (#2431)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleswing authored and greglandrum committed May 19, 2019
1 parent 1435510 commit e245349
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rdkit/Chem/MolStandardize/standardize.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,16 @@ def standardize(self, mol):
:returns: The standardized molecule.
:rtype: :rdkit:`Mol <Chem.rdchem.Mol-class.html>`
"""
mol_props = mol.GetPropsAsDict()
mol = copy.deepcopy(mol)
Chem.SanitizeMol(mol)
mol = Chem.RemoveHs(mol)
mol = self.disconnect_metals(mol)
mol = self.normalize(mol)
mol = self.reionize(mol)
Chem.AssignStereochemistry(mol, force=True, cleanIt=True)
for k, v in mol_props.items():
mol.SetProp(k, v)
# TODO: Check this removes symmetric stereocenters
return mol

Expand Down
26 changes: 26 additions & 0 deletions rdkit/Chem/MolStandardize/test_standardizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import unittest
from rdkit import Chem
from rdkit.Chem.MolStandardize.standardize import Standardizer


class FakeStandardizer(Standardizer):
def normalize(self):
def fake_normalize(y):
props = y.GetPropsAsDict()
for k, v in props:
y.ClearProp(k)
return y
return fake_normalize

class TestCase(unittest.TestCase):

def testPreserveProps(self):
PROP_NAME = "MyProp"
PROP_VALUE = "foo"
standardizer = FakeStandardizer()
m = Chem.MolFromSmiles("C")
m.SetProp(PROP_NAME, PROP_VALUE)

standardized_mol = standardizer.standardize(m)
self.assertTrue(standardized_mol.HasProp(PROP_NAME))
self.assertEqual(PROP_VALUE, standardized_mol.GetProp(PROP_NAME))

0 comments on commit e245349

Please sign in to comment.