yat  0.12.3pre
Aligner.h
1 #ifndef _theplu_yat_utility_aligner_
2 #define _theplu_yat_utility_aligner_
3 
4 // $Id: Aligner.h 3213 2014-05-05 07:51:59Z peter $
5 
6 /*
7  Copyright (C) 2012 Peter Johansson
8  Copyright (C) 2013 Jari Häkkinen, Peter Johansson
9  Copyright (C) 2014 Peter Johansson
10 
11  This file is part of the yat library, http://dev.thep.lu.se/yat
12 
13  The yat library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU General Public License as
15  published by the Free Software Foundation; either version 3 of the
16  License, or (at your option) any later version.
17 
18  The yat library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with yat. If not, see <http://www.gnu.org/licenses/>.
25 */
26 
27 #include <boost/cstdint.hpp>
28 
29 #include <deque>
30 #include <cstddef>
31 #include <iosfwd>
32 #include <vector>
33 
34 namespace theplu {
35 namespace yat {
36 namespace utility {
37 
38  class Matrix;
39 
54  class Aligner
55  {
56  public:
62  enum direction { none, right, down, diagonal };
63 
69  explicit Aligner(double gap=0, double open_gap=0);
70 
90  Aligner(double vertical_gap, double open_vertical_gap,
91  double horizon_gap, double open_horizon_gap);
92 
101  double needleman_wunsch(const Matrix& d);
102 
111  double smith_waterman(const Matrix& d);
112 
129  void operator()(const Matrix& dot, Matrix& score);
130 
137  const direction& alignment(size_t i, size_t j) const;
138 
177  class Cigar
178  {
179  public:
183  void clear(void);
184 
190  uint32_t length(void) const;
191 
197  uint8_t op(size_t i) const;
198 
205  char opchr(size_t i) const;
206 
210  uint32_t oplen(size_t i) const;
211 
215  void pop_back(uint32_t len=1);
216 
220  void pop_front(uint32_t len=1);
221 
227  void push_back(uint8_t op, uint32_t len=1);
228 
232  void push_front(uint8_t op, uint32_t len=1);
233 
243  uint32_t query_length(void) const;
244 
255  uint32_t reference_length(void) const;
256 
260  uint32_t operator[](size_t i) const;
261 
265  size_t size(void) const;
266  private:
267  std::deque<uint32_t> cigar_;
268 
269  // calculate length only counting operations whose type is set
270  // in mask, i.e., mask & type returns true
271  uint32_t length(uint8_t mask) const;
272  // using compiler generated copy
273  // Cigar(const Cigar& other);
274  // Cigar& operator=(const Cigar&);
275  };
276 
280  const Cigar cigar(size_t i, size_t j) const;
281 
282  private:
283  direction& directions(size_t i, size_t j);
284 
285  size_t columns_;
286  double vertical_gap_;
287  double open_vertical_gap_;
288  double horizon_gap_;
289  double open_horizon_gap_;
290  std::vector<direction> alignment_;
291  };
292 
293 
301  std::ostream& operator<<(std::ostream& os, const Aligner::Cigar& cigar);
302 
303 }}} // of namespace utility, yat, and theplu
304 
305 #endif
double smith_waterman(const Matrix &d)
uint32_t oplen(size_t i) const
uint32_t query_length(void) const
Translate CIGAR to a query length.
double needleman_wunsch(const Matrix &d)
const Cigar cigar(size_t i, size_t j) const
void push_back(uint8_t op, uint32_t len=1)
Aligner(double gap=0, double open_gap=0)
Constructor.
uint32_t reference_length(void) const
Translate CIGAR to a reference length.
Aligning two sequences.
Definition: Aligner.h:54
uint32_t operator[](size_t i) const
const direction & alignment(size_t i, size_t j) const
Interface to GSL matrix.
Definition: Matrix.h:63
Compact Idiosyncratic Gapped Alignment Report.
Definition: Aligner.h:177
void operator()(const Matrix &dot, Matrix &score)
calculate score matrix based on the dot matrix
direction
Definition: Aligner.h:62
void push_front(uint8_t op, uint32_t len=1)
uint8_t op(size_t i) const

Generated on Mon Jun 1 2015 12:29:52 for yat by  doxygen 1.8.5