~ubuntu-branches/debian/jessie/ugene/jessie

« back to all changes in this revision

Viewing changes to src/plugins/smith_waterman/src/SmithWatermanAlgorithm.h

  • Committer: Package Import Robot
  • Author(s): Steffen Moeller
  • Date: 2011-11-02 13:29:07 UTC
  • mfrom: (1.2.1) (3.1.11 natty)
  • Revision ID: package-import@ubuntu.com-20111102132907-o34gwnt0uj5g6hen
Tags: 1.9.8+repack-1
* First release to Debian
  - added README.Debian
  - increased policy version to 3.9.2
  - added URLs for version control system
* Added debug package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * UGENE - Integrated Bioinformatics Tools.
 
3
 * Copyright (C) 2008-2011 UniPro <ugene@unipro.ru>
 
4
 * http://ugene.unipro.ru
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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,
 
19
 * MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
#ifndef _SMITHWATERMANALGORITHM_H
 
23
#define _SMITHWATERMANALGORITHM_H
 
24
 
 
25
#include "PairAlignSequences.h"
 
26
 
 
27
#include <U2Core/SMatrix.h>
 
28
 
 
29
#include <QtCore/QVector>
 
30
#include <QtCore/QByteArray>
 
31
 
 
32
namespace U2 {
 
33
 
 
34
class SmithWatermanAlgorithm {
 
35
 
 
36
public:
 
37
    SmithWatermanAlgorithm();
 
38
    virtual ~SmithWatermanAlgorithm() {};
 
39
 
 
40
    virtual void launch(const SMatrix& m, QByteArray const & _patternSeq,
 
41
        QByteArray const & _searchSeq, int _gapOpen, int _gapExtension, int _minScore);
 
42
    
 
43
    QList<PairAlignSequences> getResults();
 
44
    static void sortByScore(QList<PairAlignSequences> & pairAlignmentStrings);
 
45
 
 
46
protected:
 
47
    bool calculateMatrixLength();
 
48
    void printMatrix() const;
 
49
    int getRow(int row) const;
 
50
    bool isValidParams();
 
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);
 
55
 
 
56
    QList<PairAlignSequences> pairAlignmentStrings;
 
57
 
 
58
    SMatrix substitutionMatrix;
 
59
 
 
60
    QByteArray patternSeq;
 
61
    QByteArray searchSeq;
 
62
 
 
63
    int gapOpen;
 
64
    int gapExtension;    
 
65
    int minScore;
 
66
    int matrixLength;
 
67
    int storedResults;
 
68
 
 
69
    QVector<QVector<char> > directionMatrix;
 
70
 
 
71
    void backtrace(int row, int col, int score);
 
72
 
 
73
    static const char STOP;
 
74
    static const char UP;
 
75
    static const char LEFT;
 
76
    static const char DIAG;
 
77
 
 
78
    struct KeyOfPairAlignSeq
 
79
    {
 
80
        KeyOfPairAlignSeq(int _score, U2Region const & _intervalSeq1) {
 
81
            setValues(_score, _intervalSeq1);
 
82
        }
 
83
//         KeyOfPairAlignSeq(int _score, U2Region const & _intervalSeq1, U2Region const & _intervalSeq2) {
 
84
//             setValues(_score, _intervalSeq1, _intervalSeq2);
 
85
//         }
 
86
 
 
87
//         KeyOfPairAlignSeq() {
 
88
//             score = 0;
 
89
// 
 
90
//             intervalSeq1.startPos = 0;
 
91
//             intervalSeq1.len = 0;
 
92
// 
 
93
//             intervalSeq2.startPos = 0;;
 
94
//             intervalSeq2.len = 0;
 
95
//         };
 
96
 
 
97
        KeyOfPairAlignSeq() {
 
98
            score = 0;
 
99
 
 
100
            intervalSeq1.startPos = 0;
 
101
            intervalSeq1.length = 0;
 
102
        };
 
103
 
 
104
 
 
105
//         static void exchange(KeyOfPairAlignSeq & a, int & pos1, KeyOfPairAlignSeq & b, int & pos2) {
 
106
//             KeyOfPairAlignSeq bufKey;
 
107
//             int buf;
 
108
// 
 
109
//             buf = pos1;
 
110
//             pos1 = pos2;
 
111
//             pos2 = buf;
 
112
// 
 
113
//             bufKey = a;
 
114
//             a = b;
 
115
//             b = bufKey;
 
116
//         }
 
117
        static void exchange(PairAlignSequences & a, PairAlignSequences & b) {
 
118
            PairAlignSequences bufKey;
 
119
 
 
120
            bufKey = a;
 
121
            a = b;
 
122
            b = bufKey;
 
123
        }
 
124
 
 
125
//         void setValues(int _score, U2Region const & _intervalSeq1, U2Region const & _intervalSeq2) {
 
126
//             score = _score;
 
127
//             intervalSeq1 = _intervalSeq1;
 
128
//             intervalSeq2 = _intervalSeq2;
 
129
//         }
 
130
 
 
131
        void setValues(int _score, U2Region const & _intervalSeq1) {
 
132
            score = _score;
 
133
            intervalSeq1 = _intervalSeq1;            
 
134
        }
 
135
 
 
136
        int score;
 
137
        U2Region intervalSeq1;
 
138
        
 
139
    };
 
140
 
 
141
 
 
142
private:
 
143
 
 
144
    QVector<QVector<int> > matrix;
 
145
    QVector<int> EMatrix;
 
146
    QVector<int> FMatrix;    
 
147
 
 
148
    void calculateMatrix();    
 
149
    
 
150
};
 
151
 
 
152
}//namespace
 
153
 
 
154
#endif