IMP  2.3.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-2014 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 #include <boost/unordered_map.hpp>
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 kernel::Restraint {
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  FloatPair norm_factors = FloatPair(0., 0.),
56  FloatKey weight_key = atom::Mass::get_mass_key(),
57  float scale = 1, bool use_rigid_bodies = true,
58  KernelType kt = GAUSSIAN);
59  //! Return the predicted density map of the model
60  SampledDensityMap *get_model_dens_map() const { return model_dens_map_; }
61  void set_scale_factor(float scale) { scalefac_ = scale; }
62  float get_scale_factor() const { return scalefac_; }
63  virtual double unprotected_evaluate(IMP::kernel::DerivativeAccumulator *accum)
64  const IMP_OVERRIDE;
67 
68 #ifndef SWIG
69  IMP_LIST(private, Particle, particle, kernel::Particle *, kernel::Particles);
70 #endif
71  private:
72  //! Store particles
73  void store_particles(kernel::ParticlesTemp ps);
74  //! Resample the model density map
75  void resample() const;
76  //! Create density maps: one for each rigid body and one for the rest.
77  void initialize_model_density_map(FloatKey weight_key);
78 
79  IMP::base::PointerMember<DensityMap> target_dens_map_;
80  mutable IMP::base::PointerMember<SampledDensityMap> model_dens_map_;
81  mutable SampledDensityMaps rb_model_dens_map_;
82  mutable IMP::base::PointerMember<SampledDensityMap> none_rb_model_dens_map_;
83  algebra::BoundingBoxD<3> target_bounding_box_;
84  // reference to the IMP environment
85  float scalefac_;
86  core::XYZs xyz_;
87  // derivatives
89  algebra::ReferenceFrame3Ds rbs_orig_rf_;
90  FloatKey weight_key_;
91  KernelParameters *kernel_params_;
92  FloatPair norm_factors_;
93  bool use_rigid_bodies_;
94  // particle handling
95  // map particles to their rigid bodies
96  boost::unordered_map<core::RigidBody, kernel::Particles> member_map_;
97  kernel::Particles all_ps_;
98  // all particles that are not part of a rigid body
99  kernel::Particles not_part_of_rb_;
100  kernel::Particles part_of_rb_;
101  core::RigidBodies rbs_;
102  KernelType kt_;
103 };
104 
105 IMPEM_END_NAMESPACE
106 
107 #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 member.
Definition: Pointer.h:147
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Simple atom decorator.
std::pair< double, double > FloatPair
A generic pair of floats.
Definition: types.h:27
SampledDensityMap * get_model_dens_map() const
Return the predicted density map of the model.
Definition: FitRestraint.h:60
Class for handling density maps.
Decorator for helping deal with a hierarchy of molecules.
Class for handling density maps.
Definition: DensityMap.h:94
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.
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:32
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.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.