Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gather and integration test #46

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions openfe_gromacs/tests/protocols/test_gromacs_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,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
Expand Down Expand Up @@ -164,9 +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
):
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"
"""
Expand Down Expand Up @@ -199,6 +197,46 @@ def test_dry_many_molecules_solvent(
)


def test_gather(benzene_system, tmp_path_factory):
hannahbaumann marked this conversation as resolved.
Show resolved Hide resolved
# 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
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check the other attributes of the results object? I.e. what else do you expect to be getting out of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean testing the get_x functions here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a bit tedious but you can probably program/template a lot of it using something like getattr and a loop.



class TestProtocolResult:
@pytest.fixture()
def protocolresult(self, md_json):
Expand Down
34 changes: 34 additions & 0 deletions openfe_gromacs/tests/protocols/test_gromacs_md_slow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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 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 = 5000
settings.simulation_settings_nvt.nsteps = 10000
settings.simulation_settings_npt.nsteps = 100000
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,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a full integration test, you really want to run "this thing under normal circumstances".

What you're testing is "is this thing yielding the results I would expect".

To do that you could test:

  1. Am I getting the right temperature?
  2. Am I getting the right pressure?
  3. Is my box volume equilibrating during the NPT phase?
  4. Is my ligand sticking around the binding site as I would expect it to?
  5. Is my energy reasonably well maintained?

Because you're marking it with the "this is really expensive" flag, it's perfectly ok to make this a much longer test (many more steps, etc...).

Loading