From d3e9cab3459daf1df961b6af0cca8f69c1d9dbdc Mon Sep 17 00:00:00 2001 From: hannahbaumann Date: Wed, 25 Sep 2024 10:38:54 +0200 Subject: [PATCH 1/6] Add gather test --- .../tests/protocols/test_gromacs_md.py | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/openfe_gromacs/tests/protocols/test_gromacs_md.py b/openfe_gromacs/tests/protocols/test_gromacs_md.py index 76c5431..c7b2216 100644 --- a/openfe_gromacs/tests/protocols/test_gromacs_md.py +++ b/openfe_gromacs/tests/protocols/test_gromacs_md.py @@ -131,7 +131,7 @@ def test_unit_tagging_setup_unit(solvent_protocol_dag, tmpdir): assert len(repeats) == 1 -def test_dry_run_ffcache_none(benzene_system, monkeypatch, tmp_path_factory): +def test_dry_run_ffcache_none(benzene_system, tmp_path_factory): settings = GromacsMDProtocol.default_settings() settings.output_settings_em.forcefield_cache = None settings.simulation_settings_em.nsteps = 10 @@ -164,7 +164,7 @@ def test_dry_run_ffcache_none(benzene_system, monkeypatch, tmp_path_factory): def test_dry_many_molecules_solvent( - benzene_many_solv_system, monkeypatch, tmp_path_factory +benzene_many_solv_system, tmp_path_factory ): """ A basic test flushing "will it work if you pass multiple molecules" @@ -198,6 +198,47 @@ def test_dry_many_molecules_solvent( ) +def test_gather(benzene_system, tmp_path_factory): + # check .gather behaves as expected + # Can't use mock.path since we need the outputs from the Setup Unit + # to execute the Run Unit + settings = GromacsMDProtocol.default_settings() + settings.output_settings_em.forcefield_cache = None + settings.simulation_settings_em.nsteps = 10 + settings.simulation_settings_nvt.nsteps = 10 + settings.simulation_settings_npt.nsteps = 1 + settings.simulation_settings_em.rcoulomb = 1.0 * off_unit.nanometer + settings.simulation_settings_nvt.rcoulomb = 1.0 * off_unit.nanometer + settings.simulation_settings_npt.rcoulomb = 1.0 * off_unit.nanometer + protocol = GromacsMDProtocol( + settings=settings, + ) + + # create DAG from protocol and take first (and only) work unit from within + dag = protocol.create( + stateA=benzene_system, + stateB=benzene_system, + mapping=None, + ) + + shared_temp = tmp_path_factory.mktemp("shared") + scratch_temp = tmp_path_factory.mktemp("scratch") + dagres = gufe.protocols.execute_DAG( + dag, + shared_basedir=shared_temp, + scratch_basedir=scratch_temp, + keep_shared=False, + n_retries=3, + ) + prot = GromacsMDProtocol( + settings=settings + ) + + res = prot.gather([dagres]) + + assert isinstance(res, GromacsMDProtocolResult) + + class TestProtocolResult: @pytest.fixture() def protocolresult(self, md_json): From 60adc2b84c6df8f2cbfe87faa7caf0cd5803bed8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 08:40:34 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- openfe_gromacs/tests/protocols/test_gromacs_md.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/openfe_gromacs/tests/protocols/test_gromacs_md.py b/openfe_gromacs/tests/protocols/test_gromacs_md.py index c7b2216..16fa5ab 100644 --- a/openfe_gromacs/tests/protocols/test_gromacs_md.py +++ b/openfe_gromacs/tests/protocols/test_gromacs_md.py @@ -163,9 +163,7 @@ def test_dry_run_ffcache_none(benzene_system, tmp_path_factory): ) -def test_dry_many_molecules_solvent( -benzene_many_solv_system, tmp_path_factory -): +def test_dry_many_molecules_solvent(benzene_many_solv_system, tmp_path_factory): """ A basic test flushing "will it work if you pass multiple molecules" """ @@ -230,9 +228,7 @@ def test_gather(benzene_system, tmp_path_factory): keep_shared=False, n_retries=3, ) - prot = GromacsMDProtocol( - settings=settings - ) + prot = GromacsMDProtocol(settings=settings) res = prot.gather([dagres]) From e1e86f0662758ba72450b301cc01b4b1808173f2 Mon Sep 17 00:00:00 2001 From: hannahbaumann Date: Thu, 26 Sep 2024 14:31:50 +0200 Subject: [PATCH 3/6] Add integration test of protein-ligand MD --- .../tests/protocols/test_gromacs_md_slow.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 openfe_gromacs/tests/protocols/test_gromacs_md_slow.py diff --git a/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py b/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py new file mode 100644 index 0000000..7578c35 --- /dev/null +++ b/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py @@ -0,0 +1,38 @@ +# This code is part of OpenFE and is licensed under the MIT license. +# For details, see https://github.com/OpenFreeEnergy/openfe-gromacs + +import gufe +import pytest +from openff.units import unit as off_unit + +from openfe_gromacs.protocols.gromacs_md.md_methods import GromacsMDProtocol + + +@pytest.mark.integration +def test_protein_ligand_md(toluene_complex_system, tmp_path_factory): + settings = GromacsMDProtocol.default_settings() + settings.simulation_settings_em.nsteps = 10 + settings.simulation_settings_nvt.nsteps = 10 + settings.simulation_settings_npt.nsteps = 100 + settings.simulation_settings_em.rcoulomb = 1.0 * off_unit.nanometer + settings.simulation_settings_nvt.rcoulomb = 1.0 * off_unit.nanometer + settings.simulation_settings_npt.rcoulomb = 1.0 * off_unit.nanometer + protocol = GromacsMDProtocol( + settings=settings, + ) + + dag = protocol.create( + stateA=toluene_complex_system, + stateB=toluene_complex_system, + mapping=None, + ) + + shared_temp = tmp_path_factory.mktemp("shared") + scratch_temp = tmp_path_factory.mktemp("scratch") + gufe.protocols.execute_DAG( + dag, + shared_basedir=shared_temp, + scratch_basedir=scratch_temp, + keep_shared=False, + n_retries=3, + ) From a755d3778191bc677fc7ae067e8cb143ea3368fe Mon Sep 17 00:00:00 2001 From: hannahbaumann Date: Mon, 30 Sep 2024 10:27:31 +0200 Subject: [PATCH 4/6] Add explanation test --- openfe_gromacs/protocols/gromacs_md/md_methods.py | 1 - openfe_gromacs/tests/protocols/test_gromacs_md.py | 7 ++++--- openfe_gromacs/tests/protocols/test_gromacs_md_slow.py | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/openfe_gromacs/protocols/gromacs_md/md_methods.py b/openfe_gromacs/protocols/gromacs_md/md_methods.py index 99b6b61..19b77fa 100644 --- a/openfe_gromacs/protocols/gromacs_md/md_methods.py +++ b/openfe_gromacs/protocols/gromacs_md/md_methods.py @@ -20,7 +20,6 @@ from collections.abc import Iterable from typing import Any -import gmxapi as gmx import gufe import pint from gufe import ChemicalSystem, SmallMoleculeComponent, settings diff --git a/openfe_gromacs/tests/protocols/test_gromacs_md.py b/openfe_gromacs/tests/protocols/test_gromacs_md.py index 16fa5ab..d00babc 100644 --- a/openfe_gromacs/tests/protocols/test_gromacs_md.py +++ b/openfe_gromacs/tests/protocols/test_gromacs_md.py @@ -197,9 +197,10 @@ def test_dry_many_molecules_solvent(benzene_many_solv_system, tmp_path_factory): def test_gather(benzene_system, tmp_path_factory): - # check .gather behaves as expected - # Can't use mock.path since we need the outputs from the Setup Unit - # to execute the Run Unit + # check .gather behaves as expected: That gather correctly creates the + # results object + # This is running a full (short) simulation of benzene in water which is ok + # since this is a cheap simulation. settings = GromacsMDProtocol.default_settings() settings.output_settings_em.forcefield_cache = None settings.simulation_settings_em.nsteps = 10 diff --git a/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py b/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py index 7578c35..cf5e60e 100644 --- a/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py +++ b/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py @@ -13,10 +13,7 @@ def test_protein_ligand_md(toluene_complex_system, tmp_path_factory): settings = GromacsMDProtocol.default_settings() settings.simulation_settings_em.nsteps = 10 settings.simulation_settings_nvt.nsteps = 10 - settings.simulation_settings_npt.nsteps = 100 - settings.simulation_settings_em.rcoulomb = 1.0 * off_unit.nanometer - settings.simulation_settings_nvt.rcoulomb = 1.0 * off_unit.nanometer - settings.simulation_settings_npt.rcoulomb = 1.0 * off_unit.nanometer + settings.simulation_settings_npt.nsteps = 10000 protocol = GromacsMDProtocol( settings=settings, ) From 96861c9fe9e24f073cc37629a5d37f4a5708159b Mon Sep 17 00:00:00 2001 From: hannahbaumann Date: Mon, 30 Sep 2024 14:53:24 +0200 Subject: [PATCH 5/6] Make slow test much slower --- openfe_gromacs/tests/protocols/test_gromacs_md_slow.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py b/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py index cf5e60e..eafba82 100644 --- a/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py +++ b/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py @@ -11,9 +11,9 @@ @pytest.mark.integration def test_protein_ligand_md(toluene_complex_system, tmp_path_factory): settings = GromacsMDProtocol.default_settings() - settings.simulation_settings_em.nsteps = 10 - settings.simulation_settings_nvt.nsteps = 10 - settings.simulation_settings_npt.nsteps = 10000 + settings.simulation_settings_em.nsteps = 5000 + settings.simulation_settings_nvt.nsteps = 10000 + settings.simulation_settings_npt.nsteps = 100000 protocol = GromacsMDProtocol( settings=settings, ) From 15923e3151c85d09932adb056c487a02e1443a80 Mon Sep 17 00:00:00 2001 From: hannahbaumann Date: Tue, 1 Oct 2024 09:49:23 +0200 Subject: [PATCH 6/6] Remove unused import --- openfe_gromacs/tests/protocols/test_gromacs_md_slow.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py b/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py index eafba82..b3d0ac9 100644 --- a/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py +++ b/openfe_gromacs/tests/protocols/test_gromacs_md_slow.py @@ -3,7 +3,6 @@ import gufe import pytest -from openff.units import unit as off_unit from openfe_gromacs.protocols.gromacs_md.md_methods import GromacsMDProtocol