8 #define USE_PENALTY_EX 0
10 static void OpeningGapCount( float *ogcp, int clus, char **seq, double *eff, int len )
15 for( i=0; i<len; i++ ) ogcp[i] = 0.0;
16 for( j=0; j<clus; j++ )
20 for( i=0; i<len; i++ )
23 gc = ( seq[j][i] == '-' );
25 if( !gb * gc ) ogcp[i] += feff;
31 static void FinalGapCount( float *fgcp, int clus, char **seq, double *eff, int len )
36 for( i=0; i<len; i++ ) fgcp[i] = 0.0;
37 for( j=0; j<clus; j++ )
40 gc = ( seq[j][0] == '-' );
41 for( i=1; i<len+1; i++ )
44 gc = ( seq[j][i] == '-' );
46 if( gb * !gc ) fgcp[i-1] += feff;
56 static int impalloclen = 0;
57 static float **impmtx = NULL;
58 float part_imp_match_out_sc( int i1, int j1 )
60 // fprintf( stderr, "impalloclen = %d\n", impalloclen );
61 // fprintf( stderr, "i1,j1=%d,%d -> impmtx=%f\n", i1, j1, impmtx[i1][j1] );
62 return( impmtx[i1][j1] );
64 if( i1 == l1 || j1 == l2 ) return( 0.0 );
65 return( impmtx[i1+start1][j1+start2] );
68 static void part_imp_match_out_vead_gapmap( float *imp, int i1, int lgth2, int start2, int *gapmap2 )
71 for( j=0; j<lgth2; j++ )
73 imp[j] += impmtx[i1][start2+gapmap2[j]];
77 void part_imp_match_init_strict( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore )
79 int dif, i, j, k1, k2, tmpint, start1, start2, end1, end2;
85 if( impalloclen <= lgth1 + 2 || impalloclen <= lgth2 + 2 )
87 if( impmtx ) FreeFloatMtx( impmtx );
88 impalloclen = MAX( lgth1, lgth2 ) + 2;
89 impmtx = AllocateFloatMtx( impalloclen+100, impalloclen+100 );
94 fprintf( stderr, "eff1 in _init_strict = \n" );
95 for( i=0; i<clus1; i++ )
96 fprintf( stderr, "eff1[] = %f\n", eff1[i] );
97 for( i=0; i<clus2; i++ )
98 fprintf( stderr, "eff2[] = %f\n", eff2[i] );
101 for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
103 effijx = 1.0 * fastathreshold;
104 for( i=0; i<clus1; i++ )
106 for( j=0; j<clus2; j++ )
108 effij = eff1[i] * eff2[j] * effijx;
109 tmpptr = localhom[i][j];
112 // fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
113 // fprintf( stderr, "end1 = %d\n", tmpptr->end1 );
114 // fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
115 // fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
120 if( *pt++ != '-' ) tmpint++;
121 if( tmpint == tmpptr->start1 ) break;
123 start1 = (int)( pt - seq1[i] ) - 1;
125 if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
131 if( tmpint == tmpptr->end1 ) break;
132 if( *pt++ != '-' ) tmpint++;
134 end1 = (int)( pt - seq1[i] ) - 1;
138 // fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
139 if( *pt++ != '-' ) tmpint++;
140 if( tmpint == tmpptr->end1 ) break;
142 end1 = (int)( pt - seq1[i] ) - 1;
150 if( *pt++ != '-' ) tmpint++;
151 if( tmpint == tmpptr->start2 ) break;
153 start2 = (int)( pt - seq2[j] ) - 1;
154 if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
160 if( tmpint == tmpptr->end2 ) break;
161 if( *pt++ != '-' ) tmpint++;
163 end2 = (int)( pt - seq2[j] ) - 1;
167 if( *pt++ != '-' ) tmpint++;
168 if( tmpint == tmpptr->end2 ) break;
170 end2 = (int)( pt - seq2[j] ) - 1;
173 // 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] );
174 // fprintf( stderr, "step 0\n" );
175 if( end1 - start1 != end2 - start2 )
177 // fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
180 k1 = start1; k2 = start2;
183 while( *pt1 && *pt2 )
185 if( *pt1 != '-' && *pt2 != '-' )
187 // ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
188 // impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
189 // impmtx[k1][k2] += tmpptr->importance * effij;
190 impmtx[k1][k2] += tmpptr->fimportance * effij;
191 // fprintf( stderr, "k1=%d, k2=%d, impalloclen=%d\n", k1, k2, impalloclen );
192 // fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
196 else if( *pt1 != '-' && *pt2 == '-' )
198 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
201 else if( *pt1 == '-' && *pt2 != '-' )
203 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
206 else if( *pt1 == '-' && *pt2 == '-' )
208 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
212 if( k1 > end1 || k2 > end2 ) break;
214 tmpptr = tmpptr->next;
219 0printf( stderr, "impmtx = \n" );
220 for( k2=0; k2<lgth2; k2++ )
221 fprintf( stderr, "%6.3f ", (double)k2 );
222 fprintf( stderr, "\n" );
223 for( k1=0; k1<lgth1; k1++ )
225 fprintf( stderr, "%d", k1 );
226 for( k2=0; k2<lgth2; k2++ )
227 fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
228 fprintf( stderr, "\n" );
234 void part_imp_match_init( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom )
236 int dif, i, j, k1, k2, tmpint, start1, start2, end1, end2;
237 static int impalloclen = 0;
240 static char *nocount1 = NULL;
241 static char *nocount2 = NULL;
243 if( impalloclen < lgth1 || impalloclen < lgth2 )
245 if( impmtx ) FreeFloatMtx( impmtx );
246 if( nocount1 ) free( nocount1 );
247 if( nocount2 ) free( nocount2 );
248 impalloclen = MAX( lgth1, lgth2 ) + 2;
249 impmtx = AllocateFloatMtx( impalloclen, impalloclen );
250 nocount1 = AllocateCharVec( impalloclen );
251 nocount2 = AllocateCharVec( impalloclen );
255 for( i=0; i<lgth1; i++ )
257 for( j=0; j<clus1; j++ )
258 if( seq1[j][i] == '-' ) break;
259 if( j != clus1 ) nocount1[i] = 1;
260 else nocount1[i] = 0;
262 for( i=0; i<lgth2; i++ )
264 for( j=0; j<clus2; j++ )
265 if( seq2[j][i] == '-' ) break;
266 if( j != clus2 ) nocount2[i] = 1;
267 else nocount2[i] = 0;
271 fprintf( stderr, "nocount2 =\n" );
272 for( i = 0; i<impalloclen; i++ )
274 fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
278 for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
280 for( i=0; i<clus1; i++ )
282 fprintf( stderr, "i = %d, seq1 = %s\n", i, seq1[i] );
283 for( j=0; j<clus2; j++ )
285 fprintf( stderr, "start1 = %d\n", localhom[i][j]->start1 );
286 fprintf( stderr, "end1 = %d\n", localhom[i][j]->end1 );
287 fprintf( stderr, "j = %d, seq2 = %s\n", j, seq2[j] );
292 if( *pt++ != '-' ) tmpint++;
293 if( tmpint == localhom[i][j]->start1 ) break;
295 start1 = pt - seq1[i] - 1;
299 // fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, localhom[i][j].end1, pt-seq1[i] );
300 if( *pt++ != '-' ) tmpint++;
301 if( tmpint == localhom[i][j]->end1 ) break;
303 end1 = pt - seq1[i] - 1;
309 if( *pt++ != '-' ) tmpint++;
310 if( tmpint == localhom[i][j]->start2 ) break;
312 start2 = pt - seq2[j] - 1;
315 if( *pt++ != '-' ) tmpint++;
316 if( tmpint == localhom[i][j]->end2 ) break;
318 end2 = pt - seq2[j] - 1;
319 // fprintf( stderr, "start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
322 fprintf( stderr, "step 0\n" );
323 while( k1 <= end1 && k2 <= end2 )
326 if( !nocount1[k1] && !nocount2[k2] )
327 impmtx[k1][k2] += localhom[i][j].wimportance * eff1[i] * eff2[j];
330 if( !nocount1[k1] && !nocount2[k2] )
331 impmtx[k1][k2] += localhom[i][j]->wimportance * eff1[i] * eff2[j];
336 dif = ( end1 - start1 ) - ( end2 - start2 );
337 fprintf( stderr, "dif = %d\n", dif );
342 fprintf( stderr, "dif = %d\n", dif );
345 while( k1 <= end1 && k2 <= end2 )
347 if( 0 <= k2 && start2 <= k2 && !nocount1[k1] && !nocount2[k2] )
348 impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
362 if( k1 >= 0 && k1 >= start1 && !nocount1[k1] && !nocount2[k2] )
363 impmtx[k1][k2] = localhom[i][j]->wimportance * eff1[i] * eff2[j];
372 fprintf( stderr, "impmtx = \n" );
373 for( k2=0; k2<lgth2; k2++ )
374 fprintf( stderr, "%6.3f ", (double)k2 );
375 fprintf( stderr, "\n" );
376 for( k1=0; k1<lgth1; k1++ )
378 fprintf( stderr, "%d", k1 );
379 for( k2=0; k2<lgth2; k2++ )
380 fprintf( stderr, "%6.3f ", impmtx[k1][k2] );
381 fprintf( stderr, "\n" );
387 static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
391 float **cpmxpd = floatwork;
392 int **cpmxpdn = intwork;
397 for( j=0; j<lgth2; j++ )
400 for( l=0; l<26; l++ )
404 cpmxpd[count][j] = cpmx2[l][j];
405 cpmxpdn[count][j] = l;
409 cpmxpdn[count][j] = -1;
413 for( l=0; l<26; l++ )
416 for( k=0; k<26; k++ )
417 scarr[l] += n_dis[k][l] * cpmx1[k][i1];
419 #if 0 /* ¤³¤ì¤ò»È¤¦¤È¤
\ad¤Ïfloatwork¤Î¥¢¥í¥±¡¼¥È¤òµÕ¤Ë¤¹¤ë */
421 float *fpt, **fptpt, *fpt2;
429 ipt=*iptpt,fpt=*fptpt;
431 *fpt2 += scarr[*ipt++] * *fpt++;
432 fpt2++,iptpt++,fptpt++;
436 for( j=0; j<lgth2; j++ )
439 for( k=0; cpmxpdn[k][j]>-1; k++ )
440 match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
445 static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw,
446 char **seq1, char **seq2,
447 char **mseq1, char **mseq2,
448 float **cpmx1, float **cpmx2,
449 short **ijp, int icyc, int jcyc,
450 int start1, int end1, int start2, int end2,
451 int *gapmap1, int *gapmap2 )
453 int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
456 lgth1 = strlen( seq1[0] );
457 lgth2 = strlen( seq2[0] );
460 for( i=0; i<lgth1; i++ )
462 fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
470 wm = lastverticalw[0];
471 for( i=0; i<lgth1; i++ )
473 if( lastverticalw[i] >= wm )
475 wm = lastverticalw[i];
476 iin = i; jin = lgth2-1;
477 ijp[lgth1][lgth2] = +( lgth1 - i );
480 for( j=0; j<lgth2; j++ )
482 if( lasthorizontalw[j] >= wm )
484 wm = lasthorizontalw[j];
485 iin = lgth1-1; jin = j;
486 ijp[lgth1][lgth2] = -( lgth2 - j );
491 for( i=0; i<lgth1+1; i++ )
495 for( j=0; j<lgth2+1; j++ )
497 ijp[0][j] = -( j + 1 );
500 for( i=0; i<icyc; i++ )
502 mseq1[i] += lgth1+lgth2;
505 for( j=0; j<jcyc; j++ )
507 mseq2[j] += lgth1+lgth2;
510 iin = lgth1; jin = lgth2;
512 for( k=0; k<=lgth1+lgth2; k++ )
514 if( ijp[iin][jin] < 0 )
516 ifi = iin-1; jfi = jin+ijp[iin][jin];
518 else if( ijp[iin][jin] > 0 )
520 ifi = iin-ijp[iin][jin]; jfi = jin-1;
524 ifi = iin-1; jfi = jin-1;
529 for( i=0; i<icyc; i++ )
530 *--mseq1[i] = seq1[i][ifi+l];
531 for( j=0; j<jcyc; j++ )
538 for( i=0; i<icyc; i++ )
540 for( j=0; j<jcyc; j++ )
541 *--mseq2[j] = seq2[j][jfi+l];
544 if( iin != lgth1 && jin != lgth2 ) // ??
546 *impwmpt += part_imp_match_out_sc( gapmap1[iin]+start1, gapmap2[jin]+start2 );
547 // fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
549 if( iin <= 0 || jin <= 0 ) break;
550 for( i=0; i<icyc; i++ )
551 *--mseq1[i] = seq1[i][ifi];
552 for( j=0; j<jcyc; j++ )
553 *--mseq2[j] = seq2[j][jfi];
555 iin = ifi; jin = jfi;
558 static float Atracking( float *lasthorizontalw, float *lastverticalw,
559 char **seq1, char **seq2,
560 char **mseq1, char **mseq2,
561 float **cpmx1, float **cpmx2,
562 short **ijp, int icyc, int jcyc )
564 int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k, lastk;
567 lgth1 = strlen( seq1[0] );
568 lgth2 = strlen( seq2[0] );
571 for( i=0; i<lgth1; i++ )
573 fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
581 wm = lastverticalw[0];
582 for( i=0; i<lgth1; i++ )
584 if( lastverticalw[i] >= wm )
586 wm = lastverticalw[i];
587 iin = i; jin = lgth2-1;
588 ijp[lgth1][lgth2] = +( lgth1 - i );
591 for( j=0; j<lgth2; j++ )
593 if( lasthorizontalw[j] >= wm )
595 wm = lasthorizontalw[j];
596 iin = lgth1-1; jin = j;
597 ijp[lgth1][lgth2] = -( lgth2 - j );
602 for( i=0; i<lgth1+1; i++ )
606 for( j=0; j<lgth2+1; j++ )
608 ijp[0][j] = -( j + 1 );
611 for( i=0; i<icyc; i++ )
613 mseq1[i] += lgth1+lgth2;
616 for( j=0; j<jcyc; j++ )
618 mseq2[j] += lgth1+lgth2;
621 iin = lgth1; jin = lgth2;
623 for( k=0; k<=lastk; k++ )
625 if( ijp[iin][jin] < 0 )
627 ifi = iin-1; jfi = jin+ijp[iin][jin];
629 else if( ijp[iin][jin] > 0 )
631 ifi = iin-ijp[iin][jin]; jfi = jin-1;
635 ifi = iin-1; jfi = jin-1;
640 for( i=0; i<icyc; i++ )
641 *--mseq1[i] = seq1[i][ifi+l];
642 for( j=0; j<jcyc; j++ )
649 for( i=0; i<icyc; i++ )
651 for( j=0; j<jcyc; j++ )
652 *--mseq2[j] = seq2[j][jfi+l];
655 if( iin <= 0 || jin <= 0 ) break;
656 for( i=0; i<icyc; i++ )
657 *--mseq1[i] = seq1[i][ifi];
658 for( j=0; j<jcyc; j++ )
659 *--mseq2[j] = seq2[j][jfi];
661 iin = ifi; jin = jfi;
666 float partA__align( char **seq1, char **seq2, double *eff1, double *eff2, int icyc, int jcyc, int alloclen, LocalHom ***localhom, float *impmatch, int start1, int end1, int start2, int end2, int *gapmap1, int *gapmap2 )
667 /* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
671 int lasti; /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
674 float wm = 0.0; /* int ?????? */
676 float *currentw, *previousw;
680 float *mjpt, *prept, *curpt;
686 static float *w1, *w2;
688 static float *initverticalw; /* kufuu sureba iranai */
689 static float *lastverticalw; /* kufuu sureba iranai */
697 static float **cpmx1;
698 static float **cpmx2;
699 static int **intwork;
700 static float **floatwork;
701 static int orlgth1 = 0, orlgth2 = 0;
702 float fpenalty = (float)penalty;
703 float fpenalty_ex = (float)penalty_ex;
712 fprintf( stderr, "eff in SA+++align\n" );
713 for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
717 mseq1 = AllocateCharMtx( njob, 0 );
718 mseq2 = AllocateCharMtx( njob, 0 );
722 lgth1 = strlen( seq1[0] );
723 lgth2 = strlen( seq2[0] );
725 if( lgth1 > orlgth1 || lgth2 > orlgth2 )
729 if( orlgth1 > 0 && orlgth2 > 0 )
733 FreeFloatVec( match );
734 FreeFloatVec( initverticalw );
735 FreeFloatVec( lastverticalw );
742 FreeFloatVec( ogcp1 );
743 FreeFloatVec( ogcp2 );
744 FreeFloatVec( fgcp1 );
745 FreeFloatVec( fgcp2 );
748 FreeFloatMtx( cpmx1 );
749 FreeFloatMtx( cpmx2 );
751 FreeFloatMtx( floatwork );
752 FreeIntMtx( intwork );
755 ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
756 ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
759 fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
762 w1 = AllocateFloatVec( ll2+2 );
763 w2 = AllocateFloatVec( ll2+2 );
764 match = AllocateFloatVec( ll2+2 );
766 initverticalw = AllocateFloatVec( ll1+2 );
767 lastverticalw = AllocateFloatVec( ll1+2 );
769 m = AllocateFloatVec( ll2+2 );
770 mp = AllocateIntVec( ll2+2 );
772 mseq = AllocateCharMtx( njob, ll1+ll2 );
774 ogcp1 = AllocateFloatVec( ll1+2 );
775 ogcp2 = AllocateFloatVec( ll2+2 );
776 fgcp1 = AllocateFloatVec( ll1+2 );
777 fgcp2 = AllocateFloatVec( ll2+2 );
779 cpmx1 = AllocateFloatMtx( 26, ll1+2 );
780 cpmx2 = AllocateFloatMtx( 26, ll2+2 );
782 floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 );
783 intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 );
786 fprintf( stderr, "succeeded\n" );
794 for( i=0; i<icyc; i++ ) mseq1[i] = mseq[i];
795 for( j=0; j<jcyc; j++ ) mseq2[j] = mseq[icyc+j];
798 if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
802 if( commonAlloc1 && commonAlloc2 )
804 FreeShortMtx( commonIP );
807 ll1 = MAX( orlgth1, commonAlloc1 );
808 ll2 = MAX( orlgth2, commonAlloc2 );
811 fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
814 commonIP = AllocateShortMtx( ll1+10, ll2+10 );
817 fprintf( stderr, "succeeded\n\n" );
825 cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
826 cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
828 OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 );
829 OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 );
830 FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 );
831 FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 );
833 for( i=0; i<lgth1; i++ )
835 ogcp1[i] = 0.5 * ( 1.0 - ogcp1[i] ) * fpenalty;
836 fgcp1[i] = 0.5 * ( 1.0 - fgcp1[i] ) * fpenalty;
838 for( i=0; i<lgth2; i++ )
840 ogcp2[i] = 0.5 * ( 1.0 - ogcp2[i] ) * fpenalty;
841 fgcp2[i] = 0.5 * ( 1.0 - fgcp2[i] ) * fpenalty;
844 for( i=0; i<lgth1; i++ )
845 fprintf( stderr, "ogcp1[%d]=%f\n", i, ogcp1[i] );
852 match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
855 match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
858 imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
864 for( i=1; i<lgth1+1; i++ )
866 initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
868 for( j=1; j<lgth2+1; j++ )
870 currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
876 for( j=1; j<lgth2+1; j++ )
877 currentw[j] -= offset * j / 2.0;
878 for( i=1; i<lgth1+1; i++ )
879 initverticalw[i] -= offset * i / 2.0;
883 for( j=1; j<lgth2+1; ++j )
885 m[j] = currentw[j-1] + ogcp1[1]; mp[j] = 0;
888 lastverticalw[0] = currentw[lgth2-1];
890 if( outgap ) lasti = lgth1+1; else lasti = lgth1;
893 fprintf( stderr, "currentw = \n" );
894 for( i=0; i<lgth1+1; i++ )
896 fprintf( stderr, "%5.2f ", currentw[i] );
898 fprintf( stderr, "\n" );
899 fprintf( stderr, "initverticalw = \n" );
900 for( i=0; i<lgth2+1; i++ )
902 fprintf( stderr, "%5.2f ", initverticalw[i] );
904 fprintf( stderr, "\n" );
905 fprintf( stderr, "fcgp\n" );
906 for( i=0; i<lgth1; i++ )
907 fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
908 for( i=0; i<lgth2; i++ )
909 fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
912 for( i=1; i<lasti; i++ )
915 previousw = currentw;
918 previousw[0] = initverticalw[i-1];
920 match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
922 fprintf( stderr, "\n" );
923 fprintf( stderr, "i=%d\n", i );
924 fprintf( stderr, "currentw = \n" );
925 for( j=0; j<lgth2; j++ )
927 fprintf( stderr, "%5.2f ", currentw[j] );
929 fprintf( stderr, "\n" );
933 // fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
934 // imp_match_out_vead( currentw, i, lgth2 );
935 part_imp_match_out_vead_gapmap( currentw, gapmap1[i]+start1, lgth2, start2, gapmap2 );
938 fprintf( stderr, "\n" );
939 fprintf( stderr, "i=%d\n", i );
940 fprintf( stderr, "currentw = \n" );
941 for( j=0; j<lgth2; j++ )
943 fprintf( stderr, "%5.2f ", currentw[j] );
945 fprintf( stderr, "\n" );
947 currentw[0] = initverticalw[i];
950 mi = previousw[0] + ogcp2[1]; mpi = 0;
955 curpt = currentw + 1;
959 fgcp1va = fgcp1[i-1];
961 for( j=1; j<lgth2+1; j++ )
967 fprintf( stderr, "%5.0f->", wm );
971 fprintf( stderr, "%5.0f?", g );
976 *ijppt = -( j - mpi );
978 g = *prept + *ogcp2pt;
990 fprintf( stderr, "%5.0f?", g );
995 *ijppt = +( i - *mpjpt );
997 g = *prept + ogcp1va;
1004 m[j] += fpenalty_ex;
1008 fprintf( stderr, "%5.0f ", wm );
1019 lastverticalw[i] = currentw[lgth2-1];
1025 for( j=1; j<lgth2+1; j++ )
1026 currentw[j] -= offset * ( lgth2 - j ) / 2.0;
1027 for( i=1; i<lgth1+1; i++ )
1028 lastverticalw[i] -= offset * ( lgth1 - i / 2.0);
1033 fprintf( stderr, "\n" );
1034 for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
1035 fprintf( stderr, "#####\n" );
1036 for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
1037 fprintf( stderr, "====>" );
1038 for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
1039 for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
1043 Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc, start1, end1, start2, end2, gapmap1, gapmap2 );
1046 Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
1048 // fprintf( stderr, "### impmatch = %f\n", *impmatch );
1050 resultlen = strlen( mseq1[0] );
1051 if( alloclen < resultlen || resultlen > N )
1053 fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
1054 ErrorExit( "LENGTH OVER!\n" );
1058 for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
1059 for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
1061 fprintf( stderr, "\n" );
1062 for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
1063 fprintf( stderr, "#####\n" );
1064 for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );