extraction_summary.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <vector>
11 #include "interop/util/exception.h"
17 
18 
19 namespace illumina { namespace interop { namespace logic { namespace summary
20 {
36  template<typename I>
38  I end,
39  const read_cycle_vector_t &cycle_to_read,
40  const size_t channel,
41  const constants::tile_naming_method naming_method,
43  const bool skip_median=false) INTEROP_THROW_SPEC((model::index_out_of_bounds_exception))
44  {
45  typedef typename model::metrics::extraction_metric::ushort_t ushort_t;
46  typedef summary_by_lane_read<ushort_t> summary_by_lane_read_t;
47  if (beg == end) return;
48  if (run.size() == 0)return;
49  const size_t surface_count = run.surface_count();
50  summary_by_lane_read_t read_lane_cache(run, std::distance(beg, end));
51  summary_by_lane_read_t read_lane_surface_cache(run, std::distance(beg, end), surface_count);
52 
53  for (; beg != end; ++beg)
54  {
55  INTEROP_BOUNDS_CHECK(beg->cycle() - 1, cycle_to_read.size(), "Cycle exceeds total cycles from Reads in the RunInfo.xml");
56  const size_t read = cycle_to_read[beg->cycle() - 1].number - 1;
57  if (cycle_to_read[beg->cycle() - 1].cycle_within_read > 1) continue;
58  INTEROP_ASSERT(read < read_lane_cache.read_count());
59  const size_t lane = beg->lane() - 1;
60  INTEROP_BOUNDS_CHECK(lane, read_lane_cache.lane_count(), "Lane exceeds number of lanes in RunInfo.xml");
61  read_lane_cache(read, lane).push_back(beg->max_intensity(channel));
62  if(surface_count < 2) continue;
63  const size_t surface = beg->surface(naming_method);
64  INTEROP_ASSERT(surface > 0);
65  read_lane_surface_cache(read, lane, surface-1).push_back(beg->max_intensity(channel));
66  }
67 
68  float first_cycle_intensity = 0;
69  size_t total = 0;
70  float first_cycle_intensity_nonindex = 0;
71  size_t total_nonindex = 0;
72 
73  for (size_t read = 0; read < run.size(); ++read)
74  {
75  INTEROP_ASSERT(read < read_lane_cache.read_count());
76  INTEROP_ASSERT(read < run.size());
77  float first_cycle_intensity_by_read = 0;
78  size_t total_by_read = 0;
79  model::summary::metric_stat first_cycle_intensity_stat;
80  for (size_t lane = 0; lane < run[read].size(); ++lane)
81  {
82  INTEROP_ASSERT(lane < read_lane_cache.lane_count());
83  INTEROP_ASSERT(lane < run[read].size());
84  summarize(read_lane_cache(read, lane).begin(), read_lane_cache(read, lane).end(), first_cycle_intensity_stat, skip_median);
85  run[read][lane].first_cycle_intensity(first_cycle_intensity_stat);
86  if(surface_count > 1)
87  {
88  for (size_t surface = 0; surface < surface_count; ++surface)
89  {
90  first_cycle_intensity_stat.clear();
91  summarize(read_lane_surface_cache(read, lane, surface).begin(),
92  read_lane_surface_cache(read, lane, surface).end(),
93  first_cycle_intensity_stat, skip_median);
94  run[read][lane][surface].first_cycle_intensity(first_cycle_intensity_stat);
95  }
96  }
97  first_cycle_intensity_by_read += std::accumulate(read_lane_cache(read, lane).begin(),
98  read_lane_cache(read, lane).end(),
99  size_t(0));
100  total_by_read += read_lane_cache(read, lane).size();
101  }
102  run[read].summary().first_cycle_intensity(
103  divide(first_cycle_intensity_by_read, static_cast<float>(total_by_read)));
104  first_cycle_intensity += first_cycle_intensity_by_read;
105  total += total_by_read;
106 
107  if (!run[read].read().is_index()) //Only for non-indexed reads
108  {
109  first_cycle_intensity_nonindex += first_cycle_intensity_by_read;
110  total_nonindex += total_by_read;
111  }
112  }
114  divide(first_cycle_intensity_nonindex, static_cast<float>(total_nonindex)));
115 
116  run.total_summary().first_cycle_intensity(divide(first_cycle_intensity, static_cast<float>(total)));
117  }
118 
119 }}}}
120 
const metric_summary & total_summary() const
Definition: run_summary.h:314
Definition: enum_description.h:15
size_t surface_count() const
Definition: run_summary.h:287
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
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
::uint16_t ushort_t
Definition: base_metric.h:141
#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
void summarize(I beg, I end, S &stat, const bool skip_median)
Definition: summary_statistics.h:149
void clear()
Definition: metric_stat.h:37
def read(run, valid_to_load=None, requires=None, search_paths=None, extra)
Definition: core.py:752
float first_cycle_intensity() const
Definition: metric_summary.h:68
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
tile_naming_method
Definition: enums.h:294
void summarize_extraction_metrics(I beg, I end, const read_cycle_vector_t &cycle_to_read, const size_t channel, const constants::tile_naming_method naming_method, model::summary::run_summary &run, const bool skip_median=false) INTEROP_THROW_SPEC((model
Definition: extraction_summary.h:37
float divide(const float num, const float div)
Definition: summary_statistics.h:231
const metric_summary & nonindex_summary() const
Definition: run_summary.h:342