You are here

Reading constraints from a file

3 posts / 0 new
Last post
Reading constraints from a file
#1

Is there a way to use a standard Rosetta constraints file in PyRosetta?

I know how to add constraints individually in the code but how can I load them from a file?

There is nothing in the documentation on this.

 

 

Category: 
Post Situation: 
Wed, 2017-06-14 18:56
lah435

PyRosetta exposes basically all of the C++, so it becomes a question of "What is the C++ function that loads a constraint file"?

Looking in main/source/src/core/scoring/constraints/util.hh, I see lots of functions that might be what you want (below).  The "fullatom" ones trigger on cst_fa_file and cst_fa_weight, the centroid ones on cst_file and cst_weight.


///////////////COMMAND LINE/////////////////////////////

////////// Centroid constraints (add and replace)

//// @brief  add constraints if specified by user.
void add_constraints_from_cmdline_to_pose( core::pose::Pose & pose );
//// @brief  add constraints if specified by user.
void add_constraints_from_cmdline_to_scorefxn(
    core::scoring::ScoreFunction & scorefxn_
);
//// @brief  add constraints if specified by user.
void add_constraints_from_cmdline(
    core::pose::Pose & pose, core::scoring::ScoreFunction & scorefxn_
);

////////// FA constraints (add and replace)

/// @brief add constraints if specified by user.
void add_fa_constraints_from_cmdline_to_pose( core::pose::Pose & pose );

/// @brief add constraints if specified by user.
void add_fa_constraints_from_cmdline_to_scorefxn(
    core::scoring::ScoreFunction & scorefxn_
);

/// @brief add constraints if specified by user.
void add_fa_constraints_from_cmdline(
    core::pose::Pose & pose,
    core::scoring::ScoreFunction & scorefxn_
);
 

 

Thu, 2017-06-15 12:00
smlewis

Another approach to use is to look at the regular Rosetta documentation at https://www.rosettacommons.org/docs/latest - particularly the RosettaScripts documentation. Each RosettaScripts Mover/Filter/etc. corresponds with a C++ level object, many of which can be used from Python with the appropriate getter/setter methods (verus the XML tags). 

For example, the description of the "ConstraintSetMover" is "Adds constraints to the pose using a constraints file". A little digging around finds it at rosetta.protocols.simple_moves.ConstraintSetMover, which doesn't have much in the way of help, but does have a constraint_file() method you can use to specify the constraint file to use, and, like all movers, an apply() method which will actually act on the Pose.

--

By the way, under the hood this mover uses the rosetta.core.scoring.constraints.ConstraintIO.get_instance().read_constraints() method to read in the constraint file, and the pose.constraint_set() method to actually set them in the pose.

 

Fri, 2017-06-16 07:22
rmoretti