Member Site › Forums › PyRosetta › PyRosetta – General › Capturing the output of scorefxn.show(pose)
- This topic has 2 replies, 2 voices, and was last updated 10 years, 4 months ago by Anonymous.
-
AuthorPosts
-
-
June 20, 2014 at 12:30 pm #1929Anonymous
I’m using PyRosetta-r21 on Ubuntu togather with IPython 2.0.0 notebooks. This works extremly well, with one small problem:
Some output is redirected to the console in which “ipython notebook” command was started instead of the notebook cell.
So the question is: is it possible to capture the output of scorefxn.show(pose)?
I have tried to use the example in “test/T007_TracerIO.py”
import rosetta as r
r.init()
from toolbox import pose_from_rcsb
#Basic tracer example
T = r.basic.PyTracer()
r.basic.Tracer.set_ios_hook(T, r.basic.Tracer.get_all_channels_string(), True)
pose = pose_from_rcsb("1YY8")
print "Captured IO"
print T.buf()
Works very well. But:
scorefxn = r.get_fa_scorefxn()
scorefxn.show(pose)
print 'nCaptured IO'
print T.buf()
Does not capture the output. (A side question, can T.buf() be cleared?)
Doing: “scorefxn.show(pose, T)” raises an error, becaus of incompatible parameters
stream = r.utility.OString()
scorefxn.show(pose, stream)
raises “RuntimeError: This class cannot be instantiated from Python” and
stream = r.utility.OStringStream
scorefxn.show(pose, stream)
Is also incompatible.
Thank you for your help and best regards,
Ajasja
-
June 21, 2014 at 12:05 am #10117Anonymous
Hi Ajasja,
Here the right way to do this:
b = rosetta.utility.OStringStream()
sf.show(b, pose)
print b.str()As you can see problem is just in order of arguments.
I am curious, how to do send this output to iPython notebook? Is there is standard API for this?
Thanks,
-
June 21, 2014 at 6:57 pm #10120Anonymous
Ahh, not used to reading the C++ signatures, so I missed it (and forgot that the first parameter is basically self and hidden in python!)
show(core::scoring::ScoreFunction {lvalue}, core::pose::Pose {lvalue} pose)
show(core::scoring::ScoreFunction {lvalue}, std::ostream {lvalue} out, core::pose::Pose {lvalue} pose)
show(core::scoring::ScoreFunction {lvalue}, std::ostream {lvalue} out)
>I am curious, how to do send this output to iPython notebook? Is there is standard API for this?I’m not using any particular API. The output of the python print statements is automatically redirected to the corresponding output cell. Only C/C++ code writing to std out is problematic. Such as the scorefx.show()
Here is a simple notebook I used to start exploring PyRosseta. IPython Notebooks also have tab comlpetition and an inbuilt help viewer, so they are really great for prototyping code.
Thanks & best regards,
Ajasja
-
-
AuthorPosts
- You must be logged in to reply to this topic.