PyRosetta coding subtleties

Member Site Forums PyRosetta PyRosetta – General PyRosetta coding subtleties

Viewing 2 reply threads
  • Author
    Posts
    • #1542
      Anonymous

        This works:
        rbptmvr=rigid.RigidBodyPerturbMover(2, rotation_magnitude, translation_magnitude)
        sequence_mover.add_mover( rbptmvr )

        This does not:
        sequence_mover.add_mover( rigid.RigidBodyPerturbMover(2, rotation_magnitude, translation_magnitude) )

        My question is, why is the intermediate reference necessary?
        I feel as if there is something fundamental about how to code in PyRosetta that I’m missing.

        The error is different depending on what is nested.
        Here is an example caused by the second statement above:

        Traceback (most recent call last):
        File “./example.py.py”, line 399, in
        main()
        File “./example.py.py”, line 311, in main
        random_mover.apply(new_pose)
        Boost.Python.ArgumentError: Python argument types in
        FaDockingSlideIntoContact.apply(FaDockingSlideIntoContact, PoseAP)
        did not match C++ signature:
        apply(FaDockingSlideIntoContact_exposer_callback {lvalue}, std::map, std::allocator > > >, std::less, std::allocator, std::allocator > > > > > > {lvalue} pmap)
        apply(protocols::docking::FaDockingSlideIntoContact {lvalue}, std::map, std::allocator > > >, std::less, std::allocator, std::allocator > > > > > > {lvalue} pmap)
        apply(FaDockingSlideIntoContact_exposer_callback {lvalue}, core::pose::Pose {lvalue} pose)
        apply(protocols::docking::FaDockingSlideIntoContact {lvalue}, core::pose::Pose {lvalue} pose)

      • #8555
        Anonymous

          I don’t know the answer, but I am always willing to speculate!

          I think this is because the underlying C++ uses a lot of “smart pointers” with “reference counting” (wikipedia has sort-of-relevant explanations; the Rosetta MIE 2011 review has more I think), whereas python uses something else. I think when you do it on one line, python “optimizes out” creation of the pointer wrapper for the RigidBodyPerturbMover, then the latter goes out of scope in C++ and self-destructs, then when the SequenceMover wants to use it it’s not there anymore. In the two line case, the python-level variable keeps the smart pointer alive.

        • #8558
          Anonymous

            This is known issues and Steven explain the underlying reason for what happening inside. We planning to move Rosetta to use Boost smart pointer sometime in the future which we think should solve this.

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