IMP  2.3.1
The Integrative Modeling Platform
GaussianEMRestraint.h
Go to the documentation of this file.
1 /**
2  * \file isd/GaussianEMRestraint.h
3  * \brief Restraint two sets of gaussians (model and gmm derived from EM map)
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPISD_GAUSSIAN_EM_RESTRAINT_H
10 #define IMPISD_GAUSSIAN_EM_RESTRAINT_H
11 
12 #include "isd_config.h"
13 #include <IMP/PairContainer.h>
15 #include <IMP/container_macros.h>
16 #include <IMP/core/XYZ.h>
17 #include <IMP/core/Gaussian.h>
18 #include <IMP/algebra/Gaussian3D.h>
21 #include <IMP/atom/Mass.h>
22 #include <math.h>
23 #include <IMP/algebra/eigen3/Eigen/Dense>
24 #include <boost/unordered_map.hpp>
25 
26 IMPISD_BEGIN_NAMESPACE
27 
28 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
29 struct KahanAccumulation{
30 double sum;
31 double correction;
32 KahanAccumulation():
33  sum(0.0),correction(0.0)
34  {}
35 };
36 struct KahanVectorAccumulation{
37  IMP_Eigen::Vector3d sum;
38  IMP_Eigen::Vector3d correction;
39 KahanVectorAccumulation():
40  sum(IMP_Eigen::Vector3d(0,0,0)),
41  correction(IMP_Eigen::Vector3d(0,0,0))
42  {}
43 };
44 KahanAccumulation KahanSum(KahanAccumulation accumulation, double value){
45  KahanAccumulation result;
46  double y = value - accumulation.correction;
47  double t = accumulation.sum + y;
48  result.correction = (t - accumulation.sum) - y;
49  result.sum = t;
50  return result;
51 }
52 KahanVectorAccumulation KahanVectorSum(KahanVectorAccumulation accumulation, IMP_Eigen::Vector3d value){
53  KahanVectorAccumulation result;
54  IMP_Eigen::Vector3d y = value - accumulation.correction;
55  IMP_Eigen::Vector3d t = accumulation.sum + y;
56  result.correction = (t - accumulation.sum) - y;
57  result.sum = t;
58  return result;
59 }
60 #endif
61 
62 
63 //! Creates a restraint between two sets of anchor points "model" and "density"
64 //
65 /**
66  */
67 class IMPISDEXPORT GaussianEMRestraint : public Restraint
68 {
69 
70  public:
71  //! Constructor
72  /**
73  \param[in] model_ps particles for the model GMM
74  \param[in] density_ps particles for the density GMM
75  \param[in] global_sigma Particle to modulate the uncertainty
76  \param[in] rigid Set to true if the model is rigid (faster)
77  */
79  ParticleIndexes model_ps, ParticleIndexes density_ps,
80  ParticleIndex global_sigma,
81  Float model_cutoff_dist,Float density_cutoff_dist,Float slope,
82  bool update_model=true, bool backbone_slope=false,
83  std::string name="GaussianEMRestraint%1%");
84 
85  double get_probability() const {
86  return exp(-unprotected_evaluate(NULL));
87  }
88  void compute_initial_scores();
89  void set_slope(Float s){slope_=s;}
90  Float get_slope(){return slope_;}
91  virtual double
92  unprotected_evaluate(IMP::kernel::DerivativeAccumulator *accum)
93  const IMP_OVERRIDE;
95  void show(std::ostream &out) const { out << "GEM restraint"; }
97 
98  private:
99  ParticleIndexes model_ps_;
100  ParticleIndexes density_ps_;
101  ParticleIndex global_sigma_;
102  Float slope_;
103  bool update_model_;
104  int msize_,dsize_;
105  Float normalization_;
106  Float dd_score_;
107  Float self_mm_score_;
110  ParticleIndexes slope_ps_; //experiment
111 
112  //variables needed to tabulate the exponential
113  Floats exp_grid_;
114  double invdx_;
115  double argmax_;
116 
117 };
118 
119 IMPISD_END_NAMESPACE
120 
121 #endif /* IMPISD_GAUSSIAN_EM_RESTRAINT_H */
Declare an efficient stl-compatible map.
A decorator for particles with mass.
Class for adding derivatives from restraints to the model.
Store a list of kernel::ParticlesTemp.
Return all pairs from a SingletonContainer.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Import IMP/kernel/container_macros.h in the namespace.
Simple XYZ decorator.
Import IMP/kernel/PairContainer.h in the namespace.
Creates a restraint between two sets of anchor points "model" and "density".
Return all pairs from a SingletonContainer.
A restraint is a term in an IMP ScoringFunction.
Decorator to hold Gaussian3D.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
virtual ModelObjectsTemp do_get_inputs() const =0
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Gaussian shape.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73