SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
flatread.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_FLATREAD_HPP__
27 #define SHORE_IO_FLATREAD_HPP__
28 
29 #include <iostream>
30 #include <vector>
31 #include <set>
32 
36 #include "shore/algo/sort_file.hpp"
37 #include "shore/fmtio/text.hpp"
38 #include "shore/fmtio/sff.hpp"
39 
40 namespace shore {
41 
44 {
45  private:
46 
47  typedef boost::function<void ()> tagfun_t;
49  tagfun_t *m_tagfuns;
50 
51  const char *m_tagbeg;
52  const char *m_tagend;
53 
54  static size_t th(const char *const s);
55 
56  protected:
57 
58  static const size_t MAXTAGS=128*128;
59 
60  shore::read::accessory *m_readtags;
61 
64 
65  void parse_tags(std::string &s);
66 
67  void tagfun_invalid();
68  void tagfun_BAx();
69  void tagfun_DST();
70  void tagfun_CLx();
71  void tagfun_RGR();
72  void tagfun_ORI();
73  void tagfun_NUM();
74 };
75 
79 {
80  private:
81 
82  shore::basic_line_reader m_reader;
83  std::string m_linebuf;
84  std::string m_tagbuf;
85  shore::read::InsertState m_insstate_conv[256];
86 
87  std::string m_readgroup_default;
88  size_t m_cliplen_default;
89  shore::read::InsertState m_pestate_default;
90 
91 
92  void set_default_tags(shore::read &r);
93 
94  public:
95 
96  typedef shore::read current_type;
97 
99  basic_flatread_reader(const std::string& fn);
100  basic_flatread_reader(std::istream *const is);
101 
102  bool next(shore::read &r);
103 
104  const std::string &get_name() const;
105 };
106 
109  shore::read,shore::read::compare_type> flatread_reader;
110 
113 
116 {
117  public:
118 
119  typedef shore::read append_type;
120 
121  private:
122 
123  shore::ostreams m_os;
124  shore::read m_readbuf;
125 
128  shore::sink<flatread_writer> m_thissink;
129 
131  shore::sff_flatten_pipe m_sffflatten;
132 
134  bool m_writetags;
135 
138  bool m_applytags;
139 
141  bool m_discard_qual_aux;
142 
143  public:
144 
145  flatread_writer(const std::string& fn);
146  flatread_writer(std::ostream*const os);
147 
149  void set_writetags(const bool w);
150 
153  void set_applytags(const bool a);
154 
156  void set_discard_qual_aux(const bool b);
157 
158  void append(const shore::read& f);
159  void append(const shore::alignment& f);
160  void append(const shore::sff_read& f);
161 
162  void flush();
163 
165  static std::ostream &write_read(std::ostream &out,
166  const shore::read &e,
167  const bool discard_qual_aux=false);
168 };
169 
171 std::ostream& operator<<(std::ostream& out,const shore::read &e);
172 
175 
176 } // namespace
177 
178 #endif // SHORE_IO_FLATREAD_HPP__
179