Example #1
0
    def check_mol_rdkit(self, clean=False):
        """
        Checks validity of rdmol molecule against internal rules
            Valence electrons
            Bond order
            Charge
            Fragments

        Args:
            self: aemol object
            rdmol: rdkit molecule object

        Returns:
            if clean = True: returns cleaned molecule
            else: returns null
        """
        if self.rdmol == None:
            self.to_rdkit()

        rdkit_vm = mol_std.RDKitValidation()
        molvs_vm = mol_std.MolVSValidation()

        rdkit_vm.validate(self.rdmol)
        molvs_vm.validate(self.rdmol)

        if clean:
            lfc = mol_stf.LargestFragmentChooser()
            idx = self.rdmol.GetProp('_Name')

            self.rdmol = lfc.choose(rself.rdmol)
            mol_std.Cleanup(self.rdmol)
            self.rdmol.SetProp('_Name', idx)
 def test20NoneHandling(self):
     with self.assertRaises(ValueError):
         rdMolStandardize.ChargeParent(None)
     with self.assertRaises(ValueError):
         rdMolStandardize.Cleanup(None)
     with self.assertRaises(ValueError):
         rdMolStandardize.FragmentParent(None)
     with self.assertRaises(ValueError):
         rdMolStandardize.Normalize(None)
     with self.assertRaises(ValueError):
         rdMolStandardize.Reionize(None)
def standardize_format(mol):
    """Clean up molecule and return in standardized format
    """
    mol = rdMolStandardize.Cleanup(mol)
    mol = get_biggest_component(mol)

    uncharger = rdMolStandardize.Uncharger()
    mol = uncharger.uncharge(mol)

    remove_isotopes(mol)
    return mol
Example #4
0
def standardize(mol, neutralize, fragment):
    """

    :param mol: The molecule to standardize
    :param neutralize: Boolean for whether to neutralize the molecule
    :param fragment: The approach for choosing the largest fragment. Either 'hac' or 'mw'. If not specified the whole
    molecule is used.
    :return: The standardized molecule
    """
    mol = rdMolStandardize.Cleanup(mol)
    #mol = lfc.choose(mol)
    # We use our own largest fragment picker as the RDKit one behaves slightly differently
    if fragment:
        mol = mol_utils.fragment(mol, fragment)
    if neutralize:
        mol = uncharger.uncharge(mol)
    return mol
Example #5
0
 def test1Cleanup(self):
     mol = Chem.MolFromSmiles("CCC(=O)O[Na]")
     nmol = rdMolStandardize.Cleanup(mol)
     self.assertEqual(Chem.MolToSmiles(nmol), "CCC(=O)[O-].[Na+]")
def standardize(mol):
    mol = rdMolStandardize.Cleanup(mol)
    mol = fragment(mol)
    mol = uncharger.uncharge(mol)
    remove_isotopes(mol)
    return mol