Capturing the output of

Member Site Forums PyRosetta PyRosetta – General Capturing the output of

  • This topic has 2 replies, 2 voices, and was last updated 10 years ago by Anonymous.
Viewing 1 reply thread
  • Author
    • #1929

        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,


      • #10117

          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?


        • #10120

            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,


        Viewing 1 reply thread
        • You must be logged in to reply to this topic.