Exemplo n.º 1
0
 def testUSRCAT(self):
   mol = Chem.MolFromSmiles("CC")
   AllChem.Compute2DCoords(mol)
   self.assertRaises(ValueError, lambda: rdMD.GetUSRCAT(mol))
   mol = Chem.MolFromSmiles("C1CCCCC1")
   mol = Chem.AddHs(mol)
   self.assertRaises(ValueError, lambda: rdMD.GetUSRCAT(mol))
   AllChem.Compute2DCoords(mol)
   usr = rdMD.GetUSRCAT(mol)
   self.assertEqual(len(usr), 60)
   self.assertRaises(ValueError, lambda: rdMD.GetUSRCAT(mol, atomSelections=[]))
   atoms = [[1, 2, 3, 4, 5, 6], []]
   usr2 = rdMD.GetUSRCAT(mol, atomSelections=atoms)
   self.assertEqual(len(usr2), 36)
   atoms = [[1, 2, 3, 4, 5, 6], [], [], []]
   usr2 = rdMD.GetUSRCAT(mol, atomSelections=atoms)
   self.assertEqual(len(usr2), 60)
   self.assertEqual(rdMD.GetUSRScore(usr, usr2, weights=[1.0, 1.0, 1.0, 1.0, 1.0]), 1.0)
def calc_usrcat(mol: MyMol, path):
    path_ = np.array(path) + 1
    results = rdMolDescriptors.GetUSRCAT(mol.mol,
                                         atomSelections=[path_.tolist()])
    keys = ['usrcat_{}'.format(n) for n in range(len(results))]
    return dict(zip(keys, results))