def test_to_and_from_dict(self): mol1 = Molecule.from_file(os.path.join(test_dir, "t3.xyz")) mm_source = KabschMatcher(mol1) d_source = mm_source.as_dict() mm_target = KabschMatcher.from_dict(d_source) self.assertDictEqual(d_source, mm_target.as_dict())
def test_get_rmsd(self): mol1 = Molecule.from_file(os.path.join(test_dir, "t3.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "t4.xyz")) mm = KabschMatcher(mol1) _, _, rmsd = mm.match(mol2) self.assertAlmostEqual(rmsd, 0.0028172956033732936, places=6)
def test_mismatched_atom_composition(self): mol1 = Molecule.from_file(os.path.join(test_dir, "benzene1.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "t2.xyz")) mm = KabschMatcher(mol1) with self.assertRaises(ValueError): _, rmsd = mm.fit(mol2)
def test_rotated_molecule(self): coords = [[0.000000, 0.000000, 0.000000], [0.000000, 0.000000, 1.089000], [1.026719, 0.000000, -0.363000], [-0.513360, -0.889165, -0.363000], [-0.513360, 0.889165, -0.363000]] op = SymmOp.from_origin_axis_angle([0, 0, 0], [0.1, 0.2, 0.3], 60) rotcoords = [op.operate(c) for c in coords] mol1 = Molecule(["C", "H", "H", "H", "H"], coords) mol2 = Molecule(["C", "H", "H", "H", "H"], rotcoords) mm = KabschMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 0., places=6)
def setUpClass(cls): cls.mol1 = Molecule.from_file(os.path.join(test_dir, "Si2O_cluster.xyz")) cls.mm = KabschMatcher(cls.mol1)
def test_to_and_from_dict(self): d = self.mm.as_dict() mm = KabschMatcher.from_dict(d) self.assertDictEqual(d, mm.as_dict())