extraction_metric.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <ctime>
17 #include <cstring>
18 #include <algorithm>
19 #include "interop/util/exception.h"
20 #include "interop/util/time.h"
25 
26 namespace illumina { namespace interop { namespace model { namespace metrics
27 {
31  {
32  public:
33  enum{
36  };
39  typedef ::uint16_t ushort_t;
40  public:
45  extraction_metric_header(ushort_t channel_count) : m_channel_count(channel_count) {}
50  ushort_t channel_count()const{return m_channel_count;}
55  void channel_count(const size_t channel_count)
56  {
57  m_channel_count = static_cast<ushort_t>(channel_count);
58  }
64  {
66  }
69  void clear()
70  {
71  m_channel_count=MAX_CHANNELS;
73  }
74  private:
75  ushort_t m_channel_count;
76  template<class MetricType, int Version>
77  friend struct io::generic_layout;
78  };
86  {
87  public:
88  enum
89  {
96  };
101  typedef std::vector<ushort_t> ushort_array_t;
104  typedef std::vector<float> float_array_t;
107  typedef ::uint16_t *ushort_pointer_t;
110  typedef float *float_pointer_t;
111 
112  public:
116  metric_base::base_cycle_metric(0, 0, 0),
117  m_date_time_csharp(0),
118  m_date_time(0),
119  m_max_intensity_values(MAX_CHANNELS, 0),
120  m_focus_scores(MAX_CHANNELS, 0)
121  {
122  }
127  extraction_metric(const header_type& header) :
128  metric_base::base_cycle_metric(0, 0, 0),
129  m_date_time_csharp(0),
130  m_date_time(0),
131  m_max_intensity_values(header.channel_count(), 0),
132  m_focus_scores(header.channel_count(), 0)
133  {
134  }
135 
147  const uint_t tile,
148  const uint_t cycle,
149  const ulong_t date_time,
150  const ushort_array_t &intensities_p90,
151  const float_array_t &focus_scores) :
152  metric_base::base_cycle_metric(lane, tile, cycle),
153  m_date_time_csharp(util::csharp_date_time::to_csharp(date_time)),
154  m_date_time(date_time),
155  m_max_intensity_values(intensities_p90),
156  m_focus_scores(focus_scores)
157  {
158  INTEROP_ASSERT(intensities_p90.size() <= MAX_CHANNELS);
159  INTEROP_ASSERT(m_focus_scores.size() <= MAX_CHANNELS);
160  m_max_intensity_values.resize(MAX_CHANNELS, 0);
161  m_focus_scores.resize(MAX_CHANNELS, 0);
162  }
163 
176  const uint_t tile,
177  const uint_t cycle,
178  const ulong_t date_time,
179  const ushort_pointer_t intensities_p90,
180  const float_pointer_t focus_scores,
182  metric_base::base_cycle_metric(lane, tile, cycle),
183  m_date_time_csharp(util::csharp_date_time::to_csharp(date_time)),
184  m_date_time(date_time),
185  m_max_intensity_values(intensities_p90, intensities_p90 + channel_count),
186  m_focus_scores(focus_scores, focus_scores + channel_count)
187  {
188  }
189 
201  const uint_t tile,
202  const uint_t cycle,
204  const ushort_array_t &intensities_p90,
205  const float_array_t &focus_scores) :
206  metric_base::base_cycle_metric(lane, tile, cycle),
207  m_date_time_csharp(date_time),
208  m_date_time(date_time.to_unix()),
209  m_max_intensity_values(intensities_p90),
210  m_focus_scores(focus_scores)
211  {
212  INTEROP_ASSERT(intensities_p90.size() <= MAX_CHANNELS);
213  INTEROP_ASSERT(m_focus_scores.size() <= MAX_CHANNELS);
214  m_max_intensity_values.resize(MAX_CHANNELS, 0);
215  m_focus_scores.resize(MAX_CHANNELS, 0);
216  }
217 
230  const uint_t tile,
231  const uint_t cycle,
233  const ushort_pointer_t intensities_p90,
234  const float_pointer_t focus_scores,
236  metric_base::base_cycle_metric(lane, tile, cycle),
237  m_date_time_csharp(date_time),
238  m_date_time(date_time.to_unix()),
239  m_max_intensity_values(intensities_p90, intensities_p90 + channel_count),
240  m_focus_scores(focus_scores, focus_scores + channel_count)
241  {
242  }
253  const uint_t tile,
254  const uint_t cycle,
255  const ushort_array_t& max_intensity_values,
256  const float_array_t& focus_scores) :
257  metric_base::base_cycle_metric(lane, tile, cycle),
258  m_date_time_csharp(0),
259  m_date_time(0),
260  m_max_intensity_values(max_intensity_values),
261  m_focus_scores(focus_scores)
262  {
263  }
264 
277  const uint_t tile,
278  const uint_t cycle,
279  const ::uint16_t* intensity_values,
280  const size_t intensity_count,
281  const float* focus_scores,
282  const size_t focus_count,
283  const size_t /*dummy*/) :
284  metric_base::base_cycle_metric(lane, tile, cycle),
285  m_date_time_csharp(0),
286  m_date_time(0),
287  m_max_intensity_values(intensity_values, intensity_values+intensity_count),
288  m_focus_scores(focus_scores, focus_scores+focus_count)
289  {
290  }
291 
292  public:
303  void set(const uint_t lane,
304  const uint_t tile,
305  const uint_t cycle,
306  const ulong_t date_time,
307  const ushort_array_t& max_intensity_values,
308  const float_array_t& focus_scores)
309  {
310  metric_base::base_cycle_metric::set_base(lane, tile, cycle);
311  m_date_time_csharp = util::csharp_date_time::to_csharp(date_time);
312  m_date_time = date_time;
313  m_max_intensity_values.assign(max_intensity_values.begin(), max_intensity_values.end());
314  m_focus_scores.assign(focus_scores.begin(), focus_scores.end());
315  }
325  void set(const uint_t lane,
326  const uint_t tile,
327  const uint_t cycle,
328  const ushort_array_t& max_intensity_values,
329  const float_array_t& focus_scores)
330  {
331  metric_base::base_cycle_metric::set_base(lane, tile, cycle);
332  m_max_intensity_values.assign(max_intensity_values.begin(), max_intensity_values.end());
333  m_focus_scores.assign(focus_scores.begin(), focus_scores.end());
334  }
335 
336  public:
354  {
355  return m_date_time;
356  }
357 
365  {
366  return m_date_time_csharp;
367  }
375  {
376  return m_date_time_csharp.value;
377  }
378 
385  {
386  INTEROP_BOUNDS_CHECK(channel, m_max_intensity_values.size(), "Channel out of bounds");
387  return m_max_intensity_values[channel];
388  }
389 
396  {
397  INTEROP_BOUNDS_CHECK(channel, m_focus_scores.size(), "Channel out of bounds");
398  return m_focus_scores[channel];
399  }
400 
408  const ushort_array_t &max_intensity_values() const
409  { return m_max_intensity_values; }
410 
417  const float_array_t &focus_scores() const
418  { return m_focus_scores; }
419 
424  size_t channel_count()const
425  {
426  return m_focus_scores.size();
427  }
433  void trim(const size_t channel_count)
434  {
435  m_focus_scores.resize(channel_count);
436  m_max_intensity_values.resize(channel_count);
437  }
444  float focusScore(size_t channel) const
445  {
446  INTEROP_ASSERT(channel < MAX_CHANNELS);
447  INTEROP_ASSERT(m_focus_scores.size() == MAX_CHANNELS);
448  return m_focus_scores[channel];
449  }
450 
457  {
458  return m_date_time;
459  }
460 
468  const float_array_t &focusScores() const
469  { return m_focus_scores; }
474  void date_time(const ulong_t time)
475  {
476  m_date_time=time;
477  m_date_time_csharp = util::csharp_date_time::to_csharp(time);
478  }
479 
484  bool is_any_p90_zero() const
485  {
486  for(size_t channel = 0; channel < channel_count(); ++channel)
487  {
488  if(max_intensity(channel) == 0)
489  return true;
490  }
491  return false;
492  }
493 
494  public:
499  static const char *prefix()
500  { return "Extraction"; }
501 
502  private:
503  util::csharp_date_time m_date_time_csharp;
504  ulong_t m_date_time;
505  ushort_array_t m_max_intensity_values;
506  float_array_t m_focus_scores;
507  template<class MetricType, int Version>
508  friend
509  struct io::generic_layout;
510  };
511 }}}}
512 
513 
size_t channel_count() const
Definition: extraction_metric.h:424
float focusScore(size_t channel) const
Definition: extraction_metric.h:444
const float_array_t & focus_scores() const
Definition: extraction_metric.h:417
extraction_metric()
Definition: extraction_metric.h:115
float focus_score(const size_t channel) const INTEROP_THROW_SPEC((model
Definition: extraction_metric.h:395
const float_array_t & focusScores() const
Definition: extraction_metric.h:468
void channel_count(const size_t channel_count)
Definition: extraction_metric.h:55
ulong_t date_time_csharp_raw() const
Definition: extraction_metric.h:374
Definition: enum_description.h:15
bool is_any_p90_zero() const
Definition: extraction_metric.h:484
uint_t tile() const
Definition: base_metric.h:284
::uint64_t value
Definition: time.h:58
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
static const char * prefix()
Definition: extraction_metric.h:499
extraction_metric_header(ushort_t channel_count)
Definition: extraction_metric.h:45
::uint16_t ushort_t
Definition: base_metric.h:141
extraction_metric(const uint_t lane, const uint_t tile, const uint_t cycle, const ulong_t date_time, const ushort_pointer_t intensities_p90, const float_pointer_t focus_scores, const uint_t channel_count=MAX_CHANNELS)
Definition: extraction_metric.h:175
base_cycle_metric(const uint_t lane=0, const uint_t tile=0, const uint_t cycle=0)
Definition: base_cycle_metric.h:90
extraction_metric(const uint_t lane, const uint_t tile, const uint_t cycle, const ulong_t date_time, const ushort_array_t &intensities_p90, const float_array_t &focus_scores)
Definition: extraction_metric.h:146
uint_t cycle() const
Definition: base_cycle_metric.h:131
ulong_t date_time() const
Definition: extraction_metric.h:353
extraction_metric(const uint_t lane, const uint_t tile, const uint_t cycle, const ushort_array_t &max_intensity_values, const float_array_t &focus_scores)
Definition: extraction_metric.h:252
#define INTEROP_ASSERT(TST)
Definition: assert.h:21
extraction_metric(const uint_t lane, const uint_t tile, const uint_t cycle, const util::csharp_date_time date_time, const ushort_array_t &intensities_p90, const float_array_t &focus_scores)
Definition: extraction_metric.h:200
::uint32_t uint_t
Definition: base_metric.h:77
Definition: generic_layout.h:24
std::vector< ushort_t > ushort_array_t
Definition: extraction_metric.h:101
::uint64_t ulong_t
Definition: base_metric.h:135
::uint16_t ushort_t
Definition: extraction_metric.h:39
uint_t lane() const
Definition: base_metric.h:269
void set_base(const uint_t lane, const uint_t tile)
Definition: base_cycle_metric.h:101
extraction_metric_header header_type
Definition: extraction_metric.h:98
ulong_t dateTime() const
Definition: extraction_metric.h:456
const ushort_array_t & max_intensity_values() const
Definition: extraction_metric.h:408
void date_time(const ulong_t time)
Definition: extraction_metric.h:474
extraction_metric(const header_type &header)
Definition: extraction_metric.h:127
const util::csharp_date_time & date_time_csharp() const
Definition: extraction_metric.h:364
ushort_t channel_count() const
Definition: extraction_metric.h:50
static csharp_date_time to_csharp(const ::uint64_t uval)
Definition: time.cpp:98
#define INTEROP_BOUNDS_CHECK(VALUE, RANGE, MESSAGE)
Definition: exception.h:24
extraction_metric(const uint_t lane, const uint_t tile, const uint_t cycle, const ::uint16_t *intensity_values, const size_t intensity_count, const float *focus_scores, const size_t focus_count, const size_t)
Definition: extraction_metric.h:276
ushort_t max_intensity(const size_t channel) const INTEROP_THROW_SPEC((model
Definition: extraction_metric.h:384
::uint16_t * ushort_pointer_t
Definition: extraction_metric.h:107
void trim(const size_t channel_count)
Definition: extraction_metric.h:433
void set(const uint_t lane, const uint_t tile, const uint_t cycle, const ulong_t date_time, const ushort_array_t &max_intensity_values, const float_array_t &focus_scores)
Definition: extraction_metric.h:303
std::vector< float > float_array_t
Definition: extraction_metric.h:104
static extraction_metric_header default_header()
Definition: extraction_metric.h:63
extraction_metric(const uint_t lane, const uint_t tile, const uint_t cycle, const util::csharp_date_time date_time, const ushort_pointer_t intensities_p90, const float_pointer_t focus_scores, const uint_t channel_count=MAX_CHANNELS)
Definition: extraction_metric.h:229
float * float_pointer_t
Definition: extraction_metric.h:110
void set(const uint_t lane, const uint_t tile, const uint_t cycle, const ushort_array_t &max_intensity_values, const float_array_t &focus_scores)
Definition: extraction_metric.h:325
void clear()
Definition: extraction_metric.h:69