yat  0.16.4pre
Aligner.h
1 #ifndef _theplu_yat_utility_aligner_
2 #define _theplu_yat_utility_aligner_
3 
4 // $Id: Aligner.h 3835 2019-08-08 01:36:46Z 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 
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 
195  const_iterator begin(void) const;
196 
200  void clear(void);
201 
209  const_iterator end(void) const;
210 
216  uint32_t length(void) const;
217 
223  uint8_t op(size_t i) const;
224 
231  char opchr(size_t i) const;
232 
236  uint32_t oplen(size_t i) const;
237 
241  void pop_back(uint32_t len=1);
242 
246  void pop_front(uint32_t len=1);
247 
253  void push_back(uint8_t op, uint32_t len=1);
254 
258  void push_front(uint8_t op, uint32_t len=1);
259 
269  uint32_t query_length(void) const;
270 
281  uint32_t reference_length(void) const;
282 
288  void reverse(void);
289 
293  uint32_t operator[](size_t i) const;
294 
298  size_t size(void) const;
299  private:
300  std::deque<uint32_t> cigar_;
301 
302  // calculate length only counting operations whose type is set
303  // in mask, i.e., mask & type returns true
304  uint32_t length(uint8_t mask) const;
305  // using compiler generated copy
306  // Cigar(const Cigar& other);
307  // Cigar& operator=(const Cigar&);
308  };
309 
313  const Cigar cigar(size_t i, size_t j) const;
314 
315  private:
316  direction& directions(size_t i, size_t j);
317 
318  size_t columns_;
319  double vertical_gap_;
320  double open_vertical_gap_;
321  double horizon_gap_;
322  double open_horizon_gap_;
323  std::vector<direction> alignment_;
324  };
325 
326 
334  std::ostream& operator<<(std::ostream& os, const Aligner::Cigar& cigar);
335 
336 }}} // of namespace utility, yat, and theplu
337 
338 #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.
std::ostream & operator<<(std::ostream &os, const Aligner::Cigar &cigar)
The Department of Theoretical Physics namespace as we define it.
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:74
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 Thu Dec 12 2019 03:12:08 for yat by  doxygen 1.8.11