IMP  2.0.0
The Integrative Modeling Platform
FitRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em/FitRestraint.h
3  * \brief Calculate score based on fit to EM map.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPEM_FIT_RESTRAINT_H
10 #define IMPEM_FIT_RESTRAINT_H
11 
12 #include <IMP/em/em_config.h>
13 #include "DensityMap.h"
14 #include "CoarseCC.h"
15 #include "SampledDensityMap.h"
16 
17 #include <IMP/atom/Hierarchy.h>
18 #include <IMP/atom/Atom.h>
19 #include <IMP/atom/Mass.h>
20 #include <IMP/core/XYZR.h>
21 #include <IMP/Model.h>
22 #include <IMP/Restraint.h>
23 #include <IMP/VersionInfo.h>
24 #include <IMP/Refiner.h>
25 
26 IMPEM_BEGIN_NAMESPACE
27 
28 //! Calculate score based on fit to EM map
29 /** \ingroup exp_restraint
30 
31  */
32 class IMPEMEXPORT FitRestraint : public Restraint
33 {
34 public:
35  //! Constructor
36  /**
37  \param[in] ps The particles participating in the fitting score
38  \param[in] em_map The density map used in the fitting score
39  \param[in] norm_factors if set, they are used as normalization factors
40  for the cross correlation calculations. This is relevant when the
41  cross-correlation score of the entire system is decomposed.
42  \param[in] weight_key the name of the weight attribute of the particles
43  \param[in] scale multiply the fitting restraint score and derivatives
44  by this value
45  \param[in] use_rigid_bodies if some of the particles are part of
46  a rigid body,
47  use the rigid body for faster calculations
48  \param[in] kt KernelType to use for simulating density from particles
49  \note Rigid-bodies are interpolated and not resampled
50  if use_rigid_bodies option is selected.
51  This significantly reduces the running time but is less accurate.
52  If the user prefers to get more accurate results, provide
53  its members as input particles and not the rigid body.
54  */
55  FitRestraint(ParticlesTemp ps,
56  DensityMap *em_map,
57  FloatPair norm_factors=FloatPair(0.,0.),
58  FloatKey weight_key= atom::Mass::get_mass_key(),
59  float scale=1,
60  bool use_rigid_bodies=true,
61  KernelType kt=GAUSSIAN);
62  //! \return the predicted density map of the model
64  return model_dens_map_;
65  }
66  void set_scale_factor(float scale) {scalefac_=scale;}
67  float get_scale_factor() const {return scalefac_;}
68  IMP_RESTRAINT(FitRestraint);
69 
70 #ifndef SWIG
71  IMP_LIST(private, Particle, particle, Particle*, Particles);
72 #endif
73 private:
74  //! Store particles
75  void store_particles(ParticlesTemp ps);
76  //! Resample the model density map
77  void resample() const;
78  //! Create density maps: one for each rigid body and one for the rest.
79  void initialize_model_density_map(FloatKey weight_key);
80 
81  IMP::OwnerPointer<DensityMap> target_dens_map_;
82  mutable IMP::OwnerPointer<SampledDensityMap> model_dens_map_;
83  mutable SampledDensityMaps rb_model_dens_map_;
84  mutable IMP::OwnerPointer<SampledDensityMap>
85  none_rb_model_dens_map_;
86  algebra::BoundingBoxD<3> target_bounding_box_;
87  // reference to the IMP environment
88  float scalefac_;
89  core::XYZs xyz_;
90  // derivatives
92  algebra::ReferenceFrame3Ds rbs_orig_rf_;
93  FloatKey weight_key_;
94  KernelParameters *kernel_params_;
95  FloatPair norm_factors_;
96  bool use_rigid_bodies_;
97  //particle handling
98  //map particles to their rigid bodies
100  Particles all_ps_;
101  Particles not_part_of_rb_; //all particles that are not part of a rigid body
102  Particles part_of_rb_;
103  core::RigidBodies rbs_;
104  KernelType kt_;
105 };
106 
107 IMPEM_END_NAMESPACE
108 
109 #endif /* IMPEM_FIT_RESTRAINT_H */