metric_filter_iterator.h
Go to the documentation of this file.
1 
9 #pragma once
10 #include <vector>
11 #include "interop/model/run/info.h"
19 
20 namespace illumina { namespace interop { namespace unittest
21 {
25  {
26  typedef std::vector <logic::utils::metric_type_description_t> metric_type_vector_t;
27  typedef metric_type_vector_t::const_iterator const_metric_type_iterator_t;
28  public:
31  m_current_metric(m_metric_types.begin()),
32  m_plot_type(constants::UnknownPlotType)
33  {
34  }
35 
36  public:
43  m_options(source.m_options),
44  m_run_info(source.m_run_info),
45  m_plot_type(source.m_plot_type)
46  {
47  m_current_metric = m_metric_types.begin() + std::distance(source.m_metric_types.begin(), source.m_current_metric);
48  m_current_filter = m_options.option_iterator(m_run_info, *m_current_metric, m_plot_type, true);
49  }
50 
51  public:
57  void reset(const std::string &run_info_filename, const constants::plot_types plot_type)
58  {
60  try
61  {
62  run.read(run_info_filename);
63  }
64  catch (const std::exception &){}
65  reset(run.run_info(), plot_type);
66  }
73  {
75  switch(m_plot_type)
76  {
78  logic::plot::plot_by_cycle(run, *m_current_metric, m_options, data, false);
79  break;
81  logic::plot::plot_by_lane(run, *m_current_metric, m_options, data, false);
82  break;
83  default:
84  INTEROP_THROW(std::runtime_error, "Plot type unsupported");
85  };
86  }
93  {
94  switch(m_plot_type)
95  {
98  break;
101  break;
102  default:
103  INTEROP_THROW(std::runtime_error, "Plot type unsupported");
104  };
105  }
112  {
113  switch(m_plot_type)
114  {
117  break;
118  default:
119  INTEROP_THROW(std::runtime_error, "Plot type unsupported");
120  };
121  }
128  {
129  switch(m_plot_type)
130  {
132  logic::plot::plot_flowcell_map(run, *m_current_metric, m_options, data, 0, 0, false);
133  break;
134  default:
135  INTEROP_THROW(std::runtime_error, "Plot type unsupported");
136  };
137  }
138 
144  void reset(const model::run::info &run_info, const constants::plot_types plot_type)
145  {
146  m_run_info = run_info;
147  m_plot_type = plot_type;
148 
149  m_metric_types.clear();
150  switch(plot_type)
151  {
154  break;
157  break;
160  break;
164  break;
166  // Sentinel (turn off surface filtering)
168  break;
169  default:
170  INTEROP_THROW(std::runtime_error, "Plot type unsupported");
171  };
172 
173  // Reduce the number of filters!
174  model::run::flowcell_layout layout = run_info.flowcell();
175  layout.lane_count(1); // TODO: increase to test filtering?
176  layout.swath_count(1);
177  layout.tile_count(1);
178  layout.sections_per_lane(1);
179  layout.lanes_per_section(1);
180  m_run_info.flowcell(layout);
181  std::string channels[] = {"Red", "Green"};
182  m_run_info.channels(util::to_vector(channels));
183  const model::run::read_info reads[] = {model::run::read_info(1, 1, 1, false)};
184  m_run_info.reads(util::to_vector(reads));
185 
186  m_plot_type = plot_type;
188  m_current_metric = m_metric_types.begin();
189  if (m_current_metric == m_metric_types.end())
190  INTEROP_THROW(std::runtime_error, "Metric iterator started exhausted");
191  m_current_filter = m_options.option_iterator(m_run_info, *m_current_metric, plot_type);
192  }
198  {
199  if (m_current_metric == m_metric_types.end())
200  INTEROP_THROW(std::runtime_error, "Metric iterator started exhausted");
201  return *m_current_metric;
202  }
203 
209  {
210  return m_options;
211  }
212 
217  bool advance()
218  {
219  if (m_current_metric == m_metric_types.end())
220  return true;
221  ++m_current_filter;
222  if (m_current_filter.is_done())
223  {
224  ++m_current_metric;
225  if( m_current_metric != m_metric_types.end())
226  m_current_filter = m_options.option_iterator(m_run_info, *m_current_metric, m_plot_type);
227  }
228  return m_current_metric == m_metric_types.end();
229  }
234  bool is_done()
235  {
236  return m_current_metric == m_metric_types.end();
237  }
242  metric_type_vector_t& metric_types()
243  {
244  return m_metric_types;
245  }
246 
247  protected:
249  void reset()
250  {
251  m_current_metric = m_metric_types.begin();
252  }
253 
254  protected:
256  metric_type_vector_t m_metric_types;
259  private:
260  util::chain_range_iterator m_current_filter;
261  const_metric_type_iterator_t m_current_metric;
262  model::run::info m_run_info;
263  constants::plot_types m_plot_type;
264  };
265 
266 }}}
267 
268 
Definition: filter_options.h:28
metric_type
Definition: enums.h:284
Definition: enum_description.h:15
void reset()
Definition: metric_filter_iterator.h:249
void plot_flowcell_map(model::metrics::run_metrics &metrics, const constants::metric_type type, const model::plot::filter_options &options, model::plot::flowcell_data &data, float *buffer,::uint32_t *tile_buffer, const bool skip_empty) INTEROP_THROW_SPEC((model
Definition: plot_flowcell_map.cpp:91
void plot(model::metrics::run_metrics &run, model::plot::flowcell_data &data) const
Definition: metric_filter_iterator.h:127
Definition: flowcell_data.h:25
void plot(model::metrics::run_metrics &run, model::plot::plot_data< model::plot::candle_stick_point > &data) const
Definition: metric_filter_iterator.h:72
Definition: metric_filter_iterator.h:24
tile_naming_method_t naming_method() const
Definition: flowcell_layout.h:150
void plot_qscore_histogram(model::metrics::run_metrics &metrics, const model::plot::filter_options &options, model::plot::plot_data< model::plot::bar_point > &data, const size_t boundary) INTEROP_THROW_SPEC((model
Definition: plot_qscore_histogram.cpp:147
bool is_done()
Definition: metric_filter_iterator.h:234
Definition: indirect_range_iterator.h:62
#define INTEROP_THROW(EXCEPTION, MESSAGE)
Definition: exception.h:18
uint_t swath_count() const
Definition: flowcell_layout.h:109
metric_filter_iterator()
Definition: metric_filter_iterator.h:30
void reset(const model::run::info &run_info, const constants::plot_types plot_type)
Definition: metric_filter_iterator.h:144
plot_types
Definition: enums.h:339
uint_t lanes_per_section() const
Definition: flowcell_layout.h:132
void plot_by_lane(const model::metrics::run_metrics &metrics, const constants::metric_type type, const model::plot::filter_options &options, model::plot::plot_data< model::plot::candle_stick_point > &data, const bool skip_empty=true) INTEROP_THROW_SPEC((model void plot_by_lane(const model::metrics::run_metrics &metrics, const std::string &metric_name, const model::plot::filter_options &options, model::plot::plot_data< model::plot::candle_stick_point > &data, const bool skip_empty=true) INTEROP_THROW_SPEC((model void list_by_lane_metrics(std::vector< logic::utils::metric_type_description_t > &types, const bool ignore_pf=false)
Definition: plot_by_lane.h:62
void plot(model::metrics::run_metrics &run, model::plot::plot_data< model::plot::bar_point > &data) const
Definition: metric_filter_iterator.h:92
const run::info & run_info() const
Definition: run_metrics.h:256
void plot_qscore_heatmap(model::metrics::run_metrics &metrics, const model::plot::filter_options &options, model::plot::heatmap_data &data, float *buffer, const size_t) INTEROP_THROW_SPEC((model
Definition: plot_qscore_heatmap.cpp:143
void list_flowcell_metrics(std::vector< logic::utils::metric_type_description_t > &types, const bool ignore_accumulated=false)
Definition: plot_flowcell_map.cpp:219
void reset(const std::string &run_info_filename, const constants::plot_types plot_type)
Definition: metric_filter_iterator.h:57
const read_vector_t & reads() const
Definition: info.h:235
constants::metric_type metric() const
Definition: metric_filter_iterator.h:197
Definition: enum_description.h:20
util::chain_range_iterator option_iterator(const model::run::info &info, const constants::metric_type metric_type, const constants::plot_types plot_type, const bool keep_state=false)
Definition: filter_options.h:653
const flowcell_layout & flowcell() const
Definition: info.h:214
metric_filter_iterator(const metric_filter_iterator &source)
Definition: metric_filter_iterator.h:41
bool advance()
Definition: metric_filter_iterator.h:217
void plot_by_cycle(model::metrics::run_metrics &metrics, const constants::metric_type type, const model::plot::filter_options &options, model::plot::plot_data< model::plot::candle_stick_point > &data, const bool skip_empty) INTEROP_THROW_SPEC((model
Definition: plot_by_cycle.cpp:381
const model::plot::filter_options & options() const
Definition: metric_filter_iterator.h:208
void plot_by_cycle(model::metrics::run_metrics &metrics, const constants::metric_type type, const model::plot::filter_options &options, model::plot::plot_data< model::plot::candle_stick_point > &data, const bool skip_empty=true) INTEROP_THROW_SPEC((model void plot_by_cycle(model::metrics::run_metrics &metrics, const std::string &metric_name, const model::plot::filter_options &options, model::plot::plot_data< model::plot::candle_stick_point > &data, const bool skip_empty=true) INTEROP_THROW_SPEC((model void list_by_cycle_metrics(std::vector< logic::utils::metric_type_description_t > &types, const bool ignore_accumulated=false)
Definition: plot_by_cycle.h:63
void plot(model::metrics::run_metrics &run, model::plot::heatmap_data &data) const
Definition: metric_filter_iterator.h:111
model::plot::filter_options m_options
Definition: metric_filter_iterator.h:258
uint_t sections_per_lane() const
Definition: flowcell_layout.h:124
void plot_sample_qc(model::metrics::run_metrics &metrics, const size_t lane, model::plot::plot_data< model::plot::bar_point > &data)
Definition: plot_sample_qc.cpp:80
metric_type_vector_t m_metric_types
Definition: metric_filter_iterator.h:256
metric_type_vector_t & metric_types()
Definition: metric_filter_iterator.h:242
Definition: flowcell_layout.h:20
void lane(const id_t l)
Definition: filter_options.h:516
void plot_by_lane(const model::metrics::run_metrics &metrics, const constants::metric_type type, const model::plot::filter_options &options, model::plot::plot_data< model::plot::candle_stick_point > &data, const bool skip_empty) INTEROP_THROW_SPEC((model
Definition: plot_by_lane.cpp:162
uint_t tile_count() const
Definition: flowcell_layout.h:116
uint_t lane_count() const
Definition: flowcell_layout.h:75
bool is_done() const
Definition: indirect_range_iterator.h:156
void tile_naming_method(const constants::tile_naming_method naming_method)
Definition: filter_options.h:439
const str_vector_t & channels() const
Definition: info.h:221