コード例 #1
0
    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 = GeneticOrderMatcher(mol1, threshold=0.01)

        _, rmsd = mm.fit(mol2)[0]
        self.assertAlmostEqual(rmsd, 7.061017534055039e-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 = GeneticOrderMatcher(mol1, threshold=0.01)

        _, rmsd = mm.fit(mol2)[0]
        self.assertAlmostEqual(rmsd, 9.459575146593829e-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 = GeneticOrderMatcher(mol1, threshold=0.01)

        _, rmsd = mm.fit(mol2)[0]
        self.assertAlmostEqual(rmsd, 0.0028172956033734615, 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 = GeneticOrderMatcher(mol1, threshold=0.01)

        _, rmsd = mm.fit(mol2)[0]
        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 = GeneticOrderMatcher(mol1, threshold=0.01)

        _, rmsd = mm.fit(mol2)[0]
        self.assertAlmostEqual(rmsd, 0.00019757961816426042, 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 = GeneticOrderMatcher(mol1, threshold=0.1)

        _, rmsd = mm.fit(mol2)[0]
        self.assertAlmostEqual(rmsd, 0.0001398867874149986, 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 = GeneticOrderMatcher(mol1, threshold=0.01)

        _, rmsd = mm.fit(mol2)[0]
        self.assertAlmostEqual(rmsd, 0.00012190586696474853, 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 = GeneticOrderMatcher(mol1, threshold=0.01)

        _, rmsd = mm.fit(mol2)[0]
        self.assertAlmostEqual(rmsd, 0., places=6)
コード例 #2
0
    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 = GeneticOrderMatcher(mol1, threshold=0.3)

        with self.assertRaises(ValueError):
            _, rmsd = mm.fit(mol2)[0]
コード例 #3
0
    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 = GeneticOrderMatcher(mol1, threshold=0.3)

        _, rmsd = mm.fit(mol2)[0]
        self.assertAlmostEqual(rmsd, 0.0028172956033734615, places=6)
コード例 #4
0
    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 = GeneticOrderMatcher(mol1, threshold=0.3)
        _, rmsd = mm.fit(mol2)[0]
        self.assertAlmostEqual(rmsd, 0., places=6)