how to read a silent file ?

Member Site Forums PyRosetta PyRosetta – General how to read a silent file ?

Viewing 6 reply threads
  • Author
    Posts
    • #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 ?

      • #7340
        Anonymous

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

        • #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.

          • #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.

            • #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…

              • #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 ?

                • #7360
                  attesor

                    I see. Many thanks for the answers!

                  • #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

                    • #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?

                      • #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.

                        • #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,

                          • #7356
                            Anonymous

                              Indeed, this is a reason too!

                            • #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.

                            Viewing 6 reply threads
                            • You must be logged in to reply to this topic.