Scoring issues – differs from command line vs .py file – for a simple ddG loop

Member Site Forums PyRosetta PyRosetta – Scripts Scoring issues – differs from command line vs .py file – for a simple ddG loop

Viewing 5 reply threads
  • Author
    • #1063

        Hello all,

        I was able to get PyRosetta up and running on my mac under OS X 10.6.6 . I am working on what I think is a simpler version of the ddG script (we don’t need the docking feature). What I am trying to do is bring in a pdb file, score it using the ddG paramters, and then mutate each residue (basically cycle through all the possible combinations)to see what happens to the ddG values are. The start of the script is here: (The loop is a mess at the moment)

        from rosetta import *

        pose = Pose()
        pose_from_pdb( pose , “2O2X_clean.pdb” )

        pymover = PyMOL_Mover()

        ddG_scorefxn = ScoreFunction()
        ddG_scorefxn.set_weight( fa_atr , 0.44 )
        ddG_scorefxn.set_weight( fa_rep , 0.07 )
        ddG_scorefxn.set_weight( fa_sol , 1.0 )
        ddG_scorefxn.set_weight( hbond_bb_sc , 0.5 )
        ddG_scorefxn.set_weight( hbond_sc , 1.0 )

        print”ddG = “

        for i in range(1,pose.total_residue()+1):

        I run this script using ipython in the same folder with the .py file and PyRosetta. When I run the script in ipython using run the ddG_scorefxn(pose) comes up blank. But when I type ddG_scorefxn(pose) on the ipython command line it spits out the answer. I’ve noticed this for a few other things as well.

        I was wondering if there was a work around for this? Thanks!


      • #6169

          Can you elaborate what do you mean by ‘ddG_scorefxn(pose) comes up blank’?

        • #6170

            Oooppss. Here is part of the output from ipython:


            core.pack.interaction_graph.interaction_graph_factory: Instantiating DensePDInteractionGraph
            core.pack.pack_rotamers: built 44 rotamers at 2 positions.
            core.pack.pack_rotamers: IG: 1272 bytes
            ddG =


            The value of the ddG_scorefxn(pose) should follow the ddG = but it doesn’t.

            But from the ipython command line
            In [5]: ddG_scorefxn(pose)
            Out[5]: 134.52022280476609

            It does.


          • #6171

              Judging from the source code above your output is exactly what expected. In your script code you only printed symbols ‘ddG = ‘ (line: print”ddG = “) but not the score itself. Perphaps you meant to write this?

              print"ddG = ", ddG_scorefxn(pose)

            • #6172

                So I changed these lines:
                print”ddG = “

                to this:
                print”ddG = “, ddG_scorefxn(pose)

                and now it works.

                So my second question is when the runs and gets down to the loop
                for i in range(1,pose.total_residue()+1):

                I think these should change each residue to a G and then print the ddG_scorefxn (this not quite what I want it to do but I am working on that ;) )

                I get the following error message:
                /Users/ara/Desktop/PhD_Project/PyRosetta/ in ()
                21 for i in range(1,pose.total_residue()+1):
                —> 22 mutate_residue(pose,i,G)
                23 ddG_scorefxn(pose)

                NameError: name ‘G’ is not defined
                WARNING: Failure executing file:

                When I execute the mutate_residue from the command line followed by the score function everything works fine. I was wondering if I need to explicitly import aa from single letters or did I mess up my loop?

                Thanks again!


              • #6173

                  G by it self is not defined, I think you most likely wanted to this (notice the string constant ‘G’ instead of just G):

                  for i in range(1,pose.total_residue()+1):
                  mutate_residue(pose, i, 'G' )
                  print 'score:', ddG_scorefxn(pose)

                • #6174

                    Thanks Sergey! I was looking at an example in ala_scan and mutate that didn’t have the ” around the aa codes. I am going to hack away at this code for awhile to see if I can get it up and running.


                  • #6180

                      Hi Ara,

                      The problems you’re running into look like basic Python issues, rather than PyRosetta specific issues. I would recommend reading through a Python tutorial to get a better idea of how to work with Python. (I’m partial to the official one at and the other documentation at – but there are others out there which are equally good.).


                    • #6181

                        Hi Rocco,

                        Thanks for the docs. I am little rusty on my python and there are large gaps in my knowledge base since I am self taught. I will check those out.

                        Thanks again,

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