Member Site › Forums › PyRosetta › PyRosetta – Applications › Docking with Constraints in PyRosetta
- This topic has 4 replies, 2 voices, and was last updated 9 years, 5 months ago by
Anonymous.
-
AuthorPosts
-
-
March 28, 2015 at 6:16 pm #2172
Anonymous
Recently I started attempting to use PyRosetta to perform protein-protein docking. I was following the PyRosetta docking tutorial at http://www.pyrosetta.org/tutorials and managed to get a script together that can generate a bunch of coarse models and then the best n of them are submitted to high resolution refined docking. I was interested in attempting to set up constraints for these docking experiments, so I generated some constraints files that include AtomPair and/or Site constraints but I’m not sure how to use these easily in PyRosetta. I discovered that I have to import rosetta.core.scoring.constraints to get access to a lot of useful functions, one of which is “add_constraints_from_cmdline_to_pose” so I can specify the constraints file in init’s “extra_options” argument. That seems to work. But I tried to use add_constraints_from_cmdline_to_scorefxn on a scoring function but it doesn’t appear to add weights for atom_pair and site constraints. Is there a special weights file for docking (was using “interchain_cen” for lowres and generally “talaris2013” for highres) that includes these weights so I don’t have to guess what they should be, or is there a way to “turn on” these constraints in a pre-existing scoring function?
I know this is the PyRosetta forum, so this may not be an appropriate place to ask this, but if I use the regular Rosetta docking_protocol to do this, do I just specify the constraints file on the command line and then the constraints will be used properly (so I don’t have to fiddle with score function options)? It seems that in the PyRosetta tutorial you run a large number of lowres docking simulations followed by a smaller amount of highres simulations on the best lowres models (if I have understood the tutorial correctly). How do you do this in regular Rosetta? Is it just specifying an nstruct value and each struct is the result of a lowres followed by highres simulation?
Thank you for your assistance and I apologize if these are basic questions that were answered elsewhere.
-
March 28, 2015 at 10:46 pm #10902
Anonymous
HI! So, it seems there are a lot of questions in this post – lets see if we can answer each of them.
1) Yes, for the namespace build, much of the extended functions and classes need to be imported. This is to save memory. The monolith build should have everything imported, but can sometimes require more memory.
2) You should be able to use those extra_options OK. For the scorefunction, they add it to the scorefunction that gets created using the get_score_function() function. This function initializes the score function from the command-line via the set default. In this case, currently, it will create the talaris2013 scorefunction and then add the weights to it before returning it to you.
If you are using a custom scorefunction, you have to add the weights to the scorefunction, typically at 1.0. If you have a lot of site_constraints, I have found that a weight of .01 works well to keep the interface ‘around’ where you want it. The command you will want is my_scorefxn.set_weight(term, weight).
The scorefunction cst terms are these: constraint_types = [atom_pair_constraint, angle_constraint, dihedral_constraint, coordinate_constraint, constant_constraint]
So, to finish this, here is a function I use in the PyRosetta Toolkit GUI when you add constraints in the file menu. You should be able to deduce everything you need from it, but will need to remove the TK GUI stuff:
def add_constraints_to_pose_and_scorefunction(pose, score, default_weight = 1.0, constraint_types = False, constraint_file=False):
“””
Adds constraint from file to pose and score. Sets all constraint_types to 1.0.
Can pass an array of constraint_types.
“””
if pose.total_residue()==0:
print “Please load a pose.”
return “”
if not constraint_types:
constraint_types = [atom_pair_constraint, angle_constraint, dihedral_constraint, coordinate_constraint, constant_constraint]if not constraint_file:
constraint_file = tkFileDialog.askopenfilename(initialdir=global_variables.current_directory, title = “Open Constraint File”)
if not constraint_file:return
global_variables.current_directory = os.path.dirname(constraint_file)
print “Setting constraints to pose and scorefunction at default weight of 1.0 if not already set. “
setup = ConstraintSetMover()
setup.constraint_file(constraint_file)
setup.apply(pose)for constraint in constraint_types:
if score.get_weight(constraint)==0:
score.set_weight(constraint, default_weight)
return constraint_file3) Yes, interchain_cen is the default for low-res. For high-res, the default in the code is actually a score with a patch: create_score_function( “docking”, “docking_min” ) The packing scorefunction is then talaris2013 – this is passed in the constructor of DockMCMProtocol (with 1 being the jump which you should have already setup via protocols::docking::setup_foldtree(pose, dock_chains, movable_jumps);:
high_res_docker = DockMCMProtocol(1, docking_scorefxn_high, packing_scorefxn)
4) In regular Rosetta, the documentation is very good and should show you how to do what you want. https://www.rosettacommons.org/docs/latest/docking-protocol.html
Hope this is everything you need! Let us know if anything else is amiss!
-Jared
-
March 29, 2015 at 9:04 pm #10905
Anonymous
Hey so, site_constraints are just custom ambiguous atom-pair constraints. They are really really awesome. I think Brian Weitzner was the one who first wrote the code. Anyway, in this case, just use the atom_pair_constraint. term
-
March 29, 2015 at 7:15 pm #10903
Anonymous
Hi Jared,
Thanks for the response, this is helpful! Actually I did not know that DockMCMProtocol takes two scoring functions so that is useful information. It seems that the correct function for generating score functions with patches is “create_score_function_ws_patch” in case anybody is reading this and having difficulty doing “create_score_function_ws_patch(“docking”, “docking_min”)”. I’ll set the AtomPair and Site constraint weights to 1.0 and tune it down to 0.1 if it seems that those weights are more appropriate. I was just trying to set up a generalized docking protocol for my coworkers and wanted to make sure I was doing it right.
I seem to be having an issue using site_constraints in PyRosetta though. When I attempt to set site_constraint to some value, I get a C++ exception. If I attempt to do the same command again, I don’t get an exception and it appears to set the constraint, but then doesn’t appear to score the constraint. Setting the site_constraint back to 0 causes a seg fault. Are site constraints not supported in PyRosetta?
Thanks for your help!
-
March 30, 2015 at 1:30 pm #10906
Anonymous
I see, I didn’t realize the atom_pair_constraint was scoring the site constraints (the constraints file I was testing had both AtomPair and Site constraints, so it obviously was a bad test). Yeah, they looked awesome, which is why I wanted to try to use them! Thanks for all your help!
-
-
AuthorPosts
- You must be logged in to reply to this topic.