/
SurfaceTetheredChain.h
118 lines (96 loc) · 3.65 KB
/
SurfaceTetheredChain.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
/**
* \file IMP/core/SurfaceTetheredChain.h
* \brief Score on surface-to-end distance of chain tethered to impenetrable surface
*
* Copyright 2007-2022 IMP Inventors. All rights reserved.
*/
#ifndef IMPCORE_SURFACE_TETHERED_CHAIN_H
#define IMPCORE_SURFACE_TETHERED_CHAIN_H
#include <IMP/core/core_config.h>
#include <IMP/UnaryFunction.h>
#include <IMP/constants.h>
IMPCORE_BEGIN_NAMESPACE
//! Score on surface-to-end distance of chain tethered to impenetrable surface
/** When a flexible linker is represented by the freely jointed chain model with
one end tethered to an impenetrable surface, the distance \f$ z \f$ of the
free end from the surface follows the distribution
\f[ p(z | \beta) = 2 \beta z \exp{(-\beta z^2)}, \f]
where \f$ \beta = \frac{3}{2 N b^2} \f$, \f$ N \f$ is the number of links,
and \f$ b \f$ is the average length of a single link. The score reaches its
minimum value when \f$ z = \frac{1}{\sqrt{2 \beta}} \f$.
See KA Dill, S Bromberg. Molecular Driving Forces. 2nd Edition. 2010.
Eq 34.7.
\note While the Gaussian approximation breaks down when \f$z > N b\f$, the
score naturally increases as a harmonic restraint with force constant
\f$2 \beta\f$.
\note The resulting score blows up as the \f$ z \f$ approaches 0.
Therefore, in this implementation, when \f$ z = .01 z_{min} \f$, where
\f$ z_{min} \f$ is the value of \f$ z \f$ where the score is minimized,
then the score increases linearly as \f$ z \f$ decreases.
\see misc::FreelyJointedChain
\see misc::WormLikeChain
\see Harmonic
\see SurfaceHeightPairScore
*/
class SurfaceTetheredChain : public UnaryFunction {
private:
void initialize() {
double N = (double) N_;
beta_ = 3. / 2. / N / b_ / b_;
z_min_ = 0.01 / sqrt(2 * beta_);
z_min_deriv_ = -141.4072141 * sqrt(beta_);
z_min_int_ = 5.2585466 - std::log(beta_) / 2.;
}
public:
SurfaceTetheredChain(int link_num, double link_length)
: N_(link_num), b_(link_length) {
IMP_USAGE_CHECK(N_ > 0, "Number of links must be positive.");
IMP_USAGE_CHECK(b_ > 0, "Link length must be positive.");
initialize();
}
virtual DerivativePair evaluate_with_derivative(
double feature) const override {
if (feature < z_min_) {
return DerivativePair(z_min_deriv_ * feature + z_min_int_,
z_min_deriv_);
} else {
return DerivativePair(beta_ * feature * feature -
std::log(2 * beta_ * feature),
2. * beta_ * feature - 1. / feature);
}
}
virtual double evaluate(double feature) const override {
return evaluate_with_derivative(feature).first;
}
IMP_OBJECT_METHODS(SurfaceTetheredChain);
//! Get number of links in chain.
int get_link_number() const { return N_; }
//! Get length of each chain link.
double get_link_length() const { return b_; }
//! Set the number of links in chain.
void set_link_number(int N) {
N_ = N;
IMP_USAGE_CHECK(N_ > 0, "Number of links must be positive.");
initialize();
}
//! Set the length of each chain link.
void set_link_length(double b) {
b_ = b;
IMP_USAGE_CHECK(b_ > 0, "Link length must be positive.");
initialize();
}
//! Get the distance at which the score is at its minimum value.
double get_distance_at_minimum() const {
return 1. / sqrt(2 * beta_);
}
//! Get the average distance from the surface.
double get_average_distance() const {
return sqrt(PI / beta_) / 2.;
}
private:
int N_;
double b_;
double beta_, z_min_, z_min_deriv_, z_min_int_;
};
IMPCORE_END_NAMESPACE
#endif /* IMPCORE_SURFACE_TETHERED_CHAIN_H */