From aceb0e4ad162a9d98a7aacca47876698fa006a21 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Wed, 18 Oct 2023 13:58:03 +0100 Subject: [PATCH 1/2] Pass match_water through to specialised water model functions. [closes #185] --- python/BioSimSpace/Sandpit/Exscientia/Solvent/_solvent.py | 1 + python/BioSimSpace/Solvent/_solvent.py | 1 + 2 files changed, 2 insertions(+) diff --git a/python/BioSimSpace/Sandpit/Exscientia/Solvent/_solvent.py b/python/BioSimSpace/Sandpit/Exscientia/Solvent/_solvent.py index 7e3d4e944..0bcb4a682 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/Solvent/_solvent.py +++ b/python/BioSimSpace/Sandpit/Exscientia/Solvent/_solvent.py @@ -142,6 +142,7 @@ def solvate( ion_conc, is_neutral, is_aligned, + match_water, work_dir, property_map, ) diff --git a/python/BioSimSpace/Solvent/_solvent.py b/python/BioSimSpace/Solvent/_solvent.py index 7e3d4e944..0bcb4a682 100644 --- a/python/BioSimSpace/Solvent/_solvent.py +++ b/python/BioSimSpace/Solvent/_solvent.py @@ -142,6 +142,7 @@ def solvate( ion_conc, is_neutral, is_aligned, + match_water, work_dir, property_map, ) From 0ab849a41a9d414cd217d845f9d9ca574a43c174 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Wed, 18 Oct 2023 16:30:50 +0100 Subject: [PATCH 2/2] Test generic solvate function as well as specialised tip3p function. --- tests/Sandpit/Exscientia/Solvent/test_solvent.py | 12 +++++++++--- tests/Solvent/test_solvent.py | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/Sandpit/Exscientia/Solvent/test_solvent.py b/tests/Sandpit/Exscientia/Solvent/test_solvent.py index f3a0b8978..e4fb56b26 100644 --- a/tests/Sandpit/Exscientia/Solvent/test_solvent.py +++ b/tests/Sandpit/Exscientia/Solvent/test_solvent.py @@ -1,11 +1,13 @@ import pytest import tempfile +from functools import partial + from sire.legacy.IO import GroTop import BioSimSpace.Sandpit.Exscientia as BSS -from tests.Sandpit.Exscientia.conftest import has_gromacs +from tests.conftest import has_gromacs @pytest.fixture(scope="module") @@ -18,8 +20,12 @@ def system(): @pytest.mark.parametrize("match_water", [True, False]) +@pytest.mark.parametrize( + "function", + [partial(BSS.Solvent.solvate, "tip3p"), BSS.Solvent.tip3p], +) @pytest.mark.skipif(not has_gromacs, reason="Requires GROMACS to be installed") -def test_crystal_water(system, match_water): +def test_crystal_water(system, match_water, function): """ Test that user defined crystal waters can be preserved during solvation and on write to GroTop format. @@ -35,7 +41,7 @@ def test_crystal_water(system, match_water): box, angles = BSS.Box.cubic(5.5 * BSS.Units.Length.nanometer) # Create the solvated system. - solvated = BSS.Solvent.tip3p(system, box, angles, match_water=match_water) + solvated = function(system, box, angles, match_water=match_water) # Search for the crystal waters in the solvated system. try: diff --git a/tests/Solvent/test_solvent.py b/tests/Solvent/test_solvent.py index 7edf20cbf..185bb6373 100644 --- a/tests/Solvent/test_solvent.py +++ b/tests/Solvent/test_solvent.py @@ -1,6 +1,8 @@ import pytest import tempfile +from functools import partial + from sire.legacy.IO import GroTop import BioSimSpace as BSS @@ -18,8 +20,12 @@ def system(): @pytest.mark.parametrize("match_water", [True, False]) +@pytest.mark.parametrize( + "function", + [partial(BSS.Solvent.solvate, "tip3p"), BSS.Solvent.tip3p], +) @pytest.mark.skipif(not has_gromacs, reason="Requires GROMACS to be installed") -def test_crystal_water(system, match_water): +def test_crystal_water(system, match_water, function): """ Test that user defined crystal waters can be preserved during solvation and on write to GroTop format. @@ -35,7 +41,7 @@ def test_crystal_water(system, match_water): box, angles = BSS.Box.cubic(5.5 * BSS.Units.Length.nanometer) # Create the solvated system. - solvated = BSS.Solvent.tip3p(system, box, angles, match_water=match_water) + solvated = function(system, box, angles, match_water=match_water) # Search for the crystal waters in the solvated system. try: