You are here

Pyrosetta: restrict repack (and minimization) to specific region

7 posts / 0 new
Last post
Pyrosetta: restrict repack (and minimization) to specific region
#1

Hi everyone,

I am trying to restrict repacking around a residue . I have written a script with PreventRepacking() and RestrictToRepacking but I am still confised about the result. Here is the code I am using:

    # Select specific residues
    nbr_selector = pyrosetta.rosetta.core.select.residue_selector.NeighborhoodResidueSelector()
    nbr_selector.set_focus(str(mutant_position))
    nbr_selector.set_distance(pack_radius)
    nbr_selector.set_include_focus_in_subset(True)
    
    prevent = operation.PreventRepackingRLT() # should be operation.RestrictToRepackRLT() ?
    restrict_to_focus = pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(prevent, nb
r_selector, True)
 
    # Create TaskFactory
    tf = TaskFactory()
    tf.push_back(operation.InitializeFromCommandline())
    tf.push_back(operation.RestrictToRepacking()) # should be operation.PreventRepacking()?
    tf.push_back(restrict_to_focus)

    # Repack
    packer = pyrosetta.rosetta.protocols.minimization_packing.PackRotamersMover(pack_scorefxn)
    packer.task_factory(tf)
    packer.apply(pose)

 

I set pack_radius = 0 so only the mutant position should be repacked. The output seems to be consistent with only a single residue repacked in the logfile.

core.scoring.ScoreFunctionFactory: SCOREFUNCTION: ref2015
core.pack.task: Packer task: initialize from command line() 
core.pack.pack_rotamers: built 2 rotamers at 1 positions.
core.pack.interaction_graph.interaction_graph_factory: Instantiating PDInteractionGraph
core.pack.task: Packer task: initialize from command line() 
core.pack.pack_rotamers: built 2 rotamers at 1 positions.
core.pack.interaction_graph.interaction_graph_factory: Instantiating DensePDInteractionGraph

I am unsure about the usage of  RestrictToRepack and PreventRepacking in the code above. Therefore, I updated it so the new code first PreventRepacking the whole protein, then RestrictToRepackRLT to only mutant position.  However, the output suggests that my understanding of PreventRepackingRLT() and RestrictToRepacking() is wrong. Is there anything I missed?

    ...
    prevent = operation.RestrictToRepackRLT()
    ...
    tf.push_back(operation.PreventRepacking())
    tf.push_back(restrict_to_focus)

core.scoring.ScoreFunctionFactory: SCOREFUNCTION: ref2015
core.pack.task: Packer task: initialize from command line() 
core.pack.pack_rotamers: built 2 rotamers at 1 positions.
core.pack.interaction_graph.interaction_graph_factory: Instantiating PDInteractionGraph
core.pack.task: Packer task: initialize from command line() 
core.pack.pack_rotamers: built 4177 rotamers at 323 positions.
core.pack.interaction_graph.interaction_graph_factory: Instantiating PDInteractionGraph

Also, I have two more follow-up.

1. I notice that the dumback rotamer library provides only 2 rotamers at the mutant position. Is there anyway to expand the rotamer library beyond only 2 rotamers  (phenylalanine)?

2. I suppose replacing pyrosetta.rosetta.protocols.minimization_packing.PackRotamersMover with MinMover will switch repacking to minimization. Nonetheless, the restriction region of the protein will still be the same.

Thank you so much for helping. I appreciate any comment.

Category: 
Post Situation: 
Tue, 2019-07-02 10:52
kschu

Hi!

 

You can use `print(packer)` to see what will get repacked and what not.

I thonk you are missing this: Once a residue as marked as not repackable it can not be made packable again

https://www.rosettacommons.org/docs/latest/rosetta_basics/structural_concepts/PackerPalette

Regarding rotamers, have a look at

https://www.rosettacommons.org/docs/latest/rosetta_basics/options/packing-options

 

 

Wed, 2019-07-03 19:06
ajasja

Thank you for the reminder.  I tried to modify part of the code but then the script does not repack at all. I thought now I have first defined RestrictToRepacking within focus and PreventRepacking out of focus. I believe I am still missing something.  Would you mind to indicate the problem again?

prevent_in = operation.RestrictToRepackingRLT()
restrict_in_focus = pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(prevent_in,nbr_selector, True)
prevent_off = operation.PreventRepackingRLT()
restrict_off_focus = pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(prevent_off, nb_selector, False)

tf = TaskFactory()
tf.push_back(operation.InitializeFromCommandLine())
tf.push_back(restrict_in_focus)
tf.push_back(restrict_off_focus)

packer = pyrosetta.rosetta.protocols.minimization_packing.PackRotamersMover(pack_scorefxn)
packer.task_factory(tf)
packer.apply(pose)

