{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Before you turn this problem in, make sure everything runs as expected. First, **restart the kernel** (in the menubar, select Kernel$\\rightarrow$Restart) and then **run all cells** (in the menubar, select Cell$\\rightarrow$Run All).\n", "\n", "Make sure you fill in any place that says `YOUR CODE HERE` or \"YOUR ANSWER HERE\", as well as your name and collaborators below:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "NAME = \"\"\n", "COLLABORATORS = \"\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "*This notebook contains material from [PyRosetta](https://RosettaCommons.github.io/PyRosetta);\n", "content is available [on Github](https://github.com/RosettaCommons/PyRosetta.notebooks.git).*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Pose Basics](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/02.01-Pose-Basics.ipynb) | [Contents](toc.ipynb) | [Index](index.ipynb) | [Accessing PyRosetta Documentation](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/02.03-Accessing-PyRosetta-Documentation.ipynb) >
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Working with Pose residues\n",
"Keywords: total_residue(), chain(), number(), pdb2pose(), pose2pdb()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Notebook setup\n",
"import sys\n",
"if 'google.colab' in sys.modules:\n",
" !pip install pyrosettacolabsetup\n",
" import pyrosettacolabsetup\n",
" pyrosettacolabsetup.setup()\n",
" print (\"Notebook is set for PyRosetta use in Colab. Have fun!\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pyrosetta import *\n",
"init()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**From previous section:**\n",
"Make sure you are in the directory with the pdb files:\n",
"\n",
"`cd google_drive/My\\ Drive/student-notebooks/`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pose = pose_from_pdb(\"inputs/5tj3.pdb\")\n",
"pose_clean = pose_from_pdb(\"inputs/5tj3.clean.pdb\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can use methods in `Pose` to count residues and pick out residues from the pose. Remember that `Pose` is a python class, and to access methods it implements, you need an instance of the class (here `pose` or `pose_clean`) and you then use a dot after the instance."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(pose.total_residue())\n",
"print(pose_clean.total_residue())\n",
"# Did you catch all the missing residues before?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" Store the `Residue` information for residue 20 of the pose by using the `pose.residue(20)` function."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "05b8fd10fd1c21fdbffacf311ee02cbc",
"grade": true,
"grade_id": "cell-b4a65f9eb1e72d02",
"locked": false,
"points": 0,
"schema_version": 1,
"solution": true
}
},
"outputs": [],
"source": [
"# residue20 = type here\n",
"# YOUR CODE HERE\n",
"raise NotImplementedError()\n",
"print(residue20.name())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 2: Residue objects\n",
"\n",
"Use the `pose`'s `.residue()` object to get the 24th residue of the protein pose. What is the 24th residue in the PDB file (look in the PDB file)? Are they the same residue?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"code_folding": [],
"deletable": false,
"nbgrader": {
"checksum": "6d95d121eddc3d59c869259e3916fded",
"grade": true,
"grade_id": "cell-0b423c45607a85e0",
"locked": false,
"points": 0,
"schema_version": 1,
"solution": true
}
},
"outputs": [],
"source": [
"# store the 24th residue in the pose into a variable (see residue20 example above)\n",
"# YOUR CODE HERE\n",
"raise NotImplementedError()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"code_folding": []
},
"outputs": [],
"source": [
"# what other methods are attached to that Residue object? (type \"residue24.\" and hit Tab to see a list of commands)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can immediately see that the numbering PyRosetta internally uses for pose residues is different from the PDB file. The information corresponding to the PDB file can be accessed through the `pose.pdb_info()` object."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(pose.pdb_info().chain(24))\n",
"print(pose.pdb_info().number(24))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"By using the `pdb2pose` method in `pdb_info()`, we can turn PDB numbering (which requires a chain ID and a residue number) into Pose numbering"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"code_folding": []
},
"outputs": [],
"source": [
"# PDB numbering to Pose numbering\n",
"print(pose.pdb_info().pdb2pose('A', 24))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the `pose2pdb` method in `pdb_info()` to see what is the corresponding PDB chain and residue ID for pose residue number 24"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"code_folding": []
},
"outputs": [],
"source": [
"# Pose numbering to PDB numbering"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"deletable": false,
"nbgrader": {
"checksum": "309cd8a058823fe1abab7d02ee273613",
"grade": true,
"grade_id": "cell-eb3b845928c9313f",
"locked": false,
"points": 0,
"schema_version": 1,
"solution": true
}
},
"outputs": [],
"source": [
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can see how to examine the identity of a residue by PDB chain and residue number.\n",
"\n",
"Once we get a residue, there are various methods in the `Residue` class that might be for running analysis. We can get instances of the `Residue` class from `Pose`. For instance, we can do the following:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"res_24 = pose.residue(24)\n",
"print(res_24.name())\n",
"print(res_24.is_charged())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"< [Pose Basics](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/02.01-Pose-Basics.ipynb) | [Contents](toc.ipynb) | [Index](index.ipynb) | [Accessing PyRosetta Documentation](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/02.03-Accessing-PyRosetta-Documentation.ipynb) >
"
]
}
],
"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.0"
},
"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
}