IMP logo
IMP Reference Guide  2.12.0
The Integrative Modeling Platform
SurfaceTetheredChain.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/SurfaceTetheredChain.h
3  * \brief Score on surface-to-end distance of chain tethered to impenetrable surface
4  *
5  * Copyright 2007-2019 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPCORE_SURFACE_TETHERED_CHAIN_H
9 #define IMPCORE_SURFACE_TETHERED_CHAIN_H
10 
11 #include <IMP/core/core_config.h>
12 #include <IMP/UnaryFunction.h>
13 #include <IMP/constants.h>
14 
15 IMPCORE_BEGIN_NAMESPACE
16 
17 //! Score on surface-to-end distance of chain tethered to impenetrable surface
18 /** When a flexible linker is represented by the freely jointed chain model with
19  one end tethered to an impenetrable surface, the distance \f$ z \f$ of the
20  free end from the surface follows the distribution
21  \f[ p(z | \beta) = 2 \beta z \exp{(-\beta z^2)}, \f]
22  where \f$ \beta = \frac{3}{2 N b^2} \f$, \f$ N \f$ is the number of links,
23  and \f$ b \f$ is the average length of a single link. The score reaches its
24  minimum value when \f$ z = \frac{1}{\sqrt{2 \beta}} \f$.
25 
26  See KA Dill, S Bromberg. Molecular Driving Forces. 2nd Edition. 2010.
27  Eq 34.7.
28 
29  \note While the Gaussian approximation breaks down when \f$z > N b\f$, the
30  score naturally increases as a harmonic restraint with force constant
31  \f$2 \beta\f$.
32 
33  \note The resulting score blows up as the \f$ z \f$ approaches 0.
34  Therefore, in this implementation, when \f$ z = .01 z_{min} \f$, where
35  \f$ z_{min} \f$ is the value of \f$ z \f$ where the score is minimized,
36  then the score increases linearly as \f$ z \f$ decreases.
37 
38  \see misc::FreelyJointedChain
39  \see misc::WormLikeChain
40  \see Harmonic
41  \see SurfaceHeightPairScore
42 */
44 
45  private:
46  void initialize() {
47  double N = (double) N_;
48  beta_ = 3. / 2. / N / b_ / b_;
49  z_min_ = 0.01 / sqrt(2 * beta_);
50  z_min_deriv_ = -141.4072141 * sqrt(beta_);
51  z_min_int_ = 5.2585466 - std::log(beta_) / 2.;
52  }
53 
54  public:
55  SurfaceTetheredChain(int link_num, double link_length)
56  : N_(link_num), b_(link_length) {
57  IMP_USAGE_CHECK(N_ > 0, "Number of links must be positive.");
58  IMP_USAGE_CHECK(b_ > 0, "Link length must be positive.");
59  initialize();
60  }
61 
62  virtual DerivativePair evaluate_with_derivative(double feature) const {
63  if (feature < z_min_) {
64  return DerivativePair(z_min_deriv_ * feature + z_min_int_,
65  z_min_deriv_);
66  } else {
67  return DerivativePair(beta_ * feature * feature -
68  std::log(2 * beta_ * feature),
69  2. * beta_ * feature - 1. / feature);
70  }
71  }
72 
73  virtual double evaluate(double feature) const {
74  return evaluate_with_derivative(feature).first;
75  }
76 
78 
79  //! Get number of links in chain.
80  int get_link_number() const { return N_; }
81 
82  //! Get length of each chain link.
83  double get_link_length() const { return b_; }
84 
85  //! Set the number of links in chain.
86  void set_link_number(int N) {
87  N_ = N;
88  IMP_USAGE_CHECK(N_ > 0, "Number of links must be positive.");
89  initialize();
90  }
91 
92  //! Set the length of each chain link.
93  void set_link_length(double b) {
94  b_ = b;
95  IMP_USAGE_CHECK(b_ > 0, "Link length must be positive.");
96  initialize();
97  }
98 
99  //! Get the distance at which the score is at its minimum value.
100  double get_distance_at_minimum() const {
101  return 1. / sqrt(2 * beta_);
102  }
103 
104  //! Get the average distance from the surface.
105  double get_average_distance() const {
106  return sqrt(PI / beta_) / 2.;
107  }
108 
109  private:
110  int N_;
111  double b_;
112  double beta_, z_min_, z_min_deriv_, z_min_int_;
113 };
114 
115 IMPCORE_END_NAMESPACE
116 
117 #endif /* IMPCORE_SURFACE_TETHERED_CHAIN_H */
double get_link_length() const
Get length of each chain link.
static const double PI
the constant pi
Various useful constants.
double get_distance_at_minimum() const
Get the distance at which the score is at its minimum value.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Single variable function.
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
Score on surface-to-end distance of chain tethered to impenetrable surface.
int get_link_number() const
Get number of links in chain.
void set_link_number(int N)
Set the number of links in chain.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:23
void set_link_length(double b)
Set the length of each chain link.
double get_average_distance() const
Get the average distance from the surface.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Definition: check_macros.h:168
Abstract single variable functor class for score functions.
Definition: UnaryFunction.h:25
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.