Merge pull request #2452 from RosettaCommons/bcov/XmlObjects
XmlObjects: Importing your xml scripts into C++/PyRosetta
Ever since I moved to PyRosetta/C++ from RosettaScripts, I've had a desire to import my RosettaScript into xml and use the components. Well now it's possible!
Consider the following code snippets:
objs = protocols.rosetta_scripts.XmlObjects.create_from_file("script.xml")
my_fully_configured_mover = objs.get_mover("best_mover")
my_fully_configured_mover.apply(pose)
the_wholel_xml_protocol = objs.get_mover("ParsedProtocol")
objs = protocols.rosetta_scripts.XmlObjects.create_from_string("""
<RESIDUE_SELECTORS>
<Chain name="chainA" chains="A" />
<Neighborhood name="neighborhood" distance="7" selector="chainA" />
</RESIDUE_SELECTORS>
""")
neighborhood = objs.get_residue_selector("neighborhood")
neighborhood.set_distance(9)
neighborhood.apply(pose)
task_op = protocols.rosetta_scripts.XmlObjects.static_get_task_operation("<PreventRepacking />")
These all work which I think opens up all sorts of possibilities. If you've worked hard on an xml and you want to use its parts in PyRosetta, now you can! I can even see large xml libraries being prepared so that one can load pre-configured movers into PyRosetta.
If you want to use this in C++, you'll need to get cozy with std::dynamic_pointer_cast< >.