Skip to content

Commit

Permalink
dry test #1
Browse files Browse the repository at this point in the history
  • Loading branch information
IAlibay committed Sep 19, 2024
1 parent 7c1ef94 commit 325657f
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 13 deletions.
12 changes: 7 additions & 5 deletions src/pontibus/protocols/solvation/asfe_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
MDOutputSettings,
InterchangeFFSettings,
PackmolSolvationSettings,
AlchemicalSettings,
ExperimentalAlchemicalSettings,
LambdaSettings,
)
from pontibus.protocols.solvation import (
Expand Down Expand Up @@ -71,15 +71,17 @@ def _default_settings(cls):
"""
return ASFESettings(
protocol_repeats=3,
solvent_forcefield_settings=InterchangeFFSettings(),
solvent_forcefield_settings=InterchangeFFSettings(
nonbonded_method='pme',
),
vacuum_forcefield_settings=InterchangeFFSettings(
nonbonded_method="nocutoff",
),
thermo_settings=ThermoSettings(
temperature=298.15 * unit.kelvin,
pressure=1 * unit.bar,
),
alchemical_settings=AlchemicalSettings(),
alchemical_settings=ExperimentalAlchemicalSettings(),
lambda_settings=LambdaSettings(
lambda_elec=[
0.0,
Expand Down Expand Up @@ -355,7 +357,7 @@ def _handle_settings(self) -> dict[str, gufe.settings.SettingsBaseModel]:
* thermo_settings : ThermoSettings
* charge_settings : OpenFFPartialChargeSettings
* solvation_settings : PackmolSolvationSettings
* alchemical_settings : AlchemicalSettings
* alchemical_settings : ExperimentalAlchemicalSettings
* lambda_settings : LambdaSettings
* engine_settings : OpenMMEngineSettings
* integrator_settings : IntegratorSettings
Expand Down Expand Up @@ -437,7 +439,7 @@ def _handle_settings(self) -> dict[str, gufe.settings.SettingsBaseModel]:
* thermo_settings : ThermoSettings
* charge_settings : OpenFFPartialChargeSettings
* solvation_settings : PackmolSolvationSettings
* alchemical_settings : AlchemicalSettings
* alchemical_settings : ExperimentalAlchemicalSettings
* lambda_settings : LambdaSettings
* engine_settings : OpenMMEngineSettings
* integrator_settings : IntegratorSettings
Expand Down
13 changes: 6 additions & 7 deletions src/pontibus/protocols/solvation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def _get_omm_objects(
* For now this method solely calls interchange system creation for
solvation.
"""

if self.verbose:
self.logger.info("Parameterizing system")

Expand All @@ -179,12 +178,12 @@ def _get_omm_objects(
# Create your interchange object
with without_oechem_backend():
interchange, comp_resids = interchange_packmol_creation(
settings["forcefield_settings"],
settings["solvation_settings"],
protein_component,
solvent_component,
solvent_offmol,
smc_components,
ffsettings=settings["forcefield_settings"],
solvation_settings=settings["solvation_settings"],
smc_components=smc_components,
protein_component=protein_component,
solvent_component=solvent_component,
solvent_offmol=solvent_offmol,
)

# Get omm objects back
Expand Down
9 changes: 8 additions & 1 deletion src/pontibus/protocols/solvation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
from pydantic.v1 import validator


class ExperimentalAlchemicalSettings(AlchemicalSettings):
experimental: bool = False
"""
Turn on experimental alchemy settings
"""


class InterchangeFFSettings(BaseForceFieldSettings):
"""
Parameters to set up the force field using Interchange and the
Expand All @@ -56,7 +63,7 @@ class InterchangeFFSettings(BaseForceFieldSettings):
]
"""List of force field ffxmls to apply"""

nonbonded_method = "PME", "NoCutoff"
nonbonded_method: Literal['pme', 'nocutoff'] = "pme"
"""
Method for treating nonbonded interactions, currently only PME and
NoCutoff are allowed. Default PME.
Expand Down
Empty file.
Empty file.
51 changes: 51 additions & 0 deletions src/pontibus/tests/protocols/solvation/test_dry_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This code is part of OpenFE and is licensed under the MIT license.
# For details, see https://github.com/OpenFreeEnergy/openfe
import pytest
from gufe import ChemicalSystem
from pontibus.protocols.solvation import ASFEProtocol, ASFESolventUnit, ASFEVacuumUnit
from pontibus.components import ExtendedSolventComponent


@pytest.mark.parametrize("method", ["repex", "sams", "independent", "InDePeNdENT"])
def test_dry_run_vacuum_benzene(benzene_modifications, method, tmpdir):
s = ASFEProtocol.default_settings()
s.protocol_repeats = 1
s.vacuum_simulation_settings.sampler_method = method

protocol = ASFEProtocol(
settings=s,
)

stateA = ChemicalSystem(
{
"benzene": benzene_modifications["benzene"],
"solvent": ExtendedSolventComponent(),
}
)

stateB = ChemicalSystem(
{
"solvent": ExtendedSolventComponent(),
}
)

# Create DAG from protocol, get the vacuum and solvent units
# and eventually dry run the first vacuum unit
dag = protocol.create(
stateA=stateA,
stateB=stateB,
mapping=None,
)
prot_units = list(dag.protocol_units)

assert len(prot_units) == 2

vac_unit = [u for u in prot_units if isinstance(u, ASFEVacuumUnit)]
sol_unit = [u for u in prot_units if isinstance(u, ASFESolventUnit)]

assert len(vac_unit) == 1
assert len(sol_unit) == 1

with tmpdir.as_cwd():
vac_sampler = vac_unit[0].run(dry=True)["debug"]["sampler"]
assert not vac_sampler.is_periodic

0 comments on commit 325657f

Please sign in to comment.