IMP  2.1.1
The Integrative Modeling Platform
RotamerLibrary.h
Go to the documentation of this file.
1 /**
2  * \file RotamerLibrary.h
3  * \brief Object representing rotamer library.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPROTAMER_ROTAMER_LIBRARY_H
10 #define IMPROTAMER_ROTAMER_LIBRARY_H
11 
12 #include <string>
13 #include <vector>
14 #include <boost/range/iterator_range.hpp>
15 #include <IMP/base/Object.h>
16 #include <IMP/atom/Residue.h>
17 #include <IMP/rotamer/rotamer_config.h>
18 
19 IMPROTAMER_BEGIN_NAMESPACE
20 
21 //! A simple class storing chi angles and their probability
22 class IMPROTAMEREXPORT RotamerAngleTuple
23 {
24 public:
25  //! default constructor. Build identity rotations with zero probability
27  : chi1_(0)
28  , chi2_(0)
29  , chi3_(0)
30  , chi4_(0)
31  , probability_(0)
32  {
33  }
34 
35  //! constructor. build rotamer data corresponding to 1 line from
36  //the library file
37  RotamerAngleTuple(float chi1, float chi2, float chi3, float chi4,
38  float probability)
39  : chi1_(chi1)
40  , chi2_(chi2)
41  , chi3_(chi3)
42  , chi4_(chi4)
43  , probability_(probability)
44  {
45  }
46 
47  //! query the chi1 angle
48  float get_chi1() const
49  {
50  return chi1_;
51  }
52 
53  //! query the chi2 angle
54  float get_chi2() const
55  {
56  return chi2_;
57  }
58 
59  //! query the chi3 angle
60  float get_chi3() const
61  {
62  return chi3_;
63  }
64 
65  //! query the chi4 angle
66  float get_chi4() const
67  {
68  return chi4_;
69  }
70 
71  //! query the probability
72  float get_probability() const
73  {
74  return probability_;
75  }
76 
78  out << "RotamerAngleTuple: " << chi1_ << ' '
79  << chi2_ << ' '
80  << chi3_ << ' ' << chi4_ << ' '
81  << probability_; });
82 
83 private:
84  float chi1_;
85  float chi2_;
86  float chi3_;
87  float chi4_;
88  float probability_;
89 };
90 
91 
93 
94 
95 //! A class storing a whole rotamer library read from a file
96 class IMPROTAMEREXPORT RotamerLibrary
97  : public IMP::base::Object
98 {
99 public:
100  //! constructor. Build an empty library object
101  /** \param[in] angle_step bucket size in degrees */
102  RotamerLibrary(unsigned angle_step = 10);
103 
104 #ifndef SWIG
105  typedef RotamerAngleTuples::const_iterator RotamerIterator;
106  typedef boost::iterator_range<RotamerIterator> RotamerRange;
107 
108  //! query the rotamer library for the rotamer data
109  /** This function returns a range of iterators to the queried contents.
110  The range can be used in the following way:
111  \code{.cpp}
112  RotamerLibrary rl;
113  // ....
114  RotamerLibrary::RotamerRange r = rl.get_rotamers_fast(...);
115  for ( RotamerLibrary::RotamerIterator p = r.begin(); p != r.end(); ++p )
116  {
117  const RotamerAngleTuple &ra = *p;
118  // process ra ...
119  }
120  \endcode
121  \param[in] residue the residue to query about
122  \param[in] phi first backbone angle
123  \param[in] psi second backbone angle
124  \param[in] probability_thr threshold on the sum of probabilities.
125  */
126  RotamerRange get_rotamers_fast(
127  IMP::atom::ResidueType residue, float phi, float psi,
128  float probability_thr) const;
129 #endif
130 
131  //! query the rotamer library for the rotamer data
132  /** This function returns a vector with the queried contents (and is
133  therefore slower than get_rotamers_fast). It is however more useful in
134  Python code
135  \param[in] residue the residue to query about
136  \param[in] phi first backbone angle
137  \param[in] psi second backbone angle
138  \param[in] probability_thr threshold on the sum of probabilities.
139  */
140  RotamerAngleTuples get_rotamers(
141  IMP::atom::ResidueType residue, float phi, float psi,
142  float probability_thr) const;
143 
144  //! load the library from file
145  /** \param[in] lib_file_name file name */
146  void read_library_file(const std::string &lib_file_name);
147 
149 
150 private:
151  unsigned backbone_angle_to_index(float phi, float psi) const;
152 
153  typedef std::vector<RotamerAngleTuples> RotamerAngleTuplesByBackbone;
154  typedef std::vector<RotamerAngleTuplesByBackbone> RotamersByResidue;
155  RotamersByResidue library_;
156 
157  unsigned angle_step_;
158  unsigned rotamers_by_backbone_size_;
159 };
160 
161 
162 IMPROTAMER_END_NAMESPACE
163 
164 #endif /* IMPROTAMER_ROTAMER_LIBRARY_H */
float get_chi2() const
query the chi2 angle
float get_probability() const
query the probability
RotamerAngleTuple(float chi1, float chi2, float chi3, float chi4, float probability)
constructor. build rotamer data corresponding to 1 line from
float get_chi3() const
query the chi3 angle
A class storing a whole rotamer library read from a file.
#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.
A simple class storing chi angles and their probability.
A decorator for Residues.
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.
RotamerAngleTuple()
default constructor. Build identity rotations with zero probability
float get_chi1() const
query the chi1 angle
A shared base class to help in debugging and things.
float get_chi4() const
query the chi4 angle