Skip to content

Commit

Permalink
Add mdout file to output_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahbaumann committed Oct 1, 2024
1 parent b546e01 commit db009fe
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
7 changes: 1 addition & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ repos:
hooks:
- id: flake8
files: ^openfe_gromacs
additional_dependencies: [
'flake8-bugbear',
'flake8-absolute-import',
'flake8-pytest-style==2',
'flake8-no-pep420',
]
additional_dependencies: [Flake8-pyproject]
- repo: https://github.com/asottile/pyupgrade
rev: 'v3.17.0'
hooks:
Expand Down
19 changes: 19 additions & 0 deletions openfe_gromacs/protocols/gromacs_md/md_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def get_filenames_em(self) -> dict[str, list[pathlib.Path]]:
- "edr_em"
- "log_em"
- "cpt_em"
- "grompp_mdp_em"
Returns
-------
Expand All @@ -183,6 +184,7 @@ def get_filenames_em(self) -> dict[str, list[pathlib.Path]]:
"edr_em",
"log_em",
"cpt_em",
"grompp_mdp_em",
]
dict_npt = {}
for file in file_keys:
Expand Down Expand Up @@ -231,6 +233,7 @@ def get_filenames_nvt(self) -> dict[str, list[pathlib.Path]]:
- "edr_nvt"
- "log_nvt"
- "cpt_nvt"
- "grompp_mdp_nvt"
Returns
-------
Expand All @@ -246,6 +249,7 @@ def get_filenames_nvt(self) -> dict[str, list[pathlib.Path]]:
"edr_nvt",
"log_nvt",
"cpt_nvt",
"grompp_mdp_nvt",
]
dict_npt = {}
for file in file_keys:
Expand Down Expand Up @@ -294,6 +298,7 @@ def get_filenames_npt(self) -> dict[str, list[pathlib.Path]]:
- "edr_npt"
- "log_npt"
- "cpt_npt"
- "grompp_mdp_npt"
Returns
-------
Expand All @@ -309,6 +314,7 @@ def get_filenames_npt(self) -> dict[str, list[pathlib.Path]]:
"edr_npt",
"log_npt",
"cpt_npt",
"grompp_mdp_em",
]
dict_npt = {}
for file in file_keys:
Expand Down Expand Up @@ -403,6 +409,7 @@ def _default_settings(cls):
engine_settings=GromacsEngineSettings(),
output_settings_em=EMOutputSettings(
mdp_file="em.mdp",
grompp_mdp_file="mdout_em.mdp",
tpr_file="em.tpr",
gro_file="em.gro",
trr_file="em.trr",
Expand All @@ -413,6 +420,7 @@ def _default_settings(cls):
),
output_settings_nvt=NVTOutputSettings(
mdp_file="nvt.mdp",
grompp_mdp_file="mdout_nvt.mdp",
tpr_file="nvt.tpr",
gro_file="nvt.gro",
trr_file="nvt.trr",
Expand All @@ -423,6 +431,7 @@ def _default_settings(cls):
),
output_settings_npt=NPTOutputSettings(
mdp_file="npt.mdp",
grompp_mdp_file="mdout_npt.mdp",
tpr_file="npt.tpr",
gro_file="npt.gro",
trr_file="npt.trr",
Expand Down Expand Up @@ -735,6 +744,7 @@ def _run_gromacs(
cpt: str,
log: str,
edr: str,
out_mdp: str,
engine_settings: GromacsEngineSettings,
shared_basebath: pathlib.Path,
):
Expand All @@ -754,6 +764,7 @@ def _run_gromacs(
cpt: str
log: str
edr: str
out_mdp: str
engine_settings: GromacsEngineSettings
shared_basebath: Pathlike, optional
Where to run the calculation, defaults to current working directory
Expand All @@ -773,6 +784,8 @@ def _run_gromacs(
top,
"-o",
tpr,
"-po",
shared_basebath / out_mdp,
],
stdin=subprocess.PIPE,
)
Expand Down Expand Up @@ -894,6 +907,7 @@ def _execute(
output_settings_em.cpt_file,
output_settings_em.log_file,
output_settings_em.edr_file,
output_settings_em.grompp_mdp_file,
engine_settings,
ctx.shared,
)
Expand All @@ -904,6 +918,7 @@ def _execute(
output_dict["edr_em"] = shared_basepath / output_settings_em.edr_file
output_dict["log_em"] = shared_basepath / output_settings_em.log_file
output_dict["cpt_em"] = shared_basepath / output_settings_em.cpt_file
output_dict["grompp_mdp_em"] = shared_basepath / output_settings_em.grompp_mdp_file

# ToDo: Should we disallow running MD without EM?
# Run NVT
Expand All @@ -929,6 +944,7 @@ def _execute(
output_settings_nvt.cpt_file,
output_settings_nvt.log_file,
output_settings_nvt.edr_file,
output_settings_nvt.grompp_mdp_file,
engine_settings,
ctx.shared,
)
Expand All @@ -939,6 +955,7 @@ def _execute(
output_dict["edr_nvt"] = shared_basepath / output_settings_nvt.edr_file
output_dict["log_nvt"] = shared_basepath / output_settings_nvt.log_file
output_dict["cpt_nvt"] = shared_basepath / output_settings_nvt.cpt_file
output_dict["grompp_mdp_nvt"] = shared_basepath / output_settings_nvt.grompp_mdp_file

# Run NPT MD simulation
if sim_settings_npt.nsteps > 0:
Expand Down Expand Up @@ -967,6 +984,7 @@ def _execute(
output_settings_npt.cpt_file,
output_settings_npt.log_file,
output_settings_npt.edr_file,
output_settings_npt.grompp_mdp_file,
engine_settings,
ctx.shared,
)
Expand All @@ -977,5 +995,6 @@ def _execute(
output_dict["edr_npt"] = shared_basepath / output_settings_npt.edr_file
output_dict["log_npt"] = shared_basepath / output_settings_npt.log_file
output_dict["cpt_npt"] = shared_basepath / output_settings_npt.cpt_file
output_dict["grompp_mdp_nvt"] = shared_basepath / output_settings_nvt.grompp_mdp_file

return output_dict
6 changes: 6 additions & 0 deletions openfe_gromacs/protocols/gromacs_md/md_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ class OutputSettings(SettingsBaseModel):
Filename for the mdp file for running simulations in Gromacs.
Default 'em.mdp'
"""
grompp_mdp_file: str = "mdout_em.mdp"
"""
Filename for the mdp file that gmx grompp outputs. This file contains
comment lines, as well as the input that gmx grompp has read.
Default 'mdout_em.mdp'
"""
tpr_file: str = "em.tpr"
"""
Filename for the tpr file for running simulations in Gromacs.
Expand Down
1 change: 1 addition & 0 deletions openfe_gromacs/protocols/gromacs_utils/write_mdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def dict2mdp(settings_dict: dict, shared_basepath):
non_mdps = [
"forcefield_cache",
"mdp_file",
"grompp_mdp_file",
"tpr_file",
"trr_file",
"xtc_file",
Expand Down
Binary file modified openfe_gromacs/tests/data/MDProtocol_json_results.gz
Binary file not shown.
Binary file modified openfe_gromacs/tests/data/MDProtocol_json_results_no_EM.gz
Binary file not shown.
8 changes: 4 additions & 4 deletions openfe_gromacs/tests/protocols/test_gromacs_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def test_get_mdp_filenames(self, protocolresult):
def test_get_filenames_em(self, protocolresult):
dict_file_path = protocolresult.get_filenames_em()
assert isinstance(dict_file_path, dict)
assert len(dict_file_path) == 7
assert len(dict_file_path) == 8
for name, file_path in dict_file_path.items():
assert isinstance(file_path, list)
assert len(file_path) == 1
Expand All @@ -264,7 +264,7 @@ def test_get_xtc_em_filename(self, protocolresult):
def test_get_filenames_nvt(self, protocolresult):
dict_file_path = protocolresult.get_filenames_nvt()
assert isinstance(dict_file_path, dict)
assert len(dict_file_path) == 7
assert len(dict_file_path) == 8
for name, file_path in dict_file_path.items():
assert isinstance(file_path, list)
assert len(file_path) == 1
Expand All @@ -285,7 +285,7 @@ def test_get_xtc_nvt_filenames(self, protocolresult):
def test_get_filenames_npt(self, protocolresult):
dict_file_path = protocolresult.get_filenames_npt()
assert isinstance(dict_file_path, dict)
assert len(dict_file_path) == 7
assert len(dict_file_path) == 8
for name, file_path in dict_file_path.items():
assert isinstance(file_path, list)
assert len(file_path) == 1
Expand Down Expand Up @@ -323,7 +323,7 @@ def test_reload_protocol_result(self, md_json_no_em):
def test_get_filenames_em(self, protocolresult):
dict_file_path = protocolresult.get_filenames_em()
assert isinstance(dict_file_path, dict)
assert len(dict_file_path) == 7
assert len(dict_file_path) == 8
for name, file_path in dict_file_path.items():
assert isinstance(file_path, type(None))

Expand Down

0 comments on commit db009fe

Please sign in to comment.