IMP  2.0.0
The Integrative Modeling Platform
MarginalNOERestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/isd/MarginalNOERestraint.h
3  * \brief A lognormal restraint that uses the ISPA model to model NOE-derived
4  * distance fit.
5  *
6  * Copyright 2007-2013 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPISD_MARGINAL_NOE_RESTRAINT_H
11 #define IMPISD_MARGINAL_NOE_RESTRAINT_H
12 
13 #include <IMP/restraint_macros.h>
14 #include <IMP/isd/isd_config.h>
15 #include <IMP/isd/ISDRestraint.h>
16 #include <IMP/PairContainer.h>
17 
18 IMPISD_BEGIN_NAMESPACE
19 
20 //! Apply an NOE distance restraint between two particles.
21 /** Marginal of the NOE lognormal model. Since restraint is complicated,
22  pass individual particles to add_contribution() command. Supports
23  ambiguous NOEs and derivatives.
24 
25  \f[p(D|X,I) = SS^{-\frac{N-1}{2}} \quad
26  SS = \sum_{i=1}^N \log^2\left(\frac{V_i^{exp}}{d_i^{-6}(X)
27  \hat{\gamma}}\right) \quad
28  \hat{\gamma} = \left(\prod_{i=1}^N \frac{V_i^{exp}}{d_i^{-6}}\right)^{1/N}
29  \f]
30  */
31 class IMPISDEXPORT MarginalNOERestraint : public ISDRestraint
32 {
33  PairContainers contribs_;
34  std::vector<double> volumes_;
35  double loggammahat_;
36  void set_log_gammahat(double loggammahat) {loggammahat_=loggammahat;}
37  double SS_;
38  void set_SS(double SS) {SS_=SS;}
39 
40 public:
41  //! Create the restraint.
42  /** Restraints should store the particles they are to act on,
43  preferably in a Singleton or PairContainer as appropriate.
44  */
46 
47 
48  // add a contribution: simple case
49  void add_contribution(Particle *p1, Particle *p2, double Iexp);
50 
51  //add a contribution: general case
52  void add_contribution(PairContainer *pc, double Iexp);
53 
54  //return the estimate of gamma given the current structure.
55  double get_log_gammahat() const {return loggammahat_;}
56 
57  //return the sum of squares wrt current structure.
58  double get_SS() const {return SS_;}
59 
60  unsigned get_number_of_contributions() const {return volumes_.size();}
61 
62  /* call for probability */
63  double get_probability() const
64  {
65  return exp(-unprotected_evaluate(nullptr));
66  }
67 
68 
69  /** This macro declares the basic needed methods: evaluate and show
70  */
71  IMP_RESTRAINT_2(MarginalNOERestraint);
72 
73 
74 };
75 
76 IMPISD_END_NAMESPACE
77 
78 #endif /* IMPISD_MARGINAL_NOE_RESTRAINT_H */