1 | #include "mltaln.h" |
---|
2 | |
---|
3 | |
---|
4 | void profilealignment2( int n0, int n2, char **aln0, char **aln2, int alloclen, char alg ) // n1 ha allgap |
---|
5 | { |
---|
6 | int i, newlen; |
---|
7 | double *effarr0, *effarr2; |
---|
8 | float dumfl; |
---|
9 | double eff; |
---|
10 | effarr0 = AllocateDoubleVec( n0 ); |
---|
11 | effarr2 = AllocateDoubleVec( n2 ); |
---|
12 | |
---|
13 | commongappick( n0, aln0 ); |
---|
14 | commongappick( n2, aln2 ); |
---|
15 | |
---|
16 | eff = 1.0 / (double)n0; for( i=0; i<n0; i++ ) effarr0[i] = eff; |
---|
17 | eff = 1.0 / (double)n2; for( i=0; i<n2; i++ ) effarr2[i] = eff; |
---|
18 | |
---|
19 | newgapstr = "-"; |
---|
20 | if( alg == 'M' ) |
---|
21 | MSalignmm( aln0, aln2, effarr0, effarr2, n0, n2, alloclen, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0 ); //outgap=1?? |
---|
22 | else |
---|
23 | A__align( aln0, aln2, effarr0, effarr2, n0, n2, alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0 ); //outgap=1?? |
---|
24 | |
---|
25 | newlen = strlen( aln0[0] ); |
---|
26 | |
---|
27 | #if 0 // tabun hitsuyou |
---|
28 | for( j=0; j<newlen; j++ ) |
---|
29 | { |
---|
30 | // fprintf( stderr, "j=%d\n", j ); |
---|
31 | for( i=0; i<n0; i++ ) |
---|
32 | { |
---|
33 | if( aln0[i][j] != '-' ) break; |
---|
34 | } |
---|
35 | if( i == n0 ) |
---|
36 | { |
---|
37 | for( i=0; i<n1; i++ ) |
---|
38 | { |
---|
39 | if( aln1[i][j] != '-' ) break; |
---|
40 | } |
---|
41 | } |
---|
42 | else i = -1; |
---|
43 | |
---|
44 | if( i == n1 ) |
---|
45 | { |
---|
46 | for( i=0; i<n1; i++ ) aln1[i][j] = '='; |
---|
47 | } |
---|
48 | } |
---|
49 | fprintf( stderr, "in profilealignment,\n" ); |
---|
50 | for( i=0; i<n0; i++ ) fprintf( stderr, "\n>aln0[%d] = \n%s\n", i, aln0[i] ); |
---|
51 | for( i=0; i<n1; i++ ) fprintf( stderr, "\n>aln1[%d] = \n%s\n", i, aln1[i] ); |
---|
52 | for( i=0; i<n2; i++ ) fprintf( stderr, "\n>aln2[%d] = \n%s\n", i, aln2[i] ); |
---|
53 | #endif |
---|
54 | |
---|
55 | free( effarr0 ); |
---|
56 | free( effarr2 ); |
---|
57 | } |
---|
58 | |
---|
59 | void profilealignment( int n0, int n1, int n2, char **aln0, char **aln1, char **aln2, int alloclen, char alg ) // n1 ha allgap |
---|
60 | { |
---|
61 | int i, j, newlen; |
---|
62 | double *effarr0, *effarr2; |
---|
63 | float dumfl; |
---|
64 | double eff; |
---|
65 | effarr0 = AllocateDoubleVec( n0 ); |
---|
66 | effarr2 = AllocateDoubleVec( n2 ); |
---|
67 | |
---|
68 | commongappick( n0, aln0 ); |
---|
69 | commongappick( n2, aln2 ); |
---|
70 | |
---|
71 | eff = 1.0 / (double)n0; for( i=0; i<n0; i++ ) effarr0[i] = eff; |
---|
72 | eff = 1.0 / (double)n2; for( i=0; i<n2; i++ ) effarr2[i] = eff; |
---|
73 | |
---|
74 | newgapstr = "-"; |
---|
75 | if( alg == 'M' ) |
---|
76 | MSalignmm( aln0, aln2, effarr0, effarr2, n0, n2, alloclen, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0 ); //outgap=1?? |
---|
77 | else |
---|
78 | A__align( aln0, aln2, effarr0, effarr2, n0, n2, alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0 ); //outgap=1?? |
---|
79 | |
---|
80 | newlen = strlen( aln0[0] ); |
---|
81 | |
---|
82 | for( i=0; i<newlen; i++ ) aln1[0][i] = '-'; |
---|
83 | aln1[0][i] = 0; |
---|
84 | for( i=1; i<n1; i++ ) strcpy( aln1[i], aln1[0] ); |
---|
85 | |
---|
86 | for( j=0; j<newlen; j++ ) |
---|
87 | { |
---|
88 | // fprintf( stderr, "j=%d\n", j ); |
---|
89 | for( i=0; i<n0; i++ ) |
---|
90 | { |
---|
91 | if( aln0[i][j] != '-' ) break; |
---|
92 | } |
---|
93 | if( i == n0 ) |
---|
94 | { |
---|
95 | for( i=0; i<n1; i++ ) |
---|
96 | { |
---|
97 | if( aln1[i][j] != '-' ) break; |
---|
98 | } |
---|
99 | } |
---|
100 | else i = -1; |
---|
101 | |
---|
102 | if( i == n1 ) |
---|
103 | { |
---|
104 | for( i=0; i<n1; i++ ) aln1[i][j] = '='; |
---|
105 | } |
---|
106 | } |
---|
107 | #if 0 |
---|
108 | fprintf( stderr, "in profilealignment,\n" ); |
---|
109 | for( i=0; i<n0; i++ ) fprintf( stderr, "\n>aln0[%d] = \n%s\n", i, aln0[i] ); |
---|
110 | for( i=0; i<n1; i++ ) fprintf( stderr, "\n>aln1[%d] = \n%s\n", i, aln1[i] ); |
---|
111 | for( i=0; i<n2; i++ ) fprintf( stderr, "\n>aln2[%d] = \n%s\n", i, aln2[i] ); |
---|
112 | #endif |
---|
113 | |
---|
114 | free( effarr0 ); |
---|
115 | free( effarr2 ); |
---|
116 | } |
---|
117 | |
---|
118 | void eq2dash( char *s ) |
---|
119 | { |
---|
120 | while( *s ) |
---|
121 | { |
---|
122 | if( *s == '=' ) *s = '-'; |
---|
123 | s++; |
---|
124 | } |
---|
125 | } |
---|
126 | |
---|
127 | void findnewgaps( int n, int rep, char **seq, int *gaplen ) |
---|
128 | { |
---|
129 | int i, pos, len, len1; |
---|
130 | |
---|
131 | len = strlen( seq[0] ); |
---|
132 | // for( i=0; i<len; i++ ) gaplen[i] = 0; // calloc de shokika sareteirukara hontou ha iranai |
---|
133 | len1 = len + 1; |
---|
134 | for( i=0; i<len1; i++ ) gaplen[i] = 0; // reallo de shokika sareteirukara iru! |
---|
135 | |
---|
136 | pos = 0; |
---|
137 | for( i=0; i<len; i++ ) |
---|
138 | { |
---|
139 | if( seq[rep][i] == '=' ) |
---|
140 | { |
---|
141 | // fprintf( stderr, "Newgap! pos = %d\n", pos ); |
---|
142 | gaplen[pos]++; |
---|
143 | } |
---|
144 | else |
---|
145 | pos++; |
---|
146 | } |
---|
147 | } |
---|
148 | |
---|
149 | void findcommongaps( int n, char **seq, int *gaplen ) |
---|
150 | { |
---|
151 | int i, j, pos, len, len1; |
---|
152 | len = strlen( seq[0] ); |
---|
153 | len1 = len+1; |
---|
154 | |
---|
155 | // fprintf( stderr, "seq[0] = %s\n", seq[0] ); |
---|
156 | for( i=0; i<len1; i++ ) gaplen[i] = 0; |
---|
157 | |
---|
158 | pos = 0; |
---|
159 | for( i=0; i<len; i++ ) |
---|
160 | { |
---|
161 | for( j=0; j<n; j++ ) |
---|
162 | if( seq[j][i] != '-' ) break; |
---|
163 | |
---|
164 | if( j == n ) gaplen[pos]++; |
---|
165 | else |
---|
166 | pos++; |
---|
167 | } |
---|
168 | #if 0 |
---|
169 | for( i=0; i<pos; i++ ) |
---|
170 | { |
---|
171 | fprintf( stderr, "vec[%d] = %d\n", i, gaplen[i] ); |
---|
172 | } |
---|
173 | #endif |
---|
174 | } |
---|
175 | |
---|
176 | void adjustgapmap( int newlen, int *gapmap, char *seq ) |
---|
177 | { |
---|
178 | int j; |
---|
179 | int pos; |
---|
180 | int newlen1 = newlen+1; |
---|
181 | int *tmpmap; |
---|
182 | |
---|
183 | |
---|
184 | tmpmap = AllocateIntVec( newlen+2 ); |
---|
185 | j = 0; |
---|
186 | pos = 0; |
---|
187 | while( *seq ) |
---|
188 | { |
---|
189 | // fprintf( stderr, "j=%d *seq = %c\n", j, *seq ); |
---|
190 | if( *seq++ == '=' ) |
---|
191 | tmpmap[j++] = 0; |
---|
192 | else |
---|
193 | { |
---|
194 | tmpmap[j++] = gapmap[pos++]; |
---|
195 | } |
---|
196 | } |
---|
197 | tmpmap[j++] = gapmap[pos]; |
---|
198 | |
---|
199 | for(j=0; j<newlen1; j++) |
---|
200 | gapmap[j] = tmpmap[j]; |
---|
201 | |
---|
202 | free( tmpmap ); |
---|
203 | } |
---|
204 | |
---|
205 | static void strncpy0( char *s1, char *s2, int n ) |
---|
206 | { |
---|
207 | while( n-- ) *s1++ = *s2++; |
---|
208 | *s1 = 0; |
---|
209 | } |
---|
210 | |
---|
211 | static int countnogaplen( int *gaplen, int *term ) |
---|
212 | { |
---|
213 | int v = 0; |
---|
214 | while( gaplen < term ) |
---|
215 | { |
---|
216 | if( *gaplen++ == 0 ) v++; |
---|
217 | else break; |
---|
218 | } |
---|
219 | return( v ); |
---|
220 | } |
---|
221 | |
---|
222 | void insertnewgaps( int njob, int *alreadyaligned, char **seq, int *ex1, int *ex2, int *gaplen, int *gapmap, int alloclen, char alg, char gapchar ) |
---|
223 | { |
---|
224 | int *mar; |
---|
225 | char *gaps; |
---|
226 | char *cptr; |
---|
227 | int i, j, k, len, rep, len0, lp, blocklen; |
---|
228 | char **mseq2, **mseq0, **mseq1; |
---|
229 | char **aseq, *newchar; |
---|
230 | int ngroup2, ngroup0, ngroup1; |
---|
231 | int *list0, *list1, *list2; |
---|
232 | int posin12, gapshift, newpos; |
---|
233 | int mlen1, mlen0, mlen2; |
---|
234 | int tmptmptmpmark = 0; |
---|
235 | |
---|
236 | mar = calloc( njob, sizeof( int ) ); |
---|
237 | list0 = calloc( njob, sizeof( int ) ); |
---|
238 | list1 = calloc( njob, sizeof( int ) ); |
---|
239 | list2 = calloc( njob, sizeof( int ) ); |
---|
240 | |
---|
241 | for( i=0; i<njob; i++ ) mar[i] = 0; |
---|
242 | for( i=0; i<njob; i++ ) |
---|
243 | { |
---|
244 | if( alreadyaligned[i]==0 ) mar[i] = 3; |
---|
245 | } |
---|
246 | for( i=0; (k=ex1[i])>-1; i++ ) |
---|
247 | { |
---|
248 | mar[k] = 1; |
---|
249 | // fprintf( stderr, "excluding %d\n", ex1[i] ); |
---|
250 | } |
---|
251 | for( i=0; (k=ex2[i])>-1; i++ ) |
---|
252 | { |
---|
253 | mar[k] = 2; |
---|
254 | // fprintf( stderr, "excluding %d\n", ex2[i] ); |
---|
255 | } |
---|
256 | |
---|
257 | ngroup2 = ngroup1 = ngroup0 = 0; |
---|
258 | for( i=0; i<njob; i++ ) |
---|
259 | { |
---|
260 | if( mar[i] == 2 ) |
---|
261 | { |
---|
262 | list2[ngroup2] = i; |
---|
263 | ngroup2++; |
---|
264 | } |
---|
265 | if( mar[i] == 1 ) |
---|
266 | { |
---|
267 | list1[ngroup1] = i; |
---|
268 | ngroup1++; |
---|
269 | } |
---|
270 | if( mar[i] == 0 ) |
---|
271 | { |
---|
272 | list0[ngroup0] = i; |
---|
273 | // fprintf( stderr, "inserting new gaps to %d\n", i ); |
---|
274 | ngroup0++; |
---|
275 | } |
---|
276 | } |
---|
277 | list0[ngroup0] = list1[ngroup1] = list2[ngroup2] = -1; |
---|
278 | if( ngroup0 == 0 ) |
---|
279 | { |
---|
280 | // fprintf( stderr, "Nothing to do\n" ); |
---|
281 | free( mar ); |
---|
282 | free( list0 ); |
---|
283 | free( list1 ); |
---|
284 | free( list2 ); |
---|
285 | return; |
---|
286 | } |
---|
287 | |
---|
288 | for( i=0; i<njob; i++ ) if( mar[i] == 0 ) break; |
---|
289 | rep = i; |
---|
290 | len = strlen( seq[rep] ); |
---|
291 | len0 = len+1; |
---|
292 | |
---|
293 | // |
---|
294 | // if( i == njob ) |
---|
295 | // { |
---|
296 | //// fprintf( stderr, "Nothing to do\n" ); |
---|
297 | // free( mar ); |
---|
298 | // return; |
---|
299 | // } |
---|
300 | |
---|
301 | mseq2 = AllocateCharMtx( ngroup2, alloclen ); |
---|
302 | mseq1 = AllocateCharMtx( ngroup1, alloclen ); |
---|
303 | mseq0 = AllocateCharMtx( ngroup0, alloclen ); |
---|
304 | aseq = AllocateCharMtx( njob, alloclen ); |
---|
305 | gaps = calloc( alloclen, sizeof( char ) ); |
---|
306 | |
---|
307 | |
---|
308 | for( i=0; i<njob; i++ ) aseq[i][0] = 0; |
---|
309 | newpos = 0; |
---|
310 | posin12 = 0; |
---|
311 | // fprintf( stderr, "\ngaplen[] = \n" ); |
---|
312 | // for(i=0; i<len0; i++ ) fprintf( stderr, "%d ", gaplen[i] ); |
---|
313 | // fprintf( stderr, "\n" ); |
---|
314 | |
---|
315 | for( j=0; j<len0; j++ ) |
---|
316 | { |
---|
317 | // fprintf( stderr, "\nj=%d, gaplen[%d]=%d\n", j, j, gaplen[j] ); |
---|
318 | if( gaplen[j] ) |
---|
319 | { |
---|
320 | // fprintf( stderr, "j=%d GAP!\n", j ); |
---|
321 | tmptmptmpmark = 1; |
---|
322 | for( i=0; i<ngroup0; i++ ) mseq0[i][0] = 0; |
---|
323 | for( i=0; i<ngroup1; i++ ) mseq1[i][0] = 0; |
---|
324 | for( i=0; i<ngroup2; i++ ) mseq2[i][0] = 0; |
---|
325 | mlen0 = mlen1 = mlen2 = 0; |
---|
326 | |
---|
327 | gapshift = gaplen[j]; |
---|
328 | cptr = gaps; |
---|
329 | while( gapshift-- ) *cptr++ = gapchar; |
---|
330 | *cptr = 0; |
---|
331 | gapshift = gaplen[j]; |
---|
332 | |
---|
333 | for( i=0; i<ngroup0; i++ ) strncpy0( mseq0[i]+mlen0, gaps, gapshift ); |
---|
334 | for( i=0; i<ngroup1; i++ ) strncpy0( mseq1[i]+mlen1, seq[list1[i]]+posin12, gapshift ); |
---|
335 | for( i=0; i<ngroup2; i++ ) strncpy0( mseq2[i]+mlen2, seq[list2[i]]+posin12, gapshift ); |
---|
336 | posin12 += gapshift; |
---|
337 | mlen0 += gapshift; |
---|
338 | mlen1 += gapshift; |
---|
339 | mlen2 += gapshift; |
---|
340 | |
---|
341 | gapshift = gapmap[posin12]; |
---|
342 | // fprintf( stderr, "gapmap[%d] kouho = %d\n", posin12, gapmap[posin12] ); |
---|
343 | |
---|
344 | |
---|
345 | for( i=0; i<ngroup0; i++ ) strncpy0( mseq0[i]+mlen0, seq[list0[i]]+j, gapshift ); |
---|
346 | for( i=0; i<ngroup1; i++ ) strncpy0( mseq1[i]+mlen1, seq[list1[i]]+posin12, gapshift ); |
---|
347 | for( i=0; i<ngroup2; i++ ) strncpy0( mseq2[i]+mlen2, seq[list2[i]]+posin12, gapshift ); |
---|
348 | mlen0 += gapshift; |
---|
349 | mlen1 += gapshift; |
---|
350 | mlen2 += gapshift; |
---|
351 | #if 0 |
---|
352 | for( i=0; i<ngroup0; i++ ) fprintf( stderr, "### mseq0[%d] = %s\n", i, mseq0[i] ); |
---|
353 | for( i=0; i<ngroup1; i++ ) fprintf( stderr, "### mseq1[%d] = %s\n", i, mseq1[i] ); |
---|
354 | for( i=0; i<ngroup2; i++ ) fprintf( stderr, "### mseq2[%d] = %s\n", i, mseq2[i] ); |
---|
355 | #endif |
---|
356 | |
---|
357 | if( gapshift ) |
---|
358 | profilealignment( ngroup0, ngroup1, ngroup2, mseq0, mseq1, mseq2, alloclen, alg ); |
---|
359 | |
---|
360 | j += gapshift; |
---|
361 | posin12 += gapshift; |
---|
362 | |
---|
363 | newpos = strlen( aseq[rep] ); // kufuu? |
---|
364 | for( i=0; i<ngroup0; i++ ) strcpy( aseq[list0[i]]+newpos, mseq0[i] ); |
---|
365 | for( i=0; i<ngroup1; i++ ) strcpy( aseq[list1[i]]+newpos, mseq1[i] ); |
---|
366 | for( i=0; i<ngroup2; i++ ) strcpy( aseq[list2[i]]+newpos, mseq2[i] ); |
---|
367 | |
---|
368 | // fprintf( stderr, "gapshift = %d\n", gapshift ); |
---|
369 | } |
---|
370 | blocklen = 1 + countnogaplen( gaplen+j+1, gaplen+len0 ); |
---|
371 | // fprintf( stderr, "\nj=%d, blocklen=%d, len0=%d\n", j, blocklen, len0 ); |
---|
372 | // blocklen = 1; |
---|
373 | // if( tmptmptmpmark ) exit( 1 ); |
---|
374 | |
---|
375 | newpos = strlen( aseq[rep] ); |
---|
376 | |
---|
377 | #if 0 |
---|
378 | for( i=0; i<ngroup0; i++ ) aseq[list0[i]][newpos] = seq[list0[i]][j]; |
---|
379 | for( i=0; i<ngroup1; i++ ) aseq[list1[i]][newpos] = seq[list1[i]][posin12]; |
---|
380 | for( i=0; i<ngroup2; i++ ) aseq[list2[i]][newpos] = seq[list2[i]][posin12]; |
---|
381 | for( i=0; i<ngroup0; i++ ) aseq[list0[i]][newpos+1] = 0; |
---|
382 | for( i=0; i<ngroup1; i++ ) aseq[list1[i]][newpos+1] = 0; |
---|
383 | for( i=0; i<ngroup2; i++ ) aseq[list2[i]][newpos+1] = 0; |
---|
384 | #else |
---|
385 | |
---|
386 | for( i=0; i<ngroup0; i++ ) |
---|
387 | { |
---|
388 | lp = list0[i]; |
---|
389 | newchar = aseq[lp] + newpos; |
---|
390 | strncpy0( newchar, seq[lp]+j, blocklen ); |
---|
391 | } |
---|
392 | for( i=0; i<ngroup1; i++ ) |
---|
393 | { |
---|
394 | lp = list1[i]; |
---|
395 | newchar = aseq[lp] + newpos; |
---|
396 | strncpy0( newchar, seq[lp]+posin12, blocklen ); |
---|
397 | } |
---|
398 | for( i=0; i<ngroup2; i++ ) |
---|
399 | { |
---|
400 | lp = list2[i]; |
---|
401 | newchar = aseq[lp] + newpos; |
---|
402 | strncpy0( newchar, seq[lp]+posin12, blocklen ); |
---|
403 | } |
---|
404 | // fprintf( stderr, "### aseq[l0] = %s\n", aseq[list0[0]] ); |
---|
405 | // fprintf( stderr, "### aseq[l1] = %s\n", aseq[list1[0]] ); |
---|
406 | // fprintf( stderr, "### aseq[l2] = %s\n", aseq[list2[0]] ); |
---|
407 | // exit( 1 ); |
---|
408 | #endif |
---|
409 | |
---|
410 | // fprintf( stderr, "j=%d -> %d\n", j, j+blocklen-1 ); |
---|
411 | j += (blocklen-1); |
---|
412 | |
---|
413 | |
---|
414 | posin12 += (blocklen-1); |
---|
415 | |
---|
416 | |
---|
417 | posin12++; |
---|
418 | } |
---|
419 | #if 0 |
---|
420 | fprintf( stderr, "\n" ); |
---|
421 | fprintf( stderr, " seq[l0] = %s\n", seq[list0[0]] ); |
---|
422 | fprintf( stderr, " seq[l1] = %s\n", seq[list1[0]] ); |
---|
423 | fprintf( stderr, " seq[l2] = %s\n", seq[list2[0]] ); |
---|
424 | fprintf( stderr, "=====>\n" ); |
---|
425 | fprintf( stderr, "aseq[l0] = %s\n", aseq[list0[0]] ); |
---|
426 | fprintf( stderr, "aseq[l1] = %s\n", aseq[list1[0]] ); |
---|
427 | fprintf( stderr, "aseq[l2] = %s\n", aseq[list2[0]] ); |
---|
428 | //if( tmptmptmpmark ) exit( 1 ); |
---|
429 | #endif |
---|
430 | |
---|
431 | // for( i=0; i<njob; i++ ) if( mar[i] != 3 ) strcpy( seq[i], aseq[i] ); |
---|
432 | for( i=0; i<ngroup0; i++ ) strcpy( seq[list0[i]], aseq[list0[i]] ); |
---|
433 | for( i=0; i<ngroup1; i++ ) strcpy( seq[list1[i]], aseq[list1[i]] ); |
---|
434 | for( i=0; i<ngroup2; i++ ) strcpy( seq[list2[i]], aseq[list2[i]] ); |
---|
435 | |
---|
436 | |
---|
437 | free( mar ); |
---|
438 | free( gaps ); |
---|
439 | free( list0 ); |
---|
440 | free( list1 ); |
---|
441 | free( list2 ); |
---|
442 | FreeCharMtx( mseq2 ); |
---|
443 | FreeCharMtx( mseq1 ); // ? added 2012/02/12 |
---|
444 | FreeCharMtx( mseq0 ); |
---|
445 | FreeCharMtx( aseq ); // ? added 2012/02/12 |
---|
446 | } |
---|
447 | |
---|
448 | |
---|
449 | void restorecommongaps( int njob, char **seq, int *ex1, int *ex2, int *gaplen, int alloclen, char gapchar ) |
---|
450 | { |
---|
451 | int *mar; |
---|
452 | char *tmpseq; |
---|
453 | char *cptr; |
---|
454 | int *iptr; |
---|
455 | int *tmpgaplen; |
---|
456 | int i, j, k, len, rep, len1; |
---|
457 | |
---|
458 | mar = calloc( njob, sizeof( int ) ); |
---|
459 | tmpseq = calloc( alloclen, sizeof( char ) ); |
---|
460 | tmpgaplen = calloc( alloclen, sizeof( int ) ); |
---|
461 | // tmpseq = calloc( alloclen+2, sizeof( char ) ); |
---|
462 | // tmpgaplen = calloc( alloclen+2, sizeof( int ) ); |
---|
463 | |
---|
464 | |
---|
465 | for( i=0; i<njob; i++ ) mar[i] = 0; |
---|
466 | for( i=0; (k=ex1[i])>-1; i++ ) |
---|
467 | { |
---|
468 | mar[k] = 1; |
---|
469 | // fprintf( stderr, "excluding %d\n", ex1[i] ); |
---|
470 | } |
---|
471 | for( i=0; (k=ex2[i])>-1; i++ ) |
---|
472 | { |
---|
473 | mar[k] = 1; |
---|
474 | // fprintf( stderr, "excluding %d\n", ex2[i] ); |
---|
475 | } |
---|
476 | |
---|
477 | for( i=0; i<njob; i++ ) |
---|
478 | if( mar[i] ) break; |
---|
479 | |
---|
480 | if( i == njob ) |
---|
481 | { |
---|
482 | // fprintf( stderr, "Nothing to do\n" ); |
---|
483 | free( mar ); |
---|
484 | free( tmpseq ); |
---|
485 | free( tmpgaplen ); |
---|
486 | return; |
---|
487 | } |
---|
488 | rep = i; |
---|
489 | len = strlen( seq[rep] ); |
---|
490 | len1 = len+1; |
---|
491 | |
---|
492 | |
---|
493 | for( i=0; i<njob; i++ ) |
---|
494 | { |
---|
495 | if( mar[i] == 0 ) continue; |
---|
496 | cptr = tmpseq; |
---|
497 | for( j=0; j<len1; j++ ) |
---|
498 | { |
---|
499 | for( k=0; k<gaplen[j]; k++ ) |
---|
500 | *(cptr++) = gapchar; // ??? |
---|
501 | *(cptr++) = seq[i][j]; |
---|
502 | } |
---|
503 | *cptr = 0; |
---|
504 | strcpy( seq[i], tmpseq ); |
---|
505 | } |
---|
506 | |
---|
507 | iptr = tmpgaplen; |
---|
508 | for( j=0; j<len1; j++ ) |
---|
509 | { |
---|
510 | *(iptr++) = gaplen[j]; |
---|
511 | for( k=0; k<gaplen[j]; k++ ) |
---|
512 | *(iptr++) = 0; |
---|
513 | } |
---|
514 | *iptr = -1; |
---|
515 | |
---|
516 | iptr = tmpgaplen; |
---|
517 | while( *iptr != -1 ) *gaplen++ = *iptr++; |
---|
518 | |
---|
519 | free( mar ); |
---|
520 | free( tmpseq ); |
---|
521 | free( tmpgaplen ); |
---|
522 | } |
---|