2
* UGENE - Integrated Bioinformatics Tools.
3
* Copyright (C) 2008-2011 UniPro <ugene@unipro.ru>
4
* http://ugene.unipro.ru
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
#ifndef _SMITHWATERMANALGORITHM_H
23
#define _SMITHWATERMANALGORITHM_H
25
#include "PairAlignSequences.h"
27
#include <U2Core/SMatrix.h>
29
#include <QtCore/QVector>
30
#include <QtCore/QByteArray>
34
class SmithWatermanAlgorithm {
37
SmithWatermanAlgorithm();
38
virtual ~SmithWatermanAlgorithm() {};
40
virtual void launch(const SMatrix& m, QByteArray const & _patternSeq,
41
QByteArray const & _searchSeq, int _gapOpen, int _gapExtension, int _minScore);
43
QList<PairAlignSequences> getResults();
44
static void sortByScore(QList<PairAlignSequences> & pairAlignmentStrings);
47
bool calculateMatrixLength();
48
void printMatrix() const;
49
int getRow(int row) const;
51
int maximum(int var1, int var2, int var3, int var4 = 0);
52
void setValues(const SMatrix& _substitutionMatrix,
53
QByteArray const & _patternSeq, QByteArray const & _searchSeq,
54
int _gapOpen, int _gapExtension, int _minScore);
56
QList<PairAlignSequences> pairAlignmentStrings;
58
SMatrix substitutionMatrix;
60
QByteArray patternSeq;
69
QVector<QVector<char> > directionMatrix;
71
void backtrace(int row, int col, int score);
73
static const char STOP;
75
static const char LEFT;
76
static const char DIAG;
78
struct KeyOfPairAlignSeq
80
KeyOfPairAlignSeq(int _score, U2Region const & _intervalSeq1) {
81
setValues(_score, _intervalSeq1);
83
// KeyOfPairAlignSeq(int _score, U2Region const & _intervalSeq1, U2Region const & _intervalSeq2) {
84
// setValues(_score, _intervalSeq1, _intervalSeq2);
87
// KeyOfPairAlignSeq() {
90
// intervalSeq1.startPos = 0;
91
// intervalSeq1.len = 0;
93
// intervalSeq2.startPos = 0;;
94
// intervalSeq2.len = 0;
100
intervalSeq1.startPos = 0;
101
intervalSeq1.length = 0;
105
// static void exchange(KeyOfPairAlignSeq & a, int & pos1, KeyOfPairAlignSeq & b, int & pos2) {
106
// KeyOfPairAlignSeq bufKey;
117
static void exchange(PairAlignSequences & a, PairAlignSequences & b) {
118
PairAlignSequences bufKey;
125
// void setValues(int _score, U2Region const & _intervalSeq1, U2Region const & _intervalSeq2) {
127
// intervalSeq1 = _intervalSeq1;
128
// intervalSeq2 = _intervalSeq2;
131
void setValues(int _score, U2Region const & _intervalSeq1) {
133
intervalSeq1 = _intervalSeq1;
137
U2Region intervalSeq1;
144
QVector<QVector<int> > matrix;
145
QVector<int> EMatrix;
146
QVector<int> FMatrix;
148
void calculateMatrix();