Files
openfe/docs/guide/setup/defining_protocols.rst
Hannah Baumann fc6689eaf1 User guide updates membrane (#1933)
* Membrane support prototype start

* Point to corresponding branch in gufe

* Make plain md protocol membrane ready

* Dry run for membrane system for debugging

* Add box vectors to modeller

* Adapt htf to allow for membrane barostat

* Fix test

* Add test files membrane

* Change test to cpu

* Prints for debugging

* Some more debugginh stuff, remove later

* Small fix

* Temporarily use branches for openmmtools and openmmforcefield

* Small fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* support membrane in gather

* First pass membrane support for SepTop protocol

* Change validation solvent

* Move changes in solvent validation to validate_solvent

* Some small fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add membrane test septop

* Change box vector units for handling membrane barostat

* Test box vectors SepTop more

* First pass at ABFE membrane prototype

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Remove some prints

* Revert box changes

* Some fixes in SepTop to fix tests

* Apply suggestion from @hannahbaumann

* Add tests for system creation

* FIx test

* Add ABFE membrane tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* More tests membrane septop and more dry outputs in septop

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add validation for box vector in ProteinMembraneComponent

* Adapt gather for membranes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* small changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Modify box vectors plain md

* Address review comments

* Remove unnecessary prints

* Subclass membrane test

* Small fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove unnecessary import

* Remove prints

* Small fix

* Small fix

* Larger change to checks for BaseSolventComponent, SolvatedPDBComponent, and adding barostat settings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Some more changes

* Small fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* ABFE enforce timestep complex solvent the same

* Update test files

* Update environment.yaml with new openmmtools and openmmforcefield versions

* Remove unnecessary checks for box_vectors which are handled in gufe

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update openfe/protocols/openmm_afe/equil_binding_afe_method.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Attempt at rewriting validate_solvent

* Move get barostat to self

* Simplify mapping in test

* Add validator for surface_tension and membrane barostat

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add membrane barostat to adaptive settings rfe protocol

* Add validation/warning for barostat component mismatch

* Fix tests (except CLI)

* More merge fixes

* Remove unnecessary imports

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add test files

* Update tests

* Add lipid ff in adaptive settings

* remove commented out lines

* Update test abfe

* Update ABFE results with new settings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix solvent validation

* change env to gufe main

* Apply suggestion from @hannahbaumann

* Remove files from before src layout change

* Update tests

* Small fix

* mark slow tests

* Update env file

* Small fix

* Update src/openfe/protocols/openmm_afe/equil_binding_afe_method.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Update src/openfe/protocols/openmm_afe/equil_binding_afe_method.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Update src/openfe/protocols/openmm_rfe/_rfe_utils/relative.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Update src/openfe/protocols/openmm_utils/system_validation.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Address review comments 1

* update doc string

* Update src/openfe/tests/protocols/openmm_abfe/test_abfe_protocol.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Update src/openfe/tests/protocols/openmm_abfe/test_abfe_protocol.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Update src/openfe/tests/protocols/openmm_abfe/test_abfe_protocol.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Update src/openfe/tests/protocols/openmm_abfe/test_abfe_protocol.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Address review comments 2

* Address review comments 3

* fix mypy

* Fix system creation tests

* Roundtrip box vectors to remove vec3 issues

* Roundtrip box vectors to remove vec3 issues

* Remove unnecessary imports

* Apply suggestion from @hannahbaumann

* Test mypy failure

* Test mypy failure 2

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* some fixes

* small fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update test files

* Update SepTop results settings

* add more tests for adaptive settings and others

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add news entry

* Fix for box vectors hybtop

* Make test slow again

* Make mypy happy

* try to make mypy happy again

* Adapt gather RFE membrane component types

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* use reference platform for the membrane energy test

* Add ChemicalSystem Component validation to Protocols

* Add test for chemicalsystem validation

* Apply suggestions from code review

Co-authored-by: Josh Horton <joshua.horton@openforcefield.org>

* Update with slight variation to @jthorton 's suggestion

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* point gufe back at main

* Drop lipid17 from adaptive settings

* just a tiny nit change

* fix typo

* Add extra class to openfecli check

* Add total particle checks to abfe protocol tests

* remove lipid17 check from adaptive settings

* remove lipid17 check from adaptive settings

* Add some checks for number of particles & residues

* Fix up some tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Minimized protein

* Update protein

* Revert back to old protein

* Apply suggestion from @hannahbaumann

* Remove box roundtrip and fix solvent from get_components

* Merge conflicts

* Update src/openfe/tests/protocols/openmm_abfe/test_abfe_protocol.py

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix merge conflict

* Forgot another one

* Move box roundtrip to _pre_equilibrate

* First go at modifying the user guide for membranes and ABFE and SepTop

* some small fixes

* Add adaptive_settings to user guide

* Add example code loading protein membrane

* Add box vector explanation

* Some smaller changes

* Make adaptive settings subheading

* Some more changes

* Add warning adaptive settings

* Update docs/guide/setup/defining_protocols.rst

Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>

* Addressing review comments

* some more updates

* Test out subheadings

* Restructure user guide

* merge conflicts

* Small fix

* some small updates

* addressing review comments

* Small fix

* address review comments

* small fix

* Add news entry

* Update docs/guide/setup/chemical_systems_and_thermodynamic_cycles.rst

Co-authored-by: Alyssa Travitz <31974495+atravitz@users.noreply.github.com>

* Update docs/guide/setup/defining_protocols.rst

Co-authored-by: Alyssa Travitz <31974495+atravitz@users.noreply.github.com>

* Update docs/guide/setup/chemical_systems_and_thermodynamic_cycles.rst

Co-authored-by: Alyssa Travitz <31974495+atravitz@users.noreply.github.com>

* Addres review comment

* Update docs/guide/setup/chemical_systems_and_thermodynamic_cycles.rst

Co-authored-by: Josh Horton <Josh.Horton@newcastle.ac.uk>

* Update docs/guide/setup/chemical_systems_and_thermodynamic_cycles.rst

Co-authored-by: Josh Horton <Josh.Horton@newcastle.ac.uk>

* Address review comment

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
Co-authored-by: Alyssa Travitz <31974495+atravitz@users.noreply.github.com>
Co-authored-by: Josh Horton <Josh.Horton@newcastle.ac.uk>
Co-authored-by: Josh Horton <joshua.horton@openforcefield.org>
2026-04-24 14:03:06 +02:00

104 lines
4.5 KiB
ReStructuredText

.. _defining-protocols:
Protocols in OpenFE
============================
A :class:`.Protocol` is a computational method for estimating the free energy difference between two chemical systems.
Just as there are multiple possible methods for estimating free energy differences,
there are multiple available ``Protocol``\s to choose from.
For example, included in the ``openfe`` package are the following:
* :class:`.RelativeHybridTopologyProtocol`
* :class:`.AbsoluteBindingProtocol`
* :class:`.SepTopProtocol`
* :class:`.AbsoluteSolvationProtocol`
* :class:`.PlainMDProtocol`
More protocols are in development, and a full list of available protocols
can be found at :ref:`userguide_protocols`.
Because :class:`.Protocol`\s share a common interface for how they are created and executed,
it is relatively straightforward to try out a new method,
or benchmark several to choose the best for a particular project.
Defining Settings and Creating Protocols
----------------------------------------
A ``Settings`` object contains all the parameters needed by a ``Protocol``.
Each ``Protocol`` has a ``.default_settings()`` method, which will provide a sensible default
starting point and relevant documentation.
.. TODO: print what a settings object looks like, or how you might define custom settings
For example, to create an instance of the OpenMM RFE Protocol with default settings::
from openfe.protocols import openmm_rfe
settings = openmm_rfe.RelativeHybridTopologyProtocol.default_settings()
protocol = openmm_rfe.RelativeHybridTopologyProtocol(settings)
``Protocol`` objects **cannot be modified once created**. This is crucial for data provenance.
Therefore, the ``Settings`` objects must be customised *before* the ``Protocol`` object is created.
For example, to customise the production run length of the RFE Protocol::
from openfe.protocols import openmm_rfe
settings = openmm_rfe.RelativeHybridTopologyProtocol.default_settings()
settings.simulation_settings.production_length = '10 ns'
protocol = openmm_rfe.RelativeHybridTopologyProtocol(settings)
Adaptive Settings
~~~~~~~~~~~~~~~~~
.. warning::
The ``_adaptive_settings()`` method is experimental and subject to change.
In addition to the ``.default_settings()`` method, some protocols
provide an ``_adaptive_settings`` method. This method generates recommended settings
based on properties of the input :class:`.ChemicalSystem`\s and, where required, the :class:`.AtomMapping`.
For example::
from openfe.protocols import openmm_rfe
settings = openmm_rfe.RelativeHybridTopologyProtocol._adaptive_settings(
stateA=stateA,
stateB=stateB,
mapping=mapping,
)
protocol = openmm_rfe.RelativeHybridTopologyProtocol(settings)
The adaptive settings may modify parameters based on properties of the input systems.
For example (:class:`.RelativeHybridTopologyProtocol`):
* Transformations involving a change in net charge use a larger number of lambda windows and longer production simulations.
* If both states contain a :class:`.ProteinComponent`, the solvation padding is set to 1 nm.
Optionally, you can pass a preexisting settings object to the ``_adaptive_settings`` method via the ``initial_settings`` argument. If provided, an adapted copy of these settings will be returned instead
of using the default settings.
In systems containing membrane-protein complexes (i.e. using a
:class:`.ProteinMembraneComponent`), adaptive settings select a membrane-appropriate barostat, the ``MonteCarloMembraneBarostat``.
Creating Transformations from Protocols
-----------------------------------------
With only ``settings`` defined, a ``Protocol`` contains no chemistry-specific information.
This means that a single ``Protocol`` object can be applied to multiple pairs of ``ChemicalSystem`` objects
to measure each free energy difference.
The :class:`.Transformation` class connects two ``ChemicalSystem`` objects with a ``Protocol``, and
often a :ref:`AtomMapping <userguide_mappings>` (depending on the system).
A ``Transformation`` object is then capable of creating computational work via the :func:`.Transformation.create()` method.
For further details on this, refer to the :ref:`userguide_execution` section.
Finally, a ``Protocol`` is responsible for using the data generated in this process to perform further analysis,
such as generating an estimate of the free energy difference.
For further details on this refer to the :ref:`userguide_results` section,
or the details of each method in :ref:`userguide_protocols`.