Errors when movers put in a function

Member Site Forums PyRosetta PyRosetta – General Errors when movers put in a function

Viewing 3 reply threads
  • Author
    Posts
    • #1050
      Anonymous

        I am using PyRosetta-40251.
        The following minimal program illustrates the problem. Note that the required indentation on the two lines of the function setupRefine has been lost on posting. The program as written (with correct indentation) does not call the function setupRefine and runs fine. If, instead, the line calling setupRefine not commented out so the function is called, and the following two lines are commented out so that the two lines are now executed from within the setupRefine function, the program produces errors but does not kill ipython. In a bigger, more fleshed out version of the program, leaving the setup of small, shear, minimization, and packing movers in the main program works fine, but if they are put into a function, their application in a later refine step produces segmentation faults or the ipython error “maximum recursion depth exceeded while calling a Python object”. Am I making some silly error?

        from rosetta import *
        init()

        def setupRefine( movemap, combined_mover, scorefxn_fold ):
        smallmover = SmallMover( movemap, 1, 3 )
        combined_mover.add_mover( smallmover )

        pose = Pose()
        make_pose_from_sequence( pose, “AAAAAA”, “fa_standard” )

        movemap = MoveMap()
        movemap.set_bb(True)
        scorefxn_fold = create_score_function( ‘standard’ )
        combined_mover = SequenceMover()

        #setupRefine( movemap, combined_mover, scorefxn_fold )
        smallmover = SmallMover( movemap, 1, 3 )
        smallmover.angle_max( 7 )
        combined_mover.add_mover( smallmover )

        mc = MonteCarlo( pose, scorefxn_fold, 1 )
        trial = TrialMover( combined_mover, mc )
        refinement = RepeatMover(trial, 5 )
        refinement.apply( pose )

        print “Normal finish”

      • #6116
        Anonymous

          A) Tip: attaching your code as a text file will prevent the forum software from breaking it. You could also use the code HTML tags (put code and /code in angle brackets).

          B) Assuming I understand the question correctly, this is a simple python error. The variable smallmover is scoped to the inside of the setupRefine function, so when setupRefine ends, it goes out of scope and is destroyed. References to smallmover after the end of setupRefine refer to an entirely separate object that python makes up as it goes. To fix it, you need to declare objects outside the inner function’s scope so they will still exist in the calling function’s scope (and pass them in as arguments to the function).

        • #6118
          Anonymous

            Robert, which Python interpreter have you used when testing this code? I was able to reproduce this error only when using iPython and in that case crash report lead to some introspect code that belong to ipython itself. Running the same version of of code with pure Python is completed without any errors. So overall your code seems to be right and it suppose to work correctly as-is. Could you try to run it with ‘python’ and see if it fix the error?

            Steven, your reasoning for (B) is right on target and it would work that way if line ‘combined_mover.add_mover( smallmover )’ was absent. – Adding small mover to sequence mover should lead to increase of OP counter for smallmover object so it will not be destroyed when execution point leave the function. In the way in this case Python behave similar to C++.

          • #6119
            Anonymous

              I am afraid that I need some really basic help. I can’t get a python program consisting of the single line “from rosetta import *” to run with Python 2.4.3 (#1, Sept. 17 2008, 16:07:08) without producing a segmentation fault, even after running source /user/local/src/PyRosetta-r40251.linux.64Bit/SetPyRosettaEnvironment.sh.

              Also, I had tried using HTML coding like code indented line of /code, with code and /code flanked with angle brackets, and although it would display the indented line of code in Courier font, my four spaces or a tab to generate the indentation were stripped out.

            • #6128
              Anonymous

                You need Python 2.6 for the 64bit version of PyRosetta.

              • #6129
                Anonymous

                  Actually, scratch that, I am getting that error with Python 2.6 as well on a different system. Started happening when I switched from PyRosetta 1.0 to 2.0. Could this be a libboost issue?

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