IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
MultipleBinormalRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/MultipleBinormalRestraint.h
3  * \brief Modeller-style multiple binormal (phi/psi) restraint.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPCORE_MULTIPLE_BINORMAL_RESTRAINT_H
10 #define IMPCORE_MULTIPLE_BINORMAL_RESTRAINT_H
11 
12 #include <IMP/core/core_config.h>
13 
14 #include <IMP/Restraint.h>
15 #include <IMP/Particle.h>
16 #include <cereal/access.hpp>
17 
18 IMPCORE_BEGIN_NAMESPACE
19 
20 class BinormalTerm;
21 
22 //! Modeller-style multiple binormal (phi/psi) restraint.
23 /** This implements a multiple binormal restraint on the two dihedral angles
24  between the two quads of Particles passed to the restraint, by
25  implementing
26  equation A.77 in the
27  \external{https://salilab.org/modeller/9.16/manual/node491.html,
28  Modeller manual}.
29  The two angles are typically the phi and psi dihedrals of a residue.
30  */
31 class IMPCOREEXPORT MultipleBinormalRestraint : public Restraint {
32  std::vector<BinormalTerm> terms_;
33  ParticleIndexQuad q1_, q2_;
34 
35  public:
36  //! Create the multiple binormal restraint.
37  /** After creating the restraint, call add_term one or more times to add
38  BinormalTerms to the restraint.
39  \param[in] m Model.
40  \param[in] q1 First quad of particles.
41  \param[in] q2 Second quad of particles.
42  */
44  const ParticleIndexQuad &q2);
45 
46  //! Add a single BinormalTerm to the restraint.
47  void add_term(const BinormalTerm &term) { terms_.push_back(term); }
48 
50  const override;
51  virtual IMP::ModelObjectsTemp do_get_inputs() const override;
53 };
54 
55 //! A single binormal term in a MultipleBinormalRestraint.
56 class BinormalTerm {
57  double correlation_, weight_;
58  std::pair<double, double> means_, stdevs_;
59 
60  friend class cereal::access;
61 
62  template<class Archive> void serialize(Archive &ar) {
63  ar(correlation_, weight_, means_.first, means_.second, stdevs_.first,
64  stdevs_.second);
65  }
66 
67  double evaluate(const double dihedral[2], double &sin1, double &sin2,
68  double &cos1, double &cos2, double &rho) const;
69 
70  public:
71  BinormalTerm()
72  : correlation_(-1), weight_(-1), means_(-1, -1), stdevs_(-1, -1) {}
73  friend class MultipleBinormalRestraint;
74 
75  void set_correlation(double correlation) { correlation_ = correlation; }
76  void set_weight(double weight) { weight_ = weight; }
77  void set_means(FloatPair means) { means_ = means; }
78  void set_standard_deviations(FloatPair stdevs) { stdevs_ = stdevs; }
80  out << "correlation: " << correlation_ << "; weight: " << weight_
81  << "; means: " << means_.first << ", " << means_.second
82  << "; standard deviations: " << stdevs_.first << ", " << stdevs_.second;
83  });
84 };
86 
87 IMPCORE_END_NAMESPACE
88 
89 #endif /* IMPCORE_MULTIPLE_BINORMAL_RESTRAINT_H */
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
virtual double unprotected_evaluate(DerivativeAccumulator *da) const
Return the unweighted score for the restraint.
std::pair< double, double > FloatPair
A generic pair of floats.
Definition: types.h:26
void add_term(const BinormalTerm &term)
Add a single BinormalTerm to the restraint.
A single binormal term in a MultipleBinormalRestraint.
A more IMP-like version of the std::vector.
Definition: Vector.h:42
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
Modeller-style multiple binormal (phi/psi) restraint.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
Abstract base class for all restraints.
virtual ModelObjectsTemp do_get_inputs() const =0
Class for adding derivatives from restraints to the model.
A restraint is a term in an IMP ScoringFunction.
Definition: Restraint.h:56