run_summary.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <vector>
11 #include "interop/util/exception.h"
12 #include "interop/util/assert.h"
13 #include "interop/model/run/info.h"
17 
18 namespace illumina { namespace interop { namespace model { namespace summary
19 {
24  {
25  public:
27  typedef std::vector<read_summary> read_summary_vector_t;
28  public:
30  typedef read_summary_vector_t::reference reference;
32  typedef read_summary_vector_t::const_reference const_reference;
34  typedef read_summary_vector_t::iterator iterator;
36  typedef read_summary_vector_t::const_iterator const_iterator;
38  typedef read_summary_vector_t::size_type size_type;
39  public:
42  run_summary() : m_surface_count(0),
43  m_lane_count(0),
44  m_read_count(0),
45  m_channel_count(0),
46  m_total_summary(0),
47  m_nonindex_summary(0)
48  {
49  }
50 
59  template<typename I>
60  run_summary(I beg, I end, const size_t lane_count, const size_t surface_count, const size_t channel_count) :
61  m_surface_count(surface_count),
62  m_lane_count(lane_count),
63  m_read_count(static_cast<size_t>(std::distance(beg, end))),
64  m_channel_count(channel_count),
65  m_total_summary(channel_count),
66  m_nonindex_summary(channel_count),
67  m_summary_by_read(beg, end)
68  {
69  preallocate_memory();
70  }
71 
79  run_summary(const std::vector<run::read_info> &reads,
80  const size_t lane_count,
81  const size_t surface_count,
82  const size_t channel_count) :
83  m_surface_count(surface_count),
84  m_lane_count(lane_count),
85  m_read_count(reads.size()),
86  m_channel_count(channel_count),
87  m_total_summary(channel_count),
88  m_nonindex_summary(channel_count),
89  m_summary_by_read(reads.begin(), reads.end())
90  {
91  preallocate_memory();
92  }
93 
94  public:
99  void initialize(const run::info& run_info)
100  {
101  initialize(run_info.reads(), run_info.flowcell().lane_count(), run_info.flowcell().surface_count(), run_info.channels().size());
102  }
110  void initialize(const std::vector<run::read_info> &reads,
111  const size_t lane_count,
112  const size_t surface_count,
113  const size_t channel_count)
114  {
115  m_total_summary = metric_summary(channel_count);
116  m_nonindex_summary = metric_summary(channel_count);
117  m_cycle_state = cycle_state_summary();
118  m_channel_count = channel_count;
119  m_read_count = reads.size();
120  m_summary_by_read.clear();
121  m_summary_by_read.reserve(reads.size());
122  for (size_t read = 0; read < reads.size(); ++read)
123  m_summary_by_read.push_back(read_summary(reads[read], channel_count));
124  m_lane_count = lane_count;
125  m_surface_count = surface_count;
126  preallocate_memory();
127  }
132  void copy_reads(std::vector<run::read_info> & dst)
133  {
134  dst.resize(size());
135  for(size_t i=0;i<dst.size();++i) dst[i] = m_summary_by_read[i].read();
136  }
137 
138  private:
139  void preallocate_memory()
140  {
141  m_total_summary = metric_summary(m_channel_count);
142  m_nonindex_summary = metric_summary(m_channel_count);
143  m_cycle_state = cycle_state_summary();
144  for (iterator b = m_summary_by_read.begin(), e = m_summary_by_read.end(); b != e; ++b)
145  {
146  b->resize(m_lane_count);
147  b->summary().resize(m_channel_count);
148  for (size_t lane = 0; lane < m_lane_count; ++lane)
149  {
150  b->operator[](lane).lane(lane + 1);
151  b->operator[](lane).resize_stat(m_channel_count);
152  if(m_surface_count > 1)
153  {
154  b->operator[](lane).resize(m_surface_count);
155  for (size_t surface = 0; surface < m_surface_count; ++surface)
156  {
157  b->operator[](lane)[surface].surface(surface + 1);
158  b->operator[](lane)[surface].resize_stat(m_channel_count);
159  }
160  }
161  }
162  }
163  }
164 
165 
166  public:
180  {
181  INTEROP_BOUNDS_CHECK(n, m_summary_by_read.size(), "Read index exceeds read count");
182  return m_summary_by_read[n];
183  }
184 
191  {
192  INTEROP_BOUNDS_CHECK(n, m_summary_by_read.size(), "Read index exceeds read count");
193  return m_summary_by_read[n];
194  }
195 
203  {
204  INTEROP_BOUNDS_CHECK(n, m_summary_by_read.size(), "Read index exceeds read count");
205  return m_summary_by_read[n];
206  }
207 
214  const_reference at(const size_type n) const INTEROP_THROW_SPEC((model::index_out_of_bounds_exception))
215  {
216  INTEROP_BOUNDS_CHECK(n, m_summary_by_read.size(), "Read index exceeds read count");
217  return m_summary_by_read[n];
218  }
219 
224  size_t size() const
225  {
226  return m_summary_by_read.size();
227  }
228 
233  iterator begin()
234  {
235  return m_summary_by_read.begin();
236  }
237 
242  iterator end()
243  {
244  return m_summary_by_read.end();
245  }
246 
251  const_iterator begin() const
252  {
253  return m_summary_by_read.begin();
254  }
255 
260  const_iterator end() const
261  {
262  return m_summary_by_read.end();
263  }
264 
265  public:
270  size_t lane_count() const
271  {
272  return m_lane_count;
273  }
274 
279  void lane_count(const size_t lane_count)
280  {
281  m_lane_count = lane_count;
282  }
287  size_t surface_count() const
288  {
289  return m_surface_count;
290  }
295  size_t channel_count() const
296  {
297  return m_channel_count;
298  }
299 
304  void surface_count(const size_t surface_count)
305  {
306  m_surface_count = surface_count;
307  }
308 
309  public:
315  {
316  return m_total_summary;
317  }
318 
324  {
325  return m_total_summary;
326  }
327 
333  {
334  m_total_summary = summary;
335  }
336 
337  public:
343  {
344  return m_nonindex_summary;
345  }
346 
352  {
353  return m_nonindex_summary;
354  }
355 
361  {
362  m_nonindex_summary = summary;
363  }
364 
365  public:
371  {
372  return m_cycle_state;
373  }
374 
380  {
381  return m_cycle_state;
382  }
386  void clear()
387  {
388  m_summary_by_read.clear();
389  m_lane_count = 0;
390  m_read_count = 0;
391  m_surface_count = 0;
392  m_channel_count = 0;
393  m_total_summary = metric_summary(0);
394  m_nonindex_summary = metric_summary(0);
395  m_cycle_state = cycle_state_summary();
396  }
397 
398  private:
404  void resize()
405  {
406  m_summary_by_read.clear();
407  m_summary_by_read.resize(m_read_count);
408  preallocate_memory();
409  }
410 
411  friend std::ostream& operator<<(std::ostream& out, const run_summary& summary);
412  friend std::istream& operator>>(std::istream& in, run_summary& summary);
413 
414  private:
415  size_t m_surface_count;
416  size_t m_lane_count;
417  size_t m_read_count;
418  size_t m_channel_count;
419 
420  private:
421  metric_summary m_total_summary;
422  metric_summary m_nonindex_summary;
423  cycle_state_summary m_cycle_state;
424 
425  private:
426  read_summary_vector_t m_summary_by_read;
427  template<class MetricType, int Version>
428  friend struct io::generic_layout;
429  };
430 
431 }}}}
432 
metric_summary & nonindex_summary()
Definition: run_summary.h:351
const metric_summary & total_summary() const
Definition: run_summary.h:314
iterator begin()
Definition: run_summary.h:233
Definition: enum_description.h:15
size_t surface_count() const
Definition: run_summary.h:287
void clear()
Definition: run_summary.h:386
Definition: cycle_state_summary.h:18
void initialize(const run::info &run_info)
Definition: run_summary.h:99
run_summary(I beg, I end, const size_t lane_count, const size_t surface_count, const size_t channel_count)
Definition: run_summary.h:60
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
size_t channel_count() const
Definition: run_summary.h:295
read_summary_vector_t::const_iterator const_iterator
Definition: run_summary.h:36
inline::uint32_t surface(const ::uint32_t tile_id, const constants::tile_naming_method method)
Definition: tile_metric.h:93
size_t size() const
Definition: run_summary.h:224
std::vector< read_summary > read_summary_vector_t
Definition: run_summary.h:27
read_summary_vector_t::const_reference const_reference
Definition: run_summary.h:32
read_summary_vector_t::size_type size_type
Definition: run_summary.h:38
run_summary()
Definition: run_summary.h:42
const_iterator begin() const
Definition: run_summary.h:251
uint_t surface_count() const
Definition: flowcell_layout.h:82
read_summary_vector_t::reference reference
Definition: run_summary.h:30
const read_vector_t & reads() const
Definition: info.h:235
def summary(run_metrics, level='Total', columns=None, dtype='f4', ignore_missing_columns=True, extra)
Definition: core.py:217
Definition: generic_layout.h:24
const cycle_state_summary & cycle_state() const
Definition: run_summary.h:370
void total_summary(const metric_summary &summary)
Definition: run_summary.h:332
const flowcell_layout & flowcell() const
Definition: info.h:214
friend std::istream & operator>>(std::istream &in, run_summary &summary)
Definition: run_summary.cpp:230
friend std::ostream & operator<<(std::ostream &out, const run_summary &summary)
Definition: run_summary.cpp:216
read_summary & operator[](const size_t n) INTEROP_THROW_SPEC((model
Definition: run_summary.h:179
void surface_count(const size_t surface_count)
Definition: run_summary.h:304
metric_summary & total_summary()
Definition: run_summary.h:323
def read(run, valid_to_load=None, requires=None, search_paths=None, extra)
Definition: core.py:752
void copy_reads(std::vector< run::read_info > &dst)
Definition: run_summary.h:132
const_iterator end() const
Definition: run_summary.h:260
read_summary & at(const size_t n) INTEROP_THROW_SPEC((model
Definition: run_summary.h:202
#define INTEROP_BOUNDS_CHECK(VALUE, RANGE, MESSAGE)
Definition: exception.h:24
void lane_count(const size_t lane_count)
Definition: run_summary.h:279
cycle_state_summary & cycle_state()
Definition: run_summary.h:379
const read_summary & operator[](const size_t n) const INTEROP_THROW_SPEC((model
Definition: run_summary.h:190
run_summary(const std::vector< run::read_info > &reads, const size_t lane_count, const size_t surface_count, const size_t channel_count)
Definition: run_summary.h:79
size_t lane_count() const
Definition: run_summary.h:270
read_summary_vector_t::iterator iterator
Definition: run_summary.h:34
uint_t lane_count() const
Definition: flowcell_layout.h:75
void initialize(const std::vector< run::read_info > &reads, const size_t lane_count, const size_t surface_count, const size_t channel_count)
Definition: run_summary.h:110
const str_vector_t & channels() const
Definition: info.h:221
iterator end()
Definition: run_summary.h:242
void nonindex_summary(const metric_summary &summary)
Definition: run_summary.h:360
const metric_summary & nonindex_summary() const
Definition: run_summary.h:342
const_reference at(const size_type n) const INTEROP_THROW_SPEC((model
Definition: run_summary.h:214