def test_10_removeGenerateConformer(self): molsmile = SMILE_SMI sm = SmallMol(molsmile) sm.generateConformers(num_confs=10, append=False) n_confs = sm.numConformers sm.removeConformers([0]) n_confs_del = sm.numConformers sm.removeConformers() n_confs_zero = sm.numConformers self.assertEqual(n_confs_del, n_confs - 1, "The number of conformations after the deletion was not reduced of " "exactly one unit") self.assertEqual(n_confs_zero, 0, "The number of conformations after the deletion was not reduced to 0")
def test_10_removeGenerateConformer(self): molsmile = SMILE_SMI sm = SmallMol(molsmile) sm.generateConformers(num_confs=10, append=False) n_confs = sm.numConformers sm.removeConformers([0]) n_confs_del = sm.numConformers sm.removeConformers() n_confs_zero = sm.numConformers self.assertEqual( n_confs_del, n_confs - 1, "The number of conformations after the deletion was not reduced of " "exactly one unit") self.assertEqual( n_confs_zero, 0, "The number of conformations after the deletion was not reduced to 0" )
def alignMol(smallmol, refmol): """ Return a new SmallMol object aligned to a refmol that can be a htmd.smallmol.smallmol.SmallMol or rdkit.Chem.rdchem.Mol. It removes all the conformers stored in the original object. Parameters ---------- smallmol: htmd.smallmol.smallmol.SmallMol The SmallMol object to align refmol: htmd.smallmol.smallmol.SmallMol or rdkit.Chem.rdchem.Mol The molecule to align to Return ------ newsmallmol: htmd.smallmol.smallmol.SmallMol a new SmallMol aligned to reference molecule """ from htmd.smallmol.smallmol import SmallMol from rdkit.Chem.rdMolAlign import GetO3A if isinstance(refmol, SmallMol): refmol = refmol.toRdkitMol(includeConformer=True) sm_rdkit = smallmol.toRdkitMol(includeConformer=True) pyO3A = GetO3A(sm_rdkit, refmol) rmsd = pyO3A.Align() print('Alignment with a RMSD of {}'.format(rmsd)) coords_new = sm_rdkit.GetConformer().GetPositions() sm_new = SmallMol(smallmol, fixHs=False) sm_new.removeConformers() sm_new.coords = coords_new[:, :, np.newaxis] return sm_new
def alignMol(smallmol, refmol): """ Return a new SmallMol object aligned to a refmol that can be a htmd.smallmol.smallmol.SmallMol or rdkit.Chem.rdchem.Mol. It removes all the conformers stored in the original object. Parameters ---------- smallmol: htmd.smallmol.smallmol.SmallMol The SmallMol object to align refmol: htmd.smallmol.smallmol.SmallMol or rdkit.Chem.rdchem.Mol The molecule to align to Return ------ newsmallmol: htmd.smallmol.smallmol.SmallMol a new SmallMol aligned to reference molecule """ from htmd.smallmol.smallmol import SmallMol from rdkit.Chem.rdMolAlign import GetO3A if isinstance(refmol, SmallMol): refmol = refmol.toRdkitMol(includeConformer=True) sm_rdkit = smallmol.toRdkitMol(includeConformer=True) pyO3A = GetO3A(sm_rdkit, refmol) rmsd = pyO3A.Align() print('Alignment with a RMSD of {}'.format(rmsd)) coords_new = sm_rdkit.GetConformer().GetPositions() sm_new = SmallMol(smallmol, fixHs=False) sm_new.removeConformers() sm_new.coords = coords_new[:, :, np.newaxis] return sm_new