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: diff --git a/feflow/protocols/nonequilibrium_cycling.py b/feflow/protocols/nonequilibrium_cycling.py index d33c2e9e..e03febce 100644 --- a/feflow/protocols/nonequilibrium_cycling.py +++ b/feflow/protocols/nonequilibrium_cycling.py @@ -913,15 +913,27 @@ 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..e16dc10a --- /dev/null +++ b/feflow/utils/system_validation.py @@ -0,0 +1,31 @@ +""" +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.")