diff --git a/cookbook/cofactors_rbfe.ipynb b/cookbook/cofactors_rbfe.ipynb deleted file mode 100644 index 380a49c..0000000 --- a/cookbook/cofactors_rbfe.ipynb +++ /dev/null @@ -1,367 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "35354229", - "metadata": {}, - "source": [ - "# Defining Cofactors\n", - "\n", - "This how-to guide demonstrates how to define cofactors (any small molecules that are not the bound ligand) with 1) the ``openfe`` CLI during the planning phase and 2) directly using the Python API.\n", - "\n", - "Similar to `ligand` definition, `cofactors` can be loaded from in SDF file format, and multiple molecules can be defined in a single file." - ] - }, - { - "cell_type": "markdown", - "id": "d18da4a7-0001-4c04-8f9b-b197f3a1f1b5", - "metadata": {}, - "source": [ - "## 1) CLI: define cofactors during ``openfe plan-rbfe-network``" - ] - }, - { - "cell_type": "markdown", - "id": "bf120991-50ab-4e6a-af73-2cf471c3d3c4", - "metadata": {}, - "source": [ - "When using openfe's CLI, including cofactors in an RBFE calculation is as simple as passing in the ``-C`` argument with the path to the SDF file containing cofactors:\n", - "\n", - "```bash\n", - "openfe plan-rbfe-network -M ligands.sdf -p protein.pdb -C cofactors.sdf\n", - "```" - ] - }, - { - "cell_type": "markdown", - "id": "a51b59e7-480c-45f9-9a7c-bf0aee1a0d8c", - "metadata": {}, - "source": [ - "## 2) Python API: define cofactors in the ``ChemicalSystem``s " - ] - }, - { - "cell_type": "markdown", - "id": "5b2f982c-1340-4272-905e-93a2d6221997", - "metadata": {}, - "source": [ - "If using the ``openfe`` Python API to set up an RBFE network, cofactors need to be included when constructing the ``ChemicalSystem``s." - ] - }, - { - "cell_type": "markdown", - "id": "7e56bd3b-9897-4761-a97b-fa6162bfa31b", - "metadata": {}, - "source": [ - "### Define the components (protein, ligands, cofactors)" - ] - }, - { - "cell_type": "markdown", - "id": "f7490fec-f420-466b-8e5b-5465f37f3d9b", - "metadata": {}, - "source": [ - "Define the ligands, protein, and solvent in the same way as a typical RBFE calculation. \n", - "\n", - "\n", - "
\n", - "Note that partial charges are already assigned for both the ligands and cofactors. See Assigning partial charges to an OpenFF Molecule or and charge-molecules CLI command for information on assigning partial charges.\n", - "\n", - "Supplying cofactors as SmallMoleculeCompoents means they will be parameterized using the small molecule force field, which might not be applicable in all situations.\n", - "
\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "371dc488-80a5-40ad-bf51-9cd5d8d4aeea", - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "import openfe\n", - "from rdkit import Chem\n", - "from openff.toolkit import Molecule\n", - "\n", - "# Create a list of OpenFF molecules\n", - "offmols = [\n", - " Molecule.from_rdkit(m)\n", - " for m in Chem.SDMolSupplier(\"assets/cofactors/eg5_ligands_charged.sdf\", removeHs=False)\n", - "]\n", - "\n", - "# Now we convert them to SmallMoleculeComponent\n", - "ligands = [openfe.SmallMoleculeComponent.from_openff(mol) for mol in offmols]\n", - "\n", - "# defaults are water with NaCl at 0.15 M\n", - "solvent = openfe.SolventComponent()\n", - "\n", - "# load in the EG5 protein\n", - "protein = openfe.ProteinComponent.from_pdb_file(\"assets/cofactors/eg5_protein.pdb\")" - ] - }, - { - "cell_type": "markdown", - "id": "7f42ca46-9edf-4dc6-abe5-bfbc8c2e6b48", - "metadata": {}, - "source": [ - "Load the cofactor(s) to be included in the simulations:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "1523c2dc-b71a-473e-b02f-77475245ae43", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "SmallMoleculeComponent(name=3L9H)" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# load in the cofactor from eg5_cofactors.sdf, here we know that there is only one cofactor in the file\n", - "# We also go through OpenFF to assign partial charges\n", - "offmol = Molecule.from_rdkit(Chem.MolFromMolFile(\"assets/cofactors/eg5_cofactor_charged.sdf\", removeHs=False))\n", - "cofactor = openfe.SmallMoleculeComponent.from_openff(offmol)\n", - "cofactor" - ] - }, - { - "cell_type": "markdown", - "id": "5722a218-82e4-4e59-94d2-9e47e8e3c00a", - "metadata": {}, - "source": [ - "### Create the Ligand Network\n", - "\n", - "(This doesn't require any specific cofactor steps, but is included for completeness)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "e7c5da37-eff9-4f63-a8b8-00248d193972", - "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "73790a2760374adc9857060c83fc8527", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Mapping: 28%|##8 | 107/378 [00:01<00:03, 71.05it/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "mapper = openfe.KartografAtomMapper()\n", - "scorer = openfe.lomap_scorers.default_lomap_score\n", - "network_planner = openfe.ligand_network_planning.generate_minimal_spanning_network\n", - "\n", - "ligand_network = network_planner(\n", - " ligands=ligands,\n", - " mappers=mapper,\n", - " scorer=scorer\n", - ")" - ] - }, - { - "cell_type": "markdown", - "id": "7afd9801-9a9d-4cda-a68f-e531a2b31180", - "metadata": {}, - "source": [ - "### Define an RBFE Protocol\n", - "\n", - "(This doesn't require any specific cofactor steps, but is included for completeness)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "32f36cd0-fb77-4d26-8354-3282bc2f1db4", - "metadata": {}, - "outputs": [], - "source": [ - "from openfe.protocols.openmm_rfe import RelativeHybridTopologyProtocol\n", - "\n", - "default_settings = RelativeHybridTopologyProtocol.default_settings()\n", - "protocol = RelativeHybridTopologyProtocol(default_settings)" - ] - }, - { - "cell_type": "markdown", - "id": "9f7e445f-e99a-433a-9987-8cfdf05bf21e", - "metadata": {}, - "source": [ - "### Create an ``AlchemicalNetwork`` that includes cofactors\n", - "\n", - "When creating the legs of``AlchemicalNetwork``, you must explicitly define the cofactors as part of the complex legs' ``ChemicalSystem``s." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "c7f13bd1-5bd4-493a-bbc5-9a11a9b1adfe", - "metadata": {}, - "outputs": [], - "source": [ - "transformations = []\n", - "for mapping in ligand_network.edges:\n", - " for leg in ['solvent', 'complex']:\n", - " # use the solvent and protein created above\n", - " sysA_dict = {'ligand': mapping.componentA,\n", - " 'solvent': solvent}\n", - " sysB_dict = {'ligand': mapping.componentB,\n", - " 'solvent': solvent}\n", - " \n", - " if leg == 'complex':\n", - " sysA_dict['protein'] = protein\n", - " sysB_dict['protein'] = protein\n", - " # Add cofactors to both sysA and sysB \n", - " sysA_dict['cofactor'] = cofactor\n", - " sysB_dict['cofactor'] = cofactor \n", - " \n", - " # we don't have to name objects, but it can make things (like filenames) more convenient\n", - " sysA = openfe.ChemicalSystem(sysA_dict, name=f\"{mapping.componentA.name}_{leg}\")\n", - " sysB = openfe.ChemicalSystem(sysB_dict, name=f\"{mapping.componentB.name}_{leg}\")\n", - " \n", - " prefix = \"rbfe_\" # prefix is only to exactly reproduce CLI\n", - " \n", - " transformation = openfe.Transformation(\n", - " stateA=sysA,\n", - " stateB=sysB,\n", - " mapping=mapping,\n", - " protocol=protocol, # use protocol created above\n", - " name=f\"{prefix}{sysA.name}_{sysB.name}\"\n", - " )\n", - " transformations.append(transformation)\n", - "\n", - "network = openfe.AlchemicalNetwork(transformations)" - ] - }, - { - "cell_type": "markdown", - "id": "c9ed73fc-13da-4a13-a433-51157cc88fad", - "metadata": {}, - "source": [ - "Cofactors can now be seen in the complex nodes of the alchemical network:" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "775f4201-7fad-4e2e-801b-56696524ed8d", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "frozenset({ChemicalSystem(name=lig_CHEMBL1096002_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1096002), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1083517_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1083517), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1096003_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1096003), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1085692_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1085692), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1077227_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1077227), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1086409_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1086409), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1089393_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1089393), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084935_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084935), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1078998_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1078998), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1088740_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1088740), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1085666_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1085666), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1082249_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1082249), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084143_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084143), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1078998_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1078998), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1083836_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1083836), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1077227_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1077227), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1088740_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1088740), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1078774_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1078774), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1077204_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1077204), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1096003_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1096003), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1093087_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1093087), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084677_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084677), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1086409_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1086409), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084935_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084935), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1085895_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1085895), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084676_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084676), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084935_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084935), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084115_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084115), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084676_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084676), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1093088_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1093088), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1085666_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1085666), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1093088_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1093088), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1083517_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1083517), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1093087_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1093087), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1082249_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1082249), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1077204_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1077204), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1078774_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1078774), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1083836_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1083836), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1089056_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1089056), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084115_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084115), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084677_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084677), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084143_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084143), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084678_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084678), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1078691_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1078691), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1089056_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1089056), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1089393_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1089393), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1082248_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1082248), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1085692_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1085692), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084678_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084678), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1086410_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1086410), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1082248_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1082248), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1096002_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1096002), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1086410_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1086410), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1084935_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1084935), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)}),\n", - " ChemicalSystem(name=lig_CHEMBL1078691_solvent, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1078691), 'solvent': SolventComponent(name=O, Na+, Cl-)}),\n", - " ChemicalSystem(name=lig_CHEMBL1085895_complex, components={'ligand': SmallMoleculeComponent(name=lig_CHEMBL1085895), 'solvent': SolventComponent(name=O, Na+, Cl-), 'protein': ProteinComponent(name=), 'cofactor': SmallMoleculeComponent(name=3L9H)})})" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "network.nodes" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "71b3826e-9bb5-464e-a0e2-121a05217db6", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.13.14" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/cookbook/loading_molecules.ipynb b/cookbook/loading_molecules.ipynb index cef6561..9b61acd 100644 --- a/cookbook/loading_molecules.ipynb +++ b/cookbook/loading_molecules.ipynb @@ -246,11 +246,19 @@ "source": [ "
\n", "\n", - "**Partial charges:** Any partial charges stored in an SDF file are read along with the molecules, and are used in simulations instead of generating new ones. The files used here already have AM1-BCC partial charges. To assign partial charges to your own molecules, see the how-to guide on [assigning partial charges with the Python API](https://docs.openfree.energy/en/stable/chow_to_guides/user_charges.html) or the [partial charges CLI tutorial](https://docs.openfree.energy/en/stable/tutorials/charge_molecules_cli_tutorial.html).\n", + "**Partial charges:** Any partial charges stored in an SDF file are read along with the molecules, and are used in simulations instead of generating new ones. The files used here already have AM1-BCC partial charges. To assign partial charges to your own molecules, see the how-to guide on [assigning partial charges with the Python API](https://docs.openfree.energy/en/latest/how_to_guides/user_charges.html) or the [partial charges CLI tutorial](https://docs.openfree.energy/en/latest/tutorials/charge_molecules_cli_tutorial.html).\n", "\n", "
" ] }, + { + "cell_type": "markdown", + "id": "64fd64eb-0e99-446a-b264-3f56a53fd7c9", + "metadata": {}, + "source": [ + "Cofactors and other small molecules are loaded in the same way; see [Including cofactors](#Including-cofactors) for how to add them to a `ChemicalSystem`." + ] + }, { "cell_type": "raw", "id": "b1c7eea8-7aaa-4a72-8d48-dfb7c32a60eb", @@ -459,6 +467,69 @@ "cs1 = ChemicalSystem({'ligand': m1, **shared_components})\n", "cs2 = ChemicalSystem({'ligand': m2, **shared_components})" ] + }, + { + "cell_type": "raw", + "id": "dd4cde5f-ad22-42fb-9518-327c86ed5a49", + "metadata": {}, + "source": [ + ".. _Including cofactors:\n", + "\n", + "Including cofactors\n", + "~~~~~~~~~~~~~~~~~~~" + ] + }, + { + "cell_type": "markdown", + "id": "5b67e0da-9c01-4b91-b81d-c4e0dc0e75c4", + "metadata": {}, + "source": [ + "### Including cofactors\n", + "\n", + "Cofactors, and any other small molecules that stay unchanged in the system, are loaded as `SmallMoleculeComponent`s in the same way as ligands. Add them to the `ChemicalSystem` of the complex in both end states, with a unique key for each cofactor:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "32fef729-d82a-43f5-99b2-ace29746255f", + "metadata": {}, + "outputs": [], + "source": [ + "from rdkit import Chem\n", + "from openfe import ChemicalSystem, ProteinComponent, SmallMoleculeComponent, SolventComponent\n", + "\n", + "# the SDF files already contain partial charges\n", + "protein = ProteinComponent.from_pdb_file('assets/cofactors/eg5_protein.pdb')\n", + "ligands = [\n", + " SmallMoleculeComponent(mol)\n", + " for mol in Chem.SDMolSupplier('assets/cofactors/eg5_ligands_charged.sdf', removeHs=False)\n", + "]\n", + "# the cofactor file contains a single molecule\n", + "cofactor = SmallMoleculeComponent.from_sdf_file('assets/cofactors/eg5_cofactor_charged.sdf')\n", + "\n", + "# the cofactor is shared by the complex systems of both end states\n", + "shared_components = {'solvent': SolventComponent(), 'protein': protein, 'cofactor1': cofactor}\n", + "\n", + "complex_a = ChemicalSystem({'ligand': ligands[0], **shared_components})\n", + "complex_b = ChemicalSystem({'ligand': ligands[1], **shared_components})" + ] + }, + { + "cell_type": "markdown", + "id": "e656582b-4026-434f-8544-66fa0e3957dd", + "metadata": {}, + "source": [ + "Further cofactors are added with the keys `cofactor2`, `cofactor3`, and so on. This is the naming the `openfe` CLI uses. Cofactors are only part of the complex systems; the solvent systems contain only the ligand and the solvent.\n", + "\n", + "When planning a network with the CLI, pass an SDF file containing all cofactors to `openfe plan-rbfe-network` with the `-C` option:\n", + "\n", + "```bash\n", + "openfe plan-rbfe-network -M ligands.sdf -p protein.pdb -C cofactors.sdf\n", + "```\n", + "\n", + "The CLI assigns partial charges to the cofactors, unless the file already contains them and `--overwrite-charges` is not set." + ] } ], "metadata": {