# Notebook setup import sys if 'google.colab' in sys.modules: !pip install pyrosettacolabsetup import pyrosettacolabsetup pyrosettacolabsetup.mount_pyrosetta_install() print ("Notebook is set for PyRosetta use in Colab. Have fun!")
from pyrosetta import * init()
From previous section: Make sure you are in the directory with the pdb files:
cd google_drive/My\ Drive/student-notebooks/
pose = pose_from_pdb("inputs/5tj3.pdb")
from IPython.display import Image Image('./Media/dihedral-final.png',width='500')
Pose objects make it easy to access angles, distances, and torsions for analysis. Lets take a look at how to get backbone torsions first.
#resid = "get the pose residue number for chain A:res 28 using the pdb2pose function" ### BEGIN SOLUTION resid = pose.pdb_info().pdb2pose('A', 28) ### END SOLUTION
print("phi:", pose.phi(resid)) print("psi:", pose.psi(resid)) print("chi1:", pose.chi(1, resid))
phi: -149.17513487055064 psi: 151.30037995499168 chi1: -82.850785668982
Say we want to find the length of the $N$-$C_\alpha$ and $C_\alpha$-$C$ bonds for residue A:28 from the PDB file. We can use a couple approaches. The first involves using the bond length in the
Conformation class, which stores some info on protein geometry. Take a look at some of the methods in the
Conformation class using tab completion.
conformation = pose.conformation() # do some tab completion here to explore the Conformation class methods #conformation.
Look at the documentation for the method
conformation.bond_length below. Remember using the
### BEGIN SOLUTION # ?conformation.bond_length ### END SOLUTION
Object `conformation.bond_length` not found.
To use the bond_length method in the
Conformation class, it looks like we'll need to make
AtomID objects. We can do this using an atom index and residue ID as follows:
# Double Check: does resid contain the Pose numbering or PDB numbering? res_28 = pose.residue(resid) N28 = AtomID(res_28.atom_index("N"), resid) CA28 = AtomID(res_28.atom_index("CA"), resid) C28 = AtomID(res_28.atom_index("C"), resid) # try printing out an AtomID object!
### BEGIN SOLUTION print(N28) ### END SOLUTION
atomno= 1 rsd= 5
As usual, if you did not know how to construct an
AtomID, you could check the documentation using
Now we can compute the bond lengths:
print(pose.conformation().bond_length(N28, CA28)) print(pose.conformation().bond_length(CA28, C28))
Alternatively, we can compute bond lengths ourselves starting from the xyz coordinates of the atoms.
Residue returns a
Vector class. The
Vector class has various useful builtin methods including computing dot products, cross products, and norms. Through operator overloading in the
Vector class, you can just subtract and add vector objects and they will manipulate the corresponding vectors appropriately.
N_xyz = res_28.xyz("N") CA_xyz = res_28.xyz("CA") C_xyz = res_28.xyz("C") N_CA_vector = CA_xyz - N_xyz CA_C_vector = CA_xyz - C_xyz print(N_CA_vector.norm()) print(CA_C_vector.norm())
Thankfully, the two approaches for computing distances check out!
Note: Not all bond lengths, angles, and torsions will be accessible using the
Conformation object. That is because the
Conformation object stores only the subset it needs to generate xyz locations for the atoms in the pose. The most stable way to get this information is to compute it using the xyz Cartesian coordinate vectors as a starting point.
This notebook includes some concepts and exercises from:
"Workshop #2: PyRosetta" in the PyRosetta workbook: https://graylab.jhu.edu/pyrosetta/downloads/documentation/pyrosetta4_online_format/PyRosetta4_Workshop2_PyRosetta.pdf
"Workshop #4.1: PyMOL_Mover" in the PyRosetta workbook: http://www.pyrosetta.org/pymol_mover-tutorial