IMP logo
IMP Reference Guide  develop.7cb8855c60,2024/10/04
The Integrative Modeling Platform
AlignmentParams.h
Go to the documentation of this file.
1 /**
2  * \file IMP/multifit/AlignmentParams.h
3  * \brief Parameters for alignments.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPMULTIFIT_ALIGNMENT_PARAMS_H
9 #define IMPMULTIFIT_ALIGNMENT_PARAMS_H
10 
11 #include <vector>
12 #include <string>
13 #include <IMP/multifit/multifit_config.h>
14 #include <IMP/value_macros.h>
15 #include <boost/property_tree/ptree.hpp>
16 #include <cereal/access.hpp>
17 #include <iostream>
18 #include <stdio.h>
19 
20 IMPMULTIFIT_BEGIN_NAMESPACE
21 
22 struct DominoParams {
23  DominoParams()
24  : max_value_threshold_(10.),
25  max_anchor_penetration_(0.1),
26  heap_size_(10000),
27  cache_size_(50000) {}
28  void add(const boost::property_tree::ptree& pt) {
29  max_value_threshold_ = pt.get<float>("domino.max_value_threshold");
30  max_num_states_for_subset_ =
31  pt.get<int>("domino.max_num_states_for_subset");
32  max_anchor_penetration_ = pt.get<float>("domino.max_anchor_penetration");
33  heap_size_ = pt.get<int>("domino.heap_size");
34  cache_size_ = pt.get<int>("domino.cache_size");
35  }
36  void show(std::ostream& s = std::cout) const {
37  s << "domino parameters: max_val_thr=" << max_value_threshold_
38  << " max_num_states4subset=" << max_num_states_for_subset_
39  << " max_anchor_penetration=" << max_anchor_penetration_
40  << " heap_size=" << heap_size_ << "cache_size=" << cache_size_
41  << std::endl;
42  }
43  float max_value_threshold_;
44  int max_num_states_for_subset_;
45  float max_anchor_penetration_;
46  int heap_size_;
47  int cache_size_;
48 
49 private:
50  friend class cereal::access;
51 
52  template<class Archive> void serialize(Archive &ar) {
53  ar(max_value_threshold_, max_num_states_for_subset_,
54  max_anchor_penetration_, heap_size_, cache_size_);
55  }
56 };
58 
59 struct XlinkParams {
60  XlinkParams()
61  : upper_bound_(10.),
62  k_(0.05),
63  max_xlink_val_(3.),
64  treat_between_residues_(true) {}
65  void add(const boost::property_tree::ptree& pt) {
66  upper_bound_ = pt.get<float>("xlink.upper_bound");
67  k_ = pt.get<float>("xlink.k");
68  max_xlink_val_ = pt.get<float>("xlink.max_value");
69  treat_between_residues_ = pt.get<bool>("xlink.between_residues");
70  }
71 
72  void show(std::ostream& s = std::cout) const {
73  s << "xlink parameters: upper_bound:" << upper_bound_ << " k:" << k_
74  << "max_xlink_val_=" << max_xlink_val_
75  << " treat_between_residues_=" << treat_between_residues_ << std::endl;
76  }
77  float upper_bound_, k_;
78  float max_xlink_val_;
79  bool treat_between_residues_;
80 
81 private:
82  friend class cereal::access;
83 
84  template<class Archive> void serialize(Archive &ar) {
85  ar(upper_bound_, k_, max_xlink_val_, treat_between_residues_);
86  }
87 };
89 
90 struct ConnectivityParams {
91  ConnectivityParams()
92  : upper_bound_(10.),
93  k_(0.05), // corresponding to 3.5A
94  max_conn_rest_val_(2.) {}
95  void add(const boost::property_tree::ptree& pt) {
96  upper_bound_ = pt.get<float>("connectivity.upper_bound");
97  k_ = pt.get<float>("connectivity.k");
98  max_conn_rest_val_ = pt.get<float>("connectivity.max_value");
99  }
100  void show(std::ostream& s = std::cout) const {
101  s << "connectivity parameters: upper_bound=" << upper_bound_ << " k=" << k_
102  << " max_conn_val=" << max_conn_rest_val_;
103  }
104  // upper bound for the connectivity restraint
105  float upper_bound_;
106  // k used for the connectivity restraint
107  float k_;
108  // maximum value allowed for the protein connectivity restraint
109  float max_conn_rest_val_;
110 
111 private:
112  friend class cereal::access;
113 
114  template<class Archive> void serialize(Archive &ar) {
115  ar(upper_bound_, k_, max_conn_rest_val_);
116  }
117 };
118 IMP_VALUES(ConnectivityParams, ConnectivityParamsList);
119 
120 struct FragmentsParams {
121  FragmentsParams()
122  : frag_len_(30),
123  bead_radius_scale_(1.),
124  load_atomic_(false),
125  subunit_rigid_(false) {}
126  void add(const boost::property_tree::ptree& pt) {
127  frag_len_ = pt.get<int>("fragments.length");
128  bead_radius_scale_ = pt.get<float>("fragments.radius_scale");
129  load_atomic_ = pt.get<bool>("fragments.atomic");
130  subunit_rigid_ = pt.get<bool>("fragments.rigid");
131  }
132  void show(std::ostream& s = std::cout) const {
133  s << "fragment parameters: frag_len=" << frag_len_
134  << " bead_rad_scale=" << bead_radius_scale_
135  << " load_atomic=" << load_atomic_ << " rigid=" << subunit_rigid_;
136  }
137  // number of residues for each fragment
138  int frag_len_;
139  // approximate radius value will be multiplied by this number
140  float bead_radius_scale_;
141  // true if we should load atomic structures
142  bool load_atomic_;
143  // true if the subunits are rigid
144  bool subunit_rigid_;
145 private:
146  friend class cereal::access;
147 
148  template<class Archive> void serialize(Archive &ar) {
149  ar(frag_len_, bead_radius_scale_, load_atomic_, subunit_rigid_);
150  }
151 };
152 IMP_VALUES(FragmentsParams, FragmentsParamsList);
153 
154 struct RogParams {
155  public:
156  RogParams() : max_score_(5), scale_(1.6) {}
157  void add(const boost::property_tree::ptree& pt) {
158  scale_ = pt.get<float>("radius_of_gyration.scale");
159  max_score_ = pt.get<float>("radius_of_gyration.max_score");
160  }
161  float get_max_score() const { return max_score_; }
162  float get_scale() const { return scale_; }
163  void show(std::ostream& s = std::cout) const {
164  s << "rog params: scale=" << scale_ << " max_score:" << max_score_
165  << std::endl;
166  }
167 
168  private:
169  // maximum score
170  float max_score_, scale_;
171  friend class cereal::access;
172 
173  template<class Archive> void serialize(Archive &ar) {
174  ar(max_score_, scale_);
175  }
176 };
178 
179 struct EVParams {
180  public:
181  EVParams()
182  : pair_distance_(3.),
183  pair_slack_(1.),
184  hlb_mean_(2.),
185  hlb_k_(0.59),
186  maximum_ev_score_for_pair_(0.3),
187  allowed_percentage_of_bad_pairs_(0.05),
188  scoring_mode_(1) {}
189  void add(const boost::property_tree::ptree& pt) {
190  pair_distance_ = pt.get<float>("excluded_volume.distance");
191  pair_slack_ = pt.get<float>("excluded_volume.slack");
192  hlb_mean_ = pt.get<float>("excluded_volume.lower_bound");
193  hlb_k_ = pt.get<float>("excluded_volume.k");
194  maximum_ev_score_for_pair_ =
195  pt.get<float>("excluded_volume.max_score_for_pair");
196  allowed_percentage_of_bad_pairs_ =
197  pt.get<float>("excluded_volume.allowed_percentage_of_bad_pairs");
198  scoring_mode_ = pt.get<int>("excluded_volume.scoring_mode");
199  // possible scoring modes are 0-2
200  if (scoring_mode_ < 0 || scoring_mode_ > 2) {
201  throw boost::property_tree::ptree_bad_data(
202  "excluded_volume.scoring_mode should be 0, 1, or 2", scoring_mode_);
203  }
204  }
205  void show(std::ostream& s = std::cout) const {
206  s << "EV params: pair_distance=" << pair_distance_
207  << " pair_slack=" << pair_slack_ << " mean=" << hlb_mean_
208  << " k=" << hlb_k_
209  << " maximum_ev_score_for_pair:" << maximum_ev_score_for_pair_
210  << " allowed_percentage_of_bad_pairs:" << allowed_percentage_of_bad_pairs_
211  << " scoring_mode:" << scoring_mode_ << std::endl;
212  }
213  float pair_distance_, pair_slack_, hlb_mean_, hlb_k_,
214  maximum_ev_score_for_pair_;
215  float allowed_percentage_of_bad_pairs_;
216  int scoring_mode_; // 0 means EV restraints are OFF
217  // 1 means EV between all pairs is calculated
218  // 2 means EV only between selected pairs is calculated
219 private:
220  friend class cereal::access;
221 
222  template<class Archive> void serialize(Archive &ar) {
223  ar(pair_distance_, pair_slack_, hlb_mean_, hlb_k_,
224  maximum_ev_score_for_pair_, allowed_percentage_of_bad_pairs_,
225  scoring_mode_);
226  }
227 };
229 
230 struct FiltersParams {
231  public:
232  FiltersParams()
233  : max_num_violated_xlink_(4),
234  max_num_violated_conn_(4),
235  max_num_violated_ev_(3) {}
236  void add(const boost::property_tree::ptree& pt) {
237  max_num_violated_conn_ = pt.get<int>("filters.conn_max_violations");
238  max_num_violated_xlink_ = pt.get<int>("filters.xlink_max_violations");
239  max_num_violated_ev_ = pt.get<int>("filters.ev_max_violations");
240  }
241  void show(std::ostream& s = std::cout) const {
242  s << "filters params: max_num_violated_xlink=" << max_num_violated_xlink_
243  << " max_num_violated_conn:" << max_num_violated_conn_
244  << "max num_violated_ev:" << max_num_violated_ev_ << std::endl;
245  }
246 
247  public:
248  int max_num_violated_xlink_, max_num_violated_conn_;
249  int max_num_violated_ev_;
250 private:
251  friend class cereal::access;
252 
253  template<class Archive> void serialize(Archive &ar) {
254  ar(max_num_violated_xlink_, max_num_violated_conn_,
255  max_num_violated_ev_);
256  }
257 };
259 
260 struct FittingParams {
261  public:
262  FittingParams()
263  : pca_max_angle_diff_(15.),
264  pca_max_size_diff_(10.),
265  pca_max_cent_dist_diff_(10.),
266  max_asmb_fit_score_(.5) {}
267  void add(const boost::property_tree::ptree& pt) {
268  pca_max_angle_diff_ = pt.get<float>("fitting.pca_max_angle_diff");
269  pca_max_size_diff_ = pt.get<float>("fitting.pca_max_size_diff");
270  pca_max_cent_dist_diff_ = pt.get<float>("fitting.pca_max_cent_dist_diff");
271  max_asmb_fit_score_ = pt.get<float>("fitting.max_asmb_fit_score");
272  }
273  void show(std::ostream& s = std::cout) const {
274  s << "filters params: pca_max_angle_diff=" << pca_max_angle_diff_
275  << " pca_max_size_diff:" << pca_max_size_diff_
276  << "pca_max_cent_dist_diff:" << pca_max_cent_dist_diff_
277  << "max_asmb_fit_score:" << max_asmb_fit_score_ << std::endl;
278  }
279 
280  public:
281  float pca_max_angle_diff_, pca_max_size_diff_;
282  float pca_max_cent_dist_diff_, max_asmb_fit_score_;
283 private:
284  friend class cereal::access;
285 
286  template<class Archive> void serialize(Archive &ar) {
287  ar(pca_max_angle_diff_, pca_max_size_diff_, pca_max_cent_dist_diff_,
288  max_asmb_fit_score_);
289  }
290 };
292 
293 struct ComplementarityParams {
294  public:
295  ComplementarityParams()
296  : max_score_(100000),
297  max_penetration_(200),
298  interior_layer_thickness_(2),
299  boundary_coef_(-3),
300  comp_coef_(1),
301  penetration_coef_(2) {}
302  void add(const boost::property_tree::ptree& pt) {
303  max_score_ = pt.get<float>("complementarity.max_score");
304  max_penetration_ = pt.get<float>("complementarity.max_penetration");
305  interior_layer_thickness_ =
306  pt.get<float>("complementarity.interior_layer_thickness");
307  boundary_coef_ = pt.get<float>("complementarity.boundary_coef");
308  comp_coef_ = pt.get<float>("complementarity.comp_coef");
309  penetration_coef_ = pt.get<float>("complementarity.penetration_coef");
310  }
311  void show(std::ostream& s = std::cout) const {
312  s << "complementarity params: max_score=" << max_score_
313  << " max penetration:" << max_penetration_
314  << " interior layer thickness:" << interior_layer_thickness_
315  << " boundary coefficient:" << boundary_coef_
316  << " complementarity coefficient: " << comp_coef_
317  << " penetration coefficient: " << penetration_coef_ << std::endl;
318  }
319 
320  public:
321  float max_score_, max_penetration_;
322  float interior_layer_thickness_;
323  float boundary_coef_, comp_coef_, penetration_coef_;
324 private:
325  friend class cereal::access;
326 
327  template<class Archive> void serialize(Archive &ar) {
328  ar(max_score_, max_penetration_, interior_layer_thickness_,
329  boundary_coef_, comp_coef_, penetration_coef_);
330  }
331 };
332 IMP_VALUES(ComplementarityParams, ComplementarityParamsList);
333 
334 class IMPMULTIFITEXPORT AlignmentParams {
335  public:
336  AlignmentParams() {}
337 
338  AlignmentParams(const char* param_filename);
339  const DominoParams& get_domino_params() const { return domino_params_; }
340  const FittingParams& get_fitting_params() const { return fitting_params_; }
341  const ComplementarityParams& get_complementarity_params() const {
342  return complementarity_params_;
343  }
344  const XlinkParams& get_xlink_params() const { return xlink_params_; }
345  const ConnectivityParams& get_connectivity_params() const {
346  return conn_params_;
347  }
348  const RogParams& get_rog_params() const { return rog_params_; }
349  const FragmentsParams& get_fragments_params() const {
350  return fragments_params_;
351  }
352  const FiltersParams& get_filters_params() const { return filters_params_; }
353  const EVParams& get_ev_params() const { return ev_params_; }
354  void show(std::ostream& s = std::cout) const {
355  s << "alignment parameters" << std::endl;
356  fitting_params_.show(s);
357  s << std::endl;
358  complementarity_params_.show(s);
359  s << std::endl;
360  domino_params_.show(s);
361  s << std::endl;
362  fragments_params_.show(s);
363  s << std::endl;
364  rog_params_.show(s);
365  s << std::endl;
366  conn_params_.show(s);
367  s << std::endl;
368  xlink_params_.show(s);
369  s << std::endl;
370  filters_params_.show(s);
371  s << std::endl;
372  ev_params_.show(s);
373  s << std::endl;
374  }
375 
376  private:
377  DominoParams domino_params_;
378  FittingParams fitting_params_;
379  ComplementarityParams complementarity_params_;
380  XlinkParams xlink_params_;
381  ConnectivityParams conn_params_;
382  FragmentsParams fragments_params_;
383  RogParams rog_params_;
384  FiltersParams filters_params_;
385  EVParams ev_params_;
386 private:
387  friend class cereal::access;
388 
389  template<class Archive> void serialize(Archive &ar) {
390  ar(domino_params_, fitting_params_, complementarity_params_,
391  xlink_params_, conn_params_, fragments_params_, rog_params_,
392  filters_params_, ev_params_);
393  }
394 };
395 IMP_VALUES(AlignmentParams, AlignmentParamsList);
396 
397 IMPMULTIFIT_END_NAMESPACE
398 
399 #endif /* IMPMULTIFIT_ALIGNMENT_PARAMS_H */
A more IMP-like version of the std::vector.
Definition: Vector.h:50
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
Macros to help in implementing Value objects.