cycle_state_summary.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "interop/util/map.h"
14 
15 
16 namespace illumina { namespace interop { namespace logic { namespace summary
17 {
18 
21 
23  typedef std::vector<std::vector<model::run::cycle_range> > cycle_range_vector2d_t;
24 
25 
34  template<typename Metric>
36  const model::metric_base::metric_set <Metric> &cycle_metrics,
37  const read_cycle_vector_t &cycle_to_read,
38  set_cycle_state_func_t set_cycle_state_fun,
40  {
41  typedef model::run::cycle_range cycle_range;
43  typedef typename model::metric_base::metric_set<Metric>::const_iterator const_metric_iterator;
44  cycle_range_vector2d_t summary_by_lane_read(run.size(), std::vector<cycle_range>(run.lane_count()));
45 
47  typedef INTEROP_UNORDERED_MAP(id_t, cycle_range) cycle_range_tile_t;
48  typedef INTEROP_UNORDERED_MAP(id_t, size_t) max_tile_map_t;
49  typedef typename max_tile_map_t::const_iterator const_max_tile_iterator;
50  typedef std::vector<cycle_range_tile_t> cycle_range_by_read_tile_t;
51  cycle_range_by_read_tile_t tmp(summary_by_lane_read.size());
52  max_tile_map_t tmp_by_tile;
53  cycle_range overall_cycle_state;
54  for (const_metric_iterator cycle_metric_it = cycle_metrics.begin(), cycle_metric_end = cycle_metrics.end();
55  cycle_metric_it != cycle_metric_end; ++cycle_metric_it)
56  {
57  INTEROP_ASSERT(cycle_metric_it->cycle() > 0);
58 
59  INTEROP_BOUNDS_CHECK(cycle_metric_it->cycle()-1, cycle_to_read.size(), "Cycle exceeds number of cycles in RunInfo.xml");
60  const read_cycle &read = cycle_to_read[cycle_metric_it->cycle() - 1];
61  if (read.number == 0) continue;
62  INTEROP_ASSERT((read.number - 1) < tmp.size());
63 
64  const id_t id = cycle_metric_it->tile_hash();
65  tmp[read.number - 1][id].update(cycle_metric_it->cycle());
66  typename max_tile_map_t::iterator it = tmp_by_tile.find(id);
67  if (it == tmp_by_tile.end())
68  tmp_by_tile[id] = cycle_metric_it->cycle();
69  else it->second = std::max(static_cast<size_t>(cycle_metric_it->cycle()), it->second);
70  }
71 
72  // Tile exists, but nothing was written out for that metric on any cycle
73  for (const_tile_iterator tile_it = tile_metrics.begin(), tile_end = tile_metrics.end();
74  tile_it != tile_end; ++tile_it)
75  {
76  size_t cycle_for_tile = 0;
77  const id_t id = model::metric_base::base_metric::create_id(tile_it->lane(), tile_it->tile());
78  for (size_t read_index = 0; read_index < tmp.size(); ++read_index)
79  {
80  if (tmp[read_index].find(tile_it->tile_hash()) == tmp[read_index].end())
81  {
82  tmp[read_index][id].update(run[read_index].read().first_cycle() - 1);
83  tmp_by_tile[id] = 0;
84  }
85  else
86  {
87  cycle_for_tile = tmp[read_index][id].last_cycle();
88  }
89  }
90  tmp_by_tile[id] = cycle_for_tile;
91  }
92  for (size_t read = 0; read < tmp.size(); ++read)
93  {
94  INTEROP_ASSERT(read < summary_by_lane_read.size());
95  for (typename cycle_range_tile_t::const_iterator it = tmp[read].begin(), end = tmp[read].end();
96  it != end; ++it)
97  {
98  const size_t lane = static_cast<size_t>(model::metric_base::base_metric::lane_from_id(it->first) - 1);
99  INTEROP_ASSERT(lane < summary_by_lane_read[read].size());
100  summary_by_lane_read[read][lane].update(it->second.last_cycle());
101  }
102  }
103 
104 
105  for (size_t read = 0; read < run.size(); ++read)
106  {
107  for (size_t lane = 0; lane < run[read].size(); ++lane)
108  {
109  const size_t first_cycle_index_of_read = run[read].read().first_cycle() - 1;
110  const cycle_range cycle_range_within_read =
111  summary_by_lane_read[read][lane] - first_cycle_index_of_read;
112  (run[read][lane].cycle_state().*set_cycle_state_fun)(cycle_range_within_read);
113  }
114  }
115  for (const_max_tile_iterator range_it = tmp_by_tile.begin(), range_end = tmp_by_tile.end();
116  range_it != range_end;
117  ++range_it)
118  overall_cycle_state.update(range_it->second);
119  (run.cycle_state().*set_cycle_state_fun)(overall_cycle_state);
120  }
121 
122 }}}}
123 
::uint32_t id_t
Definition: base_metric.h:74
Definition: enum_description.h:15
Definition: cycle_state_summary.h:18
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
#define INTEROP_UNORDERED_MAP(key_t, value_t)
Definition: map.h:24
static id_t lane_from_id(const id_t id)
Definition: base_metric.h:239
Definition: cycle_range.h:20
static id_t create_id(const id_t lane, const id_t tile, const id_t=0)
Definition: base_metric.h:229
#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
std::vector< std::vector< model::run::cycle_range > > cycle_range_vector2d_t
Definition: cycle_state_summary.h:23
void summarize_cycle_state(const model::metric_base::metric_set< model::metrics::tile_metric > &tile_metrics, const model::metric_base::metric_set< Metric > &cycle_metrics, const read_cycle_vector_t &cycle_to_read, set_cycle_state_func_t set_cycle_state_fun, model::summary::run_summary &run) INTEROP_THROW_SPEC((model
Definition: cycle_state_summary.h:35
def read(run, valid_to_load=None, requires=None, search_paths=None, extra)
Definition: core.py:752
std::vector< read_cycle > read_cycle_vector_t
Definition: map_cycle_to_read.h:39
#define INTEROP_BOUNDS_CHECK(VALUE, RANGE, MESSAGE)
Definition: exception.h:24
void(model::summary::cycle_state_summary::* set_cycle_state_func_t)(const model::run::cycle_range &)
Definition: cycle_state_summary.h:20
metric_array_t::const_iterator const_iterator
Definition: metric_set.h:77