Skip to content

Commit 151bdd3

Browse files
authored
Merge branch 'main' into bump_rc_releases_to_1.7
2 parents d671aa9 + 843ae9b commit 151bdd3

4 files changed

Lines changed: 113 additions & 210 deletions

File tree

cookbook/bespoke_parameters_showcase.ipynb

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,23 @@
4949
},
5050
{
5151
"cell_type": "code",
52-
"execution_count": null,
52+
"execution_count": 2,
5353
"metadata": {},
5454
"outputs": [],
5555
"source": [
5656
"# create the OpenFE RBFE protocol using our bespoke force field\n",
57-
"import copy\n",
58-
"from openff.units import unit\n",
5957
"from openfe.protocols.openmm_rfe import RelativeHybridTopologyProtocol\n",
6058
"import openfe\n",
6159
"\n",
62-
"# create the default protocol settings\n",
63-
"base_settings = RelativeHybridTopologyProtocol.default_settings()\n",
6460
"\n",
61+
"# create the default protocol settings\n",
62+
"settings = RelativeHybridTopologyProtocol.default_settings()\n",
6563
"# add our new force field as a string\n",
6664
"# this avoids the need to move the file around when executing the transformations\n",
67-
"base_settings.forcefield_settings.small_molecule_forcefield = bespoke_force_field.to_string()\n",
68-
"\n",
69-
"# we create a copy of the settings for the complex leg so that we can reduce the solvation cutoff\n",
70-
"complex_settings = copy.deepcopy(base_settings)\n",
71-
"complex_settings.solvation_settings.solvent_padding = 1 * unit.nanometer\n",
72-
"\n",
73-
"# create the protocols\n",
74-
"solvent_protocol = RelativeHybridTopologyProtocol(base_settings)\n",
75-
"complex_protocol = RelativeHybridTopologyProtocol(complex_settings)\n",
65+
"settings.forcefield_settings.small_molecule_forcefield = bespoke_force_field.to_string()\n",
7666
"\n",
67+
"# create the protocol\n",
68+
"protocol = RelativeHybridTopologyProtocol(settings)\n",
7769
"\n",
7870
"# create the solvent and protein components\n",
7971
"solvent = openfe.SolventComponent()\n",
@@ -90,11 +82,8 @@
9082
" 'solvent': solvent}\n",
9183
"\n",
9284
" if leg == 'complex':\n",
93-
" protocol = complex_protocol\n",
9485
" sysA_dict['protein'] = protein\n",
9586
" sysB_dict['protein'] = protein\n",
96-
" else:\n",
97-
" protocol = solvent_protocol\n",
9887
"\n",
9988
" # we don't have to name objects, but it can make things (like filenames) more convenient\n",
10089
" sysA = openfe.ChemicalSystem(sysA_dict, name=f\"{mapping.componentA.name}_{leg}\")\n",
@@ -105,7 +94,7 @@
10594
" transformation = openfe.Transformation(\n",
10695
" stateA=sysA,\n",
10796
" stateB=sysB,\n",
108-
" mapping=mapping,\n",
97+
" mapping={'ligand': mapping},\n",
10998
" protocol=protocol, # use protocol created above\n",
11099
" name=f\"{prefix}{sysA.name}_{sysB.name}\"\n",
111100
" )\n",
@@ -123,7 +112,7 @@
123112
},
124113
{
125114
"cell_type": "code",
126-
"execution_count": null,
115+
"execution_count": 3,
127116
"metadata": {},
128117
"outputs": [],
129118
"source": [
@@ -134,7 +123,7 @@
134123
"\n",
135124
"# then we write out each transformation\n",
136125
"for transformation in network.edges:\n",
137-
" transformation.to_json(transformation_dir / f\"{transformation.name}.json\")"
126+
" transformation.dump(transformation_dir / f\"{transformation.name}.json\")"
138127
]
139128
},
140129
{
@@ -143,8 +132,7 @@
143132
"source": [
144133
"# Recap\n",
145134
"\n",
146-
"So to recap the workflow can be reduced to the following steps:\n",
147-
"\n",
135+
"So to recap the workflow can be reduced to the following steps:\n\n",
148136
"- Plan the RBFE network\n",
149137
"- Create a single SMIRNOFF style force field with all of the bespoke parameters for the network using the BespokeFit `combine` CLI\n",
150138
"- Store the force field as a string in the OpenFE protocol under the `settings.forcefield_settings.small_molecule_forcefield` field\n",
@@ -156,7 +144,7 @@
156144
],
157145
"metadata": {
158146
"kernelspec": {
159-
"display_name": "Python 3 (ipykernel)",
147+
"display_name": "asapdiscovery",
160148
"language": "python",
161149
"name": "python3"
162150
},
@@ -170,16 +158,9 @@
170158
"name": "python",
171159
"nbconvert_exporter": "python",
172160
"pygments_lexer": "ipython3",
173-
"version": "3.12.11"
174-
},
175-
"widgets": {
176-
"application/vnd.jupyter.widget-state+json": {
177-
"state": {},
178-
"version_major": 2,
179-
"version_minor": 0
180-
}
161+
"version": "3.11.6"
181162
}
182163
},
183164
"nbformat": 4,
184-
"nbformat_minor": 4
165+
"nbformat_minor": 2
185166
}

