{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "*This notebook contains material from [PyRosetta](https://RosettaCommons.github.io/PyRosetta.notebooks);\n", "content is available [on Github](https://github.com/RosettaCommons/PyRosetta.notebooks.git).*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Global Ligand Docking using `XMLObjects` Using the `ref2015.wts` Scorefunction](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/08.01-Ligand-Docking-XMLObjects.ipynb) | [Contents](toc.ipynb) | [Index](index.ipynb) | [Loop Modeling](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/09.00-Loop-Modeling.ipynb) >

\"Open" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# `GALigandDock` Protocol with `pyrosetta.distributed` Using the `beta_cart.wts` Scorefunction" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*Warning*: This notebook uses `pyrosetta.distributed.viewer` code, which runs in `jupyter notebook` and might not run if you're using `jupyterlab`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*Note:* This Jupyter notebook requires the PyRosetta distributed layer. Please make sure to activate the `PyRosetta.notebooks` conda environment before running this notebook. The kernel is set to use this environment. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import logging\n", "logging.basicConfig(level=logging.INFO)\n", "import matplotlib\n", "%matplotlib inline\n", "import os\n", "import pandas as pd\n", "import pyrosetta\n", "import pyrosetta.distributed\n", "import pyrosetta.distributed.io as io\n", "import pyrosetta.distributed.viewer as viewer\n", "import pyrosetta.distributed.packed_pose as packed_pose\n", "import pyrosetta.distributed.tasks.rosetta_scripts as rosetta_scripts\n", "import seaborn\n", "seaborn.set()\n", "import sys\n", "\n", "!pip install pyrosettacolabsetup\n", "import pyrosettacolabsetup; pyrosettacolabsetup.install_pyrosetta()\n", "import pyrosetta\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load the `TPA.am1-bcc.gp.params` file when using the `-beta_cart` flag, which has `gen_potential` atom typing and AM1-BCC partial charges:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pdb_filename = \"inputs/test_lig.pdb\"\n", "ligand_params = \"inputs/TPA.am1-bcc.gp.params\"\n", "flags = f\"\"\"\n", "-ignore_unrecognized_res 1\n", "-extra_res_fa {ligand_params}\n", "-beta_cart\n", "-out:level 200\n", "\"\"\"\n", "pyrosetta.distributed.init(flags)\n", "pose_obj = io.pose_from_file(filename=pdb_filename)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we change the scorefunction in our RosettaScripts script to `beta_cart.wts`, the weights of which were optimized on protein-ligand complexes using ligands with AM1-BCC partial charges generated with Amber's `antechamber`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`GALigandDock` within RosettaScripts normally outputs multiple `.pdb` files to disk if run by the command line. However, when using the `MultioutputRosettaScriptsTask` function in `pyrosetta.distributed`, the outputs will be captured in memory within this Jupyter session!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "xml = f\"\"\"\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\"\"\"\n", "xml_obj = rosetta_scripts.MultioutputRosettaScriptsTask(xml)\n", "xml_obj.setup()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`MultioutputRosettaScriptsTask` is a python generator object. Therefore, we need to call `list()` or `set()` on it to run it.\n", "\n", "*Warning*, the following cell runs for ~45 minutes CPU time." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if not os.getenv(\"DEBUG\"):\n", " %time results = list(xml_obj(pose_obj))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Inspect the scores for the `GALigandDock` trajectories:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if not os.getenv(\"DEBUG\"):\n", " df = pd.DataFrame.from_records(packed_pose.to_dict(results))\n", " df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Now that we have performed `GALigandDock`, we can plot the ligand binding energy landscape:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if not os.getenv(\"DEBUG\"):\n", " matplotlib.rcParams[\"figure.figsize\"] = [12.0, 8.0]\n", " seaborn.scatterplot(x=\"lig_rms\", y=\"total_score\", data=df)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's look at the ligand dock with the lowest `total_score` score!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if not os.getenv(\"DEBUG\"):\n", " ppose_lowest_total_score = results[df.sort_values(by=\"total_score\").index[0]]\n", " view = viewer.init(ppose_lowest_total_score)\n", " view.add(viewer.setStyle())\n", " view.add(viewer.setStyle(command=({\"hetflag\": True}, {\"stick\": {\"colorscheme\": \"brownCarbon\", \"radius\": 0.2}})))\n", " view.add(viewer.setSurface(residue_selector=pyrosetta.rosetta.core.select.residue_selector.ChainSelector(\"E\"), opacity=0.7, color='white'))\n", " view.add(viewer.setHydrogenBonds())\n", " view()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Global Ligand Docking using `XMLObjects` Using the `ref2015.wts` Scorefunction](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/08.01-Ligand-Docking-XMLObjects.ipynb) | [Contents](toc.ipynb) | [Index](index.ipynb) | [Loop Modeling](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/09.00-Loop-Modeling.ipynb) >

\"Open" ] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:PyRosetta.notebooks] *", "language": "python", "name": "conda-env-PyRosetta.notebooks-py" }, "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.7.6" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }