You are here

Rotamer Libraries in Pyrosetta

9 posts / 0 new
Last post
Rotamer Libraries in Pyrosetta

Hello everyone. I have a quick question regarding rotamer libraries in PyRosetta. I was wondering if it is possible to read the standard Dunbrack libraries that PyRosetta uses and retrieve those rotamers or the xyz data for them in Pyrosetta. If not then it's no big deal as I could figure out a way to do it outside of PyRosetta but it would be useful if PyRosetta already has a way of doing this.

Post Situation: 
Fri, 2013-01-18 12:02

I am under the impression that this functionality is not particularly well-exposed for this sort of use, but you can certainly get at the existence of rotamers in PyRosetta. The classes you'll be looking at are probably those in core/pack/dunbrack/. This code is moderately heavily templated (it's very speed-optimized) so it may be tricky to use with pyrosetta.

The Dunbrack library isn't prescriptive in the sense of "these rotamers exist" - it's set up to have a score for all phi/psi/chi(1-4) combinations. Are you wanting to query the likelihood of rotamers you have, or have Rosetta generate a list of most likely rotamers (the latter duplicating what the packer does, which may be possible to extract into pyrosetta)?

What are you trying to do?

Fri, 2013-01-18 12:13

I was looking at the code in core/pack/dunbrack for regular Rosetta, but it seems like there aren't Python bindings for that code in PyRosetta so I may not be able to do what I wanted. We have a couple of design algorithms that we used to use prior to Rosetta from previous lab members and I wanted to test them to see if the methods themselves are any good using the Rosetta energy function and rotamer libraries. We have old Dunbrack libraries but they are at least 10 years old I believe and are unprotonated and Rosetta's are newer and protonated so I thought there might be a way to get those in PyRosetta. The old algorithms require discretized rotamers but it seems that from what you said that this might not be possible because the libraries don't contain defined, concrete rotamer objects. I can find a way around this though. Thanks for your help.

Fri, 2013-01-18 12:51

I can smooth your efforts by pointing out that the rotamer library itself is in rosetta_database/rotamer; bbdep02.May.sortlib is the 2002 library, and bbdep02.May.sortlib-correct.12.2010 is the 2010 library (the 2008 library was found to be flawed and deleted). You can surely get them directly from Roland's lab, as well ( (and probably should, if you're going to use it sans-Rosetta - he has a separate license)

These are non-prescriptive as I described before. Rosetta prescribes rotamers by setting a probability cutoff (one of the obvious columns in the file is probability); I guess you can do something similar?

Fri, 2013-01-18 13:52

bbdep02.May.sortlib-correct.12.2010 is *NOT* the Dunbrack 2010 library. It's the "-correct" adjustments (from Dec 2010) to the Dunbrack 2002 library.

The Dunbrack 2010 library is contained in rosetta_database/rotamer/ExtendedOpt1-5 (at least for the most recent versions of PyRosetta )

Regarding generating xyz coordinates for rotamers, I'd recommend looking at core.pack.rotamer_set.RotamerSetFactory and core.pack.rotamer_set.RotamerSet, particularly the build_rotamers(), num_rotamers() and rotamer() member functions of the latter. Note that for the build_rotamers function you'll need a PackerTask, with which you can set the sampling level (also called the "ex level") for the rotamers. The default settings should get you just the "on rotamer" conformation. -- Technically, you won't get *all* the rotamers, just the ones that have reasonable probabilities. These can be controlled with the -packing:dunbrack_prob_buried, -packing:dunbrack_prob_nonburied and -packing:dunbrack_prob_nonburied_semirotameric command line flags (I don't know how to change these from within PyRosetta), with closer to 1.0 being more rare rotamers (defaults are 0.98, 0.95, 0.95, respectively).

Fri, 2013-01-18 17:42

Okay, I'll look at those two packages. I probably came across them at sometime because I was looking for anything with the word "rotamer" in it but that brings back a lot of search results. I had been setting command arguments in PyRosetta with the "extra_options" arguments of the rosetta.init() command so maybe those packing arguments can be submitted there. Failing all of this I'll just do what smlewis suggested and download the 2010 Dunbrack library from their webpage and then generate the rotamers myself. Thanks for everybody's help though! This gives me a lot of helpful pointers.

Sat, 2013-01-19 10:13

If you can find it in Rosetta src and it's not in the app directory, 99+% of the time it will work in PyRosetta. You just got to know how to get it to work! What you want is to do:
from rosetta.core.pack.dunbrack import *

This will import all classes from core::pack::dunbrack namespace. You may also want to look in core.pack.rotamer_set. To only import certain classes you want to use (for example):
from rosetta.core.pack.dunbrack import RotamerLibrary

Have you been through the PyRosetta tutorials?

I don't have much experience working or coding with individual rotamers within Rosetta, so I couldn't help you there. I was able to construct a FixbbRotamerSets object and assume that most of the objects in core.pack could be constructed in PyRosetta, and hopefully all their functions should work. Make sure to check out the faq where it talks about how to construct vector1 objects and use the Rosetta options system within PyRosetta. You might want to use the 2010 Rotamer library, as there are non/semi-rotameric dihedrals not found in the 2002 library - but this also makes some code in Rosetta specific for the 2010 libary, such as the create_semi_rotameric_dunlib function in RotamerLibary just to forwarn you. If you go into a bit more specifics, we may be able to help you furthe.

Note that even in the Rotamer Libraries that you can download from the Dunbrack website, there are no xyz coordinates. They are dihedral angles for each chi. You can manually set an existing side chain's dihedral angle using the pose.set_chi function. If you can't get Rosetta to give you or make you a specific set of rotamers to try out or set on a pose, you may be able to do it manually in code through reading the textfile Rotamer Libary and writing a few functions in Python which would use the pose.set_chi function (in rosetta_database/rotamer or downloadable from the Dunbrack website). Just a thought.
Hope at least some of this is useful!

Fri, 2013-01-18 14:00

I had been using the auto-complete function in iPython to look around in core.pack but there wasn't a "dunbrack" module. But for some reason it never occurred to me to try importing it directly so maybe that's my problem. I have been through a number of the PyRosetta tutorials and they were very helpful in getting me acquainted with poses, score functions, mutating residues, replacing residues, etc. but I had been stumped on the rotamers and was doing that myself outside of PyRosetta. You know, the suggestion about reading the Dunbrack text file and reading the chi angles is an excellent idea! Our design method involves making slight variations to the chi angles, so I already found the set_chi function and figured out how to use it but I never thought of using it to read that text file (even though it seems obvious now, silly me). I think I might try that out next week because I already have an idea on how to do it, and if that fails I'll look into rotamer sets. Thanks a lot for your help. It was very useful!

Sat, 2013-01-19 10:23

Great! Please let us know if you run into any problems. Some bindings of specific variable types (templates) are not directly available in PyRosetta, so you may run into issues on the Rotamer set side. If you do, Sergey Lyskov MAY be able to configure those bindings to work, as he has for the common vector1 objects, C++ std:pair, etc. Then, you would need to wait for the updated binaries, which get released from the Gray lab pretty much every week.

There is a great deal of additional information on the text file at our website, , which should help if you have not been there before. If you decide to use the text file separately then the rotamers that are built in Rosetta, the academic licence as Steven suggested on the site can be filled out pretty quickly.

Sun, 2013-01-20 07:43