mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
Go To CR (#2431)
This commit is contained in:
committed by
Greg Landrum
parent
1435510221
commit
e245349c5a
@@ -89,6 +89,7 @@ class Standardizer(object):
|
||||
: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)
|
||||
@@ -96,6 +97,8 @@ class Standardizer(object):
|
||||
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
|
||||
|
||||
|
||||
26
rdkit/Chem/MolStandardize/test_standardizer.py
Normal file
26
rdkit/Chem/MolStandardize/test_standardizer.py
Normal file
@@ -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))
|
||||
Reference in New Issue
Block a user