IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
CrossLinkMSRestraint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/isd/CrossLinkMSRestraint.h
3  * \brief A pmf based likelihood function
4  * with prior knowledge on the false positive rate.
5  *
6  * Copyright 2007-2022 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPISD_CROSS_LINK_MSRESTRAINT_H
11 #define IMPISD_CROSS_LINK_MSRESTRAINT_H
12 
13 #include <IMP/isd/isd_config.h>
14 #include <IMP/Restraint.h>
15 #include <IMP/particle_index.h>
16 #include <IMP/isd/Scale.h>
17 #include <cereal/access.hpp>
18 #include <cereal/types/base_class.hpp>
19 #include <cereal/types/polymorphic.hpp>
20 
21 IMPISD_BEGIN_NAMESPACE
22 
23 //! A restraint for ambiguous cross-linking MS data and multiple state approach.
24 /** It marginalizes the false positive rate and depends on the expected fpr and
25  an uncertainty parameter beta.
26  */
27 class IMPISDEXPORT CrossLinkMSRestraint : public Restraint {
28 
30  IMP::ParticleIndexPairs sigmass_;
31  IMP::ParticleIndex lengthi_;
33  double length_;
34  double slope_;
35  int constr_;
36  bool get_log_prob_;
37  std::string protein1_, protein2_;
38  int residue1_, residue2_;
39 
40  friend class cereal::access;
41 
42  template<class Archive> void serialize(Archive &ar) {
43  ar(cereal::base_class<Restraint>(this),
44  ppis_, sigmass_, lengthi_, psis_, length_, slope_,
45  constr_, get_log_prob_, protein1_, protein2_, residue1_, residue2_);
46  }
47 
48  double sphere_cap(float r1, float r2, float d) const;
49 
51 
52  public:
53  //! Create the restraint.
54  CrossLinkMSRestraint(IMP::Model* m, double length,
55  bool get_log_prob = false,
56  std::string name = "CrossLinkMSRestraint%1%");
57 
60  bool get_log_prob = false,
61  std::string name = "CrossLinkMSRestraint%1%");
62 
63  CrossLinkMSRestraint(IMP::Model* m, double length, double slope,
64  bool get_log_prob = false,
65  std::string name = "CrossLinkMSRestraint%1%");
66 
68 
69  /** \name Source information
70  These methods get or set the protein name and residue index of
71  each end of the cross-link, as identified in the experiment
72  (typically these will correspond to the information in a CSV
73  file or similar). This information is not used in modeling, but
74  is written into output RMF files and is needed to generate mmCIF files.
75  %{
76  */
77  //! Set protein name for one end of the cross-link
78  void set_source_protein1(std::string protein1) { protein1_ = protein1; }
79 
80  //! Get protein name for one end of the cross-link
81  std::string get_source_protein1() const { return protein1_; }
82 
83  //! Set protein name for one end of the cross-link
84  void set_source_protein2(std::string protein2) { protein2_ = protein2; }
85 
86  //! Get protein name for one end of the cross-link
87  std::string get_source_protein2() const { return protein2_; }
88 
89  //! Set residue number for one end of the cross-link
90  void set_source_residue1(int residue1) { residue1_ = residue1; }
91 
92  //! Get residue number for one end of the cross-link
93  int get_source_residue1() const { return residue1_; }
94 
95  //! Set residue number for one end of the cross-link
96  void set_source_residue2(int residue2) { residue2_ = residue2; }
97 
98  //! Get residue number for one end of the cross-link
99  int get_source_residue2() const { return residue2_; }
100  /** @} */
101 
102  void add_contribution(const IMP::ParticleIndexPair& pps,
103  const IMP::ParticleIndexPair& sigmas,
104  IMP::ParticleIndex psi) {
105  ppis_.push_back(pps);
106  sigmass_.push_back(sigmas);
107  psis_.push_back(psi);
108  }
109 
110  double get_probability() const;
111 
112  //! Get the length of this restraint
113  /** Note that if the restraint was constructed with a length Scale,
114  this can change during sampling. */
115  double get_length() const {
116  if (constr_ == 1) {
117  return isd::Scale(get_model(), lengthi_).get_scale();
118  } else {
119  return length_;
120  }
121  }
122 
123  //! Return true iff the length is variable (stored in a Scale)
124  bool get_is_length_variable() const {
125  return constr_ == 1;
126  }
127 
128  //! Return true iff the restraint has a slope
129  bool get_has_slope() const {
130  return constr_ == 2;
131  }
132 
133  double get_slope() const { return slope_; }
134 
135  bool get_log_prob() const { return get_log_prob_; }
136 
137  //! Get the sigma particle indexes from a contribution
139  return sigmass_[i];
140  }
141 
142  //! Get the psi particle index from a contribution
144  return psis_[i];
145  }
146 
147  //! Get the particle indexes from a contribution
149  return ppis_[i];
150  }
151 
152  unsigned int get_number_of_contributions() const { return ppis_.size(); }
153 
154  virtual double unprotected_evaluate(
155  IMP::DerivativeAccumulator* accum) const override;
156  virtual IMP::ModelObjectsTemp do_get_inputs() const override;
157 
158  //! \return Information for writing to RMF files
159  RestraintInfo *get_static_info() const override;
160 
162 };
163 
164 IMPISD_END_NAMESPACE
165 
166 #endif /* IMPISD_CROSS_LINK_MSRESTRAINT_H */
A restraint for ambiguous cross-linking MS data and multiple state approach.
virtual RestraintInfo * get_static_info() const
Definition: Restraint.h:178
Functions and adaptors for dealing with particle indexes.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Take Decorator, Particle or ParticleIndex.
virtual double unprotected_evaluate(DerivativeAccumulator *da) const
Return the unweighted score for the restraint.
std::string get_source_protein1() const
Get protein name for one end of the cross-link.
A decorator for scale parameters particles.
Add scale parameter to particle.
Definition: Scale.h:24
void set_source_protein1(std::string protein1)
Set protein name for one end of the cross-link.
ParticleIndexPair get_contribution_particle_indexes(int i) const
Get the particle indexes from a contribution.
bool get_is_length_variable() const
Return true iff the length is variable (stored in a Scale)
int get_source_residue2() const
Get residue number for one end of the cross-link.
int get_source_residue1() const
Get residue number for one end of the cross-link.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
ParticleIndexPair get_contribution_sigma_indexes(int i) const
Get the sigma particle indexes from a contribution.
double get_length() const
Get the length of this restraint.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
bool get_has_slope() const
Return true iff the restraint has a slope.
std::string get_source_protein2() const
Get protein name for one end of the cross-link.
void set_source_protein2(std::string protein2)
Set protein name for one end of the cross-link.
void set_source_residue2(int residue2)
Set residue number for one end of the cross-link.
Report key:value information on restraints.
Definition: RestraintInfo.h:47
void set_source_residue1(int residue1)
Set residue number for one end of the cross-link.
Abstract base class for all restraints.
ParticleIndex get_contribution_psi_index(int i) const
Get the psi particle index from a contribution.
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