Getting chi rotamers

Member Site Forums PyRosetta PyRosetta – General Getting chi rotamers

Viewing 1 reply thread
  • Author
    • #1980


        Is there a way to get rotamers in PyRosetta? I googled around and found this old post, but the conclusion seemed to be, that it might be easier to implement the parsing of the rotamer libraries again. Is this still the case?

        I tried to explore on my own (see ipython notebook), but the most promising function



        TypeError: No Python class registered for C++ class utility::vector1<std::pair<double, double>, std::allocator<std::pair<double, double> > >

        and calling



        RuntimeError: This class cannot be instantiated from Python


        Any additional help is much appreciated.

        Best regards,


      • #10241

          When you say you want rotamers, what exactly do you want and how do you want to use them?

          If you are just looking for Residue objects that represent the rotamers, you can get them from the RotamerSet object.

          What you want to do is make a new core.pack.rotamer_set.RotamerSetFactory object. You’d then call the RSF.create_rotamer_set(residue) method, which takes an example of the residue for which you want to make the rotamers. It returns a core.pack.rotamer_set.RotamerSet object. You then need to set a (pose numbered) “sequence position” that this rotamer set corresponds to with the RS.set_resid( n ) method.

          You would then call RS.build_rotamers( pose, scorefunction, task, packer_neighbor_graph). Note that you have to have a PackerTask object which specifies how to build the rotamers for whatever sequence position you specified above. (You can control how extensively you sub-sample rotamer with the PackerTask, and even if you build rotamers for design. Remember that PackerTasks design by default, so you would have to restrict_to_repacking() in order to keep from getting design rotamers.) You can get the packer_neighbor graph from the function core.pack.create_packer_graph( pose, score_function, task).

          Once the rotamers are built, they’re stored internally in the RotamerSet. You can get them out by calling RS.rotamer( n ), where the the rotamers are numbered from 1 to RS.num_rotamers()

          pose.residue(n).chi_rotamers() doesn’t work like you think it does. It’s not used for standard rotamer libraries, but instead is used only in certain uncommon use cases for specifying rotamers.

        • #10300

            Wow, thank you this works like a charm! (for the interested — Example code notebook here).


            (Of course) I have more questions:

            –          Why does one have to set the resid of the residue in the parent pose using `rs.set_resid(res_pos)`? (Is this for the backbone dependence?)  

            –          What would be the best way visualize the rotamers (I know I can apply the rotamers chi angles to the pose and visualize the pose `rs.num_rotamers()` times, but then I also draw the other atoms `rs.num_rotamers() -1` times too many)

            –          Are these only rotamers without steric clashes (overlaps itd) or all rotamers?

            –          How can one get backbone independent rotamers?

            There is ` rotamer_set.bb_independent_rotamers(pose.residue(1).type())`, but it want’s an owning pointer, and I don’t know how to give it from Python.


            If any of these questions are better off as separate posts please don’t hesitate to say so.

            Thank you for your help and best regards,


          • #10310

              The ResidueSet needs to know what residue it’s working on so that it can pick out the correct behavior from the PackerTask. (The PackerTask controls what sort of rotamers one should generate, and does so on a per-position basis.)

              I’d probably recommend making a new Pose and then putting the residues into that pose. (Or if you have PyMol integration hooked up, you can push the poses to PyMol. I’ve never done this myself, so I’m fuzzy on the details.)

              Generating the rotamer this way there’s a limited amount of clash checking, if bump_check() on the PackerTask is true (the default). You should be able to turn this off with task.set_bump_check(False)

              A somewhat hacky way is simply calling .clone() on the residue type – try “rotamer_set.bb_independent_rotamers( pose.residue(1).type().clone() )”. (Doing it “properly” probably will be more effort than it’s worth for what you’re doing.)

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