You are here

basic scoring issues

5 posts / 0 new
Last post
basic scoring issues

I'm keep studying PyRosetta using tutorials from

I've got several errors when going through Scoring workshop.

Using Ubuntu 16.04.1 LTS 64-bit, python 2.7.12, IPython 2.4.1, PyRosetta-4

(1) Setting up a custom score function rises an error:

In [10]: scorefxn_n = ScoreFunction()

In [11]: scorefxn_n.set_weight(fa_atr, 1.0)
NameError                                 Traceback (most recent call last)
<ipython-input-11-31ac60f02dda> in <module>()
----> 1 scorefxn_n.set_weight(fa_atr, 1.0)

NameError: name 'fa_atr' is not defined


print scorefxn and work normally.

(2) another "name is not defined" problem with the emap:

In [18]: emap = EMapVector()
NameError                                 Traceback (most recent call last)
<ipython-input-18-083b4abf31a3> in <module>()
----> 1 emap = EMapVector()

NameError: name 'EMapVector' is not defined


(3) sending score function to PyMOL:

In [19]: pymol.apply(ras)

In [20]: pymol.send_energy(ras)

In [21]: pymol.send_energy(ras, fa_atr)
NameError                                 Traceback (most recent call last)
<ipython-input-21-c132bf35caaa> in <module>()
----> 1 pymol.send_energy(ras, fa_atr)

NameError: name 'fa_atr' is not defined


(4) And finally sending hbonds data to PyMOL:

In [23]: hbonds_set = get_hbonds(ras)

In [24]:, 24)
#Dch Dn Dres Da  Ach An Ares Aa  length AHDang BAHang  BAtor weight energy
#A   24  ILE  N  A   20  THR  O    2.08  160.5  165.8  117.0  1.000 -0.643

In [25]: pymol.send_hbonds(ras)
AttributeError                            Traceback (most recent call last)
<ipython-input-25-0e4c1c06cb10> in <module>()
----> 1 pymol.send_hbonds(ras)

AttributeError: 'rosetta.protocols.moves.PyMolMover' object has no attribute 'send_hbonds'


I would greatly appreciate your help, as manipulating the scoring is crutial and I can't go forward just skipping it...

Post Situation: 
Wed, 2016-11-23 00:43

It looks like it's mainly import issues.

In Python everything lives in modules, and you need to import them into the current namespace. (Py)Rosetta has a deeply nested hierarchy of modules/namespaces. For convenience, many things are aliased in the toplevel namespaces, so you can do things like `from rosetta import *`, but in truth those objects live in deeply nested location. (This is important, as only certain well-used objects are imported with the `from rosetta import *` - there are many object where you need to import them from nested modules.)

An added complication is that the hierarchy was split going from PyRosetta3 to PyRosetta4 - where there used to be only one top-level namespace, now there's both `pyrosetta` and `rosetta` - the latter being things which are from Rosetta's C++ library, and the former being code which is PyRosetta specific. (Mainly a number of convenience functions.)

In your case, things like fa_atr and EMapVector can be found in the rosetta.core.scoring namespace. They may or may not be loaded with a `from rosetta import *` command - you may need to import them (or the nested namespace) specifically.


The PyMolMover.send_hbonds() issue is a different issue.  It used to be that there was actually *two* PyMolMovers - one in the C++ code, and one at the Python level. The send_hbonds() function was a feature of the Python version, but not the C++ version. The Python version is deprecated, and the functionality is being migrated, but that hasn't happened yet (as of Nov 2016). It should happend soon, but obviously won't be in the version you're currently using. As this is just a visualization issue, you should be safe to skip this particular step. 




Wed, 2016-11-23 07:29

Most of what Rocco says is right.  The transition from PyRosetta-3 to PyRosetta-4 for us was not extremely straightforward.   In the build/install, it does mention the pyrosetta import, and I just added a note on the tutorials page that for all the tutorials, pyrosetta must be imported as well (  

from pyrosetta import *

from rosetta import * 


From my experience thus far, most of the same things are imported as they were for PyRosetta-3 (Except, that various modules FROM ROSETTA are imported when you import PyRosetta, at least when you do import *.  This might just be because the PyRosetta namespace is using certain Rosetta Modules - and so, those modules being used by the PyRosetta namespace come along for the ride (which is actually quite convenient for us - to get ScoreFunction, Pose, and some of the usual classes we use in PyRosetta).   That seems to not include the scoreterm enums like fa_atr, however.  To do this, you would want to import all of core.scoring or select pieces. 

from rosetta.core.scoring import *




from rosetta.core.scoring import ScoreType

#To use this way:






Wed, 2016-11-23 10:57

Re PyMOL mover issues: PyRosetta-4 is using C++ version of this mover while PyRosetta-3 is using Python implementation which is now deprecated. However the current C++ implementaion does not have all the methods (like send_hbonds) so we currently working on porting them to C++. I expecet this new code to be merged withing a few weeks so afrter that code above should work.

Mon, 2016-11-28 12:08

Rocco, Jared, Sergey,

Everything worked after proper import, and I can skip  PyMolMover.send_hbonds() for now.

Many thanks for the explanation and advice!!!



Thu, 2016-12-01 00:49