Keywords: score function, ScoreFunction(), get_score_function(), set_weight(), show(), etable_atom_pair_energies(), Atom objects, get_hbonds(), nhbonds(), residue_hbonds()
!pip install pyrosettacolabsetup
import pyrosettacolabsetup; pyrosettacolabsetup.install_pyrosetta()
import pyrosetta; pyrosetta.init()
import pyrosetta
pyrosetta.init()
Make sure you are in the directory with the pdb files:
cd google_drive/MyDrive/student-notebooks/
In this module, we will explore the PyRosetta score function interface. You will learn to inspect energies of a biomolecule at the whole protein, per-residue, and per-atom level. Finally, you will gain practice applying the energies to answering biological questions involving proteins. For these exercises, we will use the protein Ras (PDB 6q21). Either make sure you have the PDB file "6Q21_A.pdb" in your current directory, or if you have an Internet connection, load the pdb into a pose called ras
with the pyrosetta.pose_from_pdb method.
YOUR-CODE-HERE
To score a protein, you will begin by defining a score function using the get_score_function(is_fullatom: bool)
method in the pyrosetta.teaching
namespace. Specifying True
will return the default ref2015
all-atom energy function, while False
will specify the default centroid score function.
Create a PyRosetta score function using:
sfxn = get_score_function(True)
from pyrosetta.teaching import *
YOUR-CODE-HERE
You can see the terms, weights, and energy method options by printing the score function:
print(sfxn)
YOUR-CODE-HERE
Hint: look at the top line that starts with 'weights'
## Your Response Here
YOUR-CODE-HERE
You can also create a custom energy function that includes select terms. Typically, creating a whole new score function is unneccesary because the current one works well in most cases. However, tweaking the current enrgy function by reassigning weights and adding certain energy terms can be useful.
Here, we will make an example energy function with only the van der Waals attractive and repulsive terms, both with weights of 1. We need to use the set_weight()
. Make a new ScoreFunction
and set the weights accordingly. This is how we set the full-atom attractive (fa_atr
) and the full-atom repulsive (fa_rep
) terms.
sfxn2 = ScoreFunction()
sfxn2.set_weight(fa_atr, 1.0)
sfxn2.set_weight(fa_rep, 1.0)
YOUR-CODE-HERE
Lets compare the score of ras
using the full-atom ScoreFunction
versus the ScoreFunction
we made above using only the attractive and repulsive terms.
First, print the total energy of ras
using print(sfxn(ras))
Then, print the attractive and repulsive energy only of ras
using print(sfxn2(ras))
# print total energy of ras
YOUR-CODE-HERE
# print the attractive and repulsive energy of ras
YOUR-CODE-HERE
Using the full-atom ScoreFunction
sfxn
, break the energy of ras
down into its individual pieces with the sfxn.show(ras)
method. Which are the three most dominant contributions, and what are their values? Is this what you would have expected? Why? Note which terms are positive and negative
# use the sfxn.show() method
YOUR-CODE-HERE
# Your response here: what are the three most dominant contributions?
Unweighted, individual component energies of each residue in a structure are stored in the Pose
object and can be accessed by the energies()
method. For example, to break down the energy into each residue's contribution, we use:
print(ras.energies().show(<n>))
Where <n>
is the residue number.
What are the total van der Waals, solvation, and hydrogen-bonding contributions of residue 24?
Note: The backbone hydrogen-bonding terms for each residue are not available from the Energies
object. You can get them by using EnergyMethodOptions. See http://www.pyrosetta.org/documentation#TOC-Hydrogen-Bonds-and-Hydrogen-Bond-Scoring.
YOUR-CODE-HERE
# your response here
The van der Waals, solvation, and electrostatic terms are atom-atom pairwise energies calculated from a pre-tabulated lookup table, dependent upon the distance between the two atoms and their types. You can access this lookup table, called the etable
directly to check these energy calculations on an atom-by-atom basis. Use the etable_atom_pair_energies
function which returns a triplet of energies for attractive, repulsive and solvation scores.
(Note that the etable_atom_pair_energies()
function requires Atom
objects, not the AtomID
objects we saw in Workshop #2. For more info, look at the documentation.)
Practice: What are the attractive, repulsive, solvation, and electrostatic components between the nitrogen of residue 24 and the oxygen of residue 20?
YOUR-CODE-HERE