yat  0.18.2pre
Aligner.h
1 #ifndef _theplu_yat_utility_aligner_
2 #define _theplu_yat_utility_aligner_
3 
4 // $Id: Aligner.h 3847 2019-09-22 23:39:13Z peter $
5 
6 /*
7  Copyright (C) 2012 Peter Johansson
8  Copyright (C) 2013 Jari Häkkinen, Peter Johansson
9  Copyright (C) 2014, 2016, 2019 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 
134  void operator()(const Matrix& dot, Matrix& score);
135 
142  const direction& alignment(size_t i, size_t j) const;
143 
182  class Cigar
183  {
184  public:
188  typedef
190 
198  const_iterator begin(void) const;
199 
203  void clear(void);
204 
212  const_iterator end(void) const;
213 
219  uint32_t length(void) const;
220 
226  uint8_t op(size_t i) const;
227 
234  char opchr(size_t i) const;
235 
239  uint32_t oplen(size_t i) const;
240 
244  void pop_back(uint32_t len=1);
245 
249  void pop_front(uint32_t len=1);
250 
256  void push_back(uint8_t op, uint32_t len=1);
257 
261  void push_front(uint8_t op, uint32_t len=1);
262 
272  uint32_t query_length(void) const;
273 
284  uint32_t reference_length(void) const;
285 
291  void reverse(void);
292 
296  uint32_t operator[](size_t i) const;
297 
301  size_t size(void) const;
302  private:
303  std::deque<uint32_t> cigar_;
304 
305  // calculate length only counting operations whose type is set
306  // in mask, i.e., mask & type returns true
307  uint32_t length(uint8_t mask) const;
308  // using compiler generated copy
309  // Cigar(const Cigar& other);
310  // Cigar& operator=(const Cigar&);
311  };
312 
316  const Cigar cigar(size_t i, size_t j) const;
317 
318  private:
319  direction& directions(size_t i, size_t j);
320 
321  size_t columns_;
322  double vertical_gap_;
323  double open_vertical_gap_;
324  double horizon_gap_;
325  double open_horizon_gap_;
326  std::vector<direction> alignment_;
327  };
328 
329 
337  std::ostream& operator<<(std::ostream& os, const Aligner::Cigar& cigar);
338 
339 }}} // of namespace utility, yat, and theplu
340 
341 #endif
double smith_waterman(const Matrix &d)
const direction & alignment(size_t i, size_t j) const
The Department of Theoretical Physics namespace as we define it.
double needleman_wunsch(const Matrix &d)
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:189
Aligning two sequences.
Definition: Aligner.h:56
uint32_t reference_length(void) const
Translate CIGAR to a reference length.
uint32_t operator[](size_t i) const
const Cigar cigar(size_t i, size_t j) const
uint32_t oplen(size_t i) const
const_iterator end(void) const
const_iterator begin(void) const
Interface to GSL matrix.
Definition: Matrix.h:74
Compact Idiosyncratic Gapped Alignment Report.
Definition: Aligner.h:182
void operator()(const Matrix &dot, Matrix &score)
calculate score matrix based on the dot matrix
uint32_t query_length(void) const
Translate CIGAR to a query length.
direction
Definition: Aligner.h:64
void push_front(uint8_t op, uint32_t len=1)
void reverse(void)
reverse the CIGAR

Generated on Tue Sep 7 2021 17:32:32 for yat by  doxygen 1.8.14