info.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <string>
14 #include <vector>
15 #include "interop/util/exception.h"
22 
23 #ifdef _MSC_VER
24 #pragma warning(push)
25 #pragma warning(disable:4290) // MSVC warns that it ignores the exception specification.
26 #endif
27 
28 namespace illumina { namespace interop { namespace model { namespace run
29 {
30 
35  class info
36  {
37  public:
39  typedef ::uint32_t uint_t;
41  typedef std::vector<std::string> str_vector_t;
43  typedef std::vector<read_info> read_vector_t;
45  typedef read_vector_t::const_iterator const_read_iterator;
46  public:
59  info(const std::string &name = "",
60  const std::string &date = "",
61  const std::string instrument_name="",
62  const size_t run_number=0,
63  const uint_t version = 0,
65  const str_vector_t &channels = str_vector_t(),
66  const image_dimensions &image_dim = image_dimensions(),
67  const read_vector_t &reads = read_vector_t()) :
68  m_name(name),
69  m_date(date),
70  m_instrument_name(instrument_name),
71  m_run_number(run_number),
72  m_version(version),
73  m_flowcell(flowcell),
74  m_channels(channels),
75  m_image_dim(image_dim),
76  m_reads(reads),
77  m_total_cycle_count(0)
78  {
79  m_total_cycle_count = total_cycles();
80  }
81 
89  const read_vector_t &reads=read_vector_t(),
90  const str_vector_t &channels=str_vector_t()) :
91  m_name(""),
92  m_date(""),
93  m_instrument_name(""),
94  m_run_number(0),
95  m_version(3),
96  m_flowcell(flowcell),
97  m_channels(channels),
98  m_image_dim(image_dimensions()),
99  m_reads(reads),
100  m_total_cycle_count(0)
101  {
102  m_total_cycle_count = total_cycles();
103  }
104 
105  public:
119  void read(const std::string &run_folder) INTEROP_THROW_SPEC((xml::xml_file_not_found_exception,
126 
132  void validate()const INTEROP_THROW_SPEC((model::invalid_run_info_exception,model::invalid_tile_naming_method));
137  void validate_tiles()const INTEROP_THROW_SPEC((model::invalid_tile_list_exception));
145  void validate(const ::uint32_t lane, const ::uint32_t tile, const std::string& metric_name)const
146  INTEROP_THROW_SPEC((model::invalid_run_info_exception));
155  void validate_cycle(const ::uint32_t lane, const ::uint32_t tile, const size_t cycle, const std::string& metric_name)const
156  INTEROP_THROW_SPEC((model::invalid_run_info_exception,
166  void validate_read(const ::uint32_t lane, const ::uint32_t tile, const size_t read, const std::string& metric_name)const
167  INTEROP_THROW_SPEC((model::invalid_run_info_exception));
168 
169  public:
174  const std::string &instrument_name() const
175  { return m_instrument_name; }
180  const std::string &flowcell_id() const
181  { return m_flowcell.barcode(); }
186  size_t run_number() const
187  { return m_run_number; }
188 
193  const std::string &name() const
194  { return m_name; }
195 
200  const std::string &date() const
201  { return m_date; }
202 
207  uint_t version() const
208  { return m_version; }
209 
214  const flowcell_layout &flowcell() const
215  { return m_flowcell; }
216 
221  const str_vector_t &channels() const
222  { return m_channels; }
223 
229  { return m_image_dim; }
230 
235  const read_vector_t &reads() const
236  { return m_reads; }
237 
242  bool is_indexed() const
243  {
244  for (read_vector_t::const_iterator b = m_reads.begin(); b != m_reads.end(); ++b)
245  if (b->is_index()) return true;
246  return false;
247  }
252  bool is_paired_end()const
253  {
254  size_t non_index_read_count = 0;
255 
256  for (read_vector_t::const_iterator b = m_reads.begin(), e = m_reads.end(); b != e; ++b)
257  {
258  if (b->is_index()) continue;
259  ++non_index_read_count;
260  }
261  return non_index_read_count > 1;
262  }
268  bool is_last_cycle_of_read(const size_t cycle)const
269  {
270  for (read_vector_t::const_iterator b = m_reads.begin(), e = m_reads.end(); b != e; ++b)
271  if (b->last_cycle() == cycle) return true;
272  return false;
273  }
279  size_t cycle_within_read(const size_t cycle)const
280  {
281  for (read_vector_t::const_iterator b = m_reads.begin(), e = m_reads.end(); b != e; ++b)
282  if ( cycle <= b->last_cycle()) return cycle-b->first_cycle() + 1;
283  return 0;
284  }
285 
291  const read_info &read(const size_t read_number) const INTEROP_THROW_SPEC((model::invalid_read_exception))
292  {
293  for (read_vector_t::const_iterator b = m_reads.begin(), e = m_reads.end(); b != e; ++b)
294  if (b->number() == read_number) return *b;
295  INTEROP_THROW(invalid_read_exception, "Read number not found: " << read_number);
296  }
297 
302  void channels(const str_vector_t &channels)
303  { m_channels = channels; }
304 
309  void reads(const read_vector_t& read_vec)
310  {
311  m_reads = read_vec;
312  m_total_cycle_count = total_cycles();
313  }
314 
320  {
321  m_flowcell.set_naming_method(naming_method);
322  }
327  void flowcell(const flowcell_layout & flowcell)
328  { m_flowcell = flowcell; }
329 
334  size_t total_cycles() const
335  {
336  size_t total = 0;
337  for (read_vector_t::const_iterator b = m_reads.begin(), e = m_reads.end(); b != e; ++b)
338  total += b->total_cycles();
339  return total;
340  }
341 
346  size_t useable_cycles() const
347  {
348  size_t total = 0;
349  for (read_vector_t::const_iterator b = m_reads.begin(), e = m_reads.end(); b != e; ++b)
350  total += b->useable_cycles();
351  return total;
352  }
355  public:
360  void read_file(const std::string &filename) INTEROP_THROW_SPEC((xml::xml_file_not_found_exception,
365 
375 
380  void write(const std::string &filename)const INTEROP_THROW_SPEC((xml::xml_file_not_found_exception,
382 
387  void write(std::ostream& out)const INTEROP_THROW_SPEC((xml::bad_xml_format_exception));
388 
389  private:
390  bool is_bool_attribute_valid(const char c) const;
391 
392  private:
393  std::string m_name;
394  std::string m_date;
395  std::string m_instrument_name;
396  size_t m_run_number;
397  uint_t m_version;
398  flowcell_layout m_flowcell;
399  str_vector_t m_channels;
400  image_dimensions m_image_dim;
401  read_vector_t m_reads;
402  size_t m_total_cycle_count;
403  };
404 
405 }}}}
406 
407 #ifdef _MSC_VER
408 #pragma warning(pop)
409 #endif
410 
411 
::uint32_t uint_t
Definition: info.h:39
size_t useable_cycles() const
Definition: info.h:346
void set_naming_method(const constants::tile_naming_method naming_method)
Definition: info.h:319
Definition: enum_description.h:15
#define INTEROP_THROW_SPEC(SPEC)
Definition: exception_specification.h:15
size_t cycle_within_read(const size_t cycle) const
Definition: info.h:279
bool is_last_cycle_of_read(const size_t cycle) const
Definition: info.h:268
#define INTEROP_THROW(EXCEPTION, MESSAGE)
Definition: exception.h:18
void set_naming_method(const constants::tile_naming_method naming_method)
Definition: flowcell_layout.h:200
uint_t version() const
Definition: info.h:207
void channels(const str_vector_t &channels)
Definition: info.h:302
const read_vector_t & reads() const
Definition: info.h:235
Definition: image_dimensions.h:19
info(const std::string &name="", const std::string &date="", const std::string instrument_name="", const size_t run_number=0, const uint_t version=0, const flowcell_layout &flowcell=flowcell_layout(), const str_vector_t &channels=str_vector_t(), const image_dimensions &image_dim=image_dimensions(), const read_vector_t &reads=read_vector_t())
Definition: info.h:59
const flowcell_layout & flowcell() const
Definition: info.h:214
const image_dimensions & dimensions_of_image() const
Definition: info.h:228
const std::string & name() const
Definition: info.h:193
std::vector< read_info > read_vector_t
Definition: info.h:43
void reads(const read_vector_t &read_vec)
Definition: info.h:309
size_t total_cycles() const
Definition: info.h:334
size_t run_number() const
Definition: info.h:186
std::vector< std::string > str_vector_t
Definition: info.h:41
Definition: base_exception.h:21
read_vector_t::const_iterator const_read_iterator
Definition: info.h:45
info(const flowcell_layout &flowcell, const read_vector_t &reads=read_vector_t(), const str_vector_t &channels=str_vector_t())
Definition: info.h:88
bool is_paired_end() const
Definition: info.h:252
bool is_indexed() const
Definition: info.h:242
Definition: flowcell_layout.h:20
const std::string & instrument_name() const
Definition: info.h:174
const std::string & barcode() const
Definition: flowcell_layout.h:164
const std::string & date() const
Definition: info.h:200
void flowcell(const flowcell_layout &flowcell)
Definition: info.h:327
tile_naming_method
Definition: enums.h:294
const std::string & flowcell_id() const
Definition: info.h:180
Enum parse(const std::string &name)
Definition: enums.h:56
Definition: xml_exceptions.h:18
Definition: xml_exceptions.h:50
const str_vector_t & channels() const
Definition: info.h:221
const read_info & read(const size_t read_number) const INTEROP_THROW_SPEC((model
Definition: info.h:291