IMP logo
IMP Reference Guide  2.20.1
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 atom
54  RESIDUES - residue level, residue represented by bead
55  */
56  Restraint(const Particles& particles, const Profile* exp_profile,
57  FormFactorType ff_type = HEAVY_ATOMS);
58 
59  Restraint() {}
60 
62  const override;
63 
64  virtual IMP::ModelObjectsTemp do_get_inputs() const override;
65 
66  //! \return Information for writing to RMF files
67  RestraintInfo *get_static_info() const override;
68 
70 
71  protected:
72  ParticleIndexes particles_;
74  Pointer<ProfileFitter<ChiScore> > profile_fitter_; // computes profiles
75  // computes derivatives
76  Pointer<DerivativeCalculator> derivative_calculator_;
77  private:
78  friend class cereal::access;
79  template<class Archive> void serialize(Archive &ar) {
80  ar(cereal::base_class<IMP::Restraint>(this));
81  if (std::is_base_of<cereal::detail::OutputArchiveBase, Archive>::value) {
82  Pointer<Profile> exp_profile = const_cast<Profile*>(
83  profile_fitter_->get_profile());
84  ar(handler_->get_form_factor_type(), particles_, exp_profile);
85  } else {
86  FormFactorType ff_type;
87  Pointer<Profile> exp_profile;
88  ar(ff_type, particles_, exp_profile);
89  handler_ = new RigidBodiesProfileHandler(
90  IMP::get_particles(get_model(), particles_), ff_type);
91  profile_fitter_ = new ProfileFitter<ChiScore>(exp_profile);
92  derivative_calculator_ = new DerivativeCalculator(exp_profile);
93  }
94  }
95  IMP_OBJECT_SERIALIZE_DECL(Restraint);
96 };
97 
98 IMPSAXS_END_NAMESPACE
99 
100 #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