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.
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
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?
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.
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.
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.
Thanks rmoretti. Now I fully understand the commands.