def test_fit(self): mol1 = Molecule.from_file(os.path.join(test_dir, "benzene1.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "benzene2.xyz")) mm = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 1.4171601659148593e-05, places=6) mol1 = Molecule.from_file(os.path.join(test_dir, "c1.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "c2.xyz")) mm = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 9.479012116064961e-05, places=6) mol1 = Molecule.from_file(os.path.join(test_dir, "t3.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "t4.xyz")) mm = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 0.002825344731118855, places=6) mol1 = Molecule.from_file(os.path.join(test_dir, "j1.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "j2.xyz")) mm = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 9.28245597473488e-05, places=6) mol1 = Molecule.from_file(os.path.join(test_dir, "ethene1.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "ethene2.xyz")) mm = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 0.00021150729609276233, places=6) mol1 = Molecule.from_file(os.path.join(test_dir, "toluene1.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "toluene2.xyz")) mm = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 0.0001445787263551832, places=6) mol1 = Molecule.from_file(os.path.join(test_dir, "cyclohexane1.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "cyclohexane2.xyz")) mm = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 0.00012447269440740117, places=6) mol1 = Molecule.from_file(os.path.join(test_dir, "oxygen1.xyz")) mol2 = Molecule.from_file(os.path.join(test_dir, "oxygen2.xyz")) mm = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 0., 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 = HungarianOrderMatcher(mol1) with self.assertRaises(ValueError): _, rmsd = mm.fit(mol2)
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 = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 0.002825344731118855, places=6)
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 = HungarianOrderMatcher(mol1) _, rmsd = mm.fit(mol2) self.assertAlmostEqual(rmsd, 0., places=6)