You are here

how to read a silent file ?

13 posts / 0 new
Last post
how to read a silent file ?
#1

I could not find instructions on PyRosetta site or this forum on how to read in a silent file so I can obtain a set of poses at once. It is not in the FAQ, either. Or should I always extract_PDBs from the silent file first ?

Post Situation: 
Wed, 2012-06-27 09:34
Anonymous

Have you seen anything about PoseInputStream? I think that's the usual method to use with silent files (this is a guess)

Wed, 2012-06-27 09:38
smlewis

Reading silent files in PyRosetta is exactly the same as in Rosetta itself so as Steven already mentioned: check the PoseInputStream and so on.

Wed, 2012-06-27 09:40
Sergey

Thanks for your answers!

I spent another hour googling and playing with PyRosetta. In the end I realized I should use "rosetta.core.import_pose.pose_stream.SilentFilePoseInputStream"

from rosetta.core.import_pose.pose_stream import SilentFilePoseInputStream
pis = SilentFilePoseInputStream('yoursilentfile')

This leads to Segmentation Fault

/path/to/pyrosetta/PyRosetta.ScientificLinux-r49071.64Bit/iPyRosetta: line 6: 14200 Segmentation fault (core dumped) $PYROSETTA/ipython.py $*

I have python 2.7.3 in Ubuntu 12.04. PyRosetta v2.011 64bit. I managed to compiled a libpython2.6.so so I could start iPyRosetta. I tested some code from PyRosetta tutorial and all ran fine. I tested the iPython.py shipped with PyRosetta and got the same output. I ran SetPyRosettaEnvironment.sh before I started iPyRosetta or iPython.

Thu, 2012-06-28 02:45
attesor

Hey attesor.

Your going to want to do this (Load all pyrosetta and initialize after):

from rosetta import *
from rosetta.core.import_pose.pose_stream import SilentFilePoseInputStream
rosetta.init()

Then, you can give it a silent file, and it will work fine. Just tested in ipython....
After you load the file, you can fill your pose with:
my_pose = Pose()
and pis.fill_pose(my_pose)

Then you can use pis.has_another_pose() to check if there is another, maybe in a loop... while (pis._has_another_pose()): do x...

Not sure how to get pis.get_all_poses to work...

-J

Thu, 2012-06-28 08:24
jadolfbr

Hi, Jadolfbr,
that works very well! Thanks!

if rosetta.init() is always required, why not put it in the __init__.py of rosetta so it is executed every time rosetta is imported?

Thu, 2012-06-28 08:38
attesor

It's probably an oversight...all the C++ executables start with devel::init(argc, argv); so we're all used to putting it anyway.

Thu, 2012-06-28 13:43
smlewis

Hi attesor,

There is a solid reason for this: consider the situation when your program consist of multiple parts and they all using PyRosetta. You will need to have import statement in each of your script but would certainly like to call rosetta.init only once.

In general importing should be consider as no-action ie something that does not change state of the system. While init() is a function call a therefor change the system state.

Best,

Thu, 2012-06-28 18:41
Sergey

I think part of the reason is so that users can specify command-line arguments like this:

opts = [ 'app' , '-database' , os.path.abspath( os.environ['PYROSETTA_DATABASE'] ) , '-ex1' , '-ex2aro' , '-constant_seed' ]
args = rosetta.utility.vector1_string()
args.extend( opts )
rosetta.core.init( args )

that rosetta.init looks to be defined in the rosetta/__init__.py file, Sergey knows much more about how PyRosetta actually works, so maybe he'll chime in with a few comments...

Thu, 2012-06-28 12:19
jadolfbr

Indeed, this is a reason too!

Thu, 2012-06-28 18:43
Sergey

great that you mention this solid reason, as otherwise I will definitely invoke init() each time I import rosetta.

But I have another question: how do one know if rosetta has been initialized? Should this not be checked routinely each time after importing rosetta and before running rosetta.init(), and thus written into the tutorial? If this should be routinely checked, why can't one leave it in the __init__.py ?

Fri, 2012-06-29 07:28
attesor

Currently I am not aware of 'official' way to check if init was called already and probably there is none.

Regarding the checking for automatic checking for initialization in __init__.py: as I mentioned before it is a good practice to separate things like 'importing names' and 'calling functions' it just make things easier and more transparent in a long run. You of course are free to make local modifications, what you can do is this: add static variable in init() and check if it was already called or not etc.

Fri, 2012-06-29 09:17
Sergey

I see. Many thanks for the answers!

Fri, 2012-06-29 09:27
attesor