IMP  2.1.1
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/kernel/Model.h>
22 #include <IMP/kernel/Restraint.h>
23 #include <IMP/Refiner.h>
24 
25 IMPEM_BEGIN_NAMESPACE
26 
27 //! Calculate score based on fit to EM map
28 /** \ingroup exp_restraint
29 
30  */
31 class IMPEMEXPORT FitRestraint : public kernel::Restraint
32 {
33 public:
34  //! Constructor
35  /**
36  \param[in] ps The particles participating in the fitting score
37  \param[in] em_map The density map used in the fitting score
38  \param[in] norm_factors if set, they are used as normalization factors
39  for the cross correlation calculations. This is relevant when the
40  cross-correlation score of the entire system is decomposed.
41  \param[in] weight_key the name of the weight attribute of the particles
42  \param[in] scale multiply the fitting restraint score and derivatives
43  by this value
44  \param[in] use_rigid_bodies if some of the particles are part of
45  a rigid body,
46  use the rigid body for faster calculations
47  \param[in] kt KernelType to use for simulating density from particles
48  \note Rigid-bodies are interpolated and not resampled
49  if use_rigid_bodies option is selected.
50  This significantly reduces the running time but is less accurate.
51  If the user prefers to get more accurate results, provide
52  its members as input particles and not the rigid body.
53  */
55  DensityMap *em_map,
56  FloatPair norm_factors=FloatPair(0.,0.),
57  FloatKey weight_key= atom::Mass::get_mass_key(),
58  float scale=1,
59  bool use_rigid_bodies=true,
60  KernelType kt=GAUSSIAN);
61  //! \return the predicted density map of the model
63  return model_dens_map_;
64  }
65  void set_scale_factor(float scale) {scalefac_=scale;}
66  float get_scale_factor() const {return scalefac_;}
67  virtual double
68  unprotected_evaluate(IMP::kernel::DerivativeAccumulator *accum)
69  const IMP_OVERRIDE;
70  virtual IMP::kernel::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
72 
73 #ifndef SWIG
74  IMP_LIST(private, Particle, particle, kernel::Particle*, kernel::Particles);
75 #endif
76 private:
77  //! Store particles
78  void store_particles(kernel::ParticlesTemp ps);
79  //! Resample the model density map
80  void resample() const;
81  //! Create density maps: one for each rigid body and one for the rest.
82  void initialize_model_density_map(FloatKey weight_key);
83 
84  IMP::base::PointerMember<DensityMap> target_dens_map_;
85  mutable IMP::base::PointerMember<SampledDensityMap> model_dens_map_;
86  mutable SampledDensityMaps rb_model_dens_map_;
88  none_rb_model_dens_map_;
89  algebra::BoundingBoxD<3> target_bounding_box_;
90  // reference to the IMP environment
91  float scalefac_;
92  core::XYZs xyz_;
93  // derivatives
95  algebra::ReferenceFrame3Ds rbs_orig_rf_;
96  FloatKey weight_key_;
97  KernelParameters *kernel_params_;
98  FloatPair norm_factors_;
99  bool use_rigid_bodies_;
100  //particle handling
101  //map particles to their rigid bodies
103  kernel::Particles all_ps_;
104  //all particles that are not part of a rigid body
105  kernel::Particles not_part_of_rb_;
106  kernel::Particles part_of_rb_;
107  core::RigidBodies rbs_;
108  KernelType kt_;
109 };
110 
111 IMPEM_END_NAMESPACE
112 
113 #endif /* IMPEM_FIT_RESTRAINT_H */
A decorator for particles with mass.
Class for adding derivatives from restraints to the model.
Perform coarse fitting between two density objects.
A smart pointer to a ref-counted Object that is a class memeber.
Definition: base/Pointer.h:147
Simple atom decorator.
std::pair< double, double > FloatPair
A generic pair of floats.
Definition: base/types.h:27
SampledDensityMap * get_model_dens_map() const
Definition: FitRestraint.h:62
Class for handling density maps.
Decorator for helping deal with a hierarchy of molecules.
Class for handling density maps.
Definition: DensityMap.h:98
Class for sampling a density map from particles.
Abstract base class for all restraints.
Import IMP/kernel/Refiner.h in the namespace.
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.
Storage of a model, its restraints, constraints and particles.
Calculate score based on fit to EM map.
Definition: FitRestraint.h:31
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_LIST(protection, Ucname, lcname, Data, PluralData)
A macro to provide a uniform interface for storing lists of objects.
Decorator for a sphere-like particle.
Sampled density map.