IMP  2.1.1
The Integrative Modeling Platform
MarginalHBondRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/isd/MarginalHBondRestraint.h
3  * \brief A lognormal restraint that uses the ISPA model to model HBond-derived
4  * distance fit.
5  *
6  * Copyright 2007-2013 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPISD_MARGINAL_HBOND_RESTRAINT_H
11 #define IMPISD_MARGINAL_HBOND_RESTRAINT_H
12 
13 #include <IMP/restraint_macros.h>
14 #include <IMP/isd/isd_config.h>
15 #include <IMP/kernel/Restraint.h>
16 #include <IMP/PairContainer.h>
17 
18 IMPISD_BEGIN_NAMESPACE
19 
20 //! Apply a lognormal distance restraint between two particles.
21 /** Marginal of the lognormal model for NOEs where only \f$\sigma\f$ was
22  marginalized, and \f$\gamma\f$ was set to 1.
23  Since the restraint is complicated, pass individual particles to
24  add_contribution() command.
25 
26  \f[p(D|X,I) =
27  \left(\sum_{i=1}^N \log^2\left(\frac{V_i^{exp}}
28  {d_i^{-6}(X)}\right)\right)^{-\frac{N}{2}}
29  \f]
30  */
31 class IMPISDEXPORT MarginalHBondRestraint : public kernel::Restraint
32 {
33  PairContainers contribs_;
34  std::vector<double> volumes_;
35  double logsquares_;
36  void set_logsquares(double logsquares) {logsquares_=logsquares;}
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, "MarginalHBondRestraint%1%") {};
45 
46 
47  // add a contribution: simple case
48  void add_contribution(kernel::Particle *p1, kernel::Particle *p2, double
49  Iexp);
50 
51  //add a contribution: general case
52  void add_contribution(PairContainer *pc, double Iexp);
53 
54  //return the sum inside the parentheses
55  double get_logsquares() const {return logsquares_;}
56 
57  unsigned get_number_of_contributions() const {return volumes_.size();}
58 
59  /* call for probability */
60  double get_probability() const
61  {
62  return exp(-unprotected_evaluate(nullptr));
63  }
64 
65 
66  /** This macro declares the basic needed methods: evaluate and show
67  */
68  virtual double
69  unprotected_evaluate(IMP::kernel::DerivativeAccumulator *accum)
70  const IMP_OVERRIDE;
71  virtual IMP::kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
73 
74 
75 };
76 
77 IMPISD_END_NAMESPACE
78 
79 #endif /* IMPISD_MARGINAL_HBOND_RESTRAINT_H */
Class for adding derivatives from restraints to the model.
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
A shared container for Pairs.
Import IMP/kernel/restraint_macros.h in the namespace.
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.
Apply a lognormal distance restraint between two particles.
MarginalHBondRestraint(kernel::Model *m)
Create the restraint.
Class for storing model, its restraints, constraints, and particles.