Keywords: FastDesign, FastRelax, ResidueSelector, TaskFactory, TaskOperation, pose_from_rcsb, get_residues_from_subset, ResidueNameSelector, ChainSelector, ResiduePropertySelector, NotResidueSelector, AndResidueSelector, RestrictToRepackingRLT, RestrictAbsentCanonicalAASRLT, NoRepackDisulfides, OperateOnResidueSubset
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. :)
Warning: This notebook uses pyrosetta.distributed.viewer
code, which runs in jupyter notebook
and might not run if you're using jupyterlab
.
!pip install pyrosettacolabsetup
import pyrosettacolabsetup; pyrosettacolabsetup.install_pyrosetta()
import pyrosetta; pyrosetta.init()
Make sure you are in the directory with the pdb files:
cd google_drive/MyDrive/student-notebooks/
import logging
logging.basicConfig(level=logging.INFO)
import os
import pyrosetta
import pyrosetta.toolbox
import site
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
pyrosetta.init("-ignore_unrecognized_res 1 -ex1 -ex2aro")
For this tutorial, let's again use the native protein crambin from PDB ID 1AB1 (http://www.rcsb.org/structure/1AB1) Setup the input pose and scorefunction:
start_pose = pyrosetta.toolbox.rcsb.pose_from_rcsb("1AB1", ATOM=True, CRYS=False)
pose = start_pose.clone()
scorefxn = pyrosetta.create_score_function("ref2015_cart.wts")
To list the cysteine residues in crambin, now we use ResidueSelectors: Note difference in residue names "CYS:disulfide" vs. "CYS"
Note that we could also use the ResiduePropertySelector
and use the DISULFIDE_BONDED
property to grab these.
disulfide_res = pyrosetta.rosetta.core.select.residue_selector.ResidueNameSelector("CYS:disulfide")
print(pyrosetta.rosetta.core.select.get_residues_from_subset(disulfide_res.apply(pose)))
Inspect the starting pose using the PyMolMover
or dump_pdb()
. By default, disulfide bonds are not drawn even if they exist in PyRosetta:
You can also use this shortcut to view a pose in py3Dmol
which recognizes disulfide bonds in PyRosetta:
Run one of the following, whether you git cloned the pyrosetta_scripts repository or downloaded visualization.py from the Google Drive
%run ~/pyrosetta_scripts/pilot/apps/klimaj/py3Dmol/visualization.py
%run ./visualization.py
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.
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:
for i in pyrosetta.rosetta.core.select.get_residues_from_subset(disulfide_res.apply(pose)):
for j in pyrosetta.rosetta.core.select.get_residues_from_subset(disulfide_res.apply(pose)):
if pyrosetta.rosetta.core.conformation.is_disulfide_bond(pose.conformation(), i, j):
pyrosetta.rosetta.core.conformation.break_disulfide(pose.conformation(), i, j)
Now we can declare a ResidueSelector
for cysteine residues:
cys_res = pyrosetta.rosetta.core.select.residue_selector.ResidueNameSelector("CYS")
print(pyrosetta.rosetta.core.select.get_residues_from_subset(cys_res.apply(pose)))
Note: the pose consists of only chain "A"
print(pose.pdb_info())
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).
chain_A = pyrosetta.rosetta.core.select.residue_selector.ChainSelector("A")
print(pyrosetta.rosetta.core.select.get_residues_from_subset(chain_A.apply(pose)))
chain_A_cys_res = pyrosetta.rosetta.core.select.residue_selector.AndResidueSelector(selector1=cys_res, selector2=chain_A)
print(pyrosetta.rosetta.core.select.get_residues_from_subset(chain_A_cys_res.apply(pose)))
Specify a NotResidueSelector
selecting everything except the chain_A_cys_res
ResidueSelector to use with a RestrictToRepackingRLT
(restrict to repacking residue level task operation):
not_chain_A_cys_res = pyrosetta.rosetta.core.select.residue_selector.NotResidueSelector(chain_A_cys_res)
print(pyrosetta.rosetta.core.select.get_residues_from_subset(not_chain_A_cys_res.apply(pose)))
Quickly view the not_chain_A_cys_res
ResidueSelector:
Now we can set up the TaskOperations for FastDesign
:
# The task factory accepts all the task operations
tf = pyrosetta.rosetta.core.pack.task.TaskFactory()
# These are pretty standard
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.InitializeFromCommandline())
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.IncludeCurrent())
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.NoRepackDisulfides())
# Disable design (i.e. repack only) on not_chain_A_cys_res
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(
pyrosetta.rosetta.core.pack.task.operation.RestrictToRepackingRLT(), not_chain_A_cys_res))
# Enable design on chain_A_cys_res
aa_to_design = pyrosetta.rosetta.core.pack.task.operation.RestrictAbsentCanonicalAASRLT()
aa_to_design.aas_to_keep("ADEFGHIKLMNPQRSTVWY")
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(
aa_to_design, chain_A_cys_res))
# Convert the task factory into a PackerTask
packer_task = tf.create_task_and_apply_taskoperations(pose)
# View the PackerTask
print(packer_task)
This time we will set up a MoveMap
to establish which torsions are free to minimize
mm = pyrosetta.rosetta.core.kinematics.MoveMap()
mm.set_bb(True)
mm.set_chi(True)
mm.set_jump(True)
Set up FastDesign
rel_design = pyrosetta.rosetta.protocols.relax.FastRelax(scorefxn_in=scorefxn, standard_repeats=1, script_file="MonomerDesign2019")
rel_design.cartesian(True)
rel_design.set_task_factory(tf)
rel_design.set_movemap(mm)
rel_design.minimize_bond_angles(True)
rel_design.minimize_bond_lengths(True)
Run the FastDesign
mover. Note: this takes ~39.6 s
YOUR-CODE-HERE
Inspect the resulting design!
start_pose
prior to downstream design. Use the resulting start_pose
for analysis.start_pose
to allow only hydrophobic residues excluding glycine and prolinepyrosetta.rosetta.core.select.residue_selector.NeighborhoodResidueSelector(selector, distance, include_focus_in_subset)
pyrosetta.rosetta.core.pack.task.operation.PreventRepackingRLT()
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:
repack_only_task_operation = pyrosetta.rosetta.protocols.task_operations.ResfileCommandOperation()
repack_only_task_operation.set_command("POLAR EMPTY NC R2 NC T6 NC OP5")
repack_only_task_operation.set_residue_selector(selector)
tf.push_back(repack_only_task_operation)
By how many Angstroms RMSD did the backbone Cα atoms move?
What is the delta total_score
from start_pose
to pose
?
What is the per-residue energy difference for each mutated position between start_pose
and pose
?