Member Site › Forums › PyRosetta › PyRosetta – General › newbie question re pose syntax
- This topic has 10 replies, 2 voices, and was last updated 5 years, 8 months ago by Anonymous.
-
AuthorPosts
-
-
April 15, 2019 at 7:50 pm #3120Anonymous
Hello :
I am learning the basics of pyrosetta from this tutorial
https://graylab.jhu.edu/pyrosetta/downloads/documentation/PyRosetta_Manual.pdf
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
-
April 15, 2019 at 9:21 pm #14659Anonymous
Hi,
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.
http://www.pyrosetta.org/tutorials
-
April 16, 2019 at 1:29 pm #14661Anonymous
thank you!
-
-
April 22, 2019 at 5:11 pm #14669Anonymous
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()-
April 22, 2019 at 5:40 pm #14670Anonymous
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
root@e8ffeae28685:/opt/PyRosetta4.Release.python36.ubuntu.release-213#
python2.x doesn’t even import pyrosetta :
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “pyrosetta/__init__.py”, line 15, in <module>
import pyrosetta.rosetta as rosetta
ImportError: pyrosetta/rosetta.so: undefined symbol: PyInstanceMethod_Type
>>>
-
April 22, 2019 at 6:56 pm #14672Anonymous
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: https://drive.google.com/drive/folders/1cF48qvjqKxwuAaizLYx9uFLG1wDf1I-I?usp=sharing
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.
-
April 22, 2019 at 6:05 pm #14673Anonymous
thank you so much! – Amy
-
-
April 22, 2019 at 6:23 pm #14674Anonymous
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/__init__.py”, line 15, in <module>
import pyrosetta.rosetta as rosetta
ImportError: pyrosetta/rosetta.so: 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/__init__.py”, line 21, in <module>
import pyrosetta.rosetta
File “pyrosetta/__init__.py”, line 15, in <module>
import pyrosetta.rosetta as rosetta
ImportError: pyrosetta/rosetta.so: undefined symbol: PyInstanceMethod_Type
>>>
-
April 24, 2019 at 5:08 pm #14677Anonymous
Yes, a different python version requires a different version of PyRosetta. On the website, you can choose between python3 or python2 PyRosetta binaries.
-
-
April 24, 2019 at 3:50 pm #14666Anonymous
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
Sequence: KLPPSPPGWLPVIGHAHLMKNLLHRTLYDFSQKLGPIFSIRFGSRLVVVVSSSSLVEECFTKYDIVLANRPQASVDRR
SLGFSTTSVIGAPYGDHWRNLRKLCDLEVFAPTRLASFLSIRLDERDRMISALYKISSAGFAKVNLEAKIVELTFNNIMRMVAAKRYY
GEEAEDDEEAKRTSPEKIDLNEGSGITLPKAKTLEAMCKPR
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’
-
April 24, 2019 at 5:12 pm #14678Anonymous
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: https://www.rosettacommons.org/node/10473
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.