SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
alignment.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_ALIGNMENT_HPP__
27 #define SHORE_IO_ALIGNMENT_HPP__
28 
29 #include <iomanip>
30 #include <iostream>
31 #include <map>
32 #include <set>
33 #include <sstream>
34 #include <stdexcept>
35 #include <string>
36 #include <utility>
37 #include <vector>
38 
39 #include <boost/function.hpp>
40 
45 #include "shore/datatype/coor.hpp"
46 #include "shore/base/memops.hpp"
48 #include "shore/stream/streams.hpp"
49 #include "shore/fmtio/text.hpp"
50 #include "shore/fmtio/sam.hpp"
51 #include "shore/fmtio/read.hpp"
52 
53 namespace shore {
54 
55 
58 {
59  public:
60 
62 
65  struct config
66  {
67  shore::alignment_filter_pipe::config filters;
68 
72 
75 
76  config();
77 
78  void publish_options(shore::av_parser& p,
79  const char*const D="strand,T",
80  const char*const F="duplicate-estimation,F",
81  const char*const N="read-lengths,N",
82  const char*const X="p3fix,X",
83  const char*const B="duplicates,B",
84  const char*const A="assume-length",
85  const char*const R="region,R",
86  const char*const M="mm-range,M",
87  const char*const H="hits-range,H",
88  const char*const samref="sam-refseq",
89  const char*const pe="peflags",
90  const char*const jh="join-happy,Y",
91  const char*const ju="join-unique,U");
92 
93  void sanity_check(shore::av_parser& p);
94 
95  void setup();
96  };
97 
98  enum Sorting
99  {
100  SORTING_POS,
101  SORTING_ID,
102  SORTING_NONE
103  };
104 
105  typedef shore::alignment::cmp_type cmp_type;
106 
107  private:
108 
109  cmp_type m_cmp;
110 
111  config m_conf;
112  static const config m_defaults;
113 
117  shore::ptrkeeper m_cleaner;
118  bool m_outofrange;
119 
120  shore::thru<shore::read> m_leftovers;
121 
122  void init(const std::string& fn);
123  void init(const std::vector<std::string>& fn);
124 
125  public:
126 
127  alignment_reader(const std::string& fn,
128  const config& c=config(),const Sorting s=SORTING_POS);
129 
130  alignment_reader(const std::vector<std::string>& fn,
131  const config& c=config(),const Sorting s=SORTING_POS);
132 
133  alignment_reader(const std::string& fn,
134  const Sorting s);
135 
136  alignment_reader(const std::vector<std::string>& fn,
137  const Sorting s);
138 
140  const shore::alignment& current() const;
141 
143  bool has_data();
144 
146  void next();
147 
149  int current_fileid() const;
150 
153  shore::thru<shore::alignment> &filtered();
154 };
155 
156 typedef shore::source<alignment_reader> alignment_source;
157 
158 } // namespace
159 
160 #endif // SHORE_IO_ALIGNMENT_HPP__
161