core.scoring.ScoreFunctionFactory: SCOREFUNCTION: ref2015                                                                                  core.pack.task: Packer task: initialize from command line()                                                                         core.pack.pack_rotamers: built 2 rotamers at 1 positions.                                                        core.pack.interaction_graph.interaction_graph_factory: Instantiating PDInteractionGraph

 

Thu, 2019-07-04 01:51
kschu

First off, I assume that you've printed your packer task and have seen that you have the appropriate residues set to the appropriate behavior. (You can do this by doing something like `print( tf.create_task_and_apply_taskoperations(pose) )` or `tf.create_task_and_apply_taskoperations(pose).show()` )

From the "built 2 rotamers at 1 positions" line, it does look like you're repacking, it's just that you're only packing a single residue, and you're not getting very many rotamers at that residue.

One possible reason for this is the clash pre-check that happens during packing. The packer will look at the "fixed" atoms (the sidechains you're not repacking and the backbone) and if there's too many clashes of a rotamer with those fixed atoms, it will save time by throwing that rotamer out. (On the assumption you'd never pick a highly clashing rotamer when there's a non-clashing rotamer availible.) If your selected residue is in a tight location, it might be that all but two of the rotamers are highly clashing and are discarded.

Sidechain which are allowed to repack aren't counted as clashing for the pre-check, though, so if you increase the size of the radius you're repacking, you may permit some movement of your desired sidechain.

Tue, 2019-07-09 09:33
rmoretti

I believe the pack was only done to the single residue when mutated.  It might have nothing to do with the PackRotamersMover.

Ultimately, I decided to do the following simple task. It seems that all residues are still accessible to design. Either I do not understand PreventRepacking() or the command is not working.

import pyrosetta
from pyrosetta.rosetta.core.pack import task
pyrosetta.init()

pose = pyrosetta.pose_from_pdb('sample_1.pdb')

tf = task.TaskFactory()
tf.push_back(task.operation.InitializeFromCommandline())
tf.push_back(task.operation.PreventRepacking())
print(tf.create_task_and_apply_taskoperations(pose))

PyRosetta-4 2019 [Rosetta PyRosetta4.Release.python35.linux 2019.18+release.afa5e7070602177fda1ffba62d1bcd4252285690 2019-05-02T16:30:01] retrieved from: http://www.pyrosetta.org
(C) Copyright Rosetta Commons Member Institutions. Created in JHU by Sergey Lyskov and PyRosetta Team.
#Packer_Task

resid   pack?   design? allowed_aas
1       TRUE    TRUE    ALA:NtermProteinFull,CYS:NtermProteinFull,ASP:NtermProteinFull,GLU:NtermProteinFull,PHE:NtermProteinFull,GLY:NtermProteinFull,HIS:NtermProteinFull,HIS_D:NtermProteinFull,ILE:NtermProteinFull,LYS:NtermProteinFull,LEU:NtermProteinFull,MET:NtermProteinFull,ASN:NtermProteinFull,PRO:NtermProteinFull,GLN:NtermProteinFull,ARG:NtermProteinFull,SER:NtermProteinFull,THR:NtermProteinFull,VAL:NtermProteinFull,TRP:NtermProteinFull,TYR:NtermProteinFull
2       TRUE    TRUE    ALA,CYS,ASP,GLU,PHE,GLY,HIS,HIS_D,ILE,LYS,LEU,MET,ASN,PRO,GLN,ARG,SER,THR,VAL,TRP,TYR
3       TRUE    TRUE    ALA,CYS,ASP,GLU,PHE,GLY,HIS,HIS_D,ILE,LYS,LEU,MET,ASN,PRO,GLN,ARG,SER,THR,VAL,TRP,TYR
4       TRUE    TRUE    ALA,CYS,ASP,GLU,PHE,GLY,HIS,HIS_D,ILE,LYS,LEU,MET,ASN,PRO,GLN,ARG,SER,THR,VAL,TRP,TYR
5       TRUE    TRUE    ALA,CYS,ASP,GLU,PHE,GLY,HIS,HIS_D,ILE,LYS,LEU,MET,ASN,PRO,GLN,ARG,SER,THR,VAL,TRP,TYR
6       TRUE    TRUE    ALA,CYS,ASP,GLU,PHE,GLY,HIS,HIS_D,ILE,LYS,LEU,MET,ASN,PRO,GLN,ARG,SER,THR,VAL

 

Wed, 2019-07-10 02:55
kschu

Because a global PreventRepacking would result in a packing job that does nothing, the PreventRepacking operation requires you specify which residues you want it to apply to. By default, it acts on no residues, so the way you're using it effectively does nothing.

This is in contrast to the RestrictToRepacking operation, which does act on all residues by default. If you applied that operation, you should definitely see a difference in the output task.

Wed, 2019-07-10 09:53
rmoretti

Thanks rmoretti. Now I fully understand the commands.

Wed, 2019-07-10 23:35
kschu