IMP logo
IMP Reference Guide  2.6.1
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-2016 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 <iostream>
17 #include <stdio.h>
18 
19 IMPMULTIFIT_BEGIN_NAMESPACE
20 
21 struct DominoParams {
22  DominoParams()
23  : max_value_threshold_(10.),
24  max_anchor_penetration_(0.1),
25  heap_size_(10000),
26  cache_size_(50000) {}
27  void add(const boost::property_tree::ptree& pt) {
28  max_value_threshold_ = pt.get<float>("domino.max_value_threshold");
29  max_num_states_for_subset_ =
30  pt.get<int>("domino.max_num_states_for_subset");
31  max_anchor_penetration_ = pt.get<float>("domino.max_anchor_penetration");
32  heap_size_ = pt.get<int>("domino.heap_size");
33  cache_size_ = pt.get<int>("domino.cache_size");
34  }
35  void show(std::ostream& s = std::cout) const {
36  s << "domino parameters: max_val_thr=" << max_value_threshold_
37  << " max_num_states4subset=" << max_num_states_for_subset_
38  << " max_anchor_penetration=" << max_anchor_penetration_
39  << " heap_size=" << heap_size_ << "cache_size=" << cache_size_
40  << std::endl;
41  }
42  float max_value_threshold_;
43  int max_num_states_for_subset_;
44  float max_anchor_penetration_;
45  int heap_size_;
46  int cache_size_;
47 };
49 
50 struct XlinkParams {
51  XlinkParams()
52  : upper_bound_(10.),
53  k_(0.05),
54  max_xlink_val_(3.),
55  treat_between_residues_(true) {}
56  void add(const boost::property_tree::ptree& pt) {
57  upper_bound_ = pt.get<float>("xlink.upper_bound");
58  k_ = pt.get<float>("xlink.k");
59  max_xlink_val_ = pt.get<float>("xlink.max_value");
60  treat_between_residues_ = pt.get<bool>("xlink.between_residues");
61  }
62 
63  void show(std::ostream& s = std::cout) const {
64  s << "xlink parameters: upper_bound:" << upper_bound_ << " k:" << k_
65  << "max_xlink_val_=" << max_xlink_val_
66  << " treat_between_residues_=" << treat_between_residues_ << std::endl;
67  }
68  float upper_bound_, k_;
69  float max_xlink_val_;
70  bool treat_between_residues_;
71 };
73 
74 struct ConnectivityParams {
75  ConnectivityParams()
76  : upper_bound_(10.),
77  k_(0.05), // corresponding to 3.5A
78  max_conn_rest_val_(2.) {}
79  void add(const boost::property_tree::ptree& pt) {
80  upper_bound_ = pt.get<float>("connectivity.upper_bound");
81  k_ = pt.get<float>("connectivity.k");
82  max_conn_rest_val_ = pt.get<float>("connectivity.max_value");
83  }
84  void show(std::ostream& s = std::cout) const {
85  s << "connectivity parameters: upper_bound=" << upper_bound_ << " k=" << k_
86  << " max_conn_val=" << max_conn_rest_val_;
87  }
88  // upper bound for the connectivity restraint
89  float upper_bound_;
90  // k used for the connectivity restraint
91  float k_;
92  // maximum value allowed for the protein connectivity restraint
93  float max_conn_rest_val_;
94 };
95 IMP_VALUES(ConnectivityParams, ConnectivityParamsList);
96 
97 struct FragmentsParams {
98  FragmentsParams()
99  : frag_len_(30),
100  bead_radius_scale_(1.),
101  load_atomic_(false),
102  subunit_rigid_(false) {}
103  void add(const boost::property_tree::ptree& pt) {
104  frag_len_ = pt.get<int>("fragments.length");
105  bead_radius_scale_ = pt.get<float>("fragments.radius_scale");
106  load_atomic_ = pt.get<bool>("fragments.atomic");
107  subunit_rigid_ = pt.get<bool>("fragments.rigid");
108  }
109  void show(std::ostream& s = std::cout) const {
110  s << "fragment parameters: frag_len=" << frag_len_
111  << " bead_rad_scale=" << bead_radius_scale_
112  << " load_atomic=" << load_atomic_ << " rigid=" << subunit_rigid_;
113  }
114  // number of residues for each fragment
115  int frag_len_;
116  // approximate radius value will be multiplied by this number
117  float bead_radius_scale_;
118  // true if we should load atomic structures
119  bool load_atomic_;
120  // true if the subunits are rigid
121  bool subunit_rigid_;
122 };
123 IMP_VALUES(FragmentsParams, FragmentsParamsList);
124 
125 struct RogParams {
126  public:
127  RogParams() : max_score_(5), scale_(1.6) {}
128  void add(const boost::property_tree::ptree& pt) {
129  scale_ = pt.get<float>("radius_of_gyration.scale");
130  max_score_ = pt.get<float>("radius_of_gyration.max_score");
131  }
132  float get_max_score() const { return max_score_; }
133  float get_scale() const { return scale_; }
134  void show(std::ostream& s = std::cout) const {
135  s << "rog params: scale=" << scale_ << " max_score:" << max_score_
136  << std::endl;
137  }
138 
139  private:
140  // maximum score
141  float max_score_, scale_;
142 };
144 
145 struct EVParams {
146  public:
147  EVParams()
148  : pair_distance_(3.),
149  pair_slack_(1.),
150  hlb_mean_(2.),
151  hlb_k_(0.59),
152  maximum_ev_score_for_pair_(0.3),
153  allowed_percentage_of_bad_pairs_(0.05),
154  scoring_mode_(1) {}
155  void add(const boost::property_tree::ptree& pt) {
156  pair_distance_ = pt.get<float>("excluded_volume.distance");
157  pair_slack_ = pt.get<float>("excluded_volume.slack");
158  hlb_mean_ = pt.get<float>("excluded_volume.lower_bound");
159  hlb_k_ = pt.get<float>("excluded_volume.k");
160  maximum_ev_score_for_pair_ =
161  pt.get<float>("excluded_volume.max_score_for_pair");
162  allowed_percentage_of_bad_pairs_ =
163  pt.get<float>("excluded_volume.allowed_percentage_of_bad_pairs");
164  scoring_mode_ = pt.get<int>("excluded_volume.scoring_mode");
165  // possible scoring modes are 0-2
166  if (scoring_mode_ < 0 || scoring_mode_ > 2) {
167  throw boost::property_tree::ptree_bad_data(
168  "excluded_volume.scoring_mode should be 0, 1, or 2", scoring_mode_);
169  }
170  }
171  void show(std::ostream& s = std::cout) const {
172  s << "EV params: pair_distance=" << pair_distance_
173  << " pair_slack=" << pair_slack_ << " mean=" << hlb_mean_
174  << " k=" << hlb_k_
175  << " maximum_ev_score_for_pair:" << maximum_ev_score_for_pair_
176  << " allowed_percentage_of_bad_pairs:" << allowed_percentage_of_bad_pairs_
177  << " scoring_mode:" << scoring_mode_ << std::endl;
178  }
179  float pair_distance_, pair_slack_, hlb_mean_, hlb_k_,
180  maximum_ev_score_for_pair_;
181  float allowed_percentage_of_bad_pairs_;
182  int scoring_mode_; // 0 means EV restraints are OFF
183  // 1 means EV between all pairs is calculated
184  // 2 means EV only between selected pairs is calculated
185 };
187 
188 struct FiltersParams {
189  public:
190  FiltersParams()
191  : max_num_violated_xlink_(4),
192  max_num_violated_conn_(4),
193  max_num_violated_ev_(3) {}
194  void add(const boost::property_tree::ptree& pt) {
195  max_num_violated_conn_ = pt.get<int>("filters.conn_max_violations");
196  max_num_violated_xlink_ = pt.get<int>("filters.xlink_max_violations");
197  max_num_violated_ev_ = pt.get<int>("filters.ev_max_violations");
198  }
199  void show(std::ostream& s = std::cout) const {
200  s << "filters params: max_num_violated_xlink=" << max_num_violated_xlink_
201  << " max_num_violated_conn:" << max_num_violated_conn_
202  << "max num_violated_ev:" << max_num_violated_ev_ << std::endl;
203  }
204 
205  public:
206  int max_num_violated_xlink_, max_num_violated_conn_;
207  int max_num_violated_ev_;
208 };
210 
211 struct FittingParams {
212  public:
213  FittingParams()
214  : pca_max_angle_diff_(15.),
215  pca_max_size_diff_(10.),
216  pca_max_cent_dist_diff_(10.),
217  max_asmb_fit_score_(.5) {}
218  void add(const boost::property_tree::ptree& pt) {
219  pca_max_angle_diff_ = pt.get<float>("fitting.pca_max_angle_diff");
220  pca_max_size_diff_ = pt.get<float>("fitting.pca_max_size_diff");
221  pca_max_cent_dist_diff_ = pt.get<float>("fitting.pca_max_cent_dist_diff");
222  max_asmb_fit_score_ = pt.get<float>("fitting.max_asmb_fit_score");
223  }
224  void show(std::ostream& s = std::cout) const {
225  s << "filters params: pca_max_angle_diff=" << pca_max_angle_diff_
226  << " pca_max_size_diff:" << pca_max_size_diff_
227  << "pca_max_cent_dist_diff:" << pca_max_cent_dist_diff_
228  << "max_asmb_fit_score:" << max_asmb_fit_score_ << std::endl;
229  }
230 
231  public:
232  float pca_max_angle_diff_, pca_max_size_diff_;
233  float pca_max_cent_dist_diff_, max_asmb_fit_score_;
234 };
236 
237 struct ComplementarityParams {
238  public:
239  ComplementarityParams()
240  : max_score_(100000),
241  max_penetration_(200),
242  interior_layer_thickness_(2),
243  boundary_coef_(-3),
244  comp_coef_(1),
245  penetration_coef_(2) {}
246  void add(const boost::property_tree::ptree& pt) {
247  max_score_ = pt.get<float>("complementarity.max_score");
248  max_penetration_ = pt.get<float>("complementarity.max_penetration");
249  interior_layer_thickness_ =
250  pt.get<float>("complementarity.interior_layer_thickness");
251  boundary_coef_ = pt.get<float>("complementarity.boundary_coef");
252  comp_coef_ = pt.get<float>("complementarity.comp_coef");
253  penetration_coef_ = pt.get<float>("complementarity.penetration_coef");
254  }
255  void show(std::ostream& s = std::cout) const {
256  s << "complementarity params: max_score=" << max_score_
257  << " max penetration:" << max_penetration_
258  << " interior layer thickness:" << interior_layer_thickness_
259  << " boundary coefficient:" << boundary_coef_
260  << " complementarity coefficient: " << comp_coef_
261  << " penetration coefficient: " << penetration_coef_ << std::endl;
262  }
263 
264  public:
265  float max_score_, max_penetration_;
266  float interior_layer_thickness_;
267  float boundary_coef_, comp_coef_, penetration_coef_;
268 };
269 IMP_VALUES(ComplementarityParams, ComplementarityParamsList);
270 
271 class IMPMULTIFITEXPORT AlignmentParams {
272  public:
273  AlignmentParams(const char* param_filename);
274  const DominoParams& get_domino_params() const { return domino_params_; }
275  const FittingParams& get_fitting_params() const { return fitting_params_; }
276  const ComplementarityParams& get_complementarity_params() const {
277  return complementarity_params_;
278  }
279  const XlinkParams& get_xlink_params() const { return xlink_params_; }
280  const ConnectivityParams& get_connectivity_params() const {
281  return conn_params_;
282  }
283  const RogParams& get_rog_params() const { return rog_params_; }
284  const FragmentsParams& get_fragments_params() const {
285  return fragments_params_;
286  }
287  const FiltersParams& get_filters_params() const { return filters_params_; }
288  const EVParams& get_ev_params() const { return ev_params_; }
289  void show(std::ostream& s = std::cout) const {
290  s << "alignment parameters" << std::endl;
291  fitting_params_.show(s);
292  s << std::endl;
293  complementarity_params_.show(s);
294  s << std::endl;
295  domino_params_.show(s);
296  s << std::endl;
297  fragments_params_.show(s);
298  s << std::endl;
299  rog_params_.show(s);
300  s << std::endl;
301  conn_params_.show(s);
302  s << std::endl;
303  xlink_params_.show(s);
304  s << std::endl;
305  filters_params_.show(s);
306  s << std::endl;
307  ev_params_.show(s);
308  s << std::endl;
309  }
310 
311  private:
312  DominoParams domino_params_;
313  FittingParams fitting_params_;
314  ComplementarityParams complementarity_params_;
315  XlinkParams xlink_params_;
316  ConnectivityParams conn_params_;
317  FragmentsParams fragments_params_;
318  RogParams rog_params_;
319  FiltersParams filters_params_;
320  EVParams ev_params_;
321 };
322 IMP_VALUES(AlignmentParams, AlignmentParamsList);
323 
324 IMPMULTIFIT_END_NAMESPACE
325 
326 #endif /* IMPMULTIFIT_ALIGNMENT_PARAMS_H */
#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.
Various general useful macros for IMP.