diff --git a/cookbook/create_alchemical_network.ipynb b/cookbook/create_alchemical_network.ipynb index 9ab7f9e..8603dec 100644 --- a/cookbook/create_alchemical_network.ipynb +++ b/cookbook/create_alchemical_network.ipynb @@ -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": [ + "
\n", + "This notebook creates an Hybrid Topology RBFE AlchemicalNetwork as an example. For other protocol types, see our step-by-step tutorials on running SepTop RBFE and ABFE calculations.\n", + "
\n" + ] + }, { "cell_type": "markdown", "id": "471531a1-a351-413b-b147-794f9af4e0f8", @@ -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", @@ -90,6 +98,8 @@ "metadata": {}, "outputs": [], "source": [ + "from openfe.protocols.openmm_rfe import RelativeHybridTopologyProtocol\n", + "\n", "protocol = RelativeHybridTopologyProtocol(RelativeHybridTopologyProtocol.default_settings())" ] }, @@ -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", @@ -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", @@ -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": [], @@ -201,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "id": "77d71229-5dcc-40cf-a9ae-0724a7327578", "metadata": {}, "outputs": [], @@ -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" @@ -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": [ + "" + ] + }, + "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" ] }, { @@ -314,7 +280,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "id": "2da4dafb-20d6-4ce7-ab83-4690528097d6", "metadata": { "slideshow": { @@ -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": {