You are here

newbie question re pose syntax

11 posts / 0 new
Last post
newbie question re pose syntax

Hello :

I am learning the basics of pyrosetta from this tutorial

but when I enter the code verbatim I get an error.

is  something wrong with the syntax they give?  trying to do this:


2.1 Exploring the Pose object To load a PDB file you have to first create an empty pose object, and then assign a PDB structure to that pose: >>my_pose = Pose() >>pose_from_pdb( my_pose, “test.pdb” )



but i get this error:



In [3]: my_pose = Pose()                                                                 

In [4]: pose_from_pdb( my_pose, "coords.pdb" )                                           
TypeError                                 Traceback (most recent call last)
<ipython-input-4-80299edb3231> in <module>
----> 1 pose_from_pdb( my_pose, "coords.pdb" )

TypeError: pose_from_pdb() takes 1 positional argument but 2 were given


Have I not set up python or pyrosetta correctly?


thank you!  - Amy





Post Situation: 
Mon, 2019-04-15 12:50
Amy F



Yes, this has indeed changed.  The version of docs you showed is a very very old version, did google pull it up? I would use the tutorials as they are much more up-to-date.


Mon, 2019-04-15 14:21

thank you!

Tue, 2019-04-16 06:29
Amy F

more syntax issues :  the tutorial you mentioned has been helpful except :  when I do this

4. Examine the protein using a variety of query functions: print pose

print pose.sequence() print "Protein has", pose.total_residue(), "residues." print pose.residue(500).name()


I have to use print(pose) getting :


In [9]: print pose
 File "<ipython-input-9-153cd38136af>", line 1
   print pose
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(pose)?

which works


In [10]: print (pose)
PDB file name: coords.clean.pdb
Total residues:460
Fold tree:
FOLD_TREE  EDGE 1 460 -1


but then i get:


In [11]: print pose.sequence()
 File "<ipython-input-11-0b1e6b8f7d13>", line 1
   print pose.sequence()
SyntaxError: invalid syntax


thanks in advance for your kind assistance


also my sequence has 506 amino acids, and I get 460 reported by rosetta?


also... this isn't working either


In [22]: from pyrosetta.toolbox import get_secstruct
ImportError                               Traceback (most recent call last)
<ipython-input-22-0b79146a0f8b> in <module>()
----> 1 from pyrosetta.toolbox import get_secstruct

ImportError: cannot import name 'get_secstruct'









Wed, 2019-04-24 08:50
Amy F

If you are on python3 - ALL print statements will have parenthesis.  This is the major change from Python2 to python3.  


As for the get_secstruct(), I'm not sure exactly what happened to it and I've asked other developers who would know.  In the meantime, you can use syntax described here:

Wed, 2019-04-24 10:12

What version of python are you using?


As for the secstruct - for some reason that function has been removed, unfortunately. You can access the same information using the DSSPMover:

    DSSP = pyrosetta.rosetta.protocols.moves.DsspMover()
    DSSP.apply(pose)    # populates the pose's Pose.secstruct
    ss = pose.secstruct()
Mon, 2019-04-22 10:11

I am using python3, but 2.7 is also installed.  Is there a more current tutorial/manual available?  sincere thanks, Amy


root@e8ffeae28685:/opt/PyRosetta4.Release.python36.ubuntu.release-213# python --version
Python 2.7.15rc1
root@e8ffeae28685:/opt/PyRosetta4.Release.python36.ubuntu.release-213# python3 --version
Python 3.6.7



python2.x doesn't even import pyrosetta :


Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "pyrosetta/", line 15, in <module>
   import pyrosetta.rosetta as rosetta
ImportError: pyrosetta/ undefined symbol: PyInstanceMethod_Type




Mon, 2019-04-22 10:40
Amy F

If you are using python3, the print statement is different - you need to do print("something"), instead of print "something.".  The tutorials are all written for python2.


We have a new set of in-depth lectures and tutorials from our first Rosetta Code School this past January that will eventually go onto the PyRosetta website. Hopefully next year they will also be recorded and go on youtube.  Till then, you can find them here:

Note that the parellelization labs may be out of date and these may not reflect your own current working environment, but can be used as a general guide. The PyRosetta notebooks are for python3.

Mon, 2019-04-22 11:56

thank you so much! - Amy

Mon, 2019-04-22 11:05
Amy F

ipython3 can at least import pyrosetta, python 2.x  will not even load 


root@e8ffeae28685:/opt/PyRosetta4.Release.python36.ubuntu.release-213# python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)  
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyrosetta import *
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "pyrosetta/", line 15, in <module>
   import pyrosetta.rosetta as rosetta
ImportError: pyrosetta/ undefined symbol: PyInstanceMethod_Type
>>> from rosetta import *
__main__:1: UserWarning: Import of 'rosetta' as a top-level module is deprecated and may
be removed in 2018, import via 'pyrosetta.rosetta'.
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "rosetta/", line 21, in <module>
   import pyrosetta.rosetta
 File "pyrosetta/", line 15, in <module>
   import pyrosetta.rosetta as rosetta
ImportError: pyrosetta/ undefined symbol: PyInstanceMethod_Type


Mon, 2019-04-22 11:23
Amy F

Yes, a different python version requires a different version of PyRosetta.  On the website, you can choose between python3 or python2 PyRosetta binaries.

Wed, 2019-04-24 10:08