imaging_column.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include <string>
10 #include <iosfwd>
11 #include <vector>
12 #include "interop/util/assert.h"
13 #include "interop/util/length_of.h"
14 #include "interop/util/string.h"
18 
19 
48 #define INTEROP_IMAGING_COLUMN_TYPES \
49  INTEROP_TUPLE7(Lane, metric_base::base_metric, lane, Void, UInt, IdType, 0)\
50  INTEROP_TUPLE7(Tile, metric_base::base_metric, tile, Void, UInt, IdType, 0)\
51  INTEROP_TUPLE7(Cycle, metric_base::base_cycle_metric, cycle/*dummy*/, Void, UInt, IdType, 0)\
52  INTEROP_TUPLE7(Read, metric_base::base_read_metric, read/*dummy*/, Void, UInt, IdType, 0)\
53  INTEROP_TUPLE7(CycleWithinRead, metric_base::base_read_metric, id/*dummy*/, Void, UInt, IdType, 0)\
54  INTEROP_TUPLE7(DensityKPermm2, metrics::tile_metric, cluster_density_k, Void, Float, ValueType, 1)\
55  INTEROP_TUPLE7(DensityPfKPermm2, metrics::tile_metric, cluster_density_pf_k, Void, Float, ValueType, 1)\
56  INTEROP_TUPLE7(ClusterCountK, metrics::tile_metric, cluster_count_k, Void, Float, ValueType, 1)\
57  INTEROP_TUPLE7(ClusterCountPfK, metrics::tile_metric, cluster_count_pf_k, Void, Float, ValueType, 1)\
58  INTEROP_TUPLE7(PercentPassFilter, metrics::tile_metric, percent_pf, Void, Float, ValueType, 1)\
59  INTEROP_TUPLE7(PercentAligned, metrics::tile_metric, percent_aligned_at, Read, Float, ValueType, 1)\
60  INTEROP_TUPLE7(LegacyPhasingRate, metrics::tile_metric, percent_phasing_at, Read, Float, ValueType, 3)\
61  INTEROP_TUPLE7(LegacyPrephasingRate, metrics::tile_metric, percent_prephasing_at, Read, Float, ValueType, 3)\
62  INTEROP_TUPLE7(ErrorRate, metrics::error_metric, error_rate, Void, Float, ValueType, 3)\
63  INTEROP_TUPLE7(PercentGreaterThanQ20, metrics::q_metric, percent_over_qscore, Q20, Float, ValueType, 2)\
64  INTEROP_TUPLE7(PercentGreaterThanQ30, metrics::q_metric, percent_over_qscore, Q30, Float, ValueType, 2)\
65  INTEROP_TUPLE7(P90, metrics::extraction_metric, max_intensity_values, Void, UShort, ChannelArray, 0)\
66  INTEROP_TUPLE7(PercentNoCalls, metrics::corrected_intensity_metric,percent_nocall, Void, Float, ValueType, 1)\
67  INTEROP_TUPLE7(PercentBase, metrics::corrected_intensity_metric,percent_bases, Void, Float, BaseArray, 1)\
68  INTEROP_TUPLE7(Fwhm, metrics::extraction_metric, focus_scores, Void, Float, ChannelArray, 2) \
69  INTEROP_TUPLE7(Corrected, metrics::corrected_intensity_metric,corrected_int_all_array, Void, UShort, BaseArray, 0)\
70  INTEROP_TUPLE7(Called, metrics::corrected_intensity_metric,corrected_int_called_array, Void, UShort, BaseArray, 0)\
71  INTEROP_TUPLE7(SignalToNoise, metrics::corrected_intensity_metric,signal_to_noise, Void, Float, ValueType, 2)\
72  INTEROP_TUPLE7(PhasingWeight, metrics::phasing_metric, phasing_weight, Void, Float, ValueType, 3)\
73  INTEROP_TUPLE7(PrephasingWeight, metrics::phasing_metric, prephasing_weight, Void, Float, ValueType, 3)\
74  INTEROP_TUPLE7(PhasingSlope, metrics::dynamic_phasing_metric, phasing_slope, Void, Float, ValueType, 3)\
75  INTEROP_TUPLE7(PhasingOffset, metrics::dynamic_phasing_metric, phasing_offset, Void, Float, ValueType, 3)\
76  INTEROP_TUPLE7(PrephasingSlope, metrics::dynamic_phasing_metric, prephasing_slope, Void, Float, ValueType, 3)\
77  INTEROP_TUPLE7(PrephasingOffset, metrics::dynamic_phasing_metric, prephasing_offset, Void, Float, ValueType, 3)\
78  INTEROP_TUPLE7(MinimumContrast, metrics::image_metric, min_contrast_array, Void, UShort, ChannelArray, 0)\
79  INTEROP_TUPLE7(MaximumContrast, metrics::image_metric, max_contrast_array, Void, UShort, ChannelArray, 0)\
80  INTEROP_TUPLE7(Surface, metric_base::base_metric, surface, NamingConvention, UInt, IdType, 0)\
81  INTEROP_TUPLE7(Swath, metric_base::base_metric, swath, NamingConvention, UInt, IdType, 0)\
82  INTEROP_TUPLE7(Section, metric_base::base_metric, section, NamingConvention, UInt, IdType, 0)\
83  INTEROP_TUPLE7(TileNumber, metric_base::base_metric, number, NamingConvention, UInt, IdType, 0)\
84  INTEROP_TUPLE7(ClusterCountOccupiedK, metrics::extended_tile_metric, cluster_count_occupied_k, Void, Float, ValueType, 1)\
85  INTEROP_TUPLE7(PercentOccupied, metrics::extended_tile_metric, percent_occupied, Void, Float, ValueType, 1)
86 
87 namespace illumina { namespace interop { namespace model { namespace table
88 {
89 # define INTEROP_TUPLE7(Id, Ignored1, Ignored2, Ignored3, Ignored4, Ignored5, Ignored6) Id##Column,
90 
92 # undef INTEROP_TUPLE7
93 
97  {
98  public:
100  typedef std::vector<std::string> string_vector;
101  public:
103  imaging_column() : m_id(UnknownColumnId), m_offset(0) {}
109  imaging_column(const size_t index, const size_t offset) :
110  m_id(static_cast<column_id>(index)),
111  m_name(to_header(m_id)),
112  m_offset(offset)
113  {
115  }
122  imaging_column(const size_t index, const size_t offset, const string_vector& sub_columns) :
123  m_id(static_cast<column_id>(index)),
124  m_name(to_header(m_id)),
125  m_offset(offset),
126  m_subcolumn_names(sub_columns)
127  {
129  }
130 
131  public:
136  column_id id()const
137  {
138  return m_id;
139  }
144  const std::string& name()const
145  {
146  return m_name;
147  }
152  bool has_children()const
153  {
154  return !m_subcolumn_names.empty();
155  }
160  size_t offset()const
161  {
162  return m_offset;
163  }
168  const string_vector& subcolumns()const
169  {
170  return m_subcolumn_names;
171  }
177  std::string full_name(const size_t sub_index)const INTEROP_THROW_SPEC((model::index_out_of_bounds_exception))
178  {
179  if (has_children())
180  {
181  INTEROP_BOUNDS_CHECK(sub_index, m_subcolumn_names.size(), "SubColumn index out of bounds");
182  return m_name + "_" + m_subcolumn_names[sub_index];
183  }
184  return m_name;
185  }
186 
187  public:
192  void offset(const size_t off)
193  {
194  m_offset = off;
195  }
200  void id(const column_id val)
201  {
202  m_id = val;
203  }
208  void parse_header_for_id(const std::string& header)
209  {
210  id(constants::parse<column_id>(to_name(header)));
211  }
212 
213  public:
218  size_t size()const
219  {
220  return (has_children() ? m_subcolumn_names.size() : 1);
221  }
226  size_t column_count()const
227  {
228  return m_offset + size();
229  }
230 
231  public:
237  static std::string to_header(const column_id id)
238  {
239  return to_header(constants::to_string(id));
240  }
246  static std::string to_header(const std::string& name)
247  {
248  std::string header = name;
249  util::replace(header, "Percent", "%");
250  util::replace(header, "GreaterThan", ">=");
251  util::replace(header, "KPermm2", "(k/mm2)");
252  util::replace(header, "K", " (k)");
253  util::camel_to(header);
254  return header;
255  }
261  static std::string to_name(const std::string& header)
262  {
263  std::string name = header;
264  util::replace(name, "%", "Percent");
265  util::replace(name, ">=", "GreaterThan");
266  util::replace(name, "(k/mm2)", "KPermm2");
267  util::replace(name, " (k)", "K");
268  util::camel_from(name);
269  return name;
270  }
276  static std::string to_name(const model::table::imaging_column& header)
277  {
278  return to_name(header.name());
279  }
280 
281  private:
282  friend std::istream& operator>>(std::istream& in, imaging_column& column);
283  friend std::ostream& operator<<(std::ostream& out, const imaging_column& column);
284 
285  private:
286  column_id m_id;
287  std::string m_name;
288  size_t m_offset;
289  string_vector m_subcolumn_names;
290  };
291 
292 
293 }}}}
294 
void parse_header_for_id(const std::string &header)
Definition: imaging_column.h:208
void offset(const size_t off)
Definition: imaging_column.h:192
size_t size() const
Definition: imaging_column.h:218
Definition: enum_description.h:15
const string_vector & subcolumns() const
Definition: imaging_column.h:168
friend std::ostream & operator<<(std::ostream &out, const imaging_column &column)
Definition: imaging_table_csv.h:49
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
static std::string to_name(const std::string &header)
Definition: imaging_column.h:261
static std::string to_header(const std::string &name)
Definition: imaging_column.h:246
column_id
Definition: imaging_column.h:91
friend std::istream & operator>>(std::istream &in, imaging_column &column)
Definition: imaging_table_csv.h:23
static std::string to_name(const model::table::imaging_column &header)
Definition: imaging_column.h:276
void camel_from(std::string &str, const char sep=' ')
Definition: string.h:74
void camel_to(std::string &str, const std::string &sep=" ")
Definition: string.h:55
imaging_column(const size_t index, const size_t offset, const string_vector &sub_columns)
Definition: imaging_column.h:122
size_t column_count() const
Definition: imaging_column.h:226
#define INTEROP_ASSERT(TST)
Definition: assert.h:21
static std::string to_header(const column_id id)
Definition: imaging_column.h:237
column_id id() const
Definition: imaging_column.h:136
void id(const column_id val)
Definition: imaging_column.h:200
#define INTEROP_IMAGING_COLUMN_TYPES
Definition: imaging_column.h:48
bool replace(std::string &str, const std::string &from, const std::string &to)
Definition: string.h:39
imaging_column()
Definition: imaging_column.h:103
bool has_children() const
Definition: imaging_column.h:152
#define INTEROP_BOUNDS_CHECK(VALUE, RANGE, MESSAGE)
Definition: exception.h:24
const std::string & name() const
Definition: imaging_column.h:144
imaging_column(const size_t index, const size_t offset)
Definition: imaging_column.h:109
#define INTEROP_UNKNOWN
Definition: enums.h:17
std::string full_name(const size_t sub_index) const INTEROP_THROW_SPEC((model
Definition: imaging_column.h:177
size_t offset() const
Definition: imaging_column.h:160
std::vector< std::string > string_vector
Definition: imaging_column.h:100
std::string to_string(Enum value)
Definition: enums.h:43