Rotamer information from pose

Member Site Forums PyRosetta PyRosetta – General Rotamer information from pose

Viewing 4 reply threads
  • Author
    Posts
    • #1798
      Anonymous

        How can I get which rotamer is at a specific residue in a packed pose? Is there any function in the pose class that gives the rotamer at a residue as the output?

      • #9672
        Anonymous

          That depends slightly on what you mean by “rotamer”. If you’re just looking for the chi angles, you’ll should be able to obtain a list (actually a vector1_Real) of them from the chi() method of the Rotamer object.

          But you’re probably interested in binning them (so, e.g. 176 degrees and 178 degrees are considered to be the same). How you would do this depends on what sort of rotamer library you’re interested in. Different rotamer definition sets have different sets of bins. Rosetta typically uses the Dunbrack rotamer library, and there’s a convenience function core.pack.dunbrack.rotamer_from_chi(Residue, vector1_Size ), where the bin designations are passed back into the vector1_Size object, where different rotamers have different numbers at each of the positions – other than that the numbers are somewhat arbitrary. Note that if you’re using the Dun10 rotamer library, some of the residues are “semirotameric” for their terminal chi, so the rotamer bin for that chi is somewhat ill-defined.

          If you’re interested in some other rotamer library, or that explanation didn’t quite do it for you, you may have to get more specific on what you’re trying to accomplish.

        • #9677
          Anonymous

            Thank you so much for your kindly providing this information. Basically I would like to know the index of the rotamer in the Dunbrack library for a particular residue in a packed protein pose in PyRosetta. The function or method rotamer_from_chi is defined as: void core::pack::dunbrack::rotamer_from_chi (chemical::ResidueType const & rsd_type, ChiVector const & chi,RotVector & rot). In the function rotamer_from_chi which has three inputs, what is the first input “ResidueType”? Is it the amino acid type? So can I give a string ‘M’ or ‘MET’ as the first input? I know how to get the chi angle using the pose.chi(1,7) for getting the chi angle for residue 7 in chain 1 in the pose. Finally, the last input is RotVector, which is a list. Can I just define an empty list rotv = list()? I am getting an error in my code in the iPyRosetta command line below:

            In [1]: import rosetta

            In [2]: import rosetta.core.pack.task

            In [3]: from rosetta import *

            In [4]: init()
            PYROSETTA_DATABASE environment variable was set to: /home/ayushgoyal/Code/PyRosetta.Ubuntu-12.04LTS-r55722.64Bit/rosetta_database; using it….
            PyRosetta 3.4.0 [Rosetta-3.4 55721:55721:812a1e7baefddf32ce551097c8aabf494e5983a2] retrieved from:
            (C) Copyright Rosetta Commons Member Institutions.
            Created in JHU by Sergey Lyskov and PyRosetta Team.

            core.init: Rosetta version from
            core.init: command: PyRosetta -ex1 -ex2aro -database /home/ayushgoyal/Code/PyRosetta.Ubuntu-12.04LTS-r55722.64Bit/rosetta_database
            core.init: ‘RNG device’ seed mode, using ‘/dev/urandom’, seed=-41651338 seed_offset=0 real_seed=-41651338
            core.init.random: RandomGenerator:init: Normal mode, seed=-41651338 RG_type=mt19937

            In [5]: native_pdb = ‘/home/ayushgoyal/Proteins/1PGA/1PGA.pdb’

            In [6]: native_pose = Pose()

            In [7]: pose_from_pdb(native_pose, native_pdb);
            core.chemical.ResidueTypeSet: Finished initializing fa_standard residue type set. Created 9172 residue types
            core.pack.task: Packer task: initialize from command line()

            In [8]: native_pose.chi(1,7)
            Out[8]: -55.53287780791491

            In [9]: native_pose.residue_type(7)
            Out[9]:

            In [10]: from rosetta.core.pack.dunbrack import *

            In [11]: rotv = list()

            In [12]: rotamer_from_chi(native_pose.residue_type(7),native_pose.chi(1,7),rotv)


            ArgumentError Traceback (most recent call last)
            in ()
            —-> 1 rotamer_from_chi(native_pose.residue_type(7),native_pose.chi(1,7),rotv)

            ArgumentError: Python argument types in
            rosetta.core.pack.dunbrack.__dunbrack_all_at_once_.rotamer_from_chi(ResidueType, float, list)
            did not match C++ signature:
            rotamer_from_chi(core::conformation::Residue rsd, utility::vector1 > {lvalue} rot)
            rotamer_from_chi(core::chemical::ResidueType rsd_type, utility::vector1 > chi, utility::vector1 > {lvalue} rot)

          • #9694
            Anonymous

              Thank you again so much rmoretti for your kind help. For residue 1 in the pose created from the 1PGA.pdb, I got the Chi angles as [-68.3503, 176.299, 151.646, ] and the rotamer vector as [3, 2, 2, ]. For residue 2, I got the Chi angles are [-58.6313, 3.4e-05, ] and rotamer vector as [3, 0, ]. I was wondering how there could be more than one rotamer or conformational isomerism for a given residue? I am getting as many rotamers as the chi angles? Or does the rotamer vector of [3,2,2] define the rotamer?

              I have written the following script GetRotamer.py to print the rotamer of a particular residue in a pose:

              import rosetta
              import rosetta.core.pack.task
              from rosetta import *
              from rosetta.core.pack.dunbrack import *

              init()

              native_pose = Pose()
              native_pdb = ‘/home/ayushgoyal/Proteins/1PGA/1PGA.pdb’
              pose_from_pdb(native_pose, native_pdb);

              residue_number = 1;
              residueType = native_pose.residue_type(residue_number);
              angles = native_pose.residue(residue_number).chi();
              rotv = rosetta.utility.vector1_Size();
              rotamer_from_chi(residueType,angles,rotv)

              print ‘nChi angles are ‘, angles
              print ‘nRotamer vectors are ‘, rotv

              When I ran this script, the output was as follows:

              In [3]: run GetRotamer.py
              PYROSETTA_DATABASE environment variable was set to: /home/ayushgoyal/Code/PyRosetta.Ubuntu-12.04LTS-r55722.64Bit/rosetta_database; using it….
              PyRosetta 3.4.0 [Rosetta-3.4 55721:55721:812a1e7baefddf32ce551097c8aabf494e5983a2] retrieved from:
              (C) Copyright Rosetta Commons Member Institutions.
              Created in JHU by Sergey Lyskov and PyRosetta Team.

              core.init: Rosetta version from
              core.init: command: PyRosetta -ex1 -ex2aro -database /home/ayushgoyal/Code/PyRosetta.Ubuntu-12.04LTS-r55722.64Bit/rosetta_database
              core.init: ‘RNG device’ seed mode, using ‘/dev/urandom’, seed=1906108914 seed_offset=0 real_seed=1906108914
              core.init.random: RandomGenerator:init: Normal mode, seed=1906108914 RG_type=mt19937
              core.chemical.ResidueTypeSet: Finished initializing fa_standard residue type set. Created 9172 residue types
              core.pack.task: Packer task: initialize from command line()
              core.pack.dunbrack: Dunbrack 2010 library took 0.1 seconds to load from binary

              Chi angles are [-68.3503, 176.299, 151.646, ]

              Rotamer vectors are [3, 2, 2, ]

              I was wondering how there could be more than one rotamer or conformational isomerism for a given residue?

            • #9704
              Anonymous

                Thank you so much for your kind advice. The reason I wanted to know the rotamers for a residue is so I could calculate the self-energies and the table of pairwise energies between rotamers of mutable (molten or changeable) residues in a side-chain packing problem and redesign problem. I basically am trying to figure out how to get the tables of pairwise rotamer-to-rotamer energies between mutable residues. I want the pairwise rotamer-to-rotamer energy table between mutable residues where the residue can change to all possible amino acid types and thus all possible rotamers of all possible amino acid types. I want to include all rotamers of all possible amino acid types in the mutable residues because I am trying to extend the side chain packing (only rotamers of a single amino acid type allowed) to redesign (all rotamers of all amino acid types allowed). I am modifying code from Jason Pacheco of Brown University (I changed the rotamer_set_for_moltenresidue function to FixbbRotamerSets function to try to include all rotamers of all amino acid types but it is giving the following error – AttributeError: ‘RotamerSets’ object has no attribute ‘FixbbRotamerSets’):

                import numpy as np
                import optparse # for option sorting
                import rosetta
                import rosetta.core.pack.task

                from rosetta import *
                from scipy.sparse import *
                from rosetta.core.pack.rotamer_set import *
                from rosetta.core.pack import *
                from rosetta.core.pack.interaction_graph import *
                from rosetta.core.pack.task import * # for using resfiles

                init()

                ## FUNCTIONS ############################################

                def get_rotamer_etable( ig, rotsets, moltenresI, moltenresJ ):
                “””Computes rotamer-rotamer energy table between two residues.”””

                # check edge exists
                if not ig.get_edge_exists(moltenresI, moltenresJ):
                return None

                # get etable
                rotsI = rotsets.FixbbRotamerSets()
                rotsJ = rotsets.FixbbRotamerSets()
                n_rots_I = rotsI.num_rotamers()
                n_rots_J = rotsJ.num_rotamers()
                E = np.zeros((n_rots_I,n_rots_J))
                for s_i in range(1, n_rots_I+1):
                for s_j in range(1, n_rots_J+1):
                E[s_i-1,s_j-1] = ig.get_two_body_energy_for_edge(moltenresI, moltenresJ, s_i, s_j)
                return E

                Please kindly guide me.
                Thank you so much.

              • #9678
                Anonymous

                  ResidueType is a class in Rosetta which describes the general properties of a residue (as opposed to the Residue class, which holds information about a particular residue, e.g. the atom coordinates.) If you have a Residue object, you can get the corresponding ResidueType object with the type() member function. Alternatively, you can use the residue_type(i) member function of Pose to get the same information. — By the way, there’s also a core::pack::dunbrack::rotamer_from_chi(conformation::Residue const & rsd, RotVector & rot) version of the function, which will do the chi vector and residue type extraction for you.

                  And yes, the RotVector parameter for core::pack::dunbrack::rotamer_from_chi() is the output parameter. Just pass in an empty object of the appropriate type, and the function will fill in the results. A standard Python list probably won’t work for this, though. You’ll likely need to match the C++ level type, so you would need to create a rosetta.utility.vector1_Size() object. See http://www.pyrosetta.org/faq#TOC-2.-How-do-I-construct-Vector1-objects-

                  A final issue you’re having is your native_pose.chi(1,7) is getting a single chi value. (The first chi of the seventh residue.) What the rotamer_from_chi() function is expecting is a vector of angle values – so not just the value of a single chi, but the values for all the chis. (Yes, the vector/single value distinction still holds, even if you know that there’s only a single chi for that particular amino acid.) There isn’t a convenience function to get the vector directly from the pose. Instead you’ll need to get the Residue object, and then get the vector1 of chis from that: native_pose.residue(7).chi()

                • #9707
                  Anonymous

                    It’s the vector as a whole which defines the rotamer. You’re correct that you’re getting one number in the vector per chi angle. Each chi angle is binned (somewhat) independently, and that’s what’s reflected in the individual numbers.

                  • #9709
                    Anonymous

                      See answer in other thread: https://www.rosettacommons.org/node/3558

                  Viewing 4 reply threads
                  • You must be logged in to reply to this topic.