Member Site › Forums › PyRosetta › PyRosetta – General › how to read a silent file ?
- This topic has 12 replies, 4 voices, and was last updated 12 years, 2 months ago by
attesor.
-
AuthorPosts
-
-
June 27, 2012 at 4:34 pm #1320
Anonymous
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 ?
-
June 27, 2012 at 4:38 pm #7340
Anonymous
Have you seen anything about PoseInputStream? I think that’s the usual method to use with silent files (this is a guess)
-
June 27, 2012 at 4:40 pm #7341
Anonymous
Reading silent files in PyRosetta is exactly the same as in Rosetta itself so as Steven already mentioned: check the PoseInputStream and so on.
-
June 28, 2012 at 9:45 am #7346
attesor
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.
-
June 28, 2012 at 7:19 pm #7351
Anonymous
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…
-
June 29, 2012 at 2:28 pm #7357
attesor
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 ?
-
June 29, 2012 at 4:27 pm #7360
attesor
I see. Many thanks for the answers!
-
June 28, 2012 at 3:24 pm #7348
Anonymous
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
-
June 28, 2012 at 3:38 pm #7349
attesor
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?
-
June 28, 2012 at 8:43 pm #7353
Anonymous
It’s probably an oversight…all the C++ executables start with devel::init(argc, argv); so we’re all used to putting it anyway.
-
June 29, 2012 at 1:41 am #7355
Anonymous
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,
-
June 29, 2012 at 1:43 am #7356
Anonymous
Indeed, this is a reason too!
-
June 29, 2012 at 4:17 pm #7359
Anonymous
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.
-
-
AuthorPosts
- You must be logged in to reply to this topic.