Using OStream objects in PyRosetta

Member Site Forums PyRosetta PyRosetta – General Using OStream objects in PyRosetta

Viewing 3 reply threads
  • Author
    Posts
    • #1829
      Anonymous

        Dear users/developers,
        I’m trying to find out how to use OStream() objects in PyRosetta. This is necessary for certain functions, e.g. ConstraintSet().show_violations() must take an OStream() object.
        I saw that you cannot use rosetta.utility.OStream() directly, what is the recommended way then to get an OStream to e.g. sys.stdout or stderr?
        Or is it possible to use show_violations() without OStream?
        Thanks!

      • #9787
        Anonymous

          The ostream objects the show() functions typically are meant to accept are basic.Tracer objects, which Rosetta uses to print information to the standard output. I believe you should be able to instantiate one in Python and then pass it into any function which expects an ostream. Note that you may need to call the .flush_all_channels() method of the object to get the stored output to display.

        • #9788
          Anonymous

            As Rocco mentioned you should be able to use Tracer objects. For example of constructing one please see test/T007_TracerIO.py in your PyRosetta build.

          • #9816
            Anonymous

              Thanks for the replies! So I tried the following in ipython. I forgot to mention that I was using PyRosetta compiled from the Rosetta 3.4, which makes it I think 2.011.

              from rosetta import *
              init()
              cio = rosetta.core.scoring.constraints.ConstraintIO.get_instance()
              from rosetta.core.scoring.constraints import ConstraintSet
              cst2 = ConstraintSet()
              pose = pose_from_pdb(“protein.pdb”)
              cio.read_constraints_new(“ecs2.cst”, cst2, pose)
              tr = rosetta.basic.Tracer()
              cst2.show_violations(tr, pose, 10)

              The last command gave me this:
              ArgumentError: Python argument types in
              ConstraintSet.show_violations(ConstraintSet, Tracer, Pose, int)
              did not match C++ signature:
              show_violations(core::scoring::constraints::ConstraintSet {lvalue}, core::pose::Pose {lvalue} pose, unsigned long verbose_level, double threshold=1)
              show_violations(ConstraintSet_exposer_callback {lvalue}, std::ostream {lvalue} out, core::pose::Pose {lvalue} , unsigned long verbose_level, double threshold=1)
              show_violations(core::scoring::constraints::ConstraintSet {lvalue}, std::ostream {lvalue} out, core::pose::Pose {lvalue} , unsigned long verbose_level, double threshold=1)

              The first prototype is just a wrapper that I wrote in the .hh file to drop the requirement on OStream. The last one should be the applicable prototype but it seems like it doesn’t like a Tracer object instead of an OStream.

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