SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fastq.hpp
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2008,2009,2010,2011,2012 Stephan Ossowski, Korbinian Schneeberger,
4  * Felix Ott, Joerg Hagmann, Alf Scotland, Sebastian Bender
5  *
6  * This file is part of SHORE.
7  *
8  * SHORE is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * SHORE is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with SHORE. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
25 
26 #ifndef SHORE_IO_FASTQ_HPP__
27 #define SHORE_IO_FASTQ_HPP__
28 
29 #include <string>
30 
31 #include "shore/fmtio/read.hpp"
32 #include "shore/fmtio/flatread.hpp"
33 #include "shore/fmtio/text.hpp"
35 #include "shore/stream/streams.hpp"
37 
38 namespace shore {
39 
42 {
43  FQ_QUAL_SANGER,FQ_QUAL_ILLUMINA,FQ_QUAL_SOLEXA
44 };
45 
49 {
50  private:
51 
52  shore::basic_line_reader m_reader;
53 
54  FastqQualType m_qualtype;
55 
56  std::string m_idbuf;
57  std::string m_plusbuf;
58  std::vector<std::string> m_tokbuf1;
59  std::vector<std::string> m_tokbuf2;
60  std::string m_seqbuf;
61  std::string m_qualbuf;
62 
63 
64  bool read_entry();
65  void parse(shore::read &read);
66 
67  public:
68 
69  basic_fastq_reader(const std::string &fn);
70  basic_fastq_reader(std::istream *const is);
71 
72  void set_quality_type(const FastqQualType t);
73 
74  bool next(shore::read &r);
75 
76  std::string get_name() const;
77 };
78 
81 
84 
87 {
88  public:
89 
90  enum HeaderType
91  {
92  FQH_SHORE,
93  FQH_SHORE_PE,
94  FQH_ILLUMINA
95  //FQH_SANGER
96  //FQH_SRA
97  };
98 
99  private:
100 
101  shore::ostreams m_os;
102 
103  HeaderType m_htype;
104 
105  std::string m_machine;
106  std::string m_barcode;
107 
108  // report qualities with illumina offset, not sanger
109  bool m_illuminaqual;
110  bool m_writetags;
111 
112  shore::read_reader::rltxy m_rltxybuf;
113 
114  public:
115 
116  typedef shore::read append_type;
117 
118  fastq_writer(const std::string& fn,const HeaderType ht);
119 
121  void set_flowcell(const std::string& machine);
123  void set_barcode(const std::string& bc);
124 
125  void set_writetags(const bool b);
126 
127  void set_illumina_qualities(const bool q);
128 
129  void append(const shore::read& f);
130 
131  void flush();
132 };
133 
136 
142 {
143  private:
144 
145  static const int SANGER_TRF=33;
146 
147  shore::ostreams m_os;
148 
149  public:
150 
151  typedef shore::read append_type;
152 
153  qual_writer(const std::string &fn);
154 
155  void append(const shore::read &f);
156 
157  void flush();
158 };
159 
162 
163 } // namespace
164 
165 #endif // SHORE_IO_FASTQ_HPP__
166