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  float sum = 0.0f;
198  const size_t cycle_count = run_info.total_cycles();
199  for (size_t cycle = 1; cycle <= cycle_count; ++cycle)
200  {
201  const size_t cycle_within_read = run_info.cycle_within_read(cycle);
202  const metric_t::uint_t cycle_id = static_cast<metric_t::uint_t >(cycle);
203  metrics.insert(metric_t(7, 1113, cycle_id, kMissingValue, kMissingValue));
204  if( cycle_within_read <= 5 )
205  {
206  //Doing nothing is the same as adding a record with the missing value sentinel
207  //metrics.insert(metric_t(7, 1114, cycle, kMissingValue));
208  }
209  else if( cycle_within_read <= 35 )
210  {
211  metrics.insert(metric_t(7, 1114, cycle_id, kAverageError35, kMissingValue));
212  sum += kAverageError35;
213  }
214  else if( cycle_within_read <= 50 )
215  {
216  metrics.insert(metric_t(7, 1114, cycle_id, kAverageError50, kMissingValue));
217  sum += kAverageError35;
218  }
219  else if( cycle_within_read <= 75 )
220  {
221  metrics.insert(metric_t(7, 1114, cycle_id, kAverageError75, kMissingValue));
222  }
223  else if( cycle_within_read <= 100 )
224  {
225  metrics.insert(metric_t(7, 1114, cycle_id, kAverageError100, kMissingValue));
226  }
227  else
228  {
229  metrics.insert(metric_t(7, 1114, cycle_id, kAverageErrorAfter, kMissingValue));
230  }
231  }
232  }
233 
239  {
240  const size_t lane_count = 1;
241  const size_t surface_count = 2;
242  const size_t channel_count = 2;
243  const size_t cycles_per_read = 126;
244 
245  const model::run::read_info reads[]={
246  model::run::read_info(1, 1, cycles_per_read),
247  model::run::read_info(2, cycles_per_read+1, cycles_per_read*2)
248  };
249  summary.initialize(to_vector(reads), lane_count, surface_count, channel_count);
250 
251  const size_t read_count = util::length_of(reads);
252  const size_t total_cycles = cycles_per_read*read_count;
253  const size_t tile_count = 2;
254  const size_t lane_number = 7;
255  const float kReadError35 = 1.0f;
256  const float kReadError50 = 2.0f;
257  const float kReadError75 = 7.0f;
258  const float kReadError100 = 12.0f;
259  const float kReadError = 17.0f;
260  const float kSigma = 0.0f;
261 
262  for(size_t read_index=0;read_index < read_count;++read_index)
263  {
264  summary[read_index][0].lane(lane_number);
265  summary[read_index][0].tile_count(tile_count);
266  summary[read_index][0][0].tile_count(tile_count);
267  summary[read_index][0].cycle_state().error_cycle_range(
268  model::run::cycle_range(cycles_per_read, cycles_per_read));
269 
270  // Lane Error rate
271  summary[read_index][0].error_rate_35(model::summary::metric_stat(kReadError35,kSigma,kReadError35));
272  summary[read_index][0][0].error_rate_35(model::summary::metric_stat(kReadError35,kSigma,kReadError35));
273 
274  summary[read_index][0].error_rate_50(model::summary::metric_stat(kReadError50,kSigma,kReadError50));
275  summary[read_index][0][0].error_rate_50(model::summary::metric_stat(kReadError50,kSigma,kReadError50));
276 
277  summary[read_index][0].error_rate_75(model::summary::metric_stat(kReadError75,kSigma,kReadError75));
278  summary[read_index][0][0].error_rate_75(model::summary::metric_stat(kReadError75,kSigma,kReadError75));
279 
280  summary[read_index][0].error_rate_100(model::summary::metric_stat(kReadError100,kSigma,kReadError100));
281  summary[read_index][0][0].error_rate_100(model::summary::metric_stat(kReadError100,kSigma,kReadError100));
282 
283  summary[read_index][0].error_rate(model::summary::metric_stat(kReadError,kSigma,kReadError));
284  summary[read_index][0][0].error_rate(model::summary::metric_stat(kReadError,kSigma,kReadError));
285 
286  // Read Error Rate
287  summary[read_index].summary().error_rate(kReadError);
288  }
289  summary.nonindex_summary().error_rate(kReadError);
290  summary.total_summary().error_rate(kReadError);
291  summary.cycle_state().error_cycle_range(model::run::cycle_range(total_cycles, total_cycles));
292  }
293  };
294 
301  struct error_metric_v4 : metric_test<model::metrics::error_metric, 4>
302  {
308  {
309  metrics = metric_set_t(VERSION);
310 
311  const float kMissingValue = std::numeric_limits<float>::quiet_NaN();
312  metrics.insert(metric_t(3, 211011, 1, 0.608985f, kMissingValue));
313  metrics.insert(metric_t(3, 211011, 2, 0.298748f, kMissingValue));
314  metrics.insert(metric_t(3, 211011, 3, 0.287257f, kMissingValue));
315  }
320  template<class Collection>
321  static void create_binary_data(Collection &buffer)
322  {
323  const signed char tmp[] =
324  {4
325  ,12,3,0,67,56,3,0,1,0,113,-26,27,63,3,0,67,56,3,0,2
326  ,0,127,-11,-104,62,3,0,67,56,3,0,3,0,89,19,-109,62
327  };
328  buffer.assign(tmp, tmp+util::length_of(tmp));
329  }
330  };
331 
338  struct error_metric_v5 : metric_test<model::metrics::error_metric, 5>
339  {
345  {
346  metrics = metric_set_t(VERSION);
347  metrics.insert(metric_t(3, 211011, 1, 0.608985f, 0.298748f));
348  metrics.insert(metric_t(3, 211011, 2, 0.298748f, 0.287257f));
349  metrics.insert(metric_t(3, 211011, 3, 0.287257f, 0.608985f));
350  }
355  template<class Collection>
356  static void create_binary_data(Collection &buffer)
357  {
358  const signed char tmp[] =
359  {5,16,
360  3,0,67,56,3,0,1,0,113,-26,27,63,127,-11,-104,62,
361  3,0,67,56,3,0,2,0,127,-11,-104,62,89,19,-109,62,
362  3,0,67,56,3,0,3,0,89,19,-109,62,113,-26,27,63
363  };
364  buffer.assign(tmp, tmp+util::length_of(tmp));
365  }
366  };
367 
374  struct error_metric_v6 : metric_test<model::metrics::error_metric, 6>
375  {
381  {
382  std::vector<std::string> adapters;
383  adapters.push_back("CCCCCCCC");
384  adapters.push_back("AAAAAAAA");
385  header_t header = header_t(adapters);
386  metrics = metric_set_t(header, VERSION);
387 
388  float rates1[2] = {0.298748f, 0.1234f};
389  float rates2[2] = {0.287257f, 0.3934f};
390  float rates3[2] = {0.608985f, 0.5034f};
391  metrics.insert(metric_t(3, 211011, 1, 0.608985f, to_vector(rates1)));
392  metrics.insert(metric_t(3, 211011, 2, 0.298748f, to_vector(rates2)));
393  metrics.insert(metric_t(3, 211011, 3, 0.287257f, to_vector(rates3)));
394  }
399  template<class Collection>
400  static void create_binary_data(Collection &buffer)
401  {
402  const char tmp[] =
403  {6
404  ,20,2,0,8,0,67,67,67,67,67,67,67,67,65,65,65,65,65,65,65
405  ,65,3,0,67,56,3,0,1,0,113,-26,27,63,127,-11,-104,62,36,-71,-4
406  ,61,3,0,67,56,3,0,2,0,127,-11,-104,62,89,19,-109,62,-70,107,-55
407  ,62,3,0,67,56,3,0,3,0,89,19,-109,62,113,-26,27,63,-45,-34,0
408  ,63
409  };
410  buffer.assign(tmp, tmp+util::length_of(tmp));
411  }
412  };
413 }}}
414 
Definition: error_metrics_test.h:301
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:400
model::metric_base::metric_set< model::metrics::error_metric > metric_set_t
Definition: metric_test.h:59
Definition: summary.py:1
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:374
::uint32_t uint_t
Definition: base_metric.h:77
const cycle_state_summary & cycle_state() const
Definition: run_summary.h:370
static void create_binary_data(Collection &buffer)
Definition: error_metrics_test.h:321
static void create_binary_data(Collection &buffer)
Definition: error_metrics_test.h:356
static void create_expected(metric_set_t &metrics, const model::run::info &=model::run::info())
Definition: error_metrics_test.h:344
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:307
Definition: error_metrics_test.h:338
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:380
static void create_summary(model::summary::run_summary &summary)
Definition: error_metrics_test.h:238
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