IMP logo
IMP Reference Guide  2.5.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-2015 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/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 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::DerivativeAccumulator *accum)
64  const IMP_OVERRIDE;
67 
68 #ifndef SWIG
69  IMP_LIST(private, Particle, particle, Particle *, Particles);
70 #endif
71  private:
72  //! Store particles
73  void store_particles(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::PointerMember<DensityMap> target_dens_map_;
80  mutable IMP::PointerMember<SampledDensityMap> model_dens_map_;
81  mutable SampledDensityMaps rb_model_dens_map_;
82  mutable IMP::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, Particles> member_map_;
97  Particles all_ps_;
98  // all particles that are not part of a rigid body
99  Particles not_part_of_rb_;
100  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.
Perform coarse fitting between two density objects.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Simple atom decorator.
Storage of a model, its restraints, constraints and particles.
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
#define IMP_LIST(protection, Ucname, lcname, Data, PluralData)
A macro to provide a uniform interface for storing lists of objects.
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.
Refine a particle into a list of particles.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:146
Calculate score based on fit to EM map.
Definition: FitRestraint.h:32
Class to handle individual model particles.
Definition: Particle.h:37
Abstract base class for all restraints.
Decorator for a sphere-like particle.
Sampled density map.
virtual ModelObjectsTemp do_get_inputs() const =0
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for adding derivatives from restraints to the model.
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:52