error_metrics_test.h
Go to the documentation of this file.
1 
9 #pragma once
10 
14 #include "interop/util/length_of.h"
15 
16 
17 namespace illumina { namespace interop { namespace unittest
18 {
19 
25  struct error_metric_v3 : metric_test<model::metrics::error_metric, 3>
26  {
32  {
33  metrics = metric_set_t(VERSION);
34  const float kMissingValue = std::numeric_limits<float>::quiet_NaN();
35  metrics.insert(metric_t(7, 1114, 1, 0.450100899f, kMissingValue));
36  metrics.insert(metric_t(7, 1114, 2, 0.900201797f, kMissingValue));
37  metrics.insert(metric_t(7, 1114, 3, 0.465621591f, kMissingValue));
38  }
39 
44  template<class Collection>
45  static void create_binary_data(Collection &buffer)
46  {
47  const signed char tmp[] =
48  {
49  3, 30, 7, 0, 90, 4, 1, 0, -96, 115, -26, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50  0, 0, 0, 0, 0, 7, 0, 90, 4, 2, 0, -96, 115, 102, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51  0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 90, 4, 3, 0, -12, 101, -18, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
53  };
54  buffer.assign(tmp, tmp+util::length_of(tmp));
55  }
56 
62  {
63  const size_t lane_count = 1;
64  const size_t surface_count = 2;
65  const size_t channel_count = 2;
66  const model::run::read_info reads[] = {
67  model::run::read_info(1, 1, 3, false)
68  };
69  summary.initialize(to_vector(reads), lane_count, surface_count, channel_count);
70  summary[0][0].lane(7);
71  summary[0][0].error_rate(model::summary::metric_stat(0.67515134811401367f, 0, 0.67515134811401367f));
72  summary[0][0][0].error_rate(model::summary::metric_stat(0.67515134811401367f, 0, 0.67515134811401367f));
73  summary[0][0][0].tile_count(1);
74  summary[0][0].error_rate_35(model::summary::metric_stat());
75  summary[0][0].error_rate_50(model::summary::metric_stat());
76  summary[0][0].error_rate_75(model::summary::metric_stat());
77  summary[0][0].error_rate_100(model::summary::metric_stat());
79  summary[0].summary().error_rate(0.67515134811401367f);
80  summary.total_summary().error_rate(0.67515134811401367f);
81  summary.nonindex_summary().error_rate(0.67515134811401367f);
82  summary[0][0].tile_count(1);
84  }
85  };
86 
179  struct error_metric_requirements : metric_test<model::metrics::error_metric, 3>
180  {
186  static void create_expected(metric_set_t &metrics, const model::run::info& run_info)
187  {
188  metrics = metric_set_t(VERSION);
189 
190  const float kMissingValue = std::numeric_limits<float>::quiet_NaN();
191  const float kAverageError35 = 1.0f;
192  const float kAverageError50 = 4.0f;
193  const float kAverageError75 = 16.0f;
194  const float kAverageError100 = 26.0f;
195  const float kAverageErrorAfter = 36.0f;
196 
197  const size_t cycle_count = run_info.total_cycles();
198  for (size_t cycle = 1; cycle <= cycle_count; ++cycle)
199  {
200  const size_t cycle_within_read = run_info.cycle_within_read(cycle);
201  const metric_t::uint_t cycle_id = static_cast<metric_t::uint_t >(cycle);
202  metrics.insert(metric_t(7, 1113, cycle_id, kMissingValue, kMissingValue));
203  if( cycle_within_read <= 5 )
204  {
205  //Doing nothing is the same as adding a record with the missing value sentinel
206  //metrics.insert(metric_t(7, 1114, cycle, kMissingValue));
207  }
208  else if( cycle_within_read <= 35 )
209  {
210  metrics.insert(metric_t(7, 1114, cycle_id, kAverageError35, kMissingValue));
211  }
212  else if( cycle_within_read <= 50 )
213  {
214  metrics.insert(metric_t(7, 1114, cycle_id, kAverageError50, kMissingValue));
215  }
216  else if( cycle_within_read <= 75 )
217  {
218  metrics.insert(metric_t(7, 1114, cycle_id, kAverageError75, kMissingValue));
219  }
220  else if( cycle_within_read <= 100 )
221  {
222  metrics.insert(metric_t(7, 1114, cycle_id, kAverageError100, kMissingValue));
223  }
224  else
225  {
226  metrics.insert(metric_t(7, 1114, cycle_id, kAverageErrorAfter, kMissingValue));
227  }
228  }
229  }
230 
236  {
237  const size_t lane_count = 1;
238  const size_t surface_count = 2;
239  const size_t channel_count = 2;
240  const size_t cycles_per_read = 126;
241 
242  const model::run::read_info reads[]={
243  model::run::read_info(1, 1, cycles_per_read),
244  model::run::read_info(2, cycles_per_read+1, cycles_per_read*2)
245  };
246  summary.initialize(to_vector(reads), lane_count, surface_count, channel_count);
247 
248  const size_t read_count = util::length_of(reads);
249  const size_t total_cycles = cycles_per_read*read_count;
250  const size_t tile_count = 2;
251  const size_t lane_number = 7;
252  const float kReadError35 = 1.0f;
253  const float kReadError50 = 2.0f;
254  const float kReadError75 = 7.0f;
255  const float kReadError100 = 12.0f;
256  const float kReadError = 17.0f;
257  const float kSigma = 0.0f;
258 
259  for(size_t read_index=0;read_index < read_count;++read_index)
260  {
261  summary[read_index][0].lane(lane_number);
262  summary[read_index][0].tile_count(tile_count);
263  summary[read_index][0][0].tile_count(tile_count);
264  summary[read_index][0].cycle_state().error_cycle_range(
265  model::run::cycle_range(cycles_per_read, cycles_per_read));
266 
267  // Lane Error rate
268  summary[read_index][0].error_rate_35(model::summary::metric_stat(kReadError35,kSigma,kReadError35));
269  summary[read_index][0][0].error_rate_35(model::summary::metric_stat(kReadError35,kSigma,kReadError35));
270 
271  summary[read_index][0].error_rate_50(model::summary::metric_stat(kReadError50,kSigma,kReadError50));
272  summary[read_index][0][0].error_rate_50(model::summary::metric_stat(kReadError50,kSigma,kReadError50));
273 
274  summary[read_index][0].error_rate_75(model::summary::metric_stat(kReadError75,kSigma,kReadError75));
275  summary[read_index][0][0].error_rate_75(model::summary::metric_stat(kReadError75,kSigma,kReadError75));
276 
277  summary[read_index][0].error_rate_100(model::summary::metric_stat(kReadError100,kSigma,kReadError100));
278  summary[read_index][0][0].error_rate_100(model::summary::metric_stat(kReadError100,kSigma,kReadError100));
279 
280  summary[read_index][0].error_rate(model::summary::metric_stat(kReadError,kSigma,kReadError));
281  summary[read_index][0][0].error_rate(model::summary::metric_stat(kReadError,kSigma,kReadError));
282 
283  // Read Error Rate
284  summary[read_index].summary().error_rate(kReadError);
285  }
286  summary.nonindex_summary().error_rate(kReadError);
287  summary.total_summary().error_rate(kReadError);
288  summary.cycle_state().error_cycle_range(model::run::cycle_range(total_cycles, total_cycles));
289  }
290  };
291 
298  struct error_metric_v4 : metric_test<model::metrics::error_metric, 4>
299  {
305  {
306  metrics = metric_set_t(VERSION);
307 
308  const float kMissingValue = std::numeric_limits<float>::quiet_NaN();
309  metrics.insert(metric_t(3, 211011, 1, 0.608985f, kMissingValue));
310  metrics.insert(metric_t(3, 211011, 2, 0.298748f, kMissingValue));
311  metrics.insert(metric_t(3, 211011, 3, 0.287257f, kMissingValue));
312  }
317  template<class Collection>
318  static void create_binary_data(Collection &buffer)
319  {
320  const signed char tmp[] =
321  {4
322  ,12,3,0,67,56,3,0,1,0,113,-26,27,63,3,0,67,56,3,0,2
323  ,0,127,-11,-104,62,3,0,67,56,3,0,3,0,89,19,-109,62
324  };
325  buffer.assign(tmp, tmp+util::length_of(tmp));
326  }
327  };
328 
335  struct error_metric_v5 : metric_test<model::metrics::error_metric, 5>
336  {
342  {
343  metrics = metric_set_t(VERSION);
344  metrics.insert(metric_t(3, 211011, 1, 0.608985f, 0.298748f));
345  metrics.insert(metric_t(3, 211011, 2, 0.298748f, 0.287257f));
346  metrics.insert(metric_t(3, 211011, 3, 0.287257f, 0.608985f));
347  }
352  template<class Collection>
353  static void create_binary_data(Collection &buffer)
354  {
355  const signed char tmp[] =
356  {5,16,
357  3,0,67,56,3,0,1,0,113,-26,27,63,127,-11,-104,62,
358  3,0,67,56,3,0,2,0,127,-11,-104,62,89,19,-109,62,
359  3,0,67,56,3,0,3,0,89,19,-109,62,113,-26,27,63
360  };
361  buffer.assign(tmp, tmp+util::length_of(tmp));
362  }
363  };
364 
371  struct error_metric_v6 : metric_test<model::metrics::error_metric, 6>
372  {
378  {
379  std::vector<std::string> adapters;
380  adapters.push_back("CCCCCCCC");
381  adapters.push_back("AAAAAAAA");
382  header_t header = header_t(adapters);
383  metrics = metric_set_t(header, VERSION);
384 
385  float rates1[2] = {0.298748f, 0.1234f};
386  float rates2[2] = {0.287257f, 0.3934f};
387  float rates3[2] = {0.608985f, 0.5034f};
388  metrics.insert(metric_t(3, 211011, 1, 0.608985f, to_vector(rates1)));
389  metrics.insert(metric_t(3, 211011, 2, 0.298748f, to_vector(rates2)));
390  metrics.insert(metric_t(3, 211011, 3, 0.287257f, to_vector(rates3)));
391  }
396  template<class Collection>
397  static void create_binary_data(Collection &buffer)
398  {
399  const char tmp[] =
400  {6
401  ,20,2,0,8,0,67,67,67,67,67,67,67,67,65,65,65,65,65,65,65
402  ,65,3,0,67,56,3,0,1,0,113,-26,27,63,127,-11,-104,62,36,-71,-4
403  ,61,3,0,67,56,3,0,2,0,127,-11,-104,62,89,19,-109,62,-70,107,-55
404  ,62,3,0,67,56,3,0,3,0,89,19,-109,62,113,-26,27,63,-45,-34,0
405  ,63
406  };
407  buffer.assign(tmp, tmp+util::length_of(tmp));
408  }
409  };
410 }}}
411 
Definition: error_metrics_test.h:298
const metric_summary & total_summary() const
Definition: run_summary.h:314
void insert(const metric_type &metric)
Definition: metric_set.h:267
Definition: enum_description.h:15
void initialize(const run::info &run_info)
Definition: run_summary.h:99
size_t cycle_within_read(const size_t cycle) const
Definition: info.h:279
static std::vector< T > to_vector(const T(&vals)[N])
Definition: metric_test.h:85
Definition: error_metrics_test.h:25
Definition: cycle_range.h:20
Definition: error_metrics_test.h:179
model::metrics::error_metric metric_t
Definition: metric_test.h:57
const run::cycle_range & error_cycle_range() const
Definition: cycle_state_summary.h:68
Definition: metric_test.h:41
static void create_binary_data(Collection &buffer)
Definition: error_metrics_test.h:397
model::metric_base::metric_set< model::metrics::error_metric > metric_set_t
Definition: metric_test.h:59
static void create_expected(metric_set_t &metrics, const model::run::info &=model::run::info())
Definition: error_metrics_test.h:31
Definition: error_metrics_test.h:371
::uint32_t uint_t
Definition: base_metric.h:77
def summary(run_metrics, level='Total', columns=None, dtype='f4', ignore_missing_columns=True, extra)
Definition: core.py:217
const cycle_state_summary & cycle_state() const
Definition: run_summary.h:370
static void create_binary_data(Collection &buffer)
Definition: error_metrics_test.h:318
static void create_binary_data(Collection &buffer)
Definition: error_metrics_test.h:353
static void create_expected(metric_set_t &metrics, const model::run::info &=model::run::info())
Definition: error_metrics_test.h:341
size_t total_cycles() const
Definition: info.h:334
static void create_expected(metric_set_t &metrics, const model::run::info &=model::run::info())
Definition: error_metrics_test.h:304
Definition: error_metrics_test.h:335
float error_rate() const
Definition: metric_summary.h:52
static void create_binary_data(Collection &buffer)
Definition: error_metrics_test.h:45
static void create_summary(model::summary::run_summary &summary)
Definition: error_metrics_test.h:61
metric_t::header_type header_t
Definition: metric_test.h:61
static void create_expected(metric_set_t &metrics, const model::run::info &=model::run::info())
Definition: error_metrics_test.h:377
static void create_summary(model::summary::run_summary &summary)
Definition: error_metrics_test.h:235
size_t length_of(const T &val)
Definition: length_of.h:55
static void create_expected(metric_set_t &metrics, const model::run::info &run_info)
Definition: error_metrics_test.h:186
const metric_summary & nonindex_summary() const
Definition: run_summary.h:342