You are here

PyRosetta coding subtleties

3 posts / 0 new
Last post
PyRosetta coding subtleties

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 "./", line 399, in
File "./", line 311, in main
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)

Post Situation: 
Wed, 2013-03-27 02:59

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.

Wed, 2013-03-27 06:44

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.

Wed, 2013-03-27 10:13