Passing a dictionary from pyrosetta to rosetta

Member Site Forums PyRosetta PyRosetta – General Passing a dictionary from pyrosetta to rosetta

Viewing 1 reply thread
  • Author
    Posts
    • #2782
      Anonymous

        Hi,

        I’d like to create a function in rosetta (in C++) that ultimately will accept a python dictionary when called from pyrosetta.  What’s the best C++ class to use that will be the easiest for me to do the conversion from python dict?  (i.e. is there any existing pyrosetta code that will convert a python dictionary to, say, a C++ map).

        Thanks in advance.

      • #13918
        Anonymous

          I’d probably recommend a two-function approach: Create the C++ function how you would, using the special wrapped-map object. Then on the Python/PyRosetta side make a simple wrapper function which takes a standard Python dict and converts it to the needed C++ version.

          There’s a bunch of issues working with Python objects on the C++ side, not the least of which is that Python dicts can contain arbitrary objects in a mixed fashion. Having a wrapper on the Python side allows you to easily clean up/check the contents of the dict before passing it to the C++ interface.

      Viewing 1 reply thread
      • You must be logged in to reply to this topic.