Skip to content

Commit

Permalink
added castep, dftb, forcite and gromacs converter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiCheng45 committed Mar 21, 2024
1 parent 2f436ef commit fb66d4f
Show file tree
Hide file tree
Showing 6 changed files with 23,458 additions and 0 deletions.
Binary file added MDANSE/Tests/UnitTests/Data/H2O.trj
Binary file not shown.
1,287 changes: 1,287 additions & 0 deletions MDANSE/Tests/UnitTests/Data/H2O.xtd

Large diffs are not rendered by default.

3,283 changes: 3,283 additions & 0 deletions MDANSE/Tests/UnitTests/Data/PBAnew.md

Large diffs are not rendered by default.

18,797 changes: 18,797 additions & 0 deletions MDANSE/Tests/UnitTests/Data/md.pdb

Large diffs are not rendered by default.

Binary file added MDANSE/Tests/UnitTests/Data/md.xtc
Binary file not shown.
91 changes: 91 additions & 0 deletions MDANSE/Tests/UnitTests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
dlp_history_v4 = os.path.join(file_wd, "Data", "HISTORY4")
apoferritin_dcd = os.path.join(file_wd, "Data", "apoferritin.dcd")
apoferritin_pdb = os.path.join(file_wd, "Data", "apoferritin.pdb")
pbanew_md = os.path.join(file_wd, "Data", "PBAnew.md")
h2o_trj = os.path.join(file_wd, "Data", "H2O.trj")
h2o_xtd = os.path.join(file_wd, "Data", "H2O.xtd")
md_pdb = os.path.join(file_wd, "Data", "md.pdb")
md_xtc = os.path.join(file_wd, "Data", "md.xtc")


@pytest.mark.parametrize("compression", ["none", "gzip", "lzf"])
Expand Down Expand Up @@ -317,3 +322,89 @@ def test_namd_mdt_conversion_file_exists_and_loads_up_successfully_and_chemical_

hdftradj["instance"].close()
os.remove(temp_name + ".mdt")


@pytest.mark.parametrize("compression", ["none", "gzip", "lzf"])
def test_castep_md_conversion_file_exists_and_loads_up_successfully(compression):
temp_name = tempfile.mktemp()

parameters = {
"atom_aliases": "{}",
"castep_file": pbanew_md,
"fold": False,
"output_file": (temp_name, 64, compression),
}

castep = Converter.create("CASTEP")
castep.run(parameters, status=True)

HDFTrajectoryConfigurator("trajectory").configure(temp_name + ".mdt")

assert os.path.exists(temp_name + ".mdt")
assert os.path.isfile(temp_name + ".mdt")
os.remove(temp_name + ".mdt")


@pytest.mark.parametrize("compression", ["none", "gzip", "lzf"])
def test_dftb_conversion_file_exists_and_loads_up_successfully(compression):
temp_name = tempfile.mktemp()

parameters = {
"atom_aliases": "{}",
"fold": True,
"output_file": (temp_name, 64, compression),
"trj_file": h2o_trj,
"xtd_file": h2o_xtd,
}

dftb = Converter.create("DFTB")
dftb.run(parameters, status=True)

HDFTrajectoryConfigurator("trajectory").configure(temp_name + ".mdt")

assert os.path.exists(temp_name + ".mdt")
assert os.path.isfile(temp_name + ".mdt")
os.remove(temp_name + ".mdt")


@pytest.mark.parametrize("compression", ["none", "gzip", "lzf"])
def test_forcite_conversion_file_exists_and_loads_up_successfully(compression):
temp_name = tempfile.mktemp()

parameters = {
"atom_aliases": "{}",
"fold": False,
"output_file": (temp_name, 64, compression),
"trj_file": h2o_trj,
"xtd_file": h2o_xtd,
}

dftb = Converter.create("Forcite")
dftb.run(parameters, status=True)

HDFTrajectoryConfigurator("trajectory").configure(temp_name + ".mdt")

assert os.path.exists(temp_name + ".mdt")
assert os.path.isfile(temp_name + ".mdt")
os.remove(temp_name + ".mdt")


@pytest.mark.parametrize("compression", ["none", "gzip", "lzf"])
def test_gromacs_conversion_file_exists_and_loads_up_successfully(compression):
temp_name = tempfile.mktemp()

parameters = {
"fold": False,
"output_file": (temp_name, 64, compression),
"pdb_file": md_pdb,
"xtc_file": md_xtc,
}

dftb = Converter.create("Gromacs")
dftb.run(parameters, status=True)

HDFTrajectoryConfigurator("trajectory").configure(temp_name + ".mdt")

assert os.path.exists(temp_name + ".mdt")
assert os.path.isfile(temp_name + ".mdt")
os.remove(temp_name + ".mdt")

0 comments on commit fb66d4f

Please sign in to comment.