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