yat  0.12.3pre
SmithWaterman.h
1 #ifndef _theplu_yat_utility_smith_waterman
2 #define _theplu_yat_utility_smith_waterman
3 
4 // $Id: SmithWaterman.h 3338 2014-11-05 12:10:16Z peter $
5 
6 /*
7  Copyright (C) 2014 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include "Aligner.h"
26 #include "Matrix.h"
27 
28 #include <cstddef> // size_t
29 
30 namespace theplu {
31 namespace yat {
32 namespace utility {
33 
38  {
39  public:
45  explicit SmithWaterman(double gap=0, double open_gap=0);
46 
63  SmithWaterman(double vertical_gap, double open_vertical_gap,
64  double horizon_gap, double open_horizon_gap);
65 
74  const Aligner::Cigar& cigar(void) const;
75 
80  size_t position(void) const;
81 
85  const Matrix& score(void) const;
86 
93  double operator()(const Matrix& dot);
94 
100  template<typename RandomAccessIterator1, typename RandomAccessIterator2>
101  double operator()(RandomAccessIterator1 reference_begin,
102  RandomAccessIterator1 reference_end,
103  RandomAccessIterator2 query_begin,
104  RandomAccessIterator2 query_end,
105  double mismatch=0);
106 
107  private:
108  Aligner aligner_;
109  Aligner::Cigar cigar_;
110  size_t position_;
111  Matrix score_;
112  };
113 
114  // template implementaion
115 
116  template<typename RandomAccessIterator1, typename RandomAccessIterator2>
117  double SmithWaterman::operator()(RandomAccessIterator1 reference_begin,
118  RandomAccessIterator1 reference_end,
119  RandomAccessIterator2 query_begin,
120  RandomAccessIterator2 query_end,
121  double mismatch)
122  {
123  Matrix dot(reference_end-reference_begin, query_end-query_begin, -mismatch);
124  for (size_t i=0; i<dot.rows(); ++i)
125  for (size_t j=0; j<dot.columns(); ++j)
126  if (reference_begin[i] == query_begin[j])
127  dot(i, j) = 1;
128  return this->operator()(dot);
129  }
130 
131 }}} // of namespace utility, yat, and theplu
132 
133 #endif
double operator()(const Matrix &dot)
size_t rows(void) const
SmithWaterman(double gap=0, double open_gap=0)
Constructor.
Aligning two sequences.
Definition: Aligner.h:54
Definition: SmithWaterman.h:37
Interface to GSL matrix.
Definition: Matrix.h:63
Compact Idiosyncratic Gapped Alignment Report.
Definition: Aligner.h:177
const Matrix & score(void) const
const Aligner::Cigar & cigar(void) const
size_t columns(void) const

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