SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
gff.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_GFF_HPP__
27 #define SHORE_IO_GFF_HPP__
28 
29 #include <set>
30 #include <map>
31 #include <string>
32 
36 #include "shore/stream/streams.hpp"
37 #include "shore/fmtio/text.hpp"
38 
39 namespace shore {
40 
43 {
44  private:
45 
46  shore::row_reader m_reader;
47 
48  shore::annotation_entry m_current;
49  std::string m_attrbuf;
50 
51 
52  void parse();
53 
54  public:
55 
57 
58  gff_reader(std::istream*const in);
59 
60  gff_reader(const std::string& fn);
61 
62  const shore::annotation_entry& current() const;
63  bool has_data();
64  void next();
65 };
66 
69 
72 {
73  public:
74 
75  static const std::string HEADER;
76 
77  private:
78 
79  shore::ostreams m_os;
80 
81  std::string m_default_source;
82  std::string m_default_type;
83 
85  long m_id;
86  int m_chr;
87 
88  bool m_signed_scores;
89  bool m_enumerate;
90 
91  std::map<int,std::string> m_chrtrans;
92 
94  std::string m_buf;
95 
96  public:
97 
99 
100  gff_writer(const std::string &fn,
101  const std::string& default_type="region",
102  const bool signed_scores=true,const bool enumerate=false);
103 
104  gff_writer(std::ostream*const os,
105  const std::string& default_type="region",
106  const bool signed_scores=true,const bool enumerate=false);
107 
108  void signed_scores(const bool s)
109  {
110  m_signed_scores=s;
111  }
112 
113  void append(const shore::segment &seg);
114  void append(const shore::coverage &cov);
115  void append(const shore::alignment &aln);
116  void append(const shore::annotation_entry &ae);
117  void flush();
118 };
119 
122 
123 } // namespace
124 
125 #endif // SHORE_IO_GFF_HPP__
126