IMP  2.2.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-2014 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/isd/isd_config.h>
14 #include <IMP/kernel/Restraint.h>
15 #include <IMP/PairContainer.h>
16 
17 IMPISD_BEGIN_NAMESPACE
18 
19 //! Apply an NOE distance restraint between two particles.
20 /** Marginal of the NOE lognormal model. Since restraint is complicated,
21  pass individual particles to add_contribution() command. Supports
22  ambiguous NOEs and derivatives.
23 
24  \f[p(D|X,I) = SS^{-\frac{N-1}{2}} \quad
25  SS = \sum_{i=1}^N \log^2\left(\frac{V_i^{exp}}{d_i^{-6}(X)
26  \hat{\gamma}}\right) \quad
27  \hat{\gamma} = \left(\prod_{i=1}^N \frac{V_i^{exp}}{d_i^{-6}}\right)^{1/N}
28  \f]
29  */
30 class IMPISDEXPORT MarginalNOERestraint : public kernel::Restraint {
31  PairContainers contribs_;
32  std::vector<double> volumes_;
33  double loggammahat_;
34  void set_log_gammahat(double loggammahat) { loggammahat_ = loggammahat; }
35  double SS_;
36  void set_SS(double SS) { SS_ = SS; }
37 
38  public:
39  //! Create the restraint.
40  /** kernel::Restraints should store the particles they are to act on,
41  preferably in a Singleton or PairContainer as appropriate.
42  */
44  : Restraint(m, "MarginalNOERestraint%1%") {};
45 
46  // add a contribution: simple case
47  void add_contribution(kernel::Particle *p1, kernel::Particle *p2,
48  double Iexp);
49 
50  // add a contribution: general case
51  void add_contribution(PairContainer *pc, double Iexp);
52 
53  // return the estimate of gamma given the current structure.
54  double get_log_gammahat() const { return loggammahat_; }
55 
56  // return the sum of squares wrt current structure.
57  double get_SS() const { return SS_; }
58 
59  unsigned get_number_of_contributions() const { return volumes_.size(); }
60 
61  /* call for probability */
62  double get_probability() const { return exp(-unprotected_evaluate(nullptr)); }
63 
64  /** This macro declares the basic needed methods: evaluate and show
65  */
66  virtual double unprotected_evaluate(IMP::kernel::DerivativeAccumulator *accum)
67  const IMP_OVERRIDE;
68  virtual IMP::kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
70 };
71 
72 IMPISD_END_NAMESPACE
73 
74 #endif /* IMPISD_MARGINAL_NOE_RESTRAINT_H */
Class for adding derivatives from restraints to the model.
A shared container for Pairs.
IMP::base::Vector< IMP::base::Pointer< PairContainer > > PairContainers
Import IMP/kernel/PairContainer.h in the namespace.
Abstract base class for all restraints.
A restraint is a term in an IMP ScoringFunction.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Class to handle individual model particles.
MarginalNOERestraint(kernel::Model *m)
Create the restraint.
virtual ModelObjectsTemp do_get_inputs() const =0
Apply an NOE distance restraint between two particles.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:72