From 83c91443783f072f772925b3bc6d47f6b7cafc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Pulido?= <2949729+ijpulidos@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:04:23 -0400 Subject: [PATCH 1/3] WIP -- Initial proposal. --- feflow/protocols/nonequilibrium_cycling.py | 19 +++++++++++++++---- feflow/utils/system_validation.py | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 feflow/utils/system_validation.py diff --git a/feflow/protocols/nonequilibrium_cycling.py b/feflow/protocols/nonequilibrium_cycling.py index d33c2e9e..9e879b3e 100644 --- a/feflow/protocols/nonequilibrium_cycling.py +++ b/feflow/protocols/nonequilibrium_cycling.py @@ -913,15 +913,26 @@ def _create( self, stateA: ChemicalSystem, stateB: ChemicalSystem, - mapping: Optional[dict[str, ComponentMapping]] = None, + mapping: Optional[ComponentMapping], extends: Optional[ProtocolDAGResult] = None, ) -> list[ProtocolUnit]: - # Handle parameters - if mapping is None: - raise ValueError("`mapping` is required for this Protocol") + from feflow.utils import system_validation + # TODO: enable extending https://github.com/choderalab/feflow/pull/44 if extends: raise NotImplementedError("Can't extend simulations yet") + # TODO: Validate mapping -- comps gufe keys are the same + system_validation.validate_mappings(stateA, stateB, mapping) + + # Validate alchemical components + alchem_comps = system_validation.get_alchemical_components(stateA, stateB) + system_validation.validate_alchemical_components(alchem_comps, mapping) + + # Validate protein and solvent components + system_validation.validate_protein(stateA) + nonbonded = self.settings.forcefield_settings.nonbonded_method + system_validation.validate_solvent(stateA, nonbonded) + # inputs to `ProtocolUnit.__init__` should either be `Gufe` objects # or JSON-serializable objects num_cycles = self.settings.num_cycles diff --git a/feflow/utils/system_validation.py b/feflow/utils/system_validation.py new file mode 100644 index 00000000..d1ad4904 --- /dev/null +++ b/feflow/utils/system_validation.py @@ -0,0 +1,22 @@ +""" +Utility functions that can help validating chemical systems and its components such that they +make sense for protocols to use. +""" +# TODO: Migrate utility functions from openfe to this module +from openfe.protocols.openmm_utils.system_validation import get_alchemical_components as _ofe_get_alchemical_components +from openfe.protocols.openmm_utils.system_validation import validate_solvent as _ofe_validate_solvent +from openfe.protocols.openmm_utils.system_validation import validate_protein as _ofe_validate_protein +from openfe.protocols.openmm_rfe.equil_rfe_methods import _validate_alchemical_components + +get_alchemical_components = _ofe_get_alchemical_components +validate_solvent = _ofe_validate_solvent +validate_protein = _ofe_validate_protein +validate_alchemical_components = _validate_alchemical_components + + +# TODO: Implement function to validate mappings -- comps are the same gufe key compared to state +def validate_mappings(state_a, state_b, mapping): + """ + Validate that the components in the states and the mapping are the correct ones. + """ + raise NotImplementedError("Function not implemented.") \ No newline at end of file From 5c2041aab8855ae3cc152e207d50db9b68bc20a9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 26 Jul 2024 04:05:34 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- feflow/protocols/nonequilibrium_cycling.py | 1 + feflow/utils/system_validation.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/feflow/protocols/nonequilibrium_cycling.py b/feflow/protocols/nonequilibrium_cycling.py index 9e879b3e..e03febce 100644 --- a/feflow/protocols/nonequilibrium_cycling.py +++ b/feflow/protocols/nonequilibrium_cycling.py @@ -917,6 +917,7 @@ def _create( extends: Optional[ProtocolDAGResult] = None, ) -> list[ProtocolUnit]: from feflow.utils import system_validation + # TODO: enable extending https://github.com/choderalab/feflow/pull/44 if extends: raise NotImplementedError("Can't extend simulations yet") diff --git a/feflow/utils/system_validation.py b/feflow/utils/system_validation.py index d1ad4904..e16dc10a 100644 --- a/feflow/utils/system_validation.py +++ b/feflow/utils/system_validation.py @@ -2,11 +2,20 @@ Utility functions that can help validating chemical systems and its components such that they make sense for protocols to use. """ + # TODO: Migrate utility functions from openfe to this module -from openfe.protocols.openmm_utils.system_validation import get_alchemical_components as _ofe_get_alchemical_components -from openfe.protocols.openmm_utils.system_validation import validate_solvent as _ofe_validate_solvent -from openfe.protocols.openmm_utils.system_validation import validate_protein as _ofe_validate_protein -from openfe.protocols.openmm_rfe.equil_rfe_methods import _validate_alchemical_components +from openfe.protocols.openmm_utils.system_validation import ( + get_alchemical_components as _ofe_get_alchemical_components, +) +from openfe.protocols.openmm_utils.system_validation import ( + validate_solvent as _ofe_validate_solvent, +) +from openfe.protocols.openmm_utils.system_validation import ( + validate_protein as _ofe_validate_protein, +) +from openfe.protocols.openmm_rfe.equil_rfe_methods import ( + _validate_alchemical_components, +) get_alchemical_components = _ofe_get_alchemical_components validate_solvent = _ofe_validate_solvent @@ -19,4 +28,4 @@ def validate_mappings(state_a, state_b, mapping): """ Validate that the components in the states and the mapping are the correct ones. """ - raise NotImplementedError("Function not implemented.") \ No newline at end of file + raise NotImplementedError("Function not implemented.") From d11dd0a26f7f3bd9b0568feb619f3b71aa1a8caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Pulido?= <2949729+ijpulidos@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:12:41 -0400 Subject: [PATCH 3/3] changing name for GHA job differentiation. --- .github/workflows/rc-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rc-test.yaml b/.github/workflows/rc-test.yaml index e487396e..895e741c 100644 --- a/.github/workflows/rc-test.yaml +++ b/.github/workflows/rc-test.yaml @@ -23,7 +23,7 @@ defaults: jobs: tests: runs-on: ${{ matrix.os }}-latest - name: "💻-${{matrix.os }} 🐍-${{ matrix.python-version }}" + name: "💻-${{matrix.os }} 🐍-${{ matrix.python-version }} OpenFE RC" strategy: fail-fast: false matrix: