IMP logo
IMP Reference Guide  2.19.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-2022 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 <cereal/access.hpp>
16 #include <IMP/Object.h>
17 #include <IMP/atom/Residue.h>
18 #include <IMP/rotamer/rotamer_config.h>
19 
20 IMPROTAMER_BEGIN_NAMESPACE
21 
22 //! A simple class storing chi angles and their probability
23 class IMPROTAMEREXPORT RotamerAngleTuple {
24  public:
25  //! default constructor. Build identity rotations with zero probability
27  : chi1_(0), chi2_(0), chi3_(0), chi4_(0), probability_(0) {}
28 
29  //! constructor. build rotamer data corresponding to 1 line from
30  // the library file
31  RotamerAngleTuple(float chi1, float chi2, float chi3, float chi4,
32  float probability)
33  : chi1_(chi1),
34  chi2_(chi2),
35  chi3_(chi3),
36  chi4_(chi4),
37  probability_(probability) {}
38 
39  //! query the chi1 angle
40  float get_chi1() const { return chi1_; }
41 
42  //! query the chi2 angle
43  float get_chi2() const { return chi2_; }
44 
45  //! query the chi3 angle
46  float get_chi3() const { return chi3_; }
47 
48  //! query the chi4 angle
49  float get_chi4() const { return chi4_; }
50 
51  //! query the probability
52  float get_probability() const { return probability_; }
53 
55  out << "RotamerAngleTuple: " << chi1_ << ' ' << chi2_ << ' ' << chi3_ << ' '
56  << chi4_ << ' ' << probability_;
57  });
58 
59  private:
60  float chi1_;
61  float chi2_;
62  float chi3_;
63  float chi4_;
64  float probability_;
65 
66  friend class cereal::access;
67 
68  template<class Archive> void serialize(Archive &ar) {
69  ar(chi1_, chi2_, chi3_, chi4_, probability_);
70  }
71 };
72 
74 
75 //! A class storing a whole rotamer library read from a file
76 class IMPROTAMEREXPORT RotamerLibrary : public IMP::Object {
77  public:
78  //! constructor. Build an empty library object
79  /** \param[in] angle_step bucket size in degrees */
80  RotamerLibrary(unsigned angle_step = 10);
81 
82 #ifndef SWIG
83  typedef RotamerAngleTuples::const_iterator RotamerIterator;
84  typedef boost::iterator_range<RotamerIterator> RotamerRange;
85 
86  //! query the rotamer library for the rotamer data
87  /** This function returns a range of iterators to the queried contents.
88  The range can be used in the following way:
89  \code{.cpp}
90  RotamerLibrary rl;
91  // ....
92  RotamerLibrary::RotamerRange r = rl.get_rotamers_fast(...);
93  for ( RotamerLibrary::RotamerIterator p = r.begin(); p != r.end(); ++p )
94  {
95  const RotamerAngleTuple &ra = *p;
96  // process ra ...
97  }
98  \endcode
99  \param[in] residue the residue to query about
100  \param[in] phi first backbone angle
101  \param[in] psi second backbone angle
102  \param[in] probability_thr threshold on the sum of probabilities.
103  */
104  RotamerRange get_rotamers_fast(IMP::atom::ResidueType residue, float phi,
105  float psi, float probability_thr) const;
106 #endif
107 
108  //! query the rotamer library for the rotamer data
109  /** This function returns a vector with the queried contents (and is
110  therefore slower than get_rotamers_fast). It is however more useful in
111  Python code
112  \param[in] residue the residue to query about
113  \param[in] phi first backbone angle
114  \param[in] psi second backbone angle
115  \param[in] probability_thr threshold on the sum of probabilities.
116  */
117  RotamerAngleTuples get_rotamers(IMP::atom::ResidueType residue, float phi,
118  float psi, float probability_thr) const;
119 
120  //! load the library from file
121  /** \param[in] lib_file_name file name */
122  void read_library_file(const std::string &lib_file_name);
123 
125 
126  private:
127  unsigned backbone_angle_to_index(float phi, float psi) const;
128 
129  typedef std::vector<RotamerAngleTuples> RotamerAngleTuplesByBackbone;
130  typedef std::vector<RotamerAngleTuplesByBackbone> RotamersByResidue;
131  RotamersByResidue library_;
132 
133  unsigned angle_step_;
134  unsigned rotamers_by_backbone_size_;
135 };
136 
137 IMPROTAMER_END_NAMESPACE
138 
139 #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:42
#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:111
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