{ "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", "< [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": [
"!pip install pyrosettacolabsetup\n",
"import pyrosettacolabsetup; pyrosettacolabsetup.install_pyrosetta()\n",
"import pyrosetta; pyrosetta.init()\n"
]
},
{
"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/MyDrive/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": 9,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"524\n",
"519\n"
]
}
],
"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": 10,
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-b4a65f9eb1e72d02",
"locked": false,
"points": 0,
"schema_version": 3,
"solution": true
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ASP\n"
]
}
],
"source": [
"# residue20 = type here\n",
"### BEGIN SOLUTION\n",
"residue20 = pose.residue(20)\n",
"### END SOLUTION\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": 11,
"metadata": {
"code_folding": [],
"nbgrader": {
"grade": true,
"grade_id": "cell-0b423c45607a85e0",
"locked": false,
"points": 0,
"schema_version": 3,
"solution": true
}
},
"outputs": [],
"source": [
"# store the 24th residue in the pose into a variable (see residue20 example above)\n",
"### BEGIN SOLUTION\n",
"residue24 = pose.residue(24)\n",
"### END SOLUTION\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"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": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A\n",
"47\n"
]
}
],
"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": 14,
"metadata": {
"code_folding": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n"
]
}
],
"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": 15,
"metadata": {
"code_folding": []
},
"outputs": [],
"source": [
"# Pose numbering to PDB numbering"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-eb3b845928c9313f",
"locked": false,
"points": 0,
"schema_version": 3,
"solution": true
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"24 A \n"
]
}
],
"source": [
"### BEGIN SOLUTION\n",
"print(pose.pdb_info().pose2pdb(1))\n",
"### END SOLUTION"
]
},
{
"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": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ARG\n",
"True\n"
]
}
],
"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 (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.11.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": 4
}