IMP  2.2.0
The Integrative Modeling Platform
RotamerCalculator.h
Go to the documentation of this file.
1 /**
2  * \file IMP/rotamer/RotamerCalculator.h
3  * \brief Object performing rotations by Chi angles.
4  *
5  * Copyright 2007-2014 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  public:
26  : size_(0), residue_type_(rt) {}
27 
28  //! get coordinates of the specified atom
29  /** \param[in] index the version of the coordinates (index 0 gives the
30  original coordinates, index 1 the most probable coordinates, index 2
31  the second most probable coordinates, etc)
32  \param[in] at the requested atom
33  */
34  const IMP::algebra::Vector3D &get_coordinates(
35  unsigned index, const IMP::atom::AtomType &at) const;
36 
37  //! get number of coordinate sets for a given atom
38  /** \param[in] at the requested atom
39  */
40  unsigned get_number_of_cases(const IMP::atom::AtomType &at) const;
41 
42  //! check if a given atom is present in the data structure
43  /** \param[in] at the requested atom
44  */
45  bool get_atom_exists(const IMP::atom::AtomType &at) const;
46 
47  //! get number of rotamers
48  unsigned get_size() const { return size_; }
49 
50  //! get probability associated with the given rotamer
51  /** \param[in] index the version of the coordinates (index 1 gives
52  the coordinates of the first rotamer, etc)
53  */
54  double get_probability(unsigned index) const;
55 
56  IMP_SHOWABLE_INLINE(ResidueRotamer, { out << "ResidueRotamer"; });
57 
58  private:
59  struct Box3D {
60  Box3D() { clear(); }
61  void clear() {
62  xmin = ymin = zmin = std::numeric_limits<double>::max();
63  xmax = ymax = zmax = -std::numeric_limits<double>::max();
64  }
65  double xmin, xmax;
66  double ymin, ymax;
67  double zmin, zmax;
68  };
69 
70  static bool intersect(const Box3D &b1, const Box3D &b2);
71 
72  typedef std::vector<Box3D> Boxes3D;
73 
74  void create_bounding_boxes(Box3D &bb_box, Box3D &sc_box, Boxes3D &rot_boxes);
75 
76  void add_coordinates(const IMP::atom::AtomType &at,
77  const IMP::algebra::Vector3D &coords);
78  void push_coordinates();
79  IMP::algebra::Vector3D &get_coordinates(const IMP::atom::AtomType &at);
80  void set_coordinates(unsigned index, IMP::atom::Residue &rd) const;
81 
82  friend class RotamerCalculator;
83 
84  typedef std::vector<IMP::algebra::Vector3D> AtomCoordinates;
85  typedef std::vector<AtomCoordinates> ResidueCoordinates;
86  ResidueCoordinates residue_coordinates_;
87  std::vector<double> probabilities_;
88  unsigned size_;
89  IMP::atom::ResidueType residue_type_;
90 };
91 
93 
94 //! A class performing the rotations of atoms in the residues
95 class IMPROTAMEREXPORT RotamerCalculator : public IMP::base::Object {
96  public:
97  //! constructor
98  /** \param[in] rl an instance of RotamerLibrary
99  */
101 
102  //! get the coordinates of the residue atoms
103  /** this function performs the rotations of the atoms in the given residue
104  with the cumulative probability thr
105  \param[in] rd the residue to be rotated
106  \param[in] thr probability threshold
107  */
108  ResidueRotamer get_rotamer(const IMP::atom::Residue &rd, double thr) const;
109 
111 
112  //! set coordinates of side chains of the given protein
113  /** \param[in] protein the protein to set coordinates based on most likely
114  rotamers
115  \param[in] score scoring function to use
116  \param[in] thr query threshold
117  \param[in] K parameter in equation (42)
118  \param[in] num_iter maximum number of iterations (suggested: 6)
119  */
120  void transform(const IMP::atom::Hierarchy &protein,
121  const IMP::PairScore *score, double thr, double K,
122  int num_iter) const;
123 
124  private:
125  struct ResidueData {
126  ResidueData() : n_angles(0) {}
127 
128  bool empty() const { return n_angles == 0; }
129 
130  int n_angles;
131  std::vector<IMP::atom::AtomType> at_axes;
132  std::vector<char> rot_atoms;
133  };
134 
136  std::vector<ResidueData> residues_;
137 };
138 
139 IMPROTAMER_END_NAMESPACE
140 
141 #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:147
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.
Definition: base/Object.h:106
A decorator for a residue.
Definition: Residue.h:133
VectorD< 3 > Vector3D
Definition: VectorD.h:395
Simple 3D vector class.
unsigned get_size() const
get number of rotamers