yat  0.14.5pre
Aligner.h
1 #ifndef _theplu_yat_utility_aligner_
2 #define _theplu_yat_utility_aligner_
3 
4 // $Id: Aligner.h 3462 2016-01-27 06:51:39Z peter $
5 
6 /*
7  Copyright (C) 2012 Peter Johansson
8  Copyright (C) 2013 Jari Häkkinen, Peter Johansson
9  Copyright (C) 2014, 2016 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 "CigarIterator.h"
28 
29 #include <boost/cstdint.hpp>
30 
31 #include <deque>
32 #include <cstddef>
33 #include <iosfwd>
34 #include <vector>
35 
36 namespace theplu {
37 namespace yat {
38 namespace utility {
39 
40  class Matrix;
41 
56  class Aligner
57  {
58  public:
64  enum direction { none, right, down, diagonal };
65 
71  explicit Aligner(double gap=0, double open_gap=0);
72 
92  Aligner(double vertical_gap, double open_vertical_gap,
93  double horizon_gap, double open_horizon_gap);
94 
103  double needleman_wunsch(const Matrix& d);
104 
113  double smith_waterman(const Matrix& d);
114 
131  void operator()(const Matrix& dot, Matrix& score);
132 
139  const direction& alignment(size_t i, size_t j) const;
140 
179  class Cigar
180  {
181  public:
185  typedef
187 
193  const_iterator begin(void) const;
194 
198  void clear(void);
199 
205  const_iterator end(void) const;
206 
212  uint32_t length(void) const;
213 
219  uint8_t op(size_t i) const;
220 
227  char opchr(size_t i) const;
228 
232  uint32_t oplen(size_t i) const;
233 
237  void pop_back(uint32_t len=1);
238 
242  void pop_front(uint32_t len=1);
243 
249  void push_back(uint8_t op, uint32_t len=1);
250 
254  void push_front(uint8_t op, uint32_t len=1);
255 
265  uint32_t query_length(void) const;
266 
277  uint32_t reference_length(void) const;
278 
284  void reverse(void);
285 
289  uint32_t operator[](size_t i) const;
290 
294  size_t size(void) const;
295  private:
296  std::deque<uint32_t> cigar_;
297 
298  // calculate length only counting operations whose type is set
299  // in mask, i.e., mask & type returns true
300  uint32_t length(uint8_t mask) const;
301  // using compiler generated copy
302  // Cigar(const Cigar& other);
303  // Cigar& operator=(const Cigar&);
304  };
305 
309  const Cigar cigar(size_t i, size_t j) const;
310 
311  private:
312  direction& directions(size_t i, size_t j);
313 
314  size_t columns_;
315  double vertical_gap_;
316  double open_vertical_gap_;
317  double horizon_gap_;
318  double open_horizon_gap_;
319  std::vector<direction> alignment_;
320  };
321 
322 
330  std::ostream& operator<<(std::ostream& os, const Aligner::Cigar& cigar);
331 
332 }}} // of namespace utility, yat, and theplu
333 
334 #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
const_iterator begin(void) const
void push_back(uint8_t op, uint32_t len=1)
Aligner(double gap=0, double open_gap=0)
Constructor.
Iterator over a CIGAR.
Definition: CigarIterator.h:60
CigarIterator< std::deque< uint32_t >::const_iterator > const_iterator
Definition: Aligner.h:186
uint32_t reference_length(void) const
Translate CIGAR to a reference length.
Aligning two sequences.
Definition: Aligner.h:56
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:179
void operator()(const Matrix &dot, Matrix &score)
calculate score matrix based on the dot matrix
direction
Definition: Aligner.h:64
const_iterator end(void) const
void push_front(uint8_t op, uint32_t len=1)
uint8_t op(size_t i) const
void reverse(void)
reverse the CIGAR

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5