IMP  2.1.0
The Integrative Modeling Platform
RotamerCalculator.h
Go to the documentation of this file.
1 /**
2  * \file RotamerCalculator.h
3  * \brief Object performing rotations by Chi angles.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPROTAMER_ROTAMER_CALCULATOR_H
10 #define IMPROTAMER_ROTAMER_CALCULATOR_H
11 
12 #include <vector>
13 #include <limits>
14 #include <IMP/PairScore.h>
15 #include <IMP/algebra/Vector3D.h>
16 #include <IMP/atom/Atom.h>
17 #include <IMP/atom/Residue.h>
19 
20 IMPROTAMER_BEGIN_NAMESPACE
21 
22 //! A class storing the rotated coordinates of the atoms in the residue
23 class IMPROTAMEREXPORT ResidueRotamer
24 {
25 public:
27  : size_(0)
28  , residue_type_(rt)
29  {}
30 
31  //! get coordinates of the specified atom
32  /** \param[in] index the version of the coordinates (index 0 gives the
33  original coordinates, index 1 the most probable coordinates, index 2
34  the second most probable coordinates, etc)
35  \param[in] at the requested atom
36  */
37  const IMP::algebra::Vector3D &get_coordinates(unsigned index,
38  const IMP::atom::AtomType &at) const;
39 
40  //! get number of coordinate sets for a given atom
41  /** \param[in] at the requested atom
42  */
43  unsigned get_number_of_cases(const IMP::atom::AtomType &at) const;
44 
45  //! check if a given atom is present in the data structure
46  /** \param[in] at the requested atom
47  */
48  bool get_atom_exists(const IMP::atom::AtomType &at) const;
49 
50  //! get number of rotamers
51  unsigned get_size() const
52  {
53  return size_;
54  }
55 
56 
57  //! get probability associated with the given rotamer
58  /** \param[in] index the version of the coordinates (index 1 gives
59  the coordinates of the first rotamer, etc)
60  */
61  double get_probability(unsigned index) const;
62 
64  out << "ResidueRotamer"; });
65 
66 private:
67  struct Box3D
68  {
69  Box3D()
70  {
71  clear();
72  }
73  void clear()
74  {
75  xmin = ymin = zmin = std::numeric_limits<double>::max();
76  xmax = ymax = zmax = -std::numeric_limits<double>::max();
77  }
78  double xmin, xmax;
79  double ymin, ymax;
80  double zmin, zmax;
81  };
82 
83  static bool intersect(const Box3D &b1, const Box3D &b2);
84 
85  typedef std::vector<Box3D> Boxes3D;
86 
87  void create_bounding_boxes(Box3D &bb_box, Box3D &sc_box, Boxes3D &rot_boxes);
88 
89  void add_coordinates(const IMP::atom::AtomType &at,
90  const IMP::algebra::Vector3D &coords);
91  void push_coordinates();
92  IMP::algebra::Vector3D &get_coordinates(const IMP::atom::AtomType &at);
93  void set_coordinates(unsigned index,
94  IMP::atom::Residue &rd) const;
95 
96  friend class RotamerCalculator;
97 
98  typedef std::vector<IMP::algebra::Vector3D> AtomCoordinates;
99  typedef std::vector<AtomCoordinates> ResidueCoordinates;
100  ResidueCoordinates residue_coordinates_;
101  std::vector<double> probabilities_;
102  unsigned size_;
103  IMP::atom::ResidueType residue_type_;
104 };
105 
106 
108 
109 
110 //! A class performing the rotations of atoms in the residues
111 class IMPROTAMEREXPORT RotamerCalculator
112  : public IMP::base::Object
113 {
114 public:
115  //! constructor
116  /** \param[in] rl an instance of RotamerLibrary
117  */
119 
120  //! get the coordinates of the residue atoms
121  /** this function performs the rotations of the atoms in the given residue
122  with the cumulative probability thr
123  \param[in] rd the residue to be rotated
124  \param[in] thr probability threshold
125  */
126  ResidueRotamer get_rotamer(const IMP::atom::Residue &rd, double thr) const;
127 
129 
130  //! set coordinates of side chains of the given protein
131  /** \param[in] protein the protein to set coordinates based on most likely
132  rotamers
133  \param[in] score scoring function to use
134  \param[in] thr query threshold
135  \param[in] K parameter in equation (42)
136  \param[in] num_iter maximum number of iterations (suggested: 6)
137  */
138  void transform(const IMP::atom::Hierarchy &protein,
139  const IMP::PairScore *score, double thr,
140  double K, int num_iter) const;
141 
142 private:
143  struct ResidueData
144  {
145  ResidueData()
146  : n_angles(0)
147  {}
148 
149  bool empty() const
150  {
151  return n_angles == 0;
152  }
153 
154  int n_angles;
155  std::vector<IMP::atom::AtomType> at_axes;
156  std::vector<char> rot_atoms;
157  };
158 
160  std::vector<ResidueData> residues_;
161 };
162 
163 IMPROTAMER_END_NAMESPACE
164 
165 #endif /* IMPROTAMER_ROTAMER_CALCULATOR_H */
Object representing rotamer library.
A smart pointer to a ref-counted Object that is a class memeber.
Definition: base/Pointer.h:146
A class storing a whole rotamer library read from a file.
Simple atom decorator.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
The type of an atom.
A class storing the rotated coordinates of the atoms in the residue.
Abstract score function.
void transform(Hierarchy h, const algebra::Transformation3D &tr)
The standard decorator for manipulating molecular structures.
A class performing the rotations of atoms in the residues.
A decorator for Residues.
const ResidueType UNK
Import IMP/kernel/PairScore.h in the namespace.
The type for a residue.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Common base class for heavy weight IMP objects.
A decorator for a residue.
Definition: Residue.h:133
Simple 3D vector class.
unsigned get_size() const
get number of rotamers