Exemplo n.º 1
0
    def test_measure_only(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            tmp_path = pathlib.Path(tmpdir)
            args = get_args(
                "sugar",
                tmp_path,
                extra={
                    "mapping": None,
                    "trajectory": None,
                },
            )

            # Equivalent to
            # pycgtool <top> -b <bnd>
            main.PyCGTOOL(args)

            # Does not produce itp file
            self.assertFalse(tmp_path.joinpath("out.itp").exists())

            # Check bond dump files against reference
            for bond_type in ["length", "angle", "dihedral"]:
                out_file = tmp_path.joinpath(f"ALLA_{bond_type}.dat")
                self.assertTrue(out_file.exists())

                self.assertTrue(
                    util.cmp_file_whitespace_float(
                        self.data_dir.joinpath(f"ALLA_{bond_type}_one.dat"),
                        out_file))
Exemplo n.º 2
0
    def test_forcefield(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            tmp_path = pathlib.Path(tmpdir)
            args = get_args(
                "sugar",
                tmp_path,
                extra={
                    "output_forcefield": True,
                },
            )

            # Equivalent to
            # pycgtool <top> <trj> -m <map> -b <bnd> --output-forcefield
            main.PyCGTOOL(args)

            # Does not produce itp file
            self.assertFalse(tmp_path.joinpath("out.itp").exists())

            out_ff_dir = tmp_path.joinpath("ffout.ff")
            self.assertTrue(out_ff_dir.is_dir())

            # Compare all files in ffout.ff to reference versions
            for out_file in out_ff_dir.iterdir():
                ref_file = self.data_dir.joinpath(out_file)

                self.assertTrue(
                    util.cmp_file_whitespace_float(ref_file, out_file))
Exemplo n.º 3
0
    def test_map_only(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            tmp_path = pathlib.Path(tmpdir)
            args = get_args(
                "sugar",
                tmp_path,
                extra={
                    "output_xtc": True,
                    "bnd": None,
                },
            )

            # Equivalent to
            # pycgtool <top> <trj> -m <map> --output-xtc
            main.PyCGTOOL(args)

            self.assertTrue(
                util.compare_trajectories(
                    self.data_dir.joinpath("sugar_out.xtc"),
                    tmp_path.joinpath("out.xtc"),
                    topology_file=self.data_dir.joinpath("sugar_out.gro"),
                ))
Exemplo n.º 4
0
    def test_full(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            tmp_path = pathlib.Path(tmpdir)
            args = get_args("sugar", tmp_path)

            # Equivalent to
            # pycgtool <top> <trj> -m <map> -b <bnd>
            main.PyCGTOOL(args)

            self.assertTrue(
                util.cmp_file_whitespace_float(
                    tmp_path.joinpath("out.itp"),
                    self.data_dir.joinpath("sugar_out.itp"),
                    rtol=0.001,
                    verbose=True,
                ))

            self.assertTrue(
                util.compare_trajectories(
                    self.data_dir.joinpath("sugar_out.gro"),
                    tmp_path.joinpath("out.gro"),
                    rtol=0.001,
                ))
Exemplo n.º 5
0
    def test_full_no_traj(self):
        with tempfile.TemporaryDirectory() as tmpdir:
            tmp_path = pathlib.Path(tmpdir)
            args = get_args(
                "sugar",
                tmp_path,
                extra={
                    "trajectory": None,
                },
            )

            # Equivalent to
            # pycgtool <top> -m <map> -b <bnd>
            main.PyCGTOOL(args)

            self.assertFalse(tmp_path.joinpath("out.itp").exists())

            self.assertTrue(
                util.compare_trajectories(
                    self.data_dir.joinpath("sugar_out.gro"),
                    tmp_path.joinpath("out.gro"),
                    rtol=0.001,
                ))