8 #define USE_PENALTY_EX 0
9 #define FASTMATCHCALC 1
12 static float **impmtx = NULL;
13 static int impalloclen = 0;
14 float imp_match_out_sc( int i1, int j1 )
16 // fprintf( stderr, "imp+match = %f\n", impmtx[i1][j1] * fastathreshold );
17 // fprintf( stderr, "val = %f\n", impmtx[i1][j1] );
18 return( impmtx[i1][j1] );
20 static void imp_match_out_vead_gapmap( float *imp, int i1, int lgth2, int *gapmap2 )
23 float *pt = impmtx[i1];
24 int *gapmappt = gapmap2;
26 *imp++ += pt[*gapmappt++];
29 float *pt = impmtx[i1];
30 for( j=0; j<lgth2; j++ )
31 *imp++ += pt[gapmap2[j]];
36 static void imp_match_out_vead_tate_gapmap( float *imp, int j1, int lgth1, int *gapmap1 )
39 int *gapmappt = gapmap1;
41 *imp++ += impmtx[*gapmappt++][j1];
44 for( i=0; i<lgth1; i++ )
45 *imp++ += impmtx[gapmap1[i]][j1];
49 static void imp_match_out_vead( float *imp, int i1, int lgth2 )
52 float *pt = impmtx[i1];
57 float *pt = impmtx[i1];
58 for( j=0; j<lgth2; j++ )
62 static void imp_match_out_vead_tate( float *imp, int j1, int lgth1 )
65 for( i=0; i<lgth1; i++ )
66 *imp++ += impmtx[i][j1];
69 void imp_rna( int nseq1, int nseq2, char **seq1, char **seq2, double *eff1, double *eff2, RNApair ***grouprna1, RNApair ***grouprna2, int *gapmap1, int *gapmap2, RNApair *pair )
71 foldrna( nseq1, nseq2, seq1, seq2, eff1, eff2, grouprna1, grouprna2, impmtx, gapmap1, gapmap2, pair );
75 void imp_match_init_strict( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, double *eff1_kozo, double *eff2_kozo, LocalHom ***localhom, int forscore )
77 int i, j, k1, k2, tmpint, start1, start2, end1, end2;
82 static char *nocount1 = NULL;
83 static char *nocount2 = NULL;
86 if( impalloclen < lgth1 + 2 || impalloclen < lgth2 + 2 )
88 if( impmtx ) FreeFloatMtx( impmtx );
89 if( nocount1 ) free( nocount1 );
90 if( nocount2 ) free( nocount2 );
91 impalloclen = MAX( lgth1, lgth2 ) + 2;
92 impmtx = AllocateFloatMtx( impalloclen, impalloclen );
93 nocount1 = AllocateCharVec( impalloclen );
94 nocount2 = AllocateCharVec( impalloclen );
97 for( i=0; i<lgth1; i++ )
99 for( j=0; j<clus1; j++ )
100 if( seq1[j][i] == '-' ) break;
101 if( j != clus1 ) nocount1[i] = 1;
102 else nocount1[i] = 0;
104 for( i=0; i<lgth2; i++ )
106 for( j=0; j<clus2; j++ )
107 if( seq2[j][i] == '-' ) break;
108 if( j != clus2 ) nocount2[i] = 1;
109 else nocount2[i] = 0;
113 fprintf( stderr, "nocount2 =\n" );
114 for( i = 0; i<impalloclen; i++ )
116 fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
123 fprintf( stderr, "eff1 in _init_strict = \n" );
124 for( i=0; i<clus1; i++ )
125 fprintf( stderr, "eff1[] = %f\n", eff1[i] );
126 for( i=0; i<clus2; i++ )
127 fprintf( stderr, "eff2[] = %f\n", eff2[i] );
130 for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
132 effijx = fastathreshold;
133 for( i=0; i<clus1; i++ )
135 for( j=0; j<clus2; j++ )
137 effij = (float)( eff1[i] * eff2[j] * effijx );
138 effij_kozo = (float)( eff1_kozo[i] * eff2_kozo[j] * effijx );
139 tmpptr = localhom[i][j];
142 // fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
143 // fprintf( stderr, "end1 = %d\n", tmpptr->end1 );
144 // fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
145 // fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
150 if( *pt++ != '-' ) tmpint++;
151 if( tmpint == tmpptr->start1 ) break;
153 start1 = pt - seq1[i] - 1;
155 if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
161 // fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
162 if( tmpint == tmpptr->end1 ) break;
163 if( *pt++ != '-' ) tmpint++;
165 end1 = pt - seq1[i] - 0;
169 // fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
170 if( *pt++ != '-' ) tmpint++;
171 if( tmpint == tmpptr->end1 ) break;
173 end1 = pt - seq1[i] - 1;
181 if( *pt++ != '-' ) tmpint++;
182 if( tmpint == tmpptr->start2 ) break;
184 start2 = pt - seq2[j] - 1;
185 if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
191 if( tmpint == tmpptr->end2 ) break;
192 if( *pt++ != '-' ) tmpint++;
194 end2 = pt - seq2[j] - 0;
198 if( *pt++ != '-' ) tmpint++;
199 if( tmpint == tmpptr->end2 ) break;
201 end2 = pt - seq2[j] - 1;
204 // fprintf( stderr, "start1 = %d (%c), end1 = %d (%c), start2 = %d (%c), end2 = %d (%c)\n", start1, seq1[i][start1], end1, seq1[i][end1], start2, seq2[j][start2], end2, seq2[j][end2] );
205 // fprintf( stderr, "step 0\n" );
206 if( end1 - start1 != end2 - start2 )
208 // fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
212 k1 = start1; k2 = start2;
215 while( *pt1 && *pt2 )
217 if( *pt1 != '-' && *pt2 != '-' )
219 // ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃðդ·¤Æ²¼¤µ¤¤¡£
220 // impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
221 // impmtx[k1][k2] += tmpptr->importance * effij;
222 // impmtx[k1][k2] += tmpptr->fimportance * effij;
223 if( tmpptr->korh == 'k' )
224 impmtx[k1][k2] += tmpptr->fimportance * effij_kozo;
226 impmtx[k1][k2] += tmpptr->fimportance * effij;
228 // fprintf( stderr, "#### impmtx[k1][k2] = %f, tmpptr->fimportance=%f, effij=%f\n", impmtx[k1][k2], tmpptr->fimportance, effij );
229 // fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
230 // fprintf( stderr, "%d (%c) - %d (%c) - %f\n", k1, *pt1, k2, *pt2, tmpptr->fimportance * effij );
234 else if( *pt1 != '-' && *pt2 == '-' )
236 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
239 else if( *pt1 == '-' && *pt2 != '-' )
241 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
244 else if( *pt1 == '-' && *pt2 == '-' )
246 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
250 if( k1 > end1 || k2 > end2 ) break;
253 while( k1 <= end1 && k2 <= end2 )
255 fprintf( stderr, "k1,k2=%d,%d - ", k1, k2 );
256 if( !nocount1[k1] && !nocount2[k2] )
258 impmtx[k1][k2] += tmpptr->wimportance * eff1[i] * eff2[j] * fastathreshold;
259 fprintf( stderr, "marked\n" );
262 fprintf( stderr, "no count\n" );
266 tmpptr = tmpptr->next;
272 if( clus1 == 1 && clus2 == 1 )
274 fprintf( stderr, "writing impmtx\n" );
275 fprintf( stderr, "\n" );
276 fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
277 fprintf( stderr, "seq2[0] = %s\n", seq2[0] );
278 fprintf( stderr, "impmtx = \n" );
279 for( k2=0; k2<lgth2; k2++ )
280 fprintf( stderr, "%6.3f ", (double)k2 );
281 fprintf( stderr, "\n" );
282 for( k1=0; k1<lgth1; k1++ )
284 fprintf( stderr, "%d ", k1 );
285 for( k2=0; k2<30; k2++ )
286 fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
287 fprintf( stderr, "\n" );
295 void imp_match_init( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom )
297 int dif, i, j, k1, k2, tmpint, start1, start2, end1, end2;
298 static int impalloclen = 0;
301 static char *nocount1 = NULL;
302 static char *nocount2 = NULL;
304 if( impalloclen < lgth1 + 2 || impalloclen < lgth2 + 2 )
306 if( impmtx ) FreeFloatMtx( impmtx );
307 if( nocount1 ) free( nocount1 );
308 if( nocount2 ) free( nocount2 );
309 impalloclen = MAX( lgth1, lgth2 ) + 2;
310 impmtx = AllocateFloatMtx( impalloclen, impalloclen );
311 nocount1 = AllocateCharVec( impalloclen );
312 nocount2 = AllocateCharVec( impalloclen );
315 for( i=0; i<lgth1; i++ )
317 for( j=0; j<clus1; j++ )
318 if( seq1[j][i] == '-' ) break;
319 if( j != clus1 ) nocount1[i] = 1;
320 else nocount1[i] = 0;
322 for( i=0; i<lgth2; i++ )
324 for( j=0; j<clus2; j++ )
325 if( seq2[j][i] == '-' ) break;
326 if( j != clus2 ) nocount2[i] = 1;
327 else nocount2[i] = 0;
331 fprintf( stderr, "nocount2 =\n" );
332 for( i = 0; i<impalloclen; i++ )
334 fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
338 for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
340 for( i=0; i<clus1; i++ )
342 fprintf( stderr, "i = %d, seq1 = %s\n", i, seq1[i] );
343 for( j=0; j<clus2; j++ )
345 fprintf( stderr, "start1 = %d\n", localhom[i][j]->start1 );
346 fprintf( stderr, "end1 = %d\n", localhom[i][j]->end1 );
347 fprintf( stderr, "j = %d, seq2 = %s\n", j, seq2[j] );
352 if( *pt++ != '-' ) tmpint++;
353 if( tmpint == localhom[i][j]->start1 ) break;
355 start1 = pt - seq1[i] - 1;
359 // fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, localhom[i][j].end1, pt-seq1[i] );
360 if( *pt++ != '-' ) tmpint++;
361 if( tmpint == localhom[i][j]->end1 ) break;
363 end1 = pt - seq1[i] - 1;
369 if( *pt++ != '-' ) tmpint++;
370 if( tmpint == localhom[i][j]->start2 ) break;
372 start2 = pt - seq2[j] - 1;
375 if( *pt++ != '-' ) tmpint++;
376 if( tmpint == localhom[i][j]->end2 ) break;
378 end2 = pt - seq2[j] - 1;
379 // fprintf( stderr, "start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
382 fprintf( stderr, "step 0\n" );
383 while( k1 <= end1 && k2 <= end2 )
386 if( !nocount1[k1] && !nocount2[k2] )
387 impmtx[k1][k2] += localhom[i][j].wimportance * eff1[i] * eff2[j];
390 if( !nocount1[k1] && !nocount2[k2] )
391 impmtx[k1][k2] += localhom[i][j]->wimportance * eff1[i] * eff2[j];
396 dif = ( end1 - start1 ) - ( end2 - start2 );
397 fprintf( stderr, "dif = %d\n", dif );
402 fprintf( stderr, "dif = %d\n", dif );
405 while( k1 <= end1 && k2 <= end2 )
407 if( 0 <= k2 && start2 <= k2 && !nocount1[k1] && !nocount2[k2] )
408 impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
422 if( k1 >= 0 && k1 >= start1 && !nocount1[k1] && !nocount2[k2] )
423 impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
432 fprintf( stderr, "impmtx = \n" );
433 for( k2=0; k2<lgth2; k2++ )
434 fprintf( stderr, "%6.3f ", (double)k2 );
435 fprintf( stderr, "\n" );
436 for( k1=0; k1<lgth1; k1++ )
438 fprintf( stderr, "%d", k1 );
439 for( k2=0; k2<lgth2; k2++ )
440 fprintf( stderr, "%6.3f ", impmtx[k1][k2] );
441 fprintf( stderr, "\n" );
447 static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
452 float **cpmxpd = floatwork;
453 int **cpmxpdn = intwork;
454 float *matchpt, *cpmxpdpt, **cpmxpdptpt;
455 int *cpmxpdnpt, **cpmxpdnptpt;
459 for( j=0; j<lgth2; j++ )
462 for( l=0; l<26; l++ )
466 cpmxpd[j][count] = cpmx2[l][j];
467 cpmxpdn[j][count] = l;
471 cpmxpdn[j][count] = -1;
476 for( l=0; l<26; l++ )
479 for( j=0; j<26; j++ )
480 // scarr[l] += n_dis[j][l] * cpmx1[j][i1];
481 scarr[l] += n_dis_consweight_multi[j][l] * cpmx1[j][i1];
484 cpmxpdnptpt = cpmxpdn;
489 cpmxpdnpt = *cpmxpdnptpt++;
490 cpmxpdpt = *cpmxpdptpt++;
491 while( *cpmxpdnpt>-1 )
492 *matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++;
499 float **cpmxpd = floatwork;
500 int **cpmxpdn = intwork;
505 for( j=0; j<lgth2; j++ )
508 for( l=0; l<26; l++ )
512 cpmxpd[count][j] = cpmx2[l][j];
513 cpmxpdn[count][j] = l;
517 cpmxpdn[count][j] = -1;
520 for( l=0; l<26; l++ )
523 for( k=0; k<26; k++ )
524 scarr[l] += n_dis_consweight_multi[k][l] * cpmx1[k][i1];
525 // scarr[l] += n_dis[k][l] * cpmx1[k][i1];
527 for( j=0; j<lgth2; j++ )
530 for( k=0; cpmxpdn[k][j]>-1; k++ )
531 match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
536 static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw,
537 char **seq1, char **seq2,
538 char **mseq1, char **mseq2,
539 float **cpmx1, float **cpmx2,
540 int **ijp, int icyc, int jcyc )
542 int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
544 char *gaptable1, *gt1bk;
545 char *gaptable2, *gt2bk;
546 lgth1 = strlen( seq1[0] );
547 lgth2 = strlen( seq2[0] );
548 gt1bk = AllocateCharVec( lgth1+lgth2+1 );
549 gt2bk = AllocateCharVec( lgth1+lgth2+1 );
552 for( i=0; i<lgth1; i++ )
554 fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
562 wm = lastverticalw[0];
563 for( i=0; i<lgth1; i++ )
565 if( lastverticalw[i] >= wm )
567 wm = lastverticalw[i];
568 iin = i; jin = lgth2-1;
569 ijp[lgth1][lgth2] = +( lgth1 - i );
572 for( j=0; j<lgth2; j++ )
574 if( lasthorizontalw[j] >= wm )
576 wm = lasthorizontalw[j];
577 iin = lgth1-1; jin = j;
578 ijp[lgth1][lgth2] = -( lgth2 - j );
583 for( i=0; i<lgth1+1; i++ )
587 for( j=0; j<lgth2+1; j++ )
589 ijp[0][j] = -( j + 1 );
592 gaptable1 = gt1bk + lgth1+lgth2;
594 gaptable2 = gt2bk + lgth1+lgth2;
597 iin = lgth1; jin = lgth2;
599 for( k=0; k<=lgth1+lgth2; k++ )
601 if( ijp[iin][jin] < 0 )
603 ifi = iin-1; jfi = jin+ijp[iin][jin];
605 else if( ijp[iin][jin] > 0 )
607 ifi = iin-ijp[iin][jin]; jfi = jin-1;
611 ifi = iin-1; jfi = jin-1;
627 if( iin == lgth1 || jin == lgth2 )
631 *impwmpt += imp_match_out_sc( iin, jin );
633 // fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
635 if( iin <= 0 || jin <= 0 ) break;
639 iin = ifi; jin = jfi;
642 for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
643 for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
648 static void Atracking_localhom_gapmap( float *impwmpt, float *lasthorizontalw, float *lastverticalw,
649 char **seq1, char **seq2,
650 char **mseq1, char **mseq2,
651 float **cpmx1, float **cpmx2,
652 int **ijp, int icyc, int jcyc,
653 int *gapmap1, int *gapmap2 )
655 int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
657 char *gaptable1, *gt1bk;
658 char *gaptable2, *gt2bk;
659 lgth1 = strlen( seq1[0] );
660 lgth2 = strlen( seq2[0] );
661 gt1bk = AllocateCharVec( lgth1+lgth2+1 );
662 gt2bk = AllocateCharVec( lgth1+lgth2+1 );
665 for( i=0; i<lgth1; i++ )
667 fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
675 wm = lastverticalw[0];
676 for( i=0; i<lgth1; i++ )
678 if( lastverticalw[i] >= wm )
680 wm = lastverticalw[i];
681 iin = i; jin = lgth2-1;
682 ijp[lgth1][lgth2] = +( lgth1 - i );
685 for( j=0; j<lgth2; j++ )
687 if( lasthorizontalw[j] >= wm )
689 wm = lasthorizontalw[j];
690 iin = lgth1-1; jin = j;
691 ijp[lgth1][lgth2] = -( lgth2 - j );
696 for( i=0; i<lgth1+1; i++ )
700 for( j=0; j<lgth2+1; j++ )
702 ijp[0][j] = -( j + 1 );
705 gaptable1 = gt1bk + lgth1+lgth2;
707 gaptable2 = gt2bk + lgth1+lgth2;
710 iin = lgth1; jin = lgth2;
712 for( k=0; k<=lgth1+lgth2; k++ )
714 if( ijp[iin][jin] < 0 )
716 ifi = iin-1; jfi = jin+ijp[iin][jin];
718 else if( ijp[iin][jin] > 0 )
720 ifi = iin-ijp[iin][jin]; jfi = jin-1;
724 ifi = iin-1; jfi = jin-1;
740 if( iin == lgth1 || jin == lgth2 )
744 *impwmpt += imp_match_out_sc( gapmap1[iin], gapmap2[jin] );
746 // fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
748 if( iin <= 0 || jin <= 0 ) break;
752 iin = ifi; jin = jfi;
754 for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
755 for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
760 static float Atracking( float *lasthorizontalw, float *lastverticalw,
761 char **seq1, char **seq2,
762 char **mseq1, char **mseq2,
763 float **cpmx1, float **cpmx2,
764 int **ijp, int icyc, int jcyc )
766 int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
768 char *gaptable1, *gt1bk;
769 char *gaptable2, *gt2bk;
770 lgth1 = strlen( seq1[0] );
771 lgth2 = strlen( seq2[0] );
773 gt1bk = AllocateCharVec( lgth1+lgth2+1 );
774 gt2bk = AllocateCharVec( lgth1+lgth2+1 );
777 for( i=0; i<lgth1; i++ )
779 fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
787 wm = lastverticalw[0];
788 for( i=0; i<lgth1; i++ )
790 if( lastverticalw[i] >= wm )
792 wm = lastverticalw[i];
793 iin = i; jin = lgth2-1;
794 ijp[lgth1][lgth2] = +( lgth1 - i );
797 for( j=0; j<lgth2; j++ )
799 if( lasthorizontalw[j] >= wm )
801 wm = lasthorizontalw[j];
802 iin = lgth1-1; jin = j;
803 ijp[lgth1][lgth2] = -( lgth2 - j );
808 for( i=0; i<lgth1+1; i++ )
812 for( j=0; j<lgth2+1; j++ )
814 ijp[0][j] = -( j + 1 );
817 gaptable1 = gt1bk + lgth1+lgth2;
819 gaptable2 = gt2bk + lgth1+lgth2;
822 iin = lgth1; jin = lgth2;
823 for( k=0; k<=lgth1+lgth2; k++ )
825 if( ijp[iin][jin] < 0 )
827 ifi = iin-1; jfi = jin+ijp[iin][jin];
829 else if( ijp[iin][jin] > 0 )
831 ifi = iin-ijp[iin][jin]; jfi = jin-1;
835 ifi = iin-1; jfi = jin-1;
851 if( iin <= 0 || jin <= 0 ) break;
855 iin = ifi; jin = jfi;
858 for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
859 for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
867 float A__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, char *sgap1, char *sgap2, char *egap1, char *egap2 )
868 /* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
872 int lasti, lastj; /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
875 float wm = 0.0; /* int ?????? */
877 float *currentw, *previousw;
878 // float fpenalty = (float)penalty;
880 float fpenalty_ex = (float)penalty_ex;
885 float *mjpt, *prept, *curpt;
891 static float *w1, *w2;
893 static float *initverticalw; /* kufuu sureba iranai */
894 static float *lastverticalw; /* kufuu sureba iranai */
902 static float **cpmx1;
903 static float **cpmx2;
904 static int **intwork;
905 static float **floatwork;
906 static int orlgth1 = 0, orlgth2 = 0;
907 float fpenalty = (float)penalty;
916 fprintf( stderr, "#### eff in SA+++align\n" );
917 fprintf( stderr, "#### seq1[0] = %s\n", seq1[0] );
918 fprintf( stderr, "#### strlen( seq1[0] ) = %d\n", strlen( seq1[0] ) );
919 for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
923 mseq1 = AllocateCharMtx( njob, 0 );
924 mseq2 = AllocateCharMtx( njob, 0 );
928 lgth1 = strlen( seq1[0] );
929 lgth2 = strlen( seq2[0] );
931 if( lgth1 == 0 || lgth2 == 0 )
933 fprintf( stderr, "WARNING (Aalignmm): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
937 if( lgth1 > orlgth1 || lgth2 > orlgth2 )
941 if( orlgth1 > 0 && orlgth2 > 0 )
945 FreeFloatVec( match );
946 FreeFloatVec( initverticalw );
947 FreeFloatVec( lastverticalw );
954 FreeFloatVec( ogcp1 );
955 FreeFloatVec( ogcp2 );
956 FreeFloatVec( fgcp1 );
957 FreeFloatVec( fgcp2 );
960 FreeFloatMtx( cpmx1 );
961 FreeFloatMtx( cpmx2 );
963 FreeFloatMtx( floatwork );
964 FreeIntMtx( intwork );
967 ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
968 ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
971 fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
974 w1 = AllocateFloatVec( ll2+2 );
975 w2 = AllocateFloatVec( ll2+2 );
976 match = AllocateFloatVec( ll2+2 );
978 initverticalw = AllocateFloatVec( ll1+2 );
979 lastverticalw = AllocateFloatVec( ll1+2 );
981 m = AllocateFloatVec( ll2+2 );
982 mp = AllocateIntVec( ll2+2 );
984 mseq = AllocateCharMtx( njob, ll1+ll2 );
986 ogcp1 = AllocateFloatVec( ll1+2 );
987 ogcp2 = AllocateFloatVec( ll2+2 );
988 fgcp1 = AllocateFloatVec( ll1+2 );
989 fgcp2 = AllocateFloatVec( ll2+2 );
991 cpmx1 = AllocateFloatMtx( 26, ll1+2 );
992 cpmx2 = AllocateFloatMtx( 26, ll2+2 );
995 floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 );
996 intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 27 );
998 floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 );
999 intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 );
1003 fprintf( stderr, "succeeded\n" );
1006 orlgth1 = ll1 - 100;
1007 orlgth2 = ll2 - 100;
1011 for( i=0; i<icyc; i++ )
1016 for( j=0; j<jcyc; j++ )
1018 mseq2[j] = mseq[icyc+j];
1023 if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
1027 if( commonAlloc1 && commonAlloc2 )
1029 FreeIntMtx( commonIP );
1032 ll1 = MAX( orlgth1, commonAlloc1 );
1033 ll2 = MAX( orlgth2, commonAlloc2 );
1036 fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
1039 commonIP = AllocateIntMtx( ll1+10, ll2+10 );
1042 fprintf( stderr, "succeeded\n\n" );
1053 for( i=0; i<icyc; i++ )
1055 fprintf( stderr, "## totaleff = %f\n", t );
1059 cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
1060 cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
1064 new_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1, sgap1 );
1065 new_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2, sgap2 );
1066 new_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1, egap1 );
1067 new_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2, egap2 );
1071 st_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 );
1072 st_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
1073 st_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
1074 st_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
1077 for( i=0; i<lgth1; i++ )
1079 ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] ) * fpenalty;
1080 fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] ) * fpenalty;
1082 for( i=0; i<lgth2; i++ )
1084 ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] ) * fpenalty;
1085 fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] ) * fpenalty;
1088 for( i=0; i<lgth1; i++ )
1089 fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
1095 match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
1097 imp_match_out_vead_tate( initverticalw, 0, lgth1 ); // 060306
1099 match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
1101 imp_match_out_vead( currentw, 0, lgth2 ); // 060306
1102 #if 0 // -> tbfast.c
1104 imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
1110 for( i=1; i<lgth1+1; i++ )
1112 initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
1114 for( j=1; j<lgth2+1; j++ )
1116 currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
1122 for( j=1; j<lgth2+1; j++ )
1123 currentw[j] -= offset * j / 2.0;
1124 for( i=1; i<lgth1+1; i++ )
1125 initverticalw[i] -= offset * i / 2.0;
1129 for( j=1; j<lgth2+1; ++j )
1131 m[j] = currentw[j-1] + ogcp1[1]; mp[j] = 0;
1134 lastverticalw[0] = 0.0; // Falign kara yobaretatoki kounarukanousei ari
1136 lastverticalw[0] = currentw[lgth2-1];
1138 if( outgap ) lasti = lgth1+1; else lasti = lgth1;
1141 fprintf( stderr, "currentw = \n" );
1142 for( i=0; i<lgth1+1; i++ )
1144 fprintf( stderr, "%5.2f ", currentw[i] );
1146 fprintf( stderr, "\n" );
1147 fprintf( stderr, "initverticalw = \n" );
1148 for( i=0; i<lgth2+1; i++ )
1150 fprintf( stderr, "%5.2f ", initverticalw[i] );
1152 fprintf( stderr, "\n" );
1153 fprintf( stderr, "fcgp\n" );
1154 for( i=0; i<lgth1; i++ )
1155 fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
1156 for( i=0; i<lgth2; i++ )
1157 fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
1160 for( i=1; i<lasti; i++ )
1163 previousw = currentw;
1166 previousw[0] = initverticalw[i-1];
1168 match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
1170 fprintf( stderr, "\n" );
1171 fprintf( stderr, "i=%d\n", i );
1172 fprintf( stderr, "currentw = \n" );
1173 for( j=0; j<lgth2; j++ )
1175 fprintf( stderr, "%5.2f ", currentw[j] );
1177 fprintf( stderr, "\n" );
1181 // fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
1183 imp_match_out_vead( currentw, i, lgth2 );
1185 imp_match_out_vead( currentw, i, lgth2 );
1189 fprintf( stderr, "\n" );
1190 fprintf( stderr, "i=%d\n", i );
1191 fprintf( stderr, "currentw = \n" );
1192 for( j=0; j<lgth2; j++ )
1194 fprintf( stderr, "%5.2f ", currentw[j] );
1196 fprintf( stderr, "\n" );
1198 currentw[0] = initverticalw[i];
1201 mi = previousw[0] + ogcp2[1]; mpi = 0;
1205 curpt = currentw + 1;
1208 ogcp2pt = ogcp2 + 1;
1209 fgcp1va = fgcp1[i-1];
1212 for( j=1; j<lastj; j++ )
1218 fprintf( stderr, "%5.0f->", wm );
1221 fprintf( stderr, "%5.0f?", g );
1223 if( (g=mi+*fgcp2pt) > wm )
1226 *ijppt = -( j - mpi );
1228 if( (g=*prept+*ogcp2pt) >= mi )
1238 fprintf( stderr, "%5.0f?", g );
1240 if( (g=*mjpt+fgcp1va) > wm )
1243 *ijppt = +( i - *mpjpt );
1245 if( (g=*prept+ogcp1va) >= *mjpt )
1251 m[j] += fpenalty_ex;
1255 fprintf( stderr, "%5.0f ", wm );
1265 lastverticalw[i] = currentw[lgth2-1];
1268 // fprintf( stderr, "wm = %f\n", wm );
1273 for( j=1; j<lgth2+1; j++ )
1274 currentw[j] -= offset * ( lgth2 - j ) / 2.0;
1275 for( i=1; i<lgth1+1; i++ )
1276 lastverticalw[i] -= offset * ( lgth1 - i / 2.0);
1281 fprintf( stderr, "\n" );
1282 for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
1283 fprintf( stderr, "#####\n" );
1284 for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
1285 fprintf( stderr, "====>" );
1286 for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
1287 for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
1291 Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
1294 Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
1296 // fprintf( stderr, "### impmatch = %f\n", *impmatch );
1298 resultlen = strlen( mseq1[0] );
1299 if( alloclen < resultlen || resultlen > N )
1301 fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
1302 ErrorExit( "LENGTH OVER!\n" );
1306 for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
1307 for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
1309 fprintf( stderr, "\n" );
1310 for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
1311 fprintf( stderr, "#####\n" );
1312 for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
1315 // fprintf( stderr, "wm = %f\n", wm );
1320 float A__align_gapmap( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, int *gapmap1, int *gapmap2 )
1321 /* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
1325 int lasti, lastj; /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
1328 float wm = 0.0; /* int ?????? */
1330 float *currentw, *previousw;
1331 // float fpenalty = (float)penalty;
1333 float fpenalty_ex = (float)penalty_ex;
1338 float *mjpt, *prept, *curpt;
1341 static float mi, *m;
1343 static int mpi, *mp;
1344 static float *w1, *w2;
1345 static float *match;
1346 static float *initverticalw; /* kufuu sureba iranai */
1347 static float *lastverticalw; /* kufuu sureba iranai */
1348 static char **mseq1;
1349 static char **mseq2;
1351 static float *ogcp1;
1352 static float *ogcp2;
1353 static float *fgcp1;
1354 static float *fgcp2;
1355 static float **cpmx1;
1356 static float **cpmx2;
1357 static int **intwork;
1358 static float **floatwork;
1359 static int orlgth1 = 0, orlgth2 = 0;
1367 fprintf( stderr, "eff in SA+++align\n" );
1368 for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
1372 mseq1 = AllocateCharMtx( njob, 0 );
1373 mseq2 = AllocateCharMtx( njob, 0 );
1377 lgth1 = strlen( seq1[0] );
1378 lgth2 = strlen( seq2[0] );
1380 if( lgth1 == 0 || lgth2 == 0 )
1382 fprintf( stderr, "WARNING (Aalign_gapmap): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
1386 if( lgth1 > orlgth1 || lgth2 > orlgth2 )
1390 if( orlgth1 > 0 && orlgth2 > 0 )
1394 FreeFloatVec( match );
1395 FreeFloatVec( initverticalw );
1396 FreeFloatVec( lastverticalw );
1401 FreeCharMtx( mseq );
1403 FreeFloatVec( ogcp1 );
1404 FreeFloatVec( ogcp2 );
1405 FreeFloatVec( fgcp1 );
1406 FreeFloatVec( fgcp2 );
1409 FreeFloatMtx( cpmx1 );
1410 FreeFloatMtx( cpmx2 );
1412 FreeFloatMtx( floatwork );
1413 FreeIntMtx( intwork );
1416 ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
1417 ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
1420 fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
1423 w1 = AllocateFloatVec( ll2+2 );
1424 w2 = AllocateFloatVec( ll2+2 );
1425 match = AllocateFloatVec( ll2+2 );
1427 initverticalw = AllocateFloatVec( ll1+2 );
1428 lastverticalw = AllocateFloatVec( ll1+2 );
1430 m = AllocateFloatVec( ll2+2 );
1431 mp = AllocateIntVec( ll2+2 );
1433 mseq = AllocateCharMtx( njob, ll1+ll2 );
1435 ogcp1 = AllocateFloatVec( ll1+2 );
1436 ogcp2 = AllocateFloatVec( ll2+2 );
1437 fgcp1 = AllocateFloatVec( ll1+2 );
1438 fgcp2 = AllocateFloatVec( ll2+2 );
1440 cpmx1 = AllocateFloatMtx( 26, ll1+2 );
1441 cpmx2 = AllocateFloatMtx( 26, ll2+2 );
1444 floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 );
1445 intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 26 );
1447 floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 );
1448 intwork = AllocateIntMtx( 27, MAX( ll1, ll2 )+2 );
1452 fprintf( stderr, "succeeded\n" );
1455 orlgth1 = ll1 - 100;
1456 orlgth2 = ll2 - 100;
1460 for( i=0; i<icyc; i++ )
1465 for( j=0; j<jcyc; j++ )
1467 mseq2[j] = mseq[icyc+j];
1472 if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
1476 if( commonAlloc1 && commonAlloc2 )
1478 FreeIntMtx( commonIP );
1481 ll1 = MAX( orlgth1, commonAlloc1 );
1482 ll2 = MAX( orlgth2, commonAlloc2 );
1485 fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
1488 commonIP = AllocateIntMtx( ll1+10, ll2+10 );
1491 fprintf( stderr, "succeeded\n\n" );
1499 cpmx_calc_new( seq1, cpmx1, eff1, strlen( seq1[0] ), icyc );
1500 cpmx_calc_new( seq2, cpmx2, eff2, strlen( seq2[0] ), jcyc );
1502 st_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 );
1503 st_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
1504 st_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
1505 st_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
1507 for( i=0; i<lgth1; i++ )
1509 ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] );
1510 fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] );
1512 for( i=0; i<lgth2; i++ )
1514 ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] );
1515 fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] );
1518 for( i=0; i<lgth1; i++ )
1519 fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
1526 match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
1528 imp_match_out_vead_tate_gapmap( initverticalw, gapmap2[0], lgth1, gapmap1 ); // 060306
1531 match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
1533 imp_match_out_vead_gapmap( currentw, gapmap1[0], lgth2, gapmap2 ); // 060306
1534 #if 0 // -> tbfast.c
1536 imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
1542 for( i=1; i<lgth1+1; i++ )
1544 initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
1546 for( j=1; j<lgth2+1; j++ )
1548 currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
1554 for( j=1; j<lgth2+1; j++ )
1555 currentw[j] -= offset * j / 2.0;
1556 for( i=1; i<lgth1+1; i++ )
1557 initverticalw[i] -= offset * i / 2.0;
1561 for( j=1; j<lgth2+1; ++j )
1563 m[j] = currentw[j-1] + ogcp1[1]; mp[j] = 0;
1567 lastverticalw[0] = 0.0;
1569 lastverticalw[0] = currentw[lgth2-1];
1571 if( outgap ) lasti = lgth1+1; else lasti = lgth1;
1574 fprintf( stderr, "currentw = \n" );
1575 for( i=0; i<lgth1+1; i++ )
1577 fprintf( stderr, "%5.2f ", currentw[i] );
1579 fprintf( stderr, "\n" );
1580 fprintf( stderr, "initverticalw = \n" );
1581 for( i=0; i<lgth2+1; i++ )
1583 fprintf( stderr, "%5.2f ", initverticalw[i] );
1585 fprintf( stderr, "\n" );
1586 fprintf( stderr, "fcgp\n" );
1587 for( i=0; i<lgth1; i++ )
1588 fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
1589 for( i=0; i<lgth2; i++ )
1590 fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
1593 for( i=1; i<lasti; i++ )
1596 previousw = currentw;
1599 previousw[0] = initverticalw[i-1];
1601 match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
1603 fprintf( stderr, "\n" );
1604 fprintf( stderr, "i=%d\n", i );
1605 fprintf( stderr, "currentw = \n" );
1606 for( j=0; j<lgth2; j++ )
1608 fprintf( stderr, "%5.2f ", currentw[j] );
1610 fprintf( stderr, "\n" );
1614 // fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
1616 imp_match_out_vead( currentw, i, lgth2 );
1618 imp_match_out_vead_gapmap( currentw, gapmap1[i], lgth2, gapmap2 );
1622 fprintf( stderr, "\n" );
1623 fprintf( stderr, "i=%d\n", i );
1624 fprintf( stderr, "currentw = \n" );
1625 for( j=0; j<lgth2; j++ )
1627 fprintf( stderr, "%5.2f ", currentw[j] );
1629 fprintf( stderr, "\n" );
1631 currentw[0] = initverticalw[i];
1634 mi = previousw[0] + ogcp2[1]; mpi = 0;
1639 curpt = currentw + 1;
1642 ogcp2pt = ogcp2 + 1;
1643 fgcp1va = fgcp1[i-1];
1646 for( j=1; j<lastj; j++ )
1652 fprintf( stderr, "%5.0f->", wm );
1656 fprintf( stderr, "%5.0f?", g );
1661 *ijppt = -( j - mpi );
1663 g = *prept + *ogcp2pt;
1673 g = *mjpt + fgcp1va;
1675 fprintf( stderr, "%5.0f?", g );
1680 *ijppt = +( i - *mpjpt );
1682 g = *prept + ogcp1va;
1689 m[j] += fpenalty_ex;
1693 fprintf( stderr, "%5.0f ", wm );
1703 lastverticalw[i] = currentw[lgth2-1];
1709 for( j=1; j<lgth2+1; j++ )
1710 currentw[j] -= offset * ( lgth2 - j ) / 2.0;
1711 for( i=1; i<lgth1+1; i++ )
1712 lastverticalw[i] -= offset * ( lgth1 - i / 2.0);
1717 fprintf( stderr, "\n" );
1718 for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
1719 fprintf( stderr, "#####\n" );
1720 for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
1721 fprintf( stderr, "====>" );
1722 for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
1723 for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
1727 Atracking_localhom_gapmap( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc, gapmap1, gapmap2 );
1730 Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
1732 // fprintf( stderr, "### impmatch = %f\n", *impmatch );
1734 resultlen = strlen( mseq1[0] );
1735 if( alloclen < resultlen || resultlen > N )
1737 fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
1738 ErrorExit( "LENGTH OVER!\n" );
1742 for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
1743 for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
1745 fprintf( stderr, "\n" );
1746 for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
1747 fprintf( stderr, "#####\n" );
1748 for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
1751 // fprintf( stderr, "wm = %f\n", wm );
1756 float translate_and_Calign( char **mseq1, char **mseq2, double *effarr1, double *effarr2, int clus1, int clus2, int alloclen )
1761 char *seq = NULL, **aseq = NULL;
1762 double *effarr = NULL;
1766 if ( clus1 == 1 && clus2 != 1 )
1768 seq = mseq1[0]; aseq = mseq2; effarr = effarr2; nseq = clus2+1;
1770 printf( "effarr in transl... = \n" );
1771 for( i=0; i<clus2; i++ ) printf( "%f ", effarr2[i] );
1774 else if( clus1 != 1 && clus2 == 1 )
1776 seq = mseq2[0]; aseq = mseq1; effarr = effarr1; nseq = clus1+1;
1778 else ErrorExit( "ERROR in translate_and_Calign" );
1780 result = Calignm1( &wm, aseq, seq, effarr, nseq-2, 0 );
1782 resultlen = strlen( result[0] );
1783 if( alloclen < resultlen || resultlen > N )
1785 fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
1786 ErrorExit( "LENGTH OVER!\n" );
1788 for( i=0; i<nseq-1; i++ ) strcpy( aseq[i], result[i] );
1789 strcpy( seq, result[nseq-1] );