IMP  2.0.1
The Integrative Modeling Platform
SettingsData.h
Go to the documentation of this file.
1 /**
2  * \file IMP/multifit/SettingsData.h
3  * \brief stored multifit settings data
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPMULTIFIT_SETTINGS_DATA_H
10 #define IMPMULTIFIT_SETTINGS_DATA_H
11 #include <IMP/multifit/multifit_config.h>
12 #include <IMP/base_types.h>
13 #include <IMP/container_macros.h>
14 #include <IMP/Pointer.h>
15 #include <IMP/Model.h>
16 #include <IMP/internal/OwnerPointer.h>
18 
19 IMPMULTIFIT_BEGIN_NAMESPACE
20 
21 //! Holds data about a component needed for optimization
22 class IMPMULTIFITEXPORT ComponentHeader : public IMP::base::Object {
23  public:
24  ComponentHeader(): Object("ComponentHeader%1%") {
25  name_="";
26  filename_="";
27  surface_fn_="";
28  pdb_ap_fn_="";
29  pdb_fine_ap_fn_="";
30  num_ap_=0;
31  transformations_fn_="";
32  reference_fn_="";
33  }
34  void set_name(const std::string &name) {name_=name;}
35  inline std::string get_name() const {return name_;}
36  inline std::string get_filename() const {return filename_;}
37  void set_filename(const std::string &filename){filename_=filename;}
38  inline std::string get_surface_fn() const {return surface_fn_;}
39  void set_surface_fn(const std::string &fn){surface_fn_=fn;}
40  void set_txt_ap_fn(const std::string &pdb_ap_fn) {pdb_ap_fn_=pdb_ap_fn;}
41  inline std::string get_txt_ap_fn() const {return pdb_ap_fn_;}
42  void set_txt_fine_ap_fn(const std::string &pdb_ap_fn) {
43  pdb_fine_ap_fn_=pdb_ap_fn;}
44  inline std::string get_txt_fine_ap_fn() const {
45  return pdb_fine_ap_fn_;}
46  void set_num_ap(int num_ap) {num_ap_=num_ap;}
47  inline int get_num_ap() const {return num_ap_;}
48  void set_num_fine_ap(int num_ap) {num_fine_ap_=num_ap;}
49  inline int get_num_fine_ap() const {return num_fine_ap_;}
50  void set_transformations_fn(std::string transformations_fn)
51  { transformations_fn_=transformations_fn;}
52  std::string get_transformations_fn() const {return transformations_fn_;}
53  void set_reference_fn(const std::string &ref_fn){reference_fn_=ref_fn;}
54  std::string get_reference_fn() const {return reference_fn_;}
56  out<<name_<<"|"<<filename_<<"|"<<surface_fn_<<"|";
57  out<<pdb_ap_fn_<<"|"<<num_ap_<<"|";
58  out<<pdb_fine_ap_fn_<<"|"<<num_fine_ap_<<"|";
59  out<<transformations_fn_<<"|"<<reference_fn_<<"|"<<std::endl; }, {});
60  protected:
61  std::string name_;
62  std::string filename_;
63  std::string surface_fn_;
64  std::string pdb_ap_fn_;
65  int num_ap_;
66  std::string pdb_fine_ap_fn_;
67  int num_fine_ap_;
68  std::string transformations_fn_;
69  std::string reference_fn_;
70 };
72 
73 //! Holds data about the assembly density needed for optimization
74 class IMPMULTIFITEXPORT AssemblyHeader : public IMP::base::Object {
75  public:
76  AssemblyHeader(): Object("AssemblyHeader%1%") {
77  dens_fn_="";
78  resolution_=0.;
79  spacing_=0.;
80  threshold_=0.;
81  coarse_ap_fn_="";
82  coarse_over_sampled_ap_fn_="";
83  fine_ap_fn_="";
84  fine_over_sampled_ap_fn_="";
85  }
86  void set_dens_fn(const std::string &dens_fn) {dens_fn_=dens_fn;}
87  std::string get_dens_fn() const {return dens_fn_;}
88  void set_resolution(float res) {resolution_=res;}
89  float get_resolution() const {return resolution_;}
90  float get_spacing() const {return spacing_;}
91  void set_spacing(float spacing) {spacing_=spacing;}
92  void set_threshold(float t) {threshold_=t;}
93  float get_threshold() const {return threshold_;}
94  algebra::Vector3D get_origin() const {return origin_;}
95  void set_origin(algebra::Vector3D origin) {origin_=origin;}
96  std::string get_coarse_ap_fn () const {return coarse_ap_fn_;}
97  void set_coarse_ap_fn (const std::string &new_fn) {
98  coarse_ap_fn_ = new_fn;}
99  std::string get_coarse_over_sampled_ap_fn () const {
100  return coarse_over_sampled_ap_fn_;}
101  void set_coarse_over_sampled_ap_fn (const std::string &new_fn) {
102  coarse_over_sampled_ap_fn_=new_fn;}
103  std::string get_fine_ap_fn () const {return fine_ap_fn_;}
104  void set_fine_ap_fn (const std::string &new_fn) {
105  fine_ap_fn_ = new_fn;}
106  std::string get_fine_over_sampled_ap_fn () const {
107  return fine_over_sampled_ap_fn_;}
108  void set_fine_over_sampled_ap_fn (const std::string &new_fn) {
109  fine_over_sampled_ap_fn_=new_fn;}
111  out<<dens_fn_<<"|"<<resolution_<<"|"<<spacing_<<"|"<<threshold_
112  <<"|"<<origin_[0]<<"|";
113  out<<origin_[1]<<"|"<<origin_[2]<<"|"<<coarse_ap_fn_;
114  out<<"|"<<coarse_over_sampled_ap_fn_<<"|";
115  out<<fine_ap_fn_<<"|"<<fine_over_sampled_ap_fn_<<"|\n";
116  }, {});
117  protected:
118  std::string dens_fn_;
119  float resolution_;
120  float spacing_;
121  float threshold_;
122  algebra::Vector3D origin_;
123  std::string coarse_ap_fn_;
124  std::string coarse_over_sampled_ap_fn_;
125  std::string fine_ap_fn_;
126  std::string fine_over_sampled_ap_fn_;
127  };
128 
129 //! Holds header data for optimization
130 class IMPMULTIFITEXPORT SettingsData : public IMP::base::Object {
131 public:
132  SettingsData(): Object("SettingsData%1%"){
133  data_path_="./";}
134  static void show_component_header_line(std::ostream& out = std::cout) {
135  out<<get_component_header_line();
136  }
137  static std::string get_component_header_line(){
138  std::stringstream ss;
139  ss<<"name|protein|surface|pdb_anchor_points|number of anchor points|"<<
140  "fine pdb_anchor_points|number of fine anchor points|"<<
141  "transformations|ref filename|"<<std::endl;
142  return ss.str();
143  }
144  static void show_density_header_line(std::ostream& out = std::cout) {
145  out <<get_density_header_line();
146  }
147  static std::string get_density_header_line() {
148  std::stringstream ss;
149  ss <<"map| resolution| spacing| threshold|x-origin| y-origin| z-origin|";
150  ss<<"coarse anchor points|coarse over sampled anchor points|";
151  ss<<"fine anchor points|fine over sampled anchor points|"<<std::endl;
152  return ss.str();
153  }
154  void set_assembly_filename(const std::string &fn) {
155  asmb_fn_ = fn;
156  }
157  const char * get_assembly_filename() const {
158  return asmb_fn_.c_str();
159  }
160  void set_assembly_header(AssemblyHeader *h) {
161  dens_data_=h;
162  }
163  AssemblyHeader *get_assembly_header() const {
164  return dens_data_;
165  }
166  void set_data_path(const std::string &fn) {
167  data_path_ = fn;
168  }
169  std::string get_data_path() const {return data_path_;}
170 
171  IMP_OBJECT_INLINE(SettingsData, { out << "Settings data"; }, {});
172 
173  IMP_LIST_ACTION(public, ComponentHeader, ComponentHeaders,
174  component_header, component_headers,
176  ComponentHeaders, obj->set_was_used(true);,,);
177 
178 protected:
179  IMP::OwnerPointer<AssemblyHeader> dens_data_;
180  std::string asmb_fn_;
181  std::string data_path_;
182 };
183 
184 IMPMULTIFITEXPORT SettingsData *read_settings(const char *filename);
185 IMPMULTIFITEXPORT void write_settings(
186  const char *filename, const SettingsData *sd);
187 IMPMULTIFIT_END_NAMESPACE
188 #endif /* IMPMULTIFIT_SETTINGS_DATA_H */