Member Site › Forums › PyRosetta › PyRosetta – General › Using OStream objects in PyRosetta
- This topic has 3 replies, 3 voices, and was last updated 10 years, 8 months ago by Anonymous.
-
AuthorPosts
-
-
February 10, 2014 at 11:10 am #1829Anonymous
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! -
February 10, 2014 at 6:01 pm #9787Anonymous
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.
-
February 10, 2014 at 9:35 pm #9788Anonymous
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.
-
February 17, 2014 at 5:52 pm #9816Anonymous
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.
-
-
AuthorPosts
- You must be logged in to reply to this topic.