From 07738ca90661a21e28c3286fc3a13abfaca7c526 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Mon, 13 Jan 2025 09:29:01 -0800 Subject: [PATCH 01/20] add todo --- .../relative_alchemical_network_planner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfe/setup/alchemical_network_planner/relative_alchemical_network_planner.py b/openfe/setup/alchemical_network_planner/relative_alchemical_network_planner.py index 526651488..cf79b2f3b 100644 --- a/openfe/setup/alchemical_network_planner/relative_alchemical_network_planner.py +++ b/openfe/setup/alchemical_network_planner/relative_alchemical_network_planner.py @@ -303,7 +303,7 @@ class RBFEAlchemicalNetworkPlanner(RelativeAlchemicalNetworkPlanner): """ def __init__( self, - name: str = "easy_rbfe", + name: str = "easy_rbfe", # TODO: change this default to "" in 2.0 mappers: Optional[Iterable[LigandAtomMapper]] = None, mapping_scorer: Callable[[LigandAtomMapping], float] = default_lomap_score, ligand_network_planner: Callable = generate_minimal_spanning_network, From 538dac846d727b5b2ee8535bb33c1876b7a5ec12 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Mon, 13 Jan 2025 13:22:00 -0800 Subject: [PATCH 02/20] add n_protocol_repeats as cli parameter --- openfecli/parameters/__init__.py | 1 + openfecli/parameters/misc.py | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 openfecli/parameters/misc.py diff --git a/openfecli/parameters/__init__.py b/openfecli/parameters/__init__.py index f5a1cfa6f..171f0f84e 100644 --- a/openfecli/parameters/__init__.py +++ b/openfecli/parameters/__init__.py @@ -8,3 +8,4 @@ from .protein import PROTEIN from .molecules import MOL_DIR, COFACTORS from .plan_network_options import YAML_OPTIONS +from .misc import N_PROTOCOL_REPEATS diff --git a/openfecli/parameters/misc.py b/openfecli/parameters/misc.py new file mode 100644 index 000000000..e6d638fbc --- /dev/null +++ b/openfecli/parameters/misc.py @@ -0,0 +1,9 @@ +import click +from plugcli.params import Option + +N_PROTOCOL_REPEATS = Option( + "-n", + "--n-protocol-repeats", + type=click.INT, + help="The number of completely independent repeats of the entire sampling process.", +) From 7a7666b67cf309f0b69cbec756198b92debbf604 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Mon, 13 Jan 2025 13:29:30 -0800 Subject: [PATCH 03/20] add -n option to rbfe and rhfe planners --- openfecli/commands/plan_rbfe_network.py | 21 +++++++++++++++++---- openfecli/commands/plan_rhfe_network.py | 19 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/openfecli/commands/plan_rbfe_network.py b/openfecli/commands/plan_rbfe_network.py index 88beb4007..12952849a 100644 --- a/openfecli/commands/plan_rbfe_network.py +++ b/openfecli/commands/plan_rbfe_network.py @@ -5,7 +5,7 @@ from openfecli.utils import write, print_duration from openfecli import OFECommandPlugin from openfecli.parameters import ( - MOL_DIR, PROTEIN, OUTPUT_DIR, COFACTORS, YAML_OPTIONS, + MOL_DIR, PROTEIN, OUTPUT_DIR, COFACTORS, YAML_OPTIONS, N_PROTOCOL_REPEATS ) def plan_rbfe_network_main( @@ -16,6 +16,7 @@ def plan_rbfe_network_main( solvent, protein, cofactors, + protocol, ): """Utility method to plan a relative binding free energy network. @@ -34,7 +35,9 @@ def plan_rbfe_network_main( protein : ProteinComponent protein component for complex simulations, to which the ligands are bound cofactors : Iterable[SmallMoleculeComponent] - any cofactors alongisde the protein, can be empty list + any cofactors alongside the protein, can be empty list + protocol: Protocol + The Protocol to perform on the transformations within this network Returns ------- @@ -51,6 +54,7 @@ def plan_rbfe_network_main( mappers=mapper, mapping_scorer=mapping_scorer, ligand_network_planner=ligand_network_planner, + protocol=protocol ) alchemical_network = network_planner( ligands=small_molecules, solvent=solvent, protein=protein, @@ -83,11 +87,13 @@ def plan_rbfe_network_main( help=OUTPUT_DIR.kwargs["help"] + " Defaults to `./alchemicalNetwork`.", default="alchemicalNetwork", ) +@N_PROTOCOL_REPEATS.parameter(multiple=False, required=False, default=3, help=N_PROTOCOL_REPEATS.kwargs["help"]) @print_duration def plan_rbfe_network( molecules: list[str], protein: str, cofactors: tuple[str], yaml_settings: str, output_dir: str, + n_protocol_repeats: int, ): """ Plan a relative binding free energy network, saved as JSON files for @@ -115,6 +121,8 @@ def plan_rbfe_network( For more advanced setups, please consider using the Python layer of openfe. """ from openfecli.plan_alchemical_networks_utils import plan_alchemical_network_output + from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol + write("RBFE-NETWORK PLANNER") write("______________________") @@ -140,6 +148,10 @@ def plan_rbfe_network( cofactors = [] write("\t\tCofactors: " + str(cofactors)) + protocol_settings = RelativeHybridTopologyProtocol.default_settings() + protocol_settings.protocol_repeats = n_protocol_repeats + protocol = RelativeHybridTopologyProtocol(protocol_settings) + yaml_options = YAML_OPTIONS.get(yaml_settings) mapper_obj = yaml_options.mapper mapping_scorer = yaml_options.scorer @@ -150,9 +162,9 @@ def plan_rbfe_network( write("") write("Using Options:") - write("\tMapper: " + str(mapper_obj)) + write("\tMapper: " + str(mapper_obj)) - # TODO: write nice parameter + # TODO: write nice parameter write("\tMapping Scorer: " + str(mapping_scorer)) # TODO: write nice parameter @@ -169,6 +181,7 @@ def plan_rbfe_network( solvent=solvent, protein=protein, cofactors=cofactors, + protocol=protocol, ) write("\tDone") write("") diff --git a/openfecli/commands/plan_rhfe_network.py b/openfecli/commands/plan_rhfe_network.py index 90699d322..7508c4f3a 100644 --- a/openfecli/commands/plan_rhfe_network.py +++ b/openfecli/commands/plan_rhfe_network.py @@ -8,12 +8,12 @@ from openfecli.utils import write, print_duration from openfecli import OFECommandPlugin from openfecli.parameters import ( - MOL_DIR, MAPPER, OUTPUT_DIR, YAML_OPTIONS, + MOL_DIR, MAPPER, OUTPUT_DIR, YAML_OPTIONS, N_PROTOCOL_REPEATS ) def plan_rhfe_network_main( mapper, mapping_scorer, ligand_network_planner, small_molecules, - solvent, + solvent, protocol, ): """Utility method to plan a relative hydration free energy network. @@ -29,6 +29,8 @@ def plan_rhfe_network_main( molecules of the system solvent : SolventComponent Solvent component used for solvation + protocol: Protocol + The Protocol to perform on the transformations within this network Returns ------- @@ -44,6 +46,7 @@ def plan_rhfe_network_main( mappers=mapper, mapping_scorer=mapping_scorer, ligand_network_planner=ligand_network_planner, + protocol=protocol ) alchemical_network = network_planner( ligands=small_molecules, solvent=solvent @@ -70,8 +73,10 @@ def plan_rhfe_network_main( help=OUTPUT_DIR.kwargs["help"] + " Defaults to `./alchemicalNetwork`.", default="alchemicalNetwork", ) +@N_PROTOCOL_REPEATS.parameter(multiple=False, required=False, default=3, help=N_PROTOCOL_REPEATS.kwargs["help"]) + @print_duration -def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str): +def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str, n_protocol_repeats:int): """ Plan a relative hydration free energy network, saved as JSON files for the quickrun command. @@ -100,7 +105,8 @@ def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str) """ from openfecli.plan_alchemical_networks_utils import plan_alchemical_network_output - + from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol + write("RHFE-NETWORK PLANNER") write("______________________") write("") @@ -116,6 +122,10 @@ def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str) + " ".join([str(sm) for sm in small_molecules]) ) + protocol_settings = RelativeHybridTopologyProtocol.default_settings() + protocol_settings.protocol_repeats = n_protocol_repeats + protocol = RelativeHybridTopologyProtocol(protocol_settings) + yaml_options = YAML_OPTIONS.get(yaml_settings) mapper_obj = yaml_options.mapper mapping_scorer = yaml_options.scorer @@ -143,6 +153,7 @@ def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str) ligand_network_planner=ligand_network_planner, small_molecules=small_molecules, solvent=solvent, + protocol=protocol, ) write("\tDone") write("") From 797eb481cd28387091fb550eb7c9ce8c4524e7c7 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Mon, 13 Jan 2025 13:43:10 -0800 Subject: [PATCH 04/20] add news item --- news/add_n_protocol_repeats.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/add_n_protocol_repeats.rst diff --git a/news/add_n_protocol_repeats.rst b/news/add_n_protocol_repeats.rst new file mode 100644 index 000000000..fccfbf32e --- /dev/null +++ b/news/add_n_protocol_repeats.rst @@ -0,0 +1,23 @@ +**Added:** + +* Added ``--n-protocol-repeats`` CLI option to allow user-defined number of repeats per unit. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 8a1568d1732fc34972aee5368473130cc05043ba Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Mon, 13 Jan 2025 13:47:43 -0800 Subject: [PATCH 05/20] fix typo --- openfecli/tests/commands/test_plan_rbfe_network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openfecli/tests/commands/test_plan_rbfe_network.py b/openfecli/tests/commands/test_plan_rbfe_network.py index 25b703811..0a0678eed 100644 --- a/openfecli/tests/commands/test_plan_rbfe_network.py +++ b/openfecli/tests/commands/test_plan_rbfe_network.py @@ -63,7 +63,7 @@ def test_plan_rbfe_network_main(): for f in ['ligand_23.sdf', 'ligand_55.sdf'] ] with resources.files("openfe.tests.data") as d: - protein_compontent = ProteinComponent.from_pdb_file( + protein_component = ProteinComponent.from_pdb_file( str(d / "181l_only.pdb") ) @@ -74,7 +74,7 @@ def test_plan_rbfe_network_main(): ligand_network_planner=ligand_network_planning.generate_minimal_spanning_network, small_molecules=smallM_components, solvent=solvent_component, - protein=protein_compontent, + protein=protein_component, cofactors=[], ) print(alchemical_network) From 8aee297084deb5727c5d9c6429f8522fb11df30f Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Mon, 13 Jan 2025 13:59:19 -0800 Subject: [PATCH 06/20] update tests --- openfecli/tests/commands/test_plan_rbfe_network.py | 3 +++ openfecli/tests/commands/test_plan_rhfe_network.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/openfecli/tests/commands/test_plan_rbfe_network.py b/openfecli/tests/commands/test_plan_rbfe_network.py index 0a0678eed..536704c2f 100644 --- a/openfecli/tests/commands/test_plan_rbfe_network.py +++ b/openfecli/tests/commands/test_plan_rbfe_network.py @@ -9,6 +9,8 @@ plan_rbfe_network, plan_rbfe_network_main, ) +from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol + from gufe import AlchemicalNetwork from gufe.tokenization import JSON_HANDLER import json @@ -76,6 +78,7 @@ def test_plan_rbfe_network_main(): solvent=solvent_component, protein=protein_component, cofactors=[], + protocol=RelativeHybridTopologyProtocol(RelativeHybridTopologyProtocol.default_settings()), ) print(alchemical_network) diff --git a/openfecli/tests/commands/test_plan_rhfe_network.py b/openfecli/tests/commands/test_plan_rhfe_network.py index f5a72431f..890495365 100644 --- a/openfecli/tests/commands/test_plan_rhfe_network.py +++ b/openfecli/tests/commands/test_plan_rhfe_network.py @@ -10,6 +10,7 @@ plan_rhfe_network, plan_rhfe_network_main, ) +from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol @pytest.fixture(scope='session') @@ -54,6 +55,7 @@ def test_plan_rhfe_network_main(): ligand_network_planner=ligand_network_planning.generate_minimal_spanning_network, small_molecules=smallM_components, solvent=solvent_component, + protocol=RelativeHybridTopologyProtocol(RelativeHybridTopologyProtocol.default_settings()) ) assert alchemical_network From c23e33570eddb919e30e5dee12490611b5143053 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Tue, 14 Jan 2025 08:17:17 -0800 Subject: [PATCH 07/20] moving logic into main func --- openfecli/commands/plan_rbfe_network.py | 18 ++++++++---------- openfecli/commands/plan_rhfe_network.py | 15 ++++++++------- .../tests/commands/test_plan_rbfe_network.py | 3 +-- .../tests/commands/test_plan_rhfe_network.py | 4 +--- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/openfecli/commands/plan_rbfe_network.py b/openfecli/commands/plan_rbfe_network.py index 12952849a..e68aa4442 100644 --- a/openfecli/commands/plan_rbfe_network.py +++ b/openfecli/commands/plan_rbfe_network.py @@ -16,7 +16,7 @@ def plan_rbfe_network_main( solvent, protein, cofactors, - protocol, + n_protocol_repeats, ): """Utility method to plan a relative binding free energy network. @@ -36,8 +36,7 @@ def plan_rbfe_network_main( protein component for complex simulations, to which the ligands are bound cofactors : Iterable[SmallMoleculeComponent] any cofactors alongside the protein, can be empty list - protocol: Protocol - The Protocol to perform on the transformations within this network + n_protocol_repeats: int Returns ------- @@ -49,6 +48,11 @@ def plan_rbfe_network_main( from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import ( RBFEAlchemicalNetworkPlanner, ) + from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol + + protocol_settings = RelativeHybridTopologyProtocol.default_settings() + protocol_settings.protocol_repeats = n_protocol_repeats + protocol = RelativeHybridTopologyProtocol(protocol_settings) network_planner = RBFEAlchemicalNetworkPlanner( mappers=mapper, @@ -121,8 +125,6 @@ def plan_rbfe_network( For more advanced setups, please consider using the Python layer of openfe. """ from openfecli.plan_alchemical_networks_utils import plan_alchemical_network_output - from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol - write("RBFE-NETWORK PLANNER") write("______________________") @@ -148,10 +150,6 @@ def plan_rbfe_network( cofactors = [] write("\t\tCofactors: " + str(cofactors)) - protocol_settings = RelativeHybridTopologyProtocol.default_settings() - protocol_settings.protocol_repeats = n_protocol_repeats - protocol = RelativeHybridTopologyProtocol(protocol_settings) - yaml_options = YAML_OPTIONS.get(yaml_settings) mapper_obj = yaml_options.mapper mapping_scorer = yaml_options.scorer @@ -181,7 +179,7 @@ def plan_rbfe_network( solvent=solvent, protein=protein, cofactors=cofactors, - protocol=protocol, + n_protocol_repeats=n_protocol_repeats, ) write("\tDone") write("") diff --git a/openfecli/commands/plan_rhfe_network.py b/openfecli/commands/plan_rhfe_network.py index 7508c4f3a..15ea4652d 100644 --- a/openfecli/commands/plan_rhfe_network.py +++ b/openfecli/commands/plan_rhfe_network.py @@ -13,7 +13,7 @@ def plan_rhfe_network_main( mapper, mapping_scorer, ligand_network_planner, small_molecules, - solvent, protocol, + solvent, n_protocol_repeats, ): """Utility method to plan a relative hydration free energy network. @@ -41,6 +41,12 @@ def plan_rhfe_network_main( from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import ( RHFEAlchemicalNetworkPlanner ) + from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol + + + protocol_settings = RelativeHybridTopologyProtocol.default_settings() + protocol_settings.protocol_repeats = n_protocol_repeats + protocol = RelativeHybridTopologyProtocol(protocol_settings) network_planner = RHFEAlchemicalNetworkPlanner( mappers=mapper, @@ -105,7 +111,6 @@ def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str, """ from openfecli.plan_alchemical_networks_utils import plan_alchemical_network_output - from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol write("RHFE-NETWORK PLANNER") write("______________________") @@ -122,10 +127,6 @@ def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str, + " ".join([str(sm) for sm in small_molecules]) ) - protocol_settings = RelativeHybridTopologyProtocol.default_settings() - protocol_settings.protocol_repeats = n_protocol_repeats - protocol = RelativeHybridTopologyProtocol(protocol_settings) - yaml_options = YAML_OPTIONS.get(yaml_settings) mapper_obj = yaml_options.mapper mapping_scorer = yaml_options.scorer @@ -153,7 +154,7 @@ def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str, ligand_network_planner=ligand_network_planner, small_molecules=small_molecules, solvent=solvent, - protocol=protocol, + n_protocol_repeats=n_protocol_repeats, ) write("\tDone") write("") diff --git a/openfecli/tests/commands/test_plan_rbfe_network.py b/openfecli/tests/commands/test_plan_rbfe_network.py index 536704c2f..beb0a0d89 100644 --- a/openfecli/tests/commands/test_plan_rbfe_network.py +++ b/openfecli/tests/commands/test_plan_rbfe_network.py @@ -9,7 +9,6 @@ plan_rbfe_network, plan_rbfe_network_main, ) -from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol from gufe import AlchemicalNetwork from gufe.tokenization import JSON_HANDLER @@ -78,7 +77,7 @@ def test_plan_rbfe_network_main(): solvent=solvent_component, protein=protein_component, cofactors=[], - protocol=RelativeHybridTopologyProtocol(RelativeHybridTopologyProtocol.default_settings()), + n_protocol_repeats=3, ) print(alchemical_network) diff --git a/openfecli/tests/commands/test_plan_rhfe_network.py b/openfecli/tests/commands/test_plan_rhfe_network.py index 890495365..97ee497a1 100644 --- a/openfecli/tests/commands/test_plan_rhfe_network.py +++ b/openfecli/tests/commands/test_plan_rhfe_network.py @@ -10,8 +10,6 @@ plan_rhfe_network, plan_rhfe_network_main, ) -from openfe.setup.alchemical_network_planner.relative_alchemical_network_planner import RelativeHybridTopologyProtocol - @pytest.fixture(scope='session') def mol_dir_args(tmpdir_factory): @@ -55,7 +53,7 @@ def test_plan_rhfe_network_main(): ligand_network_planner=ligand_network_planning.generate_minimal_spanning_network, small_molecules=smallM_components, solvent=solvent_component, - protocol=RelativeHybridTopologyProtocol(RelativeHybridTopologyProtocol.default_settings()) + n_protocol_repeats=3, ) assert alchemical_network From 5eb1847ddad8468235a492d6f560d250fa296124 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Tue, 14 Jan 2025 09:04:44 -0800 Subject: [PATCH 08/20] add docstrings --- openfecli/commands/plan_rbfe_network.py | 1 + openfecli/commands/plan_rhfe_network.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/openfecli/commands/plan_rbfe_network.py b/openfecli/commands/plan_rbfe_network.py index e68aa4442..50e52f702 100644 --- a/openfecli/commands/plan_rbfe_network.py +++ b/openfecli/commands/plan_rbfe_network.py @@ -37,6 +37,7 @@ def plan_rbfe_network_main( cofactors : Iterable[SmallMoleculeComponent] any cofactors alongside the protein, can be empty list n_protocol_repeats: int + number of completely independent repeats of the entire sampling process Returns ------- diff --git a/openfecli/commands/plan_rhfe_network.py b/openfecli/commands/plan_rhfe_network.py index 15ea4652d..1ae1b7c59 100644 --- a/openfecli/commands/plan_rhfe_network.py +++ b/openfecli/commands/plan_rhfe_network.py @@ -29,8 +29,8 @@ def plan_rhfe_network_main( molecules of the system solvent : SolventComponent Solvent component used for solvation - protocol: Protocol - The Protocol to perform on the transformations within this network + n_protocol_repeats: int + number of completely independent repeats of the entire sampling process Returns ------- From b4fe6311e3d98de120d309438ded2662f7760912 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Wed, 15 Jan 2025 15:32:58 -0800 Subject: [PATCH 09/20] adding n_repeats test --- .../tests/commands/test_plan_rbfe_network.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/openfecli/tests/commands/test_plan_rbfe_network.py b/openfecli/tests/commands/test_plan_rbfe_network.py index beb0a0d89..9c3f93578 100644 --- a/openfecli/tests/commands/test_plan_rbfe_network.py +++ b/openfecli/tests/commands/test_plan_rbfe_network.py @@ -4,6 +4,7 @@ from importlib import resources import shutil from click.testing import CliRunner +from ..utils import assert_click_success from openfecli.commands.plan_rbfe_network import ( plan_rbfe_network, @@ -125,6 +126,30 @@ def test_plan_rbfe_network(mol_dir_args, protein_args): for l1, l2 in zip(expected_output_1, expected_output_2): assert l1 in result.output or l2 in result.output + network = AlchemicalNetwork.from_dict( + json.load(open("alchemicalNetwork/alchemicalNetwork.json"), cls=JSON_HANDLER.decoder) + ) + for edge in network.edges: + if "protein" in edge.stateA.components: + assert "cofactor1" in edge.stateA.components + assert "cofactor1" in edge.stateB.components + +@pytest.mark.parametrize(['input_n_repeat', 'expected_n_repeat'], [([], 3), (["-n 1"], 1)]) +def test_plan_rbfe_network_n_repeats(mol_dir_args, protein_args, input_n_repeat, expected_n_repeat): + runner = CliRunner() + + args = mol_dir_args + protein_args + input_n_repeat + + with runner.isolated_filesystem(): + result = runner.invoke(plan_rbfe_network, args) + assert_click_success(result) + + # make sure the number of repeats is correct + network = AlchemicalNetwork.from_dict( + json.load(open("alchemicalNetwork/alchemicalNetwork.json"), cls=JSON_HANDLER.decoder) + ) + for edge in network.edges: + assert edge.protocol.settings.protocol_repeats == expected_n_repeat @pytest.fixture def eg5_files(): From ca389182301a822492c5d41c3c6eb162bb3a2d69 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Wed, 15 Jan 2025 15:36:12 -0800 Subject: [PATCH 10/20] whitespace :( --- openfecli/commands/plan_rbfe_network.py | 4 ++-- openfecli/commands/plan_rhfe_network.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openfecli/commands/plan_rbfe_network.py b/openfecli/commands/plan_rbfe_network.py index 50e52f702..db1794793 100644 --- a/openfecli/commands/plan_rbfe_network.py +++ b/openfecli/commands/plan_rbfe_network.py @@ -161,9 +161,9 @@ def plan_rbfe_network( write("") write("Using Options:") - write("\tMapper: " + str(mapper_obj)) + write("\tMapper: " + str(mapper_obj)) - # TODO: write nice parameter + # TODO: write nice parameter write("\tMapping Scorer: " + str(mapping_scorer)) # TODO: write nice parameter diff --git a/openfecli/commands/plan_rhfe_network.py b/openfecli/commands/plan_rhfe_network.py index 1ae1b7c59..9620d3221 100644 --- a/openfecli/commands/plan_rhfe_network.py +++ b/openfecli/commands/plan_rhfe_network.py @@ -111,7 +111,7 @@ def plan_rhfe_network(molecules: List[str], yaml_settings: str, output_dir: str, """ from openfecli.plan_alchemical_networks_utils import plan_alchemical_network_output - + write("RHFE-NETWORK PLANNER") write("______________________") write("") From 73e84b5133c1255817f78c500974573ebde9b7ff Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Fri, 17 Jan 2025 15:32:33 -0800 Subject: [PATCH 11/20] clarifying language --- openfecli/parameters/misc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openfecli/parameters/misc.py b/openfecli/parameters/misc.py index e6d638fbc..033eb82e2 100644 --- a/openfecli/parameters/misc.py +++ b/openfecli/parameters/misc.py @@ -5,5 +5,7 @@ "-n", "--n-protocol-repeats", type=click.INT, - help="The number of completely independent repeats of the entire sampling process.", + help="The number of completely independent repeats per protocol unit. "\ + "For example, setting ``--n-protocol-repeats=1`` can allow for each individual repeat to be submitted in parallel,"\ + "whereas ``--n-protocol-repeats=3`` would run 3 repeats in serial within a single unit.", ) From e596a1f1ca058d950e0acab6a745906b7c53ca8a Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Fri, 17 Jan 2025 15:37:42 -0800 Subject: [PATCH 12/20] formatting --- openfecli/parameters/misc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openfecli/parameters/misc.py b/openfecli/parameters/misc.py index 033eb82e2..1e31f38d2 100644 --- a/openfecli/parameters/misc.py +++ b/openfecli/parameters/misc.py @@ -5,7 +5,7 @@ "-n", "--n-protocol-repeats", type=click.INT, - help="The number of completely independent repeats per protocol unit. "\ - "For example, setting ``--n-protocol-repeats=1`` can allow for each individual repeat to be submitted in parallel,"\ - "whereas ``--n-protocol-repeats=3`` would run 3 repeats in serial within a single unit.", + help="The number of completely independent repeats per protocol unit." + "For example, setting ``--n-protocol-repeats=1`` can allow for each individual repeat to be submitted in parallel," + "whereas ``--n-protocol-repeats=3`` would run 3 repeats in serial within a single unit.", ) From 034b43eeeacaf43efacf3266c98a6edd3dcca390 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Tue, 21 Jan 2025 09:24:06 -0800 Subject: [PATCH 13/20] remove -n, keep only --n-protocol-repeats --- openfecli/parameters/misc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openfecli/parameters/misc.py b/openfecli/parameters/misc.py index 1e31f38d2..8bc75455a 100644 --- a/openfecli/parameters/misc.py +++ b/openfecli/parameters/misc.py @@ -2,7 +2,6 @@ from plugcli.params import Option N_PROTOCOL_REPEATS = Option( - "-n", "--n-protocol-repeats", type=click.INT, help="The number of completely independent repeats per protocol unit." From 1a5b5828e525b1a812d919bb7d5fb846a7ed44e1 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Tue, 21 Jan 2025 09:27:47 -0800 Subject: [PATCH 14/20] formatting --- openfecli/parameters/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openfecli/parameters/misc.py b/openfecli/parameters/misc.py index 8bc75455a..d915b6bbe 100644 --- a/openfecli/parameters/misc.py +++ b/openfecli/parameters/misc.py @@ -4,7 +4,7 @@ N_PROTOCOL_REPEATS = Option( "--n-protocol-repeats", type=click.INT, - help="The number of completely independent repeats per protocol unit." - "For example, setting ``--n-protocol-repeats=1`` can allow for each individual repeat to be submitted in parallel," + help="The number of completely independent repeats per protocol unit.\n" + "For example, setting ``--n-protocol-repeats=1`` can allow for each individual repeat to be submitted in parallel, " "whereas ``--n-protocol-repeats=3`` would run 3 repeats in serial within a single unit.", ) From ea96d28b5e28b1b283e9a3b435c9c55c6535a28f Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Tue, 21 Jan 2025 09:29:10 -0800 Subject: [PATCH 15/20] clarifying language --- openfecli/parameters/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openfecli/parameters/misc.py b/openfecli/parameters/misc.py index d915b6bbe..e19e358d0 100644 --- a/openfecli/parameters/misc.py +++ b/openfecli/parameters/misc.py @@ -4,7 +4,7 @@ N_PROTOCOL_REPEATS = Option( "--n-protocol-repeats", type=click.INT, - help="The number of completely independent repeats per protocol unit.\n" + help="Number of independent repeats per protocol unit.\n" "For example, setting ``--n-protocol-repeats=1`` can allow for each individual repeat to be submitted in parallel, " - "whereas ``--n-protocol-repeats=3`` would run 3 repeats in serial within a single unit.", + "whereas ``--n-protocol-repeats=3`` would run 3 repeats in serial within a single protocol unit.", ) From 391efa67621eeced053deea40c1c8f2b96788c67 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Tue, 21 Jan 2025 10:04:28 -0800 Subject: [PATCH 16/20] removing accidentally added test check --- openfecli/tests/commands/test_plan_rbfe_network.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/openfecli/tests/commands/test_plan_rbfe_network.py b/openfecli/tests/commands/test_plan_rbfe_network.py index 9c3f93578..25af190c0 100644 --- a/openfecli/tests/commands/test_plan_rbfe_network.py +++ b/openfecli/tests/commands/test_plan_rbfe_network.py @@ -126,14 +126,6 @@ def test_plan_rbfe_network(mol_dir_args, protein_args): for l1, l2 in zip(expected_output_1, expected_output_2): assert l1 in result.output or l2 in result.output - network = AlchemicalNetwork.from_dict( - json.load(open("alchemicalNetwork/alchemicalNetwork.json"), cls=JSON_HANDLER.decoder) - ) - for edge in network.edges: - if "protein" in edge.stateA.components: - assert "cofactor1" in edge.stateA.components - assert "cofactor1" in edge.stateB.components - @pytest.mark.parametrize(['input_n_repeat', 'expected_n_repeat'], [([], 3), (["-n 1"], 1)]) def test_plan_rbfe_network_n_repeats(mol_dir_args, protein_args, input_n_repeat, expected_n_repeat): runner = CliRunner() From 0e807c0f5502cc68a4ffa99e56810c85d4d241b2 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Tue, 21 Jan 2025 10:06:49 -0800 Subject: [PATCH 17/20] switch test to use full --n-protocol-repeats flag --- openfecli/tests/commands/test_plan_rbfe_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfecli/tests/commands/test_plan_rbfe_network.py b/openfecli/tests/commands/test_plan_rbfe_network.py index 25af190c0..3fe89128d 100644 --- a/openfecli/tests/commands/test_plan_rbfe_network.py +++ b/openfecli/tests/commands/test_plan_rbfe_network.py @@ -126,7 +126,7 @@ def test_plan_rbfe_network(mol_dir_args, protein_args): for l1, l2 in zip(expected_output_1, expected_output_2): assert l1 in result.output or l2 in result.output -@pytest.mark.parametrize(['input_n_repeat', 'expected_n_repeat'], [([], 3), (["-n 1"], 1)]) +@pytest.mark.parametrize(['input_n_repeat', 'expected_n_repeat'], [([], 3), (["--n-protocol-repeats", "1"], 1)]) def test_plan_rbfe_network_n_repeats(mol_dir_args, protein_args, input_n_repeat, expected_n_repeat): runner = CliRunner() From 801b5d2326dbd38f3858fd5d720e3fa3615ed802 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Thu, 23 Jan 2025 11:58:35 -0800 Subject: [PATCH 18/20] updating help msg --- openfecli/parameters/misc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openfecli/parameters/misc.py b/openfecli/parameters/misc.py index e19e358d0..d9f3c0bda 100644 --- a/openfecli/parameters/misc.py +++ b/openfecli/parameters/misc.py @@ -4,7 +4,8 @@ N_PROTOCOL_REPEATS = Option( "--n-protocol-repeats", type=click.INT, - help="Number of independent repeats per protocol unit.\n" - "For example, setting ``--n-protocol-repeats=1`` can allow for each individual repeat to be submitted in parallel, " - "whereas ``--n-protocol-repeats=3`` would run 3 repeats in serial within a single protocol unit.", + help="Number of independent run(s) to be run per execution of a transformation using the `openfe quickrun` command.\n\n" + "For example:\n\n `--n-protocol-repeats=3` means `openfe quickrun` will execute 3 repeats in serial.\n\n" + " `--n-protocol-repeats=1` means `openfe quickrun` will execute only 1 repeat per call, " + "which allows for individual repeats to be submitted in parallel by calling `openfe quickrun` on the same input JSON file multiple times.", ) From b13c206fcab2d20647ad5e0eaf7dcfe909d680b9 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Fri, 24 Jan 2025 11:02:44 -0800 Subject: [PATCH 19/20] updating news entry --- news/add_n_protocol_repeats.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/add_n_protocol_repeats.rst b/news/add_n_protocol_repeats.rst index fccfbf32e..ffe3e9201 100644 --- a/news/add_n_protocol_repeats.rst +++ b/news/add_n_protocol_repeats.rst @@ -1,6 +1,6 @@ **Added:** -* Added ``--n-protocol-repeats`` CLI option to allow user-defined number of repeats per unit. +* Added ``--n-protocol-repeats`` CLI option to allow user-defined number of repeats per quickrun execution. This allows for parallelizing execution of repeats by setting ``--n-protocol-repeats=1`` and calling ``quickrun`` on the same input file multiple times. **Changed:** From 848f350b7f076e6b3fa61b04ff80117d24805178 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz <31974495+atravitz@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:57:37 -0800 Subject: [PATCH 20/20] Update openfecli/parameters/misc.py Co-authored-by: Irfan Alibay --- openfecli/parameters/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfecli/parameters/misc.py b/openfecli/parameters/misc.py index d9f3c0bda..41df1e0a4 100644 --- a/openfecli/parameters/misc.py +++ b/openfecli/parameters/misc.py @@ -4,7 +4,7 @@ N_PROTOCOL_REPEATS = Option( "--n-protocol-repeats", type=click.INT, - help="Number of independent run(s) to be run per execution of a transformation using the `openfe quickrun` command.\n\n" + help="Number of independent repeats(s) to be run per execution of a transformation using the `openfe quickrun` command.\n\n" "For example:\n\n `--n-protocol-repeats=3` means `openfe quickrun` will execute 3 repeats in serial.\n\n" " `--n-protocol-repeats=1` means `openfe quickrun` will execute only 1 repeat per call, " "which allows for individual repeats to be submitted in parallel by calling `openfe quickrun` on the same input JSON file multiple times.",