SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fasta.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_FASTA_HPP__
27 #define SHORE_IO_FASTA_HPP__
28 
29 #include <vector>
30 #include <string>
31 
34 #include "shore/stream/streams.hpp"
36 
38 #include "shore/fmtio/text.hpp"
39 
40 namespace shore {
41 
44 {
45  private:
46 
47  shore::sequence_record m_current;
48 
49  std::string m_strbuf;
50 
51  std::vector<std::string> m_filenames;
52  shore::istreams m_in;
53 
54  boost::shared_ptr<shore::mmapping> m_mmapping;
55 
57  size_t m_sid;
58 
59  bool m_packed;
60 
61  bool m_hasdata;
62 
63  std::string m_tokbuf[2];
64 
65  bool m_shoremode;
66  shore::row_reader *m_rtrans;
67  shore::row_reader *m_rref;
68 
69 
71  void default_load();
73  void shore_load();
74 
75  public:
76 
78 
79  fasta_reader(const std::string& filename,const bool packed=false,
80  const bool loadfirst=true);
81 
82  fasta_reader(const std::vector<std::string>& fn,const bool packed=false,
83  const bool loadfirst=true);
84 
85  ~fasta_reader();
86 
87  bool has_data() const;
88 
89  const shore::sequence_record& current() const;
90 
92  void next();
93 };
94 
97 
100 {
101  private:
102 
103  shore::ostreams m_out;
104 
105  bool m_writetags;
106 
107  public:
108 
110 
111  fasta_writer(const std::string& fn);
112 
113  void set_writetags(const bool b);
114 
115  void append(const shore::sequence_record& r);
116  void append(const shore::read& r);
117  void flush();
118 };
119 
122 
125 
126 } // namespace shore
127 
128 #endif // SHORE_IO_FASTA_HPP__
129