yat  0.13.2pre
Aligner.h
1 #ifndef _theplu_yat_utility_aligner_
2 #define _theplu_yat_utility_aligner_
3 
4 // $Id: Aligner.h 3336 2014-10-24 23:27:45Z 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 "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 
282  uint32_t operator[](size_t i) const;
283 
287  size_t size(void) const;
288  private:
289  std::deque<uint32_t> cigar_;
290 
291  // calculate length only counting operations whose type is set
292  // in mask, i.e., mask & type returns true
293  uint32_t length(uint8_t mask) const;
294  // using compiler generated copy
295  // Cigar(const Cigar& other);
296  // Cigar& operator=(const Cigar&);
297  };
298 
302  const Cigar cigar(size_t i, size_t j) const;
303 
304  private:
305  direction& directions(size_t i, size_t j);
306 
307  size_t columns_;
308  double vertical_gap_;
309  double open_vertical_gap_;
310  double horizon_gap_;
311  double open_horizon_gap_;
312  std::vector<direction> alignment_;
313  };
314 
315 
323  std::ostream& operator<<(std::ostream& os, const Aligner::Cigar& cigar);
324 
325 }}} // of namespace utility, yat, and theplu
326 
327 #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:56
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

Generated on Wed Jan 4 2017 02:23:07 for yat by  doxygen 1.8.5