check_imaging_table_column.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include <vector>
10 #include "interop/util/exception.h"
18 
19 namespace illumina { namespace interop { namespace logic { namespace table
20 {
24  {
25  typedef model::metrics::q_metric::uint_t uint_t;
26  enum VoidType
27  {
28  Void
29  };
30  public:
36  static void set_id_filled(std::vector<bool> &filled)
37  {
40  true);
42  true);
43  }
44 
51  template<class MetricSet>
52  static void
53  set_filled_for_metric_set(const MetricSet &metrics, std::vector<bool> &filled, const bool force_true = false)
54  {
55  /* For every entry in INTEROP_IMAGING_COLUMN_TYPES
56  * Add a method call to set a boolean flag to true if the column is occupied by values
57  *
58  * Example:
59  * INTEROP_TUPLE7(Lane, metric_base::base_metric, lane, Void, UInt, IdType,0) ->
60  *
61  * set_filled_laneVoid(metrics, filled, force);
62  */
63 # define INTEROP_TUPLE7(Ignore1, Ignore2, Method, Param, Ignore4, Ignore5, Ignored6) set_filled_##Method##Param(metrics, filled, force_true);
65 # undef INTEROP_TUPLE7 // Reuse this for another conversion
66  }
67 
80  template<class Metric>
81  static void set_filled_for_metric(const Metric &metric,
82  const size_t read,
83  const size_t q20_idx,
84  const size_t q30_idx,
85  const constants::tile_naming_method naming_method,
86  std::vector<bool> &filled)
87  {
88  /* For every entry in INTEROP_IMAGING_COLUMN_TYPES
89  * Add a method call to set a boolean flag to true if the column is occupied by valid values
90  *
91  * Example:
92  * INTEROP_TUPLE7(Lane, metric_base::base_metric, lane, Void, UInt, IdType, 0) ->
93  *
94  * set_filled_metric_laneVoid(metric, read, q20_idx, q30_idx, naming_method, filled);
95  */
96 # define INTEROP_TUPLE7(Ignore1, Ignore2, Method, Param, Ignore4, Ignore5, Ignored6) \
97  set_filled_metric_##Method##Param(metric, read, static_cast<uint_t>(q20_idx), static_cast<uint_t>(q30_idx), naming_method, filled);
99 # undef INTEROP_TUPLE7 // Reuse this for another conversion
100  }
101 
106  static uint32_t max_digits()
107  {
108 # define INTEROP_TUPLE7(Ignored0, Ignored1, Ignored2, Ignored3, Ignored4, Ignored5, Round) Round,
109  uint32_t digits[] = { INTEROP_IMAGING_COLUMN_TYPES 0};
110 # undef INTEROP_TUPLE7
111  uint32_t max_digit = 0;
112  for(size_t i=0;i<util::length_of(digits);++i)
113  max_digit = std::max(max_digit, digits[i]);
114  return max_digit;
115  }
116 
117  private:
118  /* For every entry in INTEROP_IMAGING_COLUMN_TYPES
119  * This macro creates two functions, one to set the filled array to true if the metric set is not empty
120  * and the other does nothing.
121  *
122  * Example:
123  * INTEROP_TUPLE7(Lane, metric_base::base_metric, lane, Void, UInt, IdType, 0) ->
124  *
125  * static void set_filled_laneVoid(const metric_base::metric_set<Metric>& metrics, std::vector<bool>& filled, const bool force_true)
126  * static void set_filled_laneVoid(const model::metric_base::empty_header&, std::vector<bool>&, const bool)
127  *
128  */
129 # define INTEROP_TUPLE7(Id, Metric, Method, Param, Ignored1, Ignored2, Ignored3) \
130  static void set_filled_##Method##Param(const model::metric_base::metric_set<model:: Metric>& metrics, std::vector<bool>& filled, const bool force_true)\
131  {\
132  filled[model::table::Id##Column] = (force_true) ? true : metrics.size()>0;\
133  }\
134  static void set_filled_##Method##Param(const model::metric_base::empty_header&, std::vector<bool>&, const bool){}
136 # undef INTEROP_TUPLE7 // Reuse this for another conversion
137 
138  private:
139  /* For every entry in INTEROP_IMAGING_COLUMN_TYPES
140  * This macro creates two functions, one to mark a column as filled if there is at least one valid metric
141  *
142  * Example:
143  * INTEROP_TUPLE7(Lane, metric_base::base_metric, lane, Void, UInt, IdType, 0) ->
144  *
145  * static void set_filled_metric_laneVoid(const Metric& metric,
146  * const size_t Read,
147  * const uint_t Q20,
148  * const uint_t Q30,
149  * const constants::tile_naming_method NamingConvention,
150  * std::vector<bool>& filled)
151  * static void set_filled_metric_laneVoid(const model::metric_base::empty_metric&
152  * const size_t,
153  * const uint_t,
154  * const uint_t,
155  * const constants::tile_naming_method,
156  * std::vector<bool>&)
157  */
158 # define INTEROP_TUPLE7(Id, Metric, Method, Param, Ignored1, Ignored2, Ignored3) \
159  static void set_filled_metric_##Method##Param(const model::Metric& metric,\
160  const size_t Read,\
161  const uint_t Q20,\
162  const uint_t Q30,\
163  const constants::tile_naming_method NamingConvention,\
164  std::vector<bool>& filled)\
165  {\
166  if(is_valid(call_adapter(metric, Param, &model:: Metric::Method))) filled[model::table::Id##Column] = true;\
167  (void)Q20;(void)Q30;(void)NamingConvention;(void)Read;\
168  }\
169  static void set_filled_metric_##Method##Param(const model::metric_base::empty_metric&,\
170  const size_t,\
171  const uint_t,\
172  const uint_t,\
173  const constants::tile_naming_method,\
174  std::vector<bool>&){}
176 # undef INTEROP_TUPLE7 // Reuse this for another conversion
177 
178  private:
184  static bool is_valid(const float val)
185  {
186  return !std::isnan(val);
187  }
188 
194  template<typename T>
195  static bool is_valid(const T val)
196  {
197  return val < std::numeric_limits<T>::max();
198  }
199 
205  template<typename T>
206  static bool is_valid(const std::vector <T> &values)
207  {
208  return !values.empty();
209  }
210  };
211 }}}}
212 
Definition: check_imaging_table_column.h:23
Definition: enum_description.h:15
static uint32_t max_digits()
Definition: check_imaging_table_column.h:106
static void set_id_filled(std::vector< bool > &filled)
Definition: check_imaging_table_column.h:36
::uint32_t uint_t
Definition: base_metric.h:77
#define INTEROP_IMAGING_COLUMN_TYPES
Definition: imaging_column.h:48
def read(run, valid_to_load=None, requires=None, search_paths=None, extra)
Definition: core.py:752
Definition: enums.h:301
size_t length_of(const T &val)
Definition: length_of.h:55
static void set_filled_for_metric(const Metric &metric, const size_t read, const size_t q20_idx, const size_t q30_idx, const constants::tile_naming_method naming_method, std::vector< bool > &filled)
Definition: check_imaging_table_column.h:81
static void set_filled_for_metric_set(const MetricSet &metrics, std::vector< bool > &filled, const bool force_true=false)
Definition: check_imaging_table_column.h:53
tile_naming_method
Definition: enums.h:294