-
Notifications
You must be signed in to change notification settings - Fork 0
/
align.h
76 lines (65 loc) · 1.98 KB
/
align.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// class of global alignment algorithm of two vectors of strings
#ifndef _ALIGN_H_
#define _ALIGN_H_
#include<string>
#include<vector>
#include<iostream>
#include<math.h>
#include<bitset>
using std::vector;
using std::string;
using std::cout;
using std::cerr;
using std::endl;
struct MtxE{
MtxE():val(-1),prev(-1){}
float val;
int prev;
};
class Alignment{
private:
static const int MaxProSize = 100000; //the maximum problem size to allow
int MyProSize;
//store of the two original sequences
//also we make sure the first seq is always the shortest one
vector< vector<string> > inseqs;
//store of the aligned sequences
vector< vector<string> > otseqs;
vector<string> names;
float FinalScore;
//penalty scores for gap,mismatch and similar
float Gap;
float Mismatch;
float Similar;
float Identical;
float Match;
bool FloatEqual(float A, float B);
int cor_to_ind(int*);//translate cors to index in Mtx
void reset_cor(int*);//reset cors array to 0
float pos_score(MtxE*,int*,bool*);
void RecCal(int lev,int* Cors,MtxE* mtx,vector<int> nzero);
void TraceAln(MtxE*);
void outputScoreMtxHelper(int,int*,MtxE*);
void outputScoreMtx(MtxE* mtx);
public:
Alignment();
//initialize the alignment by specify your own scores
Alignment(float,float,float,float,float);
~Alignment();
bool AddSeq(vector<string> const &);
bool AddSeq(vector<string> const &,string const &);
bool AddSeqs(vector< vector<string> > const &);
bool AddSeqs(vector< vector<string> > const &,vector<string> const &);
//Main function to do the alignment
//Store result in seq1a,seq2a
//Return the normalized score of the alignment
float Align();
//print out the two aligned sequences
void PrintAlignment();
//store the seq1a into 'store' if index == 1, store the seq2a if index == 2
void PrintAlignment(vector<string> & store, int index);
//Input two strings
//Output fraction of the characters that are the same
float Similarity(string a,string b);
};
#endif