map_cycle_to_read.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <vector>
11 #include <map>
14 
15 namespace illumina { namespace interop { namespace logic { namespace summary
16 {
19  struct read_cycle
20  {
26  read_cycle(const size_t r = 0, const size_t c = 0) : number(r), cycle_within_read(c),
28  { }
29 
31  size_t number;
36  };
37 
39  typedef std::vector<read_cycle> read_cycle_vector_t;
40 
48  template<typename I, typename UnaryOp>
49  void map_read_to_cycle_number(I beg, I end, read_cycle_vector_t &cycle_to_read, UnaryOp op)
50  {
51  cycle_to_read.resize(std::accumulate(beg, end, size_t(0), op::total_cycle_sum<UnaryOp>(op)));
52  std::fill(cycle_to_read.begin(), cycle_to_read.end(), 0);
53  for (; beg != end; ++beg)
54  {
55  for (size_t cycle = op(*beg).first_cycle() - 1, last_cycle = op(*beg).last_cycle(), cycle_in_read = 1;
56  cycle < last_cycle; ++cycle_in_read, ++cycle)
57  {
58  INTEROP_ASSERT(cycle < cycle_to_read.size());
59  cycle_to_read[cycle] = read_cycle(op(*beg).number(), cycle_in_read);
60  }
61  INTEROP_ASSERT((op(*beg).last_cycle() - 1) < cycle_to_read.size());
62  cycle_to_read[op(*beg).last_cycle() - 1].is_last_cycle_in_read = true;
63  }
64  }
65 
72  template<typename I>
73  void map_read_to_cycle_number(I beg, I end, read_cycle_vector_t &cycle_to_read)
74  {
75  map_read_to_cycle_number(beg, end, cycle_to_read, op::default_get_read());
76  }
77 
84  template<class Metric>
86  {
87  if( set.max_cycle() > cycle_to_read.size())
88  {
89  INTEROP_THROW(model::index_out_of_bounds_exception, "Number of expected cycles does not match " << set.prefix() << " metrics");
90  }
91  if( set.size() > 0 && set[set.size()-1].cycle() > cycle_to_read.size())
92  {
93  INTEROP_THROW(model::index_out_of_bounds_exception, "Number of expected cycles does not match " << set.prefix() << " metrics");
94  }
95  }
96 
97 
98 }}}}
99 
static const char * prefix()
Definition: metric_set.h:564
Definition: enum_description.h:15
read_cycle(const size_t r=0, const size_t c=0)
Definition: map_cycle_to_read.h:26
void map_read_to_cycle_number(I beg, I end, read_cycle_vector_t &cycle_to_read, UnaryOp op)
Definition: map_cycle_to_read.h:49
#define INTEROP_THROW(EXCEPTION, MESSAGE)
Definition: exception.h:18
size_t size() const
Definition: metric_set.h:519
bool is_last_cycle_in_read
Definition: map_cycle_to_read.h:35
size_t cycle_within_read
Definition: map_cycle_to_read.h:33
#define INTEROP_ASSERT(TST)
Definition: assert.h:21
def summary(run_metrics, level='Total', columns=None, dtype='f4', ignore_missing_columns=True, extra)
Definition: core.py:217
Definition: map_cycle_to_read.h:19
Definition: summary_statistics.h:254
std::vector< read_cycle > read_cycle_vector_t
Definition: map_cycle_to_read.h:39
size_t number
Definition: map_cycle_to_read.h:31
void validate_cycle_to_read(const model::metric_base::metric_set< Metric > &set, const summary::read_cycle_vector_t &cycle_to_read)
Definition: map_cycle_to_read.h:85