IMP logo
IMP Reference Guide  2.19.0
The Integrative Modeling Platform
saxs/Restraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/saxs/Restraint.h
3  * \brief Calculate score based on fit to SAXS profile.
4  *
5  * Copyright 2007-2023 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPSAXS_RESTRAINT_H
10 #define IMPSAXS_RESTRAINT_H
11 
12 #include <IMP/saxs/saxs_config.h>
13 
14 #include <IMP/saxs/ProfileFitter.h>
15 #include <IMP/saxs/Profile.h>
17 
19 
20 #include <IMP/Model.h>
21 #include <IMP/Restraint.h>
22 #include <IMP/Object.h>
23 #include <IMP/Pointer.h>
24 #include <cereal/access.hpp>
25 #include <cereal/types/base_class.hpp>
26 
27 IMPSAXS_BEGIN_NAMESPACE
28 
29 //! Calculate score based on fit to SAXS profile
30 /** \ingroup exp_restraint
31 
32  The restraint takes rigid bodies into account, in order
33  to speed up the calculations. Rigid body should be given as single
34  RigidBody Particle. Other, non-rigid body Particles can also be given.
35 
36  The shape of a rigid body is assumed to be defined by the set of
37  atom::Hierarchy leaves of the atom::Hierarchy rooted at the rigid body
38  particle.
39 
40  \par Algorithmic details:
41  The distances between the atoms of rigid body do not change, therefore
42  their contribution to the profile is pre-computed and stored.
43  */
44 class IMPSAXSEXPORT Restraint : public IMP::Restraint {
45  public:
46  //! Constructor
47  /**
48  \param[in] particles The particles participating in the fitting score
49  \param[in] exp_profile The experimental profile used in the fitting score
50  \param[in] ff_type Type of the form factors for profile calculations:
51  ALL_ATOMS - all atoms including hydrogens
52  HEAVY_ATOMS - no hydrogens, all other atoms included
53  CA_ATOMS - residue level, residue represented by CA
54  */
55  Restraint(const Particles& particles, const Profile* exp_profile,
56  FormFactorType ff_type = HEAVY_ATOMS);
57 
58  Restraint() {}
59 
61  const override;
62 
63  virtual IMP::ModelObjectsTemp do_get_inputs() const override;
64 
65  //! \return Information for writing to RMF files
66  RestraintInfo *get_static_info() const override;
67 
69 
70  protected:
71  ParticleIndexes particles_;
73  Pointer<ProfileFitter<ChiScore> > profile_fitter_; // computes profiles
74  // computes derivatives
75  Pointer<DerivativeCalculator> derivative_calculator_;
76  private:
77  friend class cereal::access;
78  template<class Archive> void serialize(Archive &ar) {
79  ar(cereal::base_class<IMP::Restraint>(this));
80  if (std::is_base_of<cereal::detail::OutputArchiveBase, Archive>::value) {
81  Pointer<Profile> exp_profile = const_cast<Profile*>(
82  profile_fitter_->get_profile());
83  ar(handler_->get_form_factor_type(), particles_, exp_profile);
84  } else {
85  FormFactorType ff_type;
86  Pointer<Profile> exp_profile;
87  ar(ff_type, particles_, exp_profile);
88  handler_ = new RigidBodiesProfileHandler(
89  IMP::get_particles(get_model(), particles_), ff_type);
90  profile_fitter_ = new ProfileFitter<ChiScore>(exp_profile);
91  derivative_calculator_ = new DerivativeCalculator(exp_profile);
92  }
93  }
94  IMP_OBJECT_SERIALIZE_DECL(Restraint);
95 };
96 
97 IMPSAXS_END_NAMESPACE
98 
99 #endif /* IMPSAXS_RESTRAINT_H */
virtual RestraintInfo * get_static_info() const
Definition: Restraint.h:178
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Calculate score based on fit to SAXS profile.
Storage of a model, its restraints, constraints and particles.
virtual double unprotected_evaluate(DerivativeAccumulator *da) const
Return the unweighted score for the restraint.
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
Get the particles from a list of indexes.
a class for fitting two profiles
A smart pointer to a reference counted object.
Definition: Pointer.h:87
Restraint()
Default constructor.
Handle the profile for a set of particles, which may include rigid bodies.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
Report key:value information on restraints.
Definition: RestraintInfo.h:47
A nullptr-initialized pointer to an IMP Object.
A shared base class to help in debugging and things.
Abstract base class for all restraints.
Fit two profiles with user-defined scoring function as a template parameter.
Definition: ProfileFitter.h:29
FormFactorType
type of the form factors for profile calculations
virtual ModelObjectsTemp do_get_inputs() const =0
A class for computing SAXS derivatives.
Class for adding derivatives from restraints to the model.
A class for profile storing and computation.
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:56