def test6Charge(self): mol = Chem.MolFromSmiles("C1=C(C=CC(=C1)[S]([O-])=O)[S](O)(=O)=O") # instantiate with default acid base pair library reionizer = rdMolStandardize.Reionizer() nm = reionizer.reionize(mol) self.assertEqual(Chem.MolToSmiles(nm), "O=S(O)c1ccc(S(=O)(=O)[O-])cc1") # try reionize with another acid base pair library without the right # pairs abfile = os.path.join(RDConfig.RDDataDir, 'MolStandardize', 'acid_base_pairs2.txt') reionizer2 = rdMolStandardize.Reionizer(abfile) nm2 = reionizer2.reionize(mol) self.assertEqual(Chem.MolToSmiles(nm2), "O=S([O-])c1ccc(S(=O)(=O)O)cc1") # test Uncharger uncharger = rdMolStandardize.Uncharger() mol3 = Chem.MolFromSmiles("O=C([O-])c1ccccc1") nm3 = uncharger.uncharge(mol3) self.assertEqual(Chem.MolToSmiles(nm3), "O=C(O)c1ccccc1") # test canonical Uncharger uncharger = rdMolStandardize.Uncharger(canonicalOrder=False) mol3 = Chem.MolFromSmiles("C[N+](C)(C)CC(C(=O)[O-])CC(=O)[O-]") nm3 = uncharger.uncharge(mol3) self.assertEqual(Chem.MolToSmiles(nm3), "C[N+](C)(C)CC(CC(=O)[O-])C(=O)O") uncharger = rdMolStandardize.Uncharger(canonicalOrder=True) nm3 = uncharger.uncharge(mol3) self.assertEqual(Chem.MolToSmiles(nm3), "C[N+](C)(C)CC(CC(=O)O)C(=O)[O-]")
def reionize(mol): """Ensure the strongest acid groups ionize first in partially ionized molecules. Parameters ---------- mol: rdkit.Chem.Mol The partially ionized molecule. Returns ------- mol: rdkit.Chem.Mol Returns a molecule, with strongest acid groups ionized first. """ return rdMolStandardize.Reionizer().reionize(mol)
def standardize_mol( mol: Chem.rdchem.Mol, disconnect_metals: bool = False, normalize: bool = True, reionize: bool = True, uncharge: bool = False, stereo: bool = True, ): r""" This function returns a standardized version the given molecule, with or without disconnect the metals. The process is apply in the order of the argument. Arguments: mol: The molecule to standardize. disconnect_metals: Whether to disconnect the metallic atoms from non-metals normalize: Whether to apply normalization (correct functional groups and recombine charges). reionize: Whether to apply molecule reionization uncharge: Whether to remove all charge from molecule stereo: Whether to attempt to assign stereochemistry Returns: mol: The standardized molecule. """ mol = copy_mol(mol) if disconnect_metals: md = rdMolStandardize.MetalDisconnector() mol = md.Disconnect(mol) if normalize: mol = rdMolStandardize.Normalize(mol) if reionize: reionizer = rdMolStandardize.Reionizer() mol = reionizer.reionize(mol) if uncharge: uncharger = rdMolStandardize.Uncharger() mol = uncharger.uncharge(mol) if stereo: Chem.AssignStereochemistry(mol, force=False, cleanIt=True) return mol
def my_standardizer(mol: Chem.Mol) -> Chem.Mol: """ MolVS implementation of standardization Args: mol (Chem.Mol): non-standardized rdkit mol object Returns: Chem.Mol: stndardized rdkit mol object """ mol = copy.deepcopy(mol) Chem.SanitizeMol(mol) mol = Chem.RemoveHs(mol) disconnector = rdMolStandardize.MetalDisconnector() mol = disconnector.Disconnect(mol) normalizer = rdMolStandardize.Normalizer() mol = normalizer.normalize(mol) reionizer = rdMolStandardize.Reionizer() mol = reionizer.reionize(mol) Chem.AssignStereochemistry(mol, force=True, cleanIt=True) # TODO: Check this removes symmetric stereocenters return mol