Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 35 additions & 69 deletions cookbook/create_alchemical_network.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
"[Alchemical Network]: https://docs.openfree.energy/en/stable/reference/api/generated/openfe.AlchemicalNetwork.html"
]
},
{
"cell_type": "markdown",
"id": "a052ba0b",
"metadata": {},
"source": [
"<div class=\"alert alert-info\">\n",
"This notebook creates an Hybrid Topology RBFE AlchemicalNetwork as an example. For other protocol types, see our step-by-step tutorials on running <a href=https://docs.openfree.energy/en/stable/tutorials/septop_tutorial.html>SepTop RBFE</a> and <a href=https://docs.openfree.energy/en/stable/tutorials/abfe_tutorial.html>ABFE</a> calculations.\n",
"</div>\n"
]
},
{
"cell_type": "markdown",
"id": "471531a1-a351-413b-b147-794f9af4e0f8",
Expand Down Expand Up @@ -57,8 +67,6 @@
"source": [
"import openfe\n",
"import rdkit.Chem\n",
"from openff.units import unit\n",
"from openfe.protocols.openmm_rfe import RelativeHybridTopologyProtocol\n",
"\n",
"ligand_network = openfe.ligand_network_planning.generate_minimal_spanning_network(\n",
" ligands=[\n",
Expand Down Expand Up @@ -90,6 +98,8 @@
"metadata": {},
"outputs": [],
"source": [
"from openfe.protocols.openmm_rfe import RelativeHybridTopologyProtocol\n",
"\n",
"protocol = RelativeHybridTopologyProtocol(RelativeHybridTopologyProtocol.default_settings())"
]
},
Expand All @@ -115,6 +125,8 @@
},
"outputs": [],
"source": [
"from openff.units import unit\n",
"\n",
"solvent = openfe.SolventComponent(\n",
" ion_concentration=0.15 * unit.molar\n",
")\n",
Expand All @@ -131,36 +143,6 @@
"## Create the Alchemical Network"
]
},
{
"cell_type": "markdown",
"id": "8b2f6271-3c89-4cd6-8283-e617d535b910",
"metadata": {},
"source": [
"### Automatically"
]
},
{
"cell_type": "markdown",
"id": "cc13516d-92b6-44ac-a3eb-20e7f9e00631",
"metadata": {},
"source": [
"The `LigandNetwork.to_rbfe_alchemical_network()` method makes constructing alchemical networks for relative binding free energy calculations very simple: "
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "733dee64-d23a-4eb0-87cf-c03065b8d2a6",
"metadata": {},
"outputs": [],
"source": [
"alchemical_network_auto = ligand_network.to_rbfe_alchemical_network(\n",
" solvent=solvent,\n",
" protein=protein,\n",
" protocol=protocol,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "35774b4f-83e7-4235-960b-aa591e20e016",
Expand All @@ -174,14 +156,14 @@
"id": "0da5558b-3894-4c11-aafd-e4478972e161",
"metadata": {},
"source": [
"If your needs are not catered to by the above method, you can instead loop over the `LigandNetwork` edges and manually create the `Transformation` objects for each of them. This gives you full control over the entire network. For more information, see [Under the Hood]:\n",
"To create an `AlchemicalNetwork` loop over the `LigandNetwork` edges and manually create the `Transformation` objects for each of them. This gives you full control over the entire network. For more information, see [Under the Hood]:\n",
"\n",
"[Under the Hood]: https://docs.openfree.energy/en/stable/cookbook/under_the_hood.html"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "c49f36b1-c3c1-425e-b1de-24da25ed01c3",
"metadata": {},
"outputs": [],
Expand All @@ -201,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "77d71229-5dcc-40cf-a9ae-0724a7327578",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -232,8 +214,7 @@
" stateB=system_b,\n",
" mapping=mapping,\n",
" protocol=protocol,\n",
" # Using the same name as to_rbfe_alchemical_network()\n",
" name=f\"easy_rbfe_{system_a.name}_{system_b.name}\"\n",
" name=f\"rbfe_{system_a.name}_{system_b.name}\"\n",
" )\n",
" \n",
" transformations.append(transformation)\n"
Expand All @@ -249,39 +230,24 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"id": "fc6cac68-bdcd-4d51-b4e1-f9bb7169c6f6",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"<AlchemicalNetwork-130d122e6027d856bebe9a480b35f363>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alchemical_network = openfe.AlchemicalNetwork(transformations)"
]
},
{
"cell_type": "markdown",
"id": "b623d82e-1069-4c69-81af-ccc795ba5690",
"metadata": {},
"source": [
"We can confirm that this produces identical results to the previous strategy:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "c9baa54c-513a-486a-a06a-fd8fd5d19fa5",
"metadata": {
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"assert alchemical_network == ligand_network.to_rbfe_alchemical_network(\n",
" solvent=solvent,\n",
" protein=protein,\n",
" protocol=protocol,\n",
")"
"alchemical_network = openfe.AlchemicalNetwork(transformations)\n",
"alchemical_network"
]
},
{
Expand Down Expand Up @@ -314,7 +280,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"id": "2da4dafb-20d6-4ce7-ab83-4690528097d6",
"metadata": {
"slideshow": {
Expand Down Expand Up @@ -359,7 +325,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.11"
"version": "3.13.15"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
Loading