{ "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", "< [Protein Design with a Resfile and FastRelax](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/06.03-Design-with-a-resfile-and-relax.ipynb) | [Contents](toc.ipynb) | [Index](index.ipynb) | [HBNet Before Design](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/06.05-HBNet-Before-Design.ipynb) >

\"Open" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Protein Design 2\n", "\n", "Keywords: FastDesign, FastRelax, ResidueSelector, TaskFactory, TaskOperation, pose_from_rcsb, get_residues_from_subset, ResidueNameSelector, ChainSelector, ResiduePropertySelector, NotResidueSelector, AndResidueSelector, RestrictToRepackingRLT, RestrictAbsentCanonicalAASRLT, NoRepackDisulfides, OperateOnResidueSubset\n", "\n", "## Overview\n", "\n", "Here, we will expand upon our knowledge of ResidueSelectors and TaskOperations and how to use them. We can once again use FastRelax or FastDesign to do design. Since we don't need any additional tools offered by FastDesign, we will use FastRelax. I like to call it RelaxedDesign. :)" ] }, { "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": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!pip install pyrosettacolabsetup\n", "import pyrosettacolabsetup; pyrosettacolabsetup.install_pyrosetta()\n", "import pyrosetta; pyrosetta.init()\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Make sure you are in the directory with the pdb files:**\n", "\n", "`cd google_drive/MyDrive/student-notebooks/`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import logging\n", "logging.basicConfig(level=logging.INFO)\n", "import os\n", "import pyrosetta\n", "import pyrosetta.toolbox\n", "import site\n", "\n", "from IPython.core.display import display, HTML\n", "display(HTML(\"\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Initialize PyRosetta " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pyrosetta.init(\"-ignore_unrecognized_res 1 -ex1 -ex2aro\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " For this tutorial, let's again use the native protein crambin from PDB ID 1AB1 (http://www.rcsb.org/structure/1AB1)\n", " Setup the input pose and scorefunction:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "start_pose = pyrosetta.toolbox.rcsb.pose_from_rcsb(\"1AB1\", ATOM=True, CRYS=False)\n", "pose = start_pose.clone()\n", "scorefxn = pyrosetta.create_score_function(\"ref2015_cart.wts\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " To list the cysteine residues in crambin, now we use ResidueSelectors:\n", " Note difference in residue names \"CYS:disulfide\" vs. \"CYS\"\n", " \n", " Note that we could also use the `ResiduePropertySelector` and use the `DISULFIDE_BONDED` property to grab these." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "disulfide_res = pyrosetta.rosetta.core.select.residue_selector.ResidueNameSelector(\"CYS:disulfide\")\n", "print(pyrosetta.rosetta.core.select.get_residues_from_subset(disulfide_res.apply(pose)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Inspect the starting pose using the `PyMolMover` or `dump_pdb()`. By default, disulfide bonds are not drawn even if they exist in PyRosetta:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " You can also use this shortcut to view a pose in `py3Dmol` which recognizes disulfide bonds in PyRosetta:\n", " \n", "Run one of the following, whether you git cloned the pyrosetta_scripts repository or downloaded visualization.py from the Google Drive\n", "\n", "`%run ~/pyrosetta_scripts/pilot/apps/klimaj/py3Dmol/visualization.py`\n", "`%run ./visualization.py`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Design strategy\n", "\n", "Design away the cysteine residues (i.e. disulfide bonds) using ResidueSelectors and TaskOperations, allowing all side-chains to re-pack and all backbone and side-chain torsions to minimize using the `FastDesign` mover." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Note: because we did not include the `-detect_disulfide 0` command line flag in `pyrosetta.init()`, in order to mutate disulfide bonded cysteine residues using packing steps in the `FastDesign` mover, first we need to break the disulfide bonds:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for i in pyrosetta.rosetta.core.select.get_residues_from_subset(disulfide_res.apply(pose)):\n", " for j in pyrosetta.rosetta.core.select.get_residues_from_subset(disulfide_res.apply(pose)):\n", " if pyrosetta.rosetta.core.conformation.is_disulfide_bond(pose.conformation(), i, j):\n", " pyrosetta.rosetta.core.conformation.break_disulfide(pose.conformation(), i, j)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Now we can declare a `ResidueSelector` for cysteine residues:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cys_res = pyrosetta.rosetta.core.select.residue_selector.ResidueNameSelector(\"CYS\")\n", "print(pyrosetta.rosetta.core.select.get_residues_from_subset(cys_res.apply(pose)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Note: the pose consists of only chain \"A\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(pose.pdb_info())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Although the pose contains only chain A, if the pose contained other chains we could make the selection to only select chain A and cysteine residues using an `AndResidueSelector`. We will use this ResidueSelector with `RestrictAbsentCanonicalAASRLT` (restrict absent canonical amino acids residue level task operation)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "chain_A = pyrosetta.rosetta.core.select.residue_selector.ChainSelector(\"A\")\n", "print(pyrosetta.rosetta.core.select.get_residues_from_subset(chain_A.apply(pose)))\n", "chain_A_cys_res = pyrosetta.rosetta.core.select.residue_selector.AndResidueSelector(selector1=cys_res, selector2=chain_A)\n", "print(pyrosetta.rosetta.core.select.get_residues_from_subset(chain_A_cys_res.apply(pose)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Specify a `NotResidueSelector` selecting everything except the `chain_A_cys_res` ResidueSelector to use with a `RestrictToRepackingRLT` (restrict to repacking residue level task operation):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "not_chain_A_cys_res = pyrosetta.rosetta.core.select.residue_selector.NotResidueSelector(chain_A_cys_res)\n", "print(pyrosetta.rosetta.core.select.get_residues_from_subset(not_chain_A_cys_res.apply(pose)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Quickly view the `not_chain_A_cys_res` ResidueSelector:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Now we can set up the TaskOperations for `FastDesign`:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# The task factory accepts all the task operations\n", "tf = pyrosetta.rosetta.core.pack.task.TaskFactory()\n", "\n", "# These are pretty standard\n", "tf.push_back(pyrosetta.rosetta.core.pack.task.operation.InitializeFromCommandline())\n", "tf.push_back(pyrosetta.rosetta.core.pack.task.operation.IncludeCurrent())\n", "tf.push_back(pyrosetta.rosetta.core.pack.task.operation.NoRepackDisulfides())\n", "\n", "\n", "# Disable design (i.e. repack only) on not_chain_A_cys_res\n", "tf.push_back(pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(\n", " pyrosetta.rosetta.core.pack.task.operation.RestrictToRepackingRLT(), not_chain_A_cys_res))\n", "\n", "# Enable design on chain_A_cys_res\n", "aa_to_design = pyrosetta.rosetta.core.pack.task.operation.RestrictAbsentCanonicalAASRLT()\n", "aa_to_design.aas_to_keep(\"ADEFGHIKLMNPQRSTVWY\")\n", "tf.push_back(pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(\n", " aa_to_design, chain_A_cys_res))\n", "\n", "# Convert the task factory into a PackerTask\n", "packer_task = tf.create_task_and_apply_taskoperations(pose)\n", "# View the PackerTask\n", "print(packer_task)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " This time we will set up a `MoveMap` to establish which torsions are free to minimize" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mm = pyrosetta.rosetta.core.kinematics.MoveMap()\n", "mm.set_bb(True)\n", "mm.set_chi(True)\n", "mm.set_jump(True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set up `FastDesign`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rel_design = pyrosetta.rosetta.protocols.relax.FastRelax(scorefxn_in=scorefxn, standard_repeats=1, script_file=\"MonomerDesign2019\")\n", "rel_design.cartesian(True)\n", "rel_design.set_task_factory(tf)\n", "rel_design.set_movemap(mm)\n", "rel_design.minimize_bond_angles(True)\n", "rel_design.minimize_bond_lengths(True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Run the `FastDesign` mover. Note: this takes ~39.6 s" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "deletable": false, "nbgrader": { "cell_type": "code", "checksum": "a9a5ac8b784aee1a5313f76960bb4cb0", "grade": true, "grade_id": "cell-0276fa644308dd5b", "locked": false, "points": 0, "schema_version": 3, "solution": true } }, "outputs": [], "source": [ "YOUR-CODE-HERE" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Inspect the resulting design!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## *Design Challenge*:\n", "\n", "### Copy and modify this script to:\n", " - Repack all residues and allow all degrees of freedom to minimize (i.e. FastRelax) `start_pose` prior to downstream design. Use the resulting `start_pose` for analysis.\n", " - Re-design the cysteine residues in `start_pose` to allow only hydrophobic residues excluding glycine and proline\n", " - Only re-pack residues within a 6 Angstroms radius around the neighborhood of each cysteine residue (Cα-Cα distance)\n", " - Note this will require using:\n", " - The NeighborhoodResidueSelector: `pyrosetta.rosetta.core.select.residue_selector.NeighborhoodResidueSelector(selector, distance, include_focus_in_subset)`\n", " - The prevent repacking residue level task operation: `pyrosetta.rosetta.core.pack.task.operation.PreventRepackingRLT()`\n", " - Minimize only the side-chains (chi degrees of freedom) being re-packed or designed\n", " - Allow the backbone torsions to minimize, except for the first, last and any proline phi/psi angles\n", " \n", "## *Extra Challenge!*\n", "\n", " Instead of using `pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset` TaskOperations, use `pyrosetta.rosetta.protocols.task_operations.ResfileCommandOperation` TaskOperations by applying resfile-style commands to ResidueSelectors. Example:\n", " > repack_only_task_operation = pyrosetta.rosetta.protocols.task_operations.ResfileCommandOperation() \n", " > repack_only_task_operation.set_command(\"POLAR EMPTY NC R2 NC T6 NC OP5\") \n", " > repack_only_task_operation.set_residue_selector(selector) \n", " > tf.push_back(repack_only_task_operation)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " By how many Angstroms RMSD did the backbone Cα atoms move?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " What is the delta `total_score` from `start_pose` to `pose`?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " What is the per-residue energy difference for each mutated position between `start_pose` and `pose`?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Protein Design with a Resfile and FastRelax](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/06.03-Design-with-a-resfile-and-relax.ipynb) | [Contents](toc.ipynb) | [Index](index.ipynb) | [HBNet Before Design](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/06.05-HBNet-Before-Design.ipynb) >

\"Open" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.1" }, "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 }