You are here

Capturing the output of

3 posts / 0 new
Last post
Capturing the output of

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

I have tried to use the example in "test/"


import rosetta as r
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()
print '\nCaptured IO'
print T.buf()


Does not capture the output. (A side question, can T.buf() be cleared?) 

Doing: ", T)" raises an error, becaus of incompatible parameters

stream = r.utility.OString(), stream)

raises "RuntimeError: This class cannot be instantiated from Python" and

stream = r.utility.OStringStream, stream)

Is also incompatible.


Thank you for your help and best regards,

Post Situation: 
Fri, 2014-06-20 05:30

Hi Ajasja,

Here the right way to do this:

b = rosetta.utility.OStringStream(), 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?


Fri, 2014-06-20 17:05

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

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,

Sat, 2014-06-21 11:57