run_metrics.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "interop/util/exception.h"
16 #include "interop/model/run/info.h"
18 
19 //Metrics
33 
34 namespace illumina { namespace interop { namespace model { namespace metrics
35 {
36 
55  {
56  public:
58  typedef make_type_list<
67  q_metric,
72  >::result_t metric_type_list_t;
73 
74  private:
75  template<class T>
76  struct create_metric_set
77  {
79  };
81  typedef object_list<metric_set_list_t> metric_list_t;
82 
83  public:
87  typedef std::map<id_t, metric_base::base_metric> tile_metric_map_t;
89  typedef std::map<id_t, metric_base::base_cycle_metric> cycle_metric_map_t;
90 
91  public:
94 
95  public:
99  {
100  }
101 
108  m_run_info(run_info),
109  m_run_parameters(run_param)
110  {
111  }
112 
113  public:
128  void read(const std::string &run_folder, const size_t thread_count=1) INTEROP_THROW_SPEC((xml::xml_file_not_found_exception,
129  xml::bad_xml_format_exception,
130  xml::empty_xml_format_exception,
131  xml::missing_xml_element_exception,
132  xml::xml_parse_exception,
133  io::file_not_found_exception,
134  io::bad_format_exception,
135  io::incomplete_file_exception,
142  model::invalid_parameter));
152  void read(const std::string &run_folder,
153  const std::vector<unsigned char>& valid_to_load,
154  const size_t thread_count=1,
155  const bool skip_loaded=false)
156  INTEROP_THROW_SPEC((xml::xml_file_not_found_exception,
157  xml::bad_xml_format_exception,
158  xml::empty_xml_format_exception,
159  xml::missing_xml_element_exception,
160  xml::xml_parse_exception,
161  io::file_not_found_exception,
162  io::bad_format_exception,
163  io::incomplete_file_exception,
164  model::invalid_channel_exception,
165  model::index_out_of_bounds_exception,
166  model::invalid_tile_naming_method,
167  model::invalid_tile_list_exception,
168  model::invalid_run_info_exception,
169  model::invalid_run_info_cycle_exception,
170  model::invalid_parameter));
171 
176  size_t read_xml(const std::string &run_folder) INTEROP_THROW_SPEC((io::file_not_found_exception,
177  xml::xml_file_not_found_exception,
178  xml::bad_xml_format_exception,
179  xml::empty_xml_format_exception,
180  xml::missing_xml_element_exception,
181  xml::xml_parse_exception));
182 
187  void read_run_info(const std::string &run_folder) INTEROP_THROW_SPEC((xml::xml_file_not_found_exception,
188  xml::bad_xml_format_exception,
189  xml::empty_xml_format_exception,
190  xml::missing_xml_element_exception,
191  xml::xml_parse_exception));
192 
198  size_t read_run_parameters(const std::string &run_folder, const bool force_load=false) INTEROP_THROW_SPEC((
199  io::file_not_found_exception,
200  xml::xml_file_not_found_exception,
201  xml::bad_xml_format_exception,
202  xml::empty_xml_format_exception,
203  xml::missing_xml_element_exception,
204  xml::xml_parse_exception));
205 
210  void finalize_after_load(size_t count = std::numeric_limits<size_t>::max()) INTEROP_THROW_SPEC((
211  model::invalid_channel_exception,
212  model::invalid_tile_naming_method,
213  model::index_out_of_bounds_exception,
214  model::invalid_tile_list_exception,
215  model::invalid_run_info_exception,
216  model::invalid_run_info_cycle_exception,
217  model::invalid_parameter));
218 
223  bool empty() const;
224 
229  void legacy_channel_update(const constants::instrument_type type);
230 
235  void set_naming_method(const constants::tile_naming_method naming_method);
241  size_t count_legacy_bins(const size_t legacy_bin_count=std::numeric_limits<size_t>::max())const;
249  bool is_run_parameters_required(const size_t legacy_bin_count=std::numeric_limits<size_t>::max())const;
250 
251  public:
256  const run::info &run_info() const
257  {
258  return m_run_info;
259  }
260 
265  void run_info(const run::info &info)
266  {
267  m_run_info = info;
268  }
275  {
276  return m_run_parameters;
277  }
278 
283  void run_parameters(const run::parameters &param)
284  {
285  m_run_parameters = param;
286  }
287 
295  void list_filenames(const constants::metric_group group,
296  std::vector<std::string>& files,
297  const std::string& run_folder,
298  const bool use_out=true)
300 
308  void list_filenames(std::vector<std::string>& files,
309  const std::string& run_folder,
310  const bool bycycle=false,
311  const bool use_out=true)
312  INTEROP_THROW_SPEC((invalid_run_info_exception));
313 
314  public:
319  template<class T>
320  void set(const T& metrics)
321  {
322  //static_assert( )
323  m_metrics.get< T >() = metrics;
324  }
329  template<class T>
331  {
332  typedef typename metric_base::metric_set_helper<T>::metric_set_t metric_set_t;
333  return m_metrics.get< metric_set_t >();
334  }
335 
340  template<class T>
342  {
343  typedef typename metric_base::metric_set_helper<T>::metric_set_t metric_set_t;
344  return m_metrics.get< metric_set_t >();
345  }
346 
352  template<class T>
354  {
355  return m_metrics.get<metric_base::metric_set<T> >();
356  }
357 
358  public:
364  void copy_tile(const run_metrics& metrics, const metric_base::base_metric& tile_id);
370  void append_tiles(const run_metrics& metrics, const metric_base::base_metric& tile_id);
378  void check_for_data_sources(const std::string &run_folder, const size_t last_cycle);
390  void read_metrics(const std::string &run_folder, const size_t last_cycle, const size_t thread_count) INTEROP_THROW_SPEC((
407  void read_metrics(const std::string &run_folder,
408  const size_t last_cycle,
409  const std::vector<unsigned char>& valid_to_load,
410  const size_t thread_count,
411  const bool skip_loaded=false) INTEROP_THROW_SPEC((
412  io::file_not_found_exception,
413  io::bad_format_exception,
414  io::incomplete_file_exception,
415  model::invalid_parameter));
421  void write_metrics(const std::string &run_folder, const bool use_out=true)const INTEROP_THROW_SPEC((
422  io::file_not_found_exception,
423  io::bad_format_exception));
424 
425 
432  void read_metrics_from_buffer(const constants::metric_group group,
433  ::uint8_t* buffer,
434  const size_t buffer_size) INTEROP_THROW_SPEC((
435  io::file_not_found_exception,
436  io::bad_format_exception,
437  io::incomplete_file_exception,
445  void write_metrics_to_buffer(const constants::metric_group group,
446  ::uint8_t* buffer,
447  const size_t buffer_size)const INTEROP_THROW_SPEC((
448  io::invalid_argument,
449  io::bad_format_exception,
450  io::incomplete_file_exception));
456  size_t calculate_buffer_size(const constants::metric_group group)const INTEROP_THROW_SPEC((
457  io::invalid_argument, io::bad_format_exception));
458 
465 
470  template<class ReadFunc>
471  void read_callback(ReadFunc &func)
472  {
473  metrics_callback(func);
474  func(m_run_info);
475  finalize_after_load();
476  }
477 
482  template<class Func>
483  void metrics_callback(Func &func)
484  {
485  m_metrics.apply(func);
486  }
491  template<class Func>
492  void metrics_callback(Func &func)const
493  {
494  m_metrics.apply(func);
495  }
501  bool is_group_empty(const std::string& group_name) const;
507  bool is_group_empty(const constants::metric_group group_id) const;
508 
513  void populate_id_map(tile_metric_map_t &map) const;
514 
519  void populate_id_map(cycle_metric_map_t &map) const;
522  void sort();
523 
526  void clear();
527 
528  private:
529  metric_list_t m_metrics;
530  run::info m_run_info;
531  run::parameters m_run_parameters;
532 
533  };
534 
535 
536 }}}}
537 
run_metrics(const run::info &run_info, const run::parameters &run_param=run::parameters())
Definition: run_metrics.h:107
std::map< id_t, metric_base::base_metric > tile_metric_map_t
Definition: run_metrics.h:87
Error rate for a spiked in PhiX control sample.
Definition: error_metric.h:112
void read_metrics(const std::string &run_folder, const size_t last_cycle, const size_t thread_count) INTEROP_THROW_SPEC((io void read_metrics(const std::string &run_folder, const size_t last_cycle, const std::vector< unsigned char > &valid_to_load, const size_t thread_count, const bool skip_loaded=false) INTEROP_THROW_SPEC((io void write_metrics(const std::string &run_folder, const bool use_out=true) const INTEROP_THROW_SPEC((io void read_metrics_from_buffer(const constants::metric_group group,::uint8_t *buffer, const size_t buffer_size) INTEROP_THROW_SPEC((io void write_metrics_to_buffer(const constants::metric_group group,::uint8_t *buffer, const size_t buffer_size) const INTEROP_THROW_SPEC((io size_t calculate_buffer_size(const constants::metric_group group) const INTEROP_THROW_SPEC((io voi validate)() INTEROP_THROW_SPEC((invalid_run_info_exception
Definition: run_metrics.h:464
void read_callback(ReadFunc &func)
Definition: run_metrics.h:471
Definition: enum_description.h:15
void apply(UnaryOp &op)
Definition: object_list.h:142
bool is_run_parameters_required(const size_t legacy_bin_count=std::numeric_limits< size_t >::max()) const
Definition: run_metrics_helper.cpp:219
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
std::set< uint_t > id_set_t
Definition: metric_set.h:65
const run::parameters & run_parameters() const
Definition: run_metrics.h:274
void read(const std::string &run_folder, const size_t thread_count=1) INTEROP_THROW_SPEC((xml void read(const std::string &run_folder, const std::vector< unsigned char > &valid_to_load, const size_t thread_count=1, const bool skip_loaded=false) INTEROP_THROW_SPEC((xml size_t read_xml(const std::string &run_folder) INTEROP_THROW_SPEC((io void read_run_info(const std::string &run_folder) INTEROP_THROW_SPEC((xml size_t read_run_parameters(const std::string &run_folder, const bool force_load=false) INTEROP_THROW_SPEC((io void finalize_after_load(size_t count=std::numeric_limits< size_t >::max()) INTEROP_THROW_SPEC((model bool empty() const
Definition: run_metrics.h:223
make_type_list< corrected_intensity_metric, dynamic_phasing_metric, error_metric, extended_tile_metric, extraction_metric, image_metric, index_metric, phasing_metric, q_metric, q_by_lane_metric, q_collapsed_metric, tile_metric, summary_run_metric >::result_t metric_type_list_t
Definition: run_metrics.h:72
void clear()
Definition: run_metrics.cpp:557
Definition: stream_exceptions.h:45
metric_group
Definition: enums.h:289
Definition: type_traits.h:36
metric_base::metric_set< T > & get_metric_set()
Definition: run_metrics.h:353
const run::info & run_info() const
Definition: run_metrics.h:256
T & get()
Definition: object_list.h:122
void populate_id_map(tile_metric_map_t &map) const
Definition: run_metrics_helper.cpp:320
void sort()
Definition: run_metrics_helper.cpp:360
std::map< id_t, metric_base::base_cycle_metric > cycle_metric_map_t
Definition: run_metrics.h:89
metric_base::metric_set< error_metric >::id_set_t id_set_t
Definition: run_metrics.h:93
Definition: extended_tile_metric.h:31
def read(run, valid_to_load=None, requires=None, search_paths=None, extra)
Definition: core.py:752
Definition: enums.h:301
Definition: model_exceptions.h:50
void run_parameters(const run::parameters &param)
Definition: run_metrics.h:283
void legacy_channel_update(const constants::instrument_type type)
Definition: run_metrics.cpp:568
run_metrics()
Definition: run_metrics.h:98
bool is_group_empty(const std::string &group_name) const
Definition: run_metrics_helper.cpp:330
size_t count_legacy_bins(const size_t legacy_bin_count=std::numeric_limits< size_t >::max()) const
Definition: run_metrics_helper.cpp:228
void run_info(const run::info &info)
Definition: run_metrics.h:265
void check_for_data_sources(const std::string &run_folder, const size_t last_cycle)
Definition: run_metrics_helper.cpp:371
void copy_tile(const run_metrics &metrics, const metric_base::base_metric &tile_id)
Definition: run_metrics.cpp:309
Definition: stream_exceptions.h:59
Definition: stream_exceptions.h:73
Definition: type_traits.h:55
void append_tiles(const run_metrics &metrics, const metric_base::base_metric &tile_id)
Definition: run_metrics.cpp:319
void metrics_callback(Func &func) const
Definition: run_metrics.h:492
void set_naming_method(const constants::tile_naming_method naming_method)
Definition: run_metrics.cpp:577
metric_base::base_metric::id_t id_t
Definition: run_metrics.h:85
Intensity and count metrics for each base.
Definition: corrected_intensity_metric.h:50
Definition: dynamic_phasing_metric.h:28
instrument_type
Definition: enums.h:309
tile_naming_method
Definition: enums.h:294
void set(const T &metrics)
Definition: run_metrics.h:320
void list_filenames(const constants::metric_group group, std::vector< std::string > &files, const std::string &run_folder, const bool use_out=true) INTEROP_THROW_SPEC((invalid_run_info_exception))
Definition: run_metrics_helper.cpp:260
void metrics_callback(Func &func)
Definition: run_metrics.h:483
ulong_t id_t
Definition: base_metric.h:138
void read_metrics(std::istream &in, MetricSet &metrics, const size_t file_size, const bool rebuild=true)
Definition: metric_stream.h:99