annotate alignCustomAmplicon/utils.cpp @ 5:0aaf65fbb48a draft default tip

Uploaded
author fcaramia
date Wed, 20 Mar 2013 00:22:08 -0400
parents d32bddcff685
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
1 #include <stdio.h>
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
2 #include <string>
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
3 #include <vector>
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
4
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
5 #define max(a,b,c) a > b ? ( a > c ? a : c ) : ( b > c ? b : c ) ;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
6 #define min(a,b,c) a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
7 using namespace std;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
8
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
9 void printMatrix (float* m, int rows, int cols)
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
10 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
11 for(int i = 0; i < rows; i++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
12 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
13 for(int j = 0; j < cols; j++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
14 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
15 printf("%.2f ", *(m + i*cols +j));
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
16 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
17 printf("\n");
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
18 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
19
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
20 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
21
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
22 int levenshteinDistance(string s, string t)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
23 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
24 //Calculate Edit distance of 2 strings
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
25 if(s == t)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
26 return 0;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
27 int size1 = s.length()+1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
28 int size2 = t.length()+1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
29 int d[size1][size2];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
30
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
31 for (int i=0; i<size1; i++)d[i][0] = i;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
32 for (int i=0; i<size2; i++)d[0][i] = i;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
33
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
34 for (int i=1; i<size1; i++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
35 for (int j=1; j<size2; j++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
36 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
37 if(s[i-1] == t[j-1] )
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
38 d[i][j] = d[i-1][j-1]; //if equeal no operation
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
39 else
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
40 d[i][j] = min(d[i-1][j] + 1,d[i][j-1] + 1,d[i-1][j-1] + 1 ); //Addition, deletion or substitution
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
41
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
42 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
43
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
44 return d[size1-1][size2-1]; // return edit distance
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
45 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
46
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
47 float nw_align2 (string &seq1, string &seq2, float matchScore, float missmatch_penalty, float gapPenOpen, float gapPenExt, bool noFrontGapPenalty, bool noEndGapPenalty, bool debug)
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
48 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
49 //Do NW alignment of 2 strings...
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
50 int size1 = seq1.length();
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
51 int size2 = seq2.length();
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
52
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
53 float scores[size1+1][size2+1];
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
54 char dir[size1+1][size2+1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
55 char gaps[size1+1][size2+1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
56
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
57 for(int i = 0; i <= size1; i++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
58 {
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
59 scores[i][0] = (float)(i-1)*gapPenExt + gapPenOpen;
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
60 dir[i][0] = 'U';
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
61 gaps[i][0] = 'D';
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
62 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
63 for(int j = 0; j <= size2; j++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
64 {
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
65 scores[0][j] = (float)(j-1)*gapPenExt + gapPenOpen;
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
66 dir[0][j] = 'L';
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
67 gaps[0][j] = 'I';
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
68 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
69
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
70 scores[0][0] = 0;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
71 gaps[0][0] = 'N';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
72
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
73 if (noFrontGapPenalty)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
74 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
75 for(int i = 0; i <= size1; i++) scores[i][0] = 0;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
76 for(int j = 0; j <= size2; j++) scores[0][j] = 0;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
77 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
78
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
79 float match;
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
80 float del;
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
81 float insert;
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
82
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
83 for(int i = 1; i <= size1; i++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
84 for(int j = 1; j <= size2; j++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
85 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
86 if (seq1[i-1] == 'N' || seq2[j-1] == 'N')
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
87 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
88 match = scores[i-1][j-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
89 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
90 else
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
91 {
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
92 match = scores[i-1][j-1] + (float)(seq1[i-1] == seq2[j-1]? matchScore : missmatch_penalty); //1.9f clustalw
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
93 }
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
94 del = scores[i-1][j] + (gaps[i-1][j] != 'D'? gapPenOpen:gapPenExt);
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
95 insert = scores[i][j-1] + (gaps[i][j-1] != 'I'? gapPenOpen:gapPenExt);
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
96
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
97 //debug
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
98 //if (match == del || match == insert)
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
99 //{
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
100 //printf("I:%d J:%d match = %f del %f insert %f %c %c\n",i,j,match,del,insert,seq1[i-1],seq2[j-1]);
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
101 //}
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
102
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
103 if (match > del && match > insert)
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
104 {
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
105 scores[i][j] = match;
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
106 dir[i][j] = 'D';
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
107 gaps[i][j] = 'N';
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
108 }
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
109 else if(match >= del && match >= insert && seq1[i-1] != seq2[j-1])
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
110 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
111 scores[i][j] = match;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
112 dir[i][j] = 'D';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
113 gaps[i][j] = 'N';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
114 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
115 else if(del > insert)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
116 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
117 scores[i][j] = del;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
118 dir[i][j] = 'U';
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
119 gaps[i][j] = 'D';
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
120 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
121 else
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
122 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
123 scores[i][j] = insert;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
124 dir[i][j] = 'L';
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
125 gaps[i][j] = 'I';
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
126 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
127 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
128
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
129 //debug
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
130 //if (debug)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
131 // printMatrix(*scores, size1+1, size2+1);
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
132 //printMatrix(*dir, size1+1, size2+1);
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
133
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
134 string alignment1="";
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
135 string alignment2="";
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
136
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
137
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
138 int cont1 = size1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
139 int cont2 = size2;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
140 int max1 = size1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
141 int max2 = size2;
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
142 float num = scores[size1][size2];;
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
143
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
144 if (noEndGapPenalty)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
145 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
146 //Search Maxes
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
147
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
148 for(int i = 1; i <= size1; i++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
149 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
150 if(num<scores[i][size2])
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
151 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
152 num = scores[i][size2];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
153 max1 = i;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
154 max2 = size2;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
155 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
156 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
157 for(int j = 1; j <= size2; j++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
158 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
159 if(num<scores[size1][j])
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
160 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
161 num = scores[size1][j];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
162 max1 = size1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
163 max2 = j;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
164 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
165 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
166 cont1 = max1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
167 cont2 = max2;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
168 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
169
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
170 while (cont1 > 0 && cont2 > 0)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
171 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
172 if(dir[cont1][cont2] == 'D')
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
173 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
174 alignment1+= seq1[cont1-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
175 alignment2+= seq2[cont2-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
176 cont1--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
177 cont2--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
178
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
179 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
180 else if(dir[cont1][cont2] == 'L')
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
181 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
182 alignment1+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
183 alignment2+= seq2[cont2-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
184 cont2--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
185 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
186 else
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
187 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
188 alignment1+= seq1[cont1-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
189 alignment2+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
190 cont1--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
191
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
192 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
193 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
194
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
195 while (cont1 > 0)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
196 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
197 alignment1+= seq1[cont1-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
198 alignment2+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
199 cont1--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
200 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
201
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
202 while (cont2 > 0)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
203 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
204 alignment1+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
205 alignment2+= seq2[cont2-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
206 cont2--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
207 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
208
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
209 alignment1 = string (alignment1.rbegin(),alignment1.rend());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
210 alignment2 = string (alignment2.rbegin(),alignment2.rend());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
211
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
212
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
213 if (noEndGapPenalty)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
214 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
215 //Need to fill out rest of alignment...
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
216 if (max1 != size1)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
217 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
218 for (int i=max1; i<size1; ++i )
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
219 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
220 alignment1+= seq1 [i];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
221 alignment2+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
222
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
223 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
224 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
225
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
226 if (max2 != size2)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
227 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
228
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
229 for (int i=max2; i<size2; ++i )
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
230 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
231 alignment2+= seq2 [i];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
232 alignment1+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
233
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
234 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
235 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
236
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
237 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
238 if (debug)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
239 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
240 printf("Seq1: %s\n", alignment1.c_str());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
241 printf("Seq2: %s\n\n", alignment2.c_str());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
242
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
243 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
244
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
245 //Returns
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
246 seq1 = alignment1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
247 seq2 = alignment2;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
248
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
249 return num;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
250
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
251 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
252
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
253 vector <string> nw_alignAlignments (vector<string> a1, vector<string> a2, float matchScore, float missmatch_penalty, float gapPenOpen, float gapPenExt, bool noFrontGapPenalty, bool noEndGapPenalty, bool debug)
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
254 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
255 //Do NW alignment of 2 strings...
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
256 int size1 = a1[0].length();
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
257 int size2 = a2[0].length();
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
258 int v1 = a1.size();
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
259 int v2 = a2.size();
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
260 int combs = v1 * v2;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
261
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
262 vector<string> msa;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
263 msa.clear();
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
264 vector<string> alignment1, alignment2;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
265
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
266 for (int i=0;i<v1;++i)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
267 alignment1.push_back(string());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
268 for (int i=0;i<v2;++i)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
269 alignment2.push_back(string());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
270
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
271
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
272
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
273 float scores[size1+1][size2+1];
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
274 char dir[size1+1][size2+1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
275 char gaps[size1+1][size2+1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
276
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
277 for(int i = 0; i <= size1; i++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
278 {
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
279 scores[i][0] = (float)(i-1)*gapPenExt + gapPenOpen;
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
280 dir[i][0] = 'U';
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
281 gaps[i][0] = 'D';
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
282 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
283 for(int j = 0; j <= size2; j++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
284 {
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
285 scores[0][j] = (float)(j-1)*gapPenExt + gapPenOpen;
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
286 dir[0][j] = 'L';
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
287 gaps[0][j] = 'I';
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
288 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
289
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
290 scores[0][0] = 0;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
291 gaps[0][0] = 'N';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
292
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
293 if (noFrontGapPenalty)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
294 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
295 for(int i = 0; i <= size1; i++) scores[i][0] = 0;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
296 for(int j = 0; j <= size2; j++) scores[0][j] = 0;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
297 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
298
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
299 float match;
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
300 float del;
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
301 float insert;
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
302 bool missmatch;
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
303
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
304 for(int i = 1; i <= size1; i++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
305 for(int j = 1; j <= size2; j++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
306 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
307
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
308 match = del = insert = 0.0f;
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
309 missmatch = true;
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
310 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
311 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
312 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
313 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
314 if (a1[z][i-1] == 'N' || a2[w][j-1] == 'N')
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
315 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
316 match += scores[i-1][j-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
317 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
318 else
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
319 {
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
320 match += scores[i-1][j-1] + (float)(a1[z][i-1] == a2[w][j-1]? matchScore:missmatch_penalty);
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
321 if(a1[z][i-1] == a2[w][j-1])
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
322 {
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
323 missmatch = false;
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
324 }
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
325 }
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
326 del += scores[i-1][j] + (gaps[i-1][j] != 'D'? gapPenOpen:gapPenExt);
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
327 insert += scores[i][j-1] + (gaps[i][j-1] != 'I'? gapPenOpen:gapPenExt);
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
328 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
329 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
330
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
331 match /= combs;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
332 del /= combs;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
333 insert /= combs;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
334
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
335 if (match > del && match > insert)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
336 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
337 scores[i][j] = match;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
338 dir[i][j] = 'D';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
339 gaps[i][j] = 'N';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
340 }
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
341 else if(match >= del && match >= insert && missmatch)
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
342 {
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
343 scores[i][j] = match;
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
344 dir[i][j] = 'D';
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
345 gaps[i][j] = 'N';
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
346 }
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
347 else if(del > insert)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
348 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
349 scores[i][j] = del;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
350 dir[i][j] = 'U';
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
351 gaps[i][j] = 'D';
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
352 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
353 else
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
354 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
355 scores[i][j] = insert;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
356 dir[i][j] = 'L';
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
357 gaps[i][j] = 'I';
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
358 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
359 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
360
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
361 //debug
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
362 // if (debug)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
363 // printMatrix(*scores, size1+1, size2+1);
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
364 //printMatrix(*dir, size1+1, size2+1);
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
365
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
366
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
367 int cont1 = size1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
368 int cont2 = size2;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
369 int max1 = size1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
370 int max2 = size2;
5
0aaf65fbb48a Uploaded
fcaramia
parents: 0
diff changeset
371 float num = scores[size1][size2];
0
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
372
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
373 if (noEndGapPenalty)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
374 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
375 //Search Maxes
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
376
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
377 for(int i = 1; i <= size1; i++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
378 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
379 if(num<scores[i][size2])
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
380 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
381 num = scores[i][size2];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
382 max1 = i;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
383 max2 = size2;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
384 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
385 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
386 for(int j = 1; j <= size2; j++)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
387 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
388 if(num<scores[size1][j])
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
389 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
390 num = scores[size1][j];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
391 max1 = size1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
392 max2 = j;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
393 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
394 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
395 cont1 = max1;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
396 cont2 = max2;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
397 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
398
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
399 while (cont1 > 0 && cont2 > 0)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
400 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
401 if(dir[cont1][cont2] == 'D')
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
402 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
403
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
404 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
405 alignment1[z]+= a1[z][cont1-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
406
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
407 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
408 alignment2[w]+= a2[w][cont2-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
409
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
410 cont1--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
411 cont2--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
412
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
413 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
414 else if(dir[cont1][cont2] == 'L')
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
415 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
416 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
417 alignment1[z]+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
418 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
419 alignment2[w]+= a2[w][cont2-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
420
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
421 cont2--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
422 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
423 else
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
424 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
425 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
426 alignment1[z]+= a1[z][cont1-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
427
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
428 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
429 alignment2[w]+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
430
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
431 cont1--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
432
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
433 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
434 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
435
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
436 while (cont1 > 0)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
437 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
438 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
439 alignment1[z]+= a1[z][cont1-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
440 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
441 alignment2[w]+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
442
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
443 cont1--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
444 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
445
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
446 while (cont2 > 0)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
447 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
448 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
449 alignment1[z]+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
450 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
451 alignment2[w]+= a2[w][cont2-1];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
452
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
453 cont2--;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
454 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
455
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
456
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
457
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
458
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
459 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
460 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
461 alignment1[z] = string (alignment1[z].rbegin(),alignment1[z].rend());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
462 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
463 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
464 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
465 alignment2[w] = string (alignment2[w].rbegin(),alignment2[w].rend());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
466 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
467
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
468
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
469
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
470 if (noEndGapPenalty)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
471 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
472 //Need to fill out rest of alignment...
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
473 if (max1 != size1)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
474 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
475 for (int i=max1; i<size1; ++i )
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
476 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
477 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
478 alignment1[z]+= a1[z][i];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
479 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
480 alignment2[w]+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
481
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
482 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
483 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
484
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
485 if (max2 != size2)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
486 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
487
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
488 for (int i=max2; i<size2; ++i )
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
489 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
490 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
491 alignment1[z]+= '-';
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
492 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
493 alignment2[w]+= a2[w][i];
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
494
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
495 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
496 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
497
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
498 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
499
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
500 //returns
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
501 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
502 msa.push_back(alignment1[z]);
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
503 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
504 msa.push_back(alignment2[w]);
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
505
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
506 if (debug)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
507 {
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
508 for(int z=0;z<v1;++z)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
509 printf("%s\n",alignment1[z].c_str());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
510 for(int w=0;w<v2;++w)
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
511 printf("%s\n",alignment2[w].c_str());
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
512
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
513 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
514
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
515 return msa;
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
516
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
517 }
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
518
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
519
d32bddcff685 Uploaded
fcaramia
parents:
diff changeset
520