cookbook/choose_protocol.ipynb

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -178,82 +178,64 @@
178178
"text": [
179179
"{'alchemical_settings': {'endstate_dispersion_correction': False,\n",
180180
" 'explicit_charge_correction': False,\n",
181-
" 'explicit_charge_correction_cutoff': {'unit': 'nanometer',\n",
182-
" 'val': 0.8},\n",
181+
" 'explicit_charge_correction_cutoff': <Quantity(0.8, 'nanometer')>,\n",
183182
" 'softcore_LJ': 'gapsys',\n",
184183
" 'softcore_alpha': 0.85,\n",
185184
" 'turn_off_core_unique_exceptions': False,\n",
186185
" 'use_dispersion_correction': False},\n",
187-
" 'engine_settings': {'compute_platform': 'cuda', 'gpu_device_index': None},\n",
186+
" 'engine_settings': {'compute_platform': None, 'gpu_device_index': None},\n",
188187
" 'forcefield_settings': {'constraints': 'hbonds',\n",
189188
" 'forcefields': ['amber/ff14SB.xml',\n",
190189
" 'amber/tip3p_standard.xml',\n",
191190
" 'amber/tip3p_HFE_multivalent.xml',\n",
192191
" 'amber/phosaa10.xml'],\n",
193192
" 'hydrogen_mass': 3.0,\n",
194-
" 'nonbonded_cutoff': {'unit': 'nanometer', 'val': 0.9},\n",
193+
" 'nonbonded_cutoff': <Quantity(1.0, 'nanometer')>,\n",
195194
" 'nonbonded_method': 'PME',\n",
196195
" 'rigid_water': True,\n",
197-
" 'small_molecule_forcefield': 'openff-2.2.1'},\n",
198-
" 'integrator_settings': {'barostat_frequency': {'unit': 'timestep',\n",
199-
" 'val': 25.0},\n",
196+
" 'small_molecule_forcefield': 'openff-2.1.1'},\n",
197+
" 'integrator_settings': {'barostat_frequency': <Quantity(25.0, 'timestep')>,\n",
200198
" 'constraint_tolerance': 1e-06,\n",
201-
" 'langevin_collision_rate': {'unit': '1 / picosecond',\n",
202-
" 'val': 1.0},\n",
199+
" 'langevin_collision_rate': <Quantity(1.0, '1 / picosecond')>,\n",
203200
" 'n_restart_attempts': 20,\n",
204201
" 'reassign_velocities': False,\n",
205202
" 'remove_com': False,\n",
206-
" 'timestep': {'unit': 'femtosecond', 'val': 4.0}},\n",
203+
" 'timestep': <Quantity(4.0, 'femtosecond')>},\n",
207204
" 'lambda_settings': {'lambda_functions': 'default', 'lambda_windows': 11},\n",
208-
" 'output_settings': {'checkpoint_interval': {'unit': 'nanosecond', 'val': 1.0},\n",
205+
" 'output_settings': {'checkpoint_interval': <Quantity(1.0, 'nanosecond')>,\n",
209206
" 'checkpoint_storage_filename': 'checkpoint.chk',\n",
210207
" 'forcefield_cache': 'db.json',\n",
211208
" 'output_filename': 'simulation.nc',\n",
212209
" 'output_indices': 'not water',\n",
213210
" 'output_structure': 'hybrid_system.pdb',\n",
214-
" 'positions_write_frequency': {'unit': 'picosecond',\n",
215-
" 'val': 100.0},\n",
211+
" 'positions_write_frequency': <Quantity(100.0, 'picosecond')>,\n",
216212
" 'velocities_write_frequency': None},\n",
217213
" 'partial_charge_settings': {'nagl_model': None,\n",
218214
" 'number_of_conformers': None,\n",
219215
" 'off_toolkit_backend': 'ambertools',\n",
220216
" 'partial_charge_method': 'am1bcc'},\n",
221217
" 'protocol_repeats': 3,\n",
222-
" 'simulation_settings': {'early_termination_target_error': {'unit': 'kilocalorie_per_mole',\n",
223-
" 'val': 0.0},\n",
224-
" 'equilibration_length': {'unit': 'nanosecond',\n",
225-
" 'val': 1.0},\n",
218+
" 'simulation_settings': {'early_termination_target_error': <Quantity(0.0, 'kilocalorie_per_mole')>,\n",
219+
" 'equilibration_length': <Quantity(1.0, 'nanosecond')>,\n",
226220
" 'minimization_steps': 5000,\n",
227221
" 'n_replicas': 11,\n",
228-
" 'production_length': {'unit': 'nanosecond',\n",
229-
" 'val': 5.0},\n",
230-
" 'real_time_analysis_interval': {'unit': 'picosecond',\n",
231-
" 'val': 250.0},\n",
232-
" 'real_time_analysis_minimum_time': {'unit': 'picosecond',\n",
233-
" 'val': 500.0},\n",
222+
" 'production_length': <Quantity(5.0, 'nanosecond')>,\n",
223+
" 'real_time_analysis_interval': <Quantity(250.0, 'picosecond')>,\n",
224+
" 'real_time_analysis_minimum_time': <Quantity(500.0, 'picosecond')>,\n",
234225
" 'sampler_method': 'repex',\n",
235226
" 'sams_flatness_criteria': 'logZ-flatness',\n",
236227
" 'sams_gamma0': 1.0,\n",
237-
" 'time_per_iteration': {'unit': 'picosecond',\n",
238-
" 'val': 2.5}},\n",
239-
" 'solvation_settings': {'box_shape': 'dodecahedron',\n",
228+
" 'time_per_iteration': <Quantity(1.0, 'picosecond')>},\n",
229+
" 'solvation_settings': {'box_shape': 'cube',\n",
240230
" 'box_size': None,\n",
241231
" 'box_vectors': None,\n",
242232
" 'number_of_solvent_molecules': None,\n",
243233
" 'solvent_model': 'tip3p',\n",
244-
" 'solvent_padding': {'unit': 'nanometer', 'val': 1.5}},\n",
234+
" 'solvent_padding': <Quantity(1.2, 'nanometer')>},\n",
245235
" 'thermo_settings': {'ph': None,\n",
246-
" 'pressure': {'unit': 'bar', 'val': 1},\n",
236+
" 'pressure': <Quantity(0.986923267, 'standard_atmosphere')>,\n",
247237
" 'redox_potential': None,\n",
248-
" 'temperature': {'unit': 'kelvin', 'val': 298.15}}}\n"
249-
]
250-
},
251-
{
252-
"name": "stderr",
253-
"output_type": "stream",
254-
"text": [
255-
"/Users/atravitz/micromamba/envs/openfe-conda/lib/python3.11/site-packages/gufe/settings/models.py:30: PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/\n",
256-
" pprint.pprint(self.dict())\n"
238+
" 'temperature': <Quantity(298.15, 'kelvin')>}}\n"
257239
]
258240
}
259241
],
@@ -336,11 +318,11 @@
336318
" ],\n",
337319
" \n",
338320
" # Small molecule force field to use with OpenMM template generator:\n",
339-
" small_molecule_forcefield='openff-2.2.1',\n",
321+
" small_molecule_forcefield='openff-2.1.1',\n",
340322
" \n",
341323
" # Nonbonded settings\n",
342324
" nonbonded_method='PME', # Particle Mesh Ewald for long range electrostatics\n",
343-
" nonbonded_cutoff=0.9 * unit.nm, # Cut off Lennard-Jones interactions beyond 0.9 nm\n",
325+
" nonbonded_cutoff=1.0 * unit.nm, # Cut off Lennard-Jones interactions beyond 1 nm\n",
344326
" ),\n",
345327
" thermo_settings=equil_rfe_settings.ThermoSettings(\n",
346328
" temperature=298.15 * unit.kelvin, # Set thermostat temperature\n",
@@ -350,8 +332,8 @@
350332
" ),\n",
351333
" solvation_settings=equil_rfe_settings.OpenMMSolvationSettings(\n",
352334
" solvent_model='tip3p', # Solvent model to generate starting coords\n",
353-
" solvent_padding=1.5 * unit.nm, # Minimum padding distance from the solute\n",
354-
" box_shape = 'dodecahedron', # Dodecahedron water box\n",
335+
" solvent_padding=1.2 * unit.nm, # Total distance between periodic image starting coords\n",
336+
" box_shape = 'cube', # Cubic water box\n",
355337
" box_size = None, # Size of the water box\n",
356338
" box_vectors = None, # Box vectors\n",
357339
" number_of_solvent_molecules = None, # Number of solvent molecules\n",
@@ -390,7 +372,7 @@
390372
" # Alchemical Space Sampling settings\n",
391373
" n_replicas=11, # Number of replicas sampling alchemical space\n",
392374
" sampler_method='repex', # Sample lambda with Hamiltonian Replica Exchange\n",
393-
" time_per_iteration=2.5*unit.ps, # Time interval between state sampling (MCMC) attempts\n",
375+
" time_per_iteration=1*unit.ps, # Time interval between state sampling (MCMC) attempts\n",
394376
" \n",
395377
" # SAMS sampling settings (used if sampler_method='sams')\n",
396378
" sams_flatness_criteria='logZ-flatness', # Criteria for switch to asymptomatically optimal scheme\n",
@@ -405,7 +387,7 @@
405387
" early_termination_target_error=0.0*unit.kilocalorie_per_mole,\n",
406388
" ),\n",
407389
" engine_settings=equil_rfe_settings.OpenMMEngineSettings(\n",
408-
" compute_platform=\"cuda\", # Force the usage of a CUDA device for compute\n",
390+
" compute_platform=None, # Let OpenMM choose the best platform for your hardware\n",
409391
" ),\n",
410392
" integrator_settings=equil_rfe_settings.IntegratorSettings(\n",
411393
" timestep=4 * unit.femtosecond, # Integration timestep\n",
@@ -484,14 +466,6 @@
484466
"source": [
485467
"Unlike `ProtocolSettings`, a `Protocol` instance is immutable. The only way to safely change the settings of a `Protocol` is to recreate it from the modified `ProtocolSettings` object."
486468
]
487-
},
488-
{
489-
"cell_type": "code",
490-
"execution_count": null,
491-
"id": "91e223bc-5dc7-4533-ba5d-da112809be9a",
492-
"metadata": {},
493-
"outputs": [],
494-
"source": []
495469
}
496470
],
497471
"metadata": {
@@ -510,7 +484,7 @@
510484
"name": "python",
511485
"nbconvert_exporter": "python",
512486
"pygments_lexer": "ipython3",
513-
"version": "3.11.14"
487+
"version": "3.12.10"
514488
},
515489
"widgets": {
516490
"application/vnd.jupyter.widget-state+json": {

0 commit comments

Comments
 (0)