Member Site › Forums › PyRosetta › PyRosetta – General › Reading constraints from a file
- This topic has 6 replies, 3 voices, and was last updated 7 years, 6 months ago by Anonymous.
-
AuthorPosts
-
-
June 15, 2017 at 1:56 am #2673Anonymous
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.
-
June 15, 2017 at 7:00 pm #12409Anonymous
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_
);
-
June 15, 2017 at 7:00 pm #12930Anonymous
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_
);
-
June 15, 2017 at 7:00 pm #13451Anonymous
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_
);
-
June 16, 2017 at 2:22 pm #12413Anonymous
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.
-
June 16, 2017 at 2:22 pm #12934Anonymous
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.
-
June 16, 2017 at 2:22 pm #13455Anonymous
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.
-
-
AuthorPosts
- You must be logged in to reply to this topic.