Reading constraints from a file

Member Site Forums PyRosetta PyRosetta – General Reading constraints from a file

Viewing 6 reply threads
  • Author
    Posts
    • #2673
      Anonymous

        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.

         

         

      • #12409
        Anonymous

          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_

          );

           

           

        • #12930
          Anonymous

            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_

            );

             

             

          • #13451
            Anonymous

              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_

              );

               

               

            • #12413
              Anonymous

                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.

                 

              • #12934
                Anonymous

                  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.

                   

                • #13455
                  Anonymous

                    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.

                     

                Viewing 6 reply threads
                • You must be logged in to reply to this topic.