IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
RotamerLibrary.h
Go to the documentation of this file.
1 /**
2  * \file IMP/rotamer/RotamerLibrary.h
3  * \brief Object representing rotamer library.
4  *
5  * Copyright 2007-2018 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/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  public:
24  //! default constructor. Build identity rotations with zero probability
26  : chi1_(0), chi2_(0), chi3_(0), chi4_(0), probability_(0) {}
27 
28  //! constructor. build rotamer data corresponding to 1 line from
29  // the library file
30  RotamerAngleTuple(float chi1, float chi2, float chi3, float chi4,
31  float probability)
32  : chi1_(chi1),
33  chi2_(chi2),
34  chi3_(chi3),
35  chi4_(chi4),
36  probability_(probability) {}
37 
38  //! query the chi1 angle
39  float get_chi1() const { return chi1_; }
40 
41  //! query the chi2 angle
42  float get_chi2() const { return chi2_; }
43 
44  //! query the chi3 angle
45  float get_chi3() const { return chi3_; }
46 
47  //! query the chi4 angle
48  float get_chi4() const { return chi4_; }
49 
50  //! query the probability
51  float get_probability() const { return probability_; }
52 
54  out << "RotamerAngleTuple: " << chi1_ << ' ' << chi2_ << ' ' << chi3_ << ' '
55  << chi4_ << ' ' << probability_;
56  });
57 
58  private:
59  float chi1_;
60  float chi2_;
61  float chi3_;
62  float chi4_;
63  float probability_;
64 };
65 
67 
68 //! A class storing a whole rotamer library read from a file
69 class IMPROTAMEREXPORT RotamerLibrary : public IMP::Object {
70  public:
71  //! constructor. Build an empty library object
72  /** \param[in] angle_step bucket size in degrees */
73  RotamerLibrary(unsigned angle_step = 10);
74 
75 #ifndef SWIG
76  typedef RotamerAngleTuples::const_iterator RotamerIterator;
77  typedef boost::iterator_range<RotamerIterator> RotamerRange;
78 
79  //! query the rotamer library for the rotamer data
80  /** This function returns a range of iterators to the queried contents.
81  The range can be used in the following way:
82  \code{.cpp}
83  RotamerLibrary rl;
84  // ....
85  RotamerLibrary::RotamerRange r = rl.get_rotamers_fast(...);
86  for ( RotamerLibrary::RotamerIterator p = r.begin(); p != r.end(); ++p )
87  {
88  const RotamerAngleTuple &ra = *p;
89  // process ra ...
90  }
91  \endcode
92  \param[in] residue the residue to query about
93  \param[in] phi first backbone angle
94  \param[in] psi second backbone angle
95  \param[in] probability_thr threshold on the sum of probabilities.
96  */
97  RotamerRange get_rotamers_fast(IMP::atom::ResidueType residue, float phi,
98  float psi, float probability_thr) const;
99 #endif
100 
101  //! query the rotamer library for the rotamer data
102  /** This function returns a vector with the queried contents (and is
103  therefore slower than get_rotamers_fast). It is however more useful in
104  Python code
105  \param[in] residue the residue to query about
106  \param[in] phi first backbone angle
107  \param[in] psi second backbone angle
108  \param[in] probability_thr threshold on the sum of probabilities.
109  */
110  RotamerAngleTuples get_rotamers(IMP::atom::ResidueType residue, float phi,
111  float psi, float probability_thr) const;
112 
113  //! load the library from file
114  /** \param[in] lib_file_name file name */
115  void read_library_file(const std::string &lib_file_name);
116 
118 
119  private:
120  unsigned backbone_angle_to_index(float phi, float psi) const;
121 
122  typedef std::vector<RotamerAngleTuples> RotamerAngleTuplesByBackbone;
123  typedef std::vector<RotamerAngleTuplesByBackbone> RotamersByResidue;
124  RotamersByResidue library_;
125 
126  unsigned angle_step_;
127  unsigned rotamers_by_backbone_size_;
128 };
129 
130 IMPROTAMER_END_NAMESPACE
131 
132 #endif /* IMPROTAMER_ROTAMER_LIBRARY_H */
float get_chi2() const
query the chi2 angle
float get_probability() const
query the probability
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
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
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A class storing a whole rotamer library read from a file.
A more IMP-like version of the std::vector.
Definition: Vector.h:39
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
A simple class storing chi angles and their probability.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
A decorator for Residues.
The type for a residue.
A shared base class to help in debugging and things.
RotamerAngleTuple()
default constructor. Build identity rotations with zero probability
float get_chi1() const
query the chi1 angle
float get_chi4() const
query the chi4 angle