def test_fit(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.fit(mol2)
        self.assertAlmostEqual(rmsd, 0.0028172956033732936, 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 = KabschMatcher(mol1)

        _, rmsd = mm.fit(mol2)
        self.assertAlmostEqual(rmsd, 0.0, places=6)
    def test_missmatched_atom_order(self):

        mol1 = Molecule.from_file(os.path.join(test_dir, "benzene1.xyz"))
        mol2 = Molecule.from_file(os.path.join(test_dir, "benzene2.xyz"))

        mm = KabschMatcher(mol1)

        with self.assertRaises(ValueError):
            _, rmsd = mm.fit(mol2)

        mol1 = Molecule.from_file(os.path.join(test_dir, "c1.xyz"))
        mol2 = Molecule.from_file(os.path.join(test_dir, "c2.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)