8 #define USE_PENALTY_EX 0
9 #define FASTMATCHCALC 1
12 static float countnocountmatch( Gappat *pat1, Gappat *pat2, int r )
15 Gappat *pat1bk = pat1;
16 Gappat *pat2bk = pat2;
18 // pat1[][0] ha total gap.
19 for( pat1=pat1bk+1; pat1->len != 0; pat1++ )
21 if( r ) fprintf( stderr, "b %d-%d, len=%d,%d\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len );
22 for( pat2=pat2bk+1; pat2->len != 0; pat2++ )
24 if( pat1->len == pat2->len )
26 if( r ) fprintf( stderr, " x%d-%d, len=%d,%d\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len );
27 val += pat1->freq * pat2->freq;
28 if( r ) fprintf( stderr, "y %d-%d, val = %f\n", pat1-pat1bk, pat2-pat2bk,val );
29 if( r ) fprintf( stderr, "z tsugi, %d-%d, len=%d,%d\n", pat1-pat1bk+1, pat2-pat2bk+1, (pat1+1)->len, (pat2+1)->len );
31 if( r ) fprintf( stderr, "a %d-%d, len=%d,%d\n", pat1-pat1bk, pat2-pat2bk, pat1->len, pat2->len );
34 // fprintf( stderr, "nocountmatch=%f\n", val );
38 static float countnocountx( Gappat *pat1, float diaf1, Gappat *pat2, int offset1, int r )
43 Gappat *pat1bk = pat1;
44 Gappat *pat2bk = pat2;
47 for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
49 if( pat2->len == offset1 )
51 gmatch = diaf1 * pat2->freq;
52 // if( r ) fprintf( stderr, "match0!!, len=%d, gmatch=%f * %f\n", pat2->len, diaf1, pat2->freq );
55 for( pat1=pat1bk+1; pat1->len != 0; pat1++ ) // excl. len=0
57 for( pat2=pat2bk+1; pat2->len != 0; pat2++ ) // excl. len=0
59 if( pat1->len + offset1 == pat2->len )
61 gmatch += pat1->freq * pat2->freq;
62 // if( r ) fprintf( stderr, "match1!!, len=%d, gmatch=%f * %f\n", pat2->len, pat1->freq, pat2->freq );
69 static float countnocount( Gappat *pat1, Gappat *pat2, int offset1, int offset2 ) //osoi
72 Gappat *pat1bk = pat1;
73 Gappat *pat2bk = pat2;
75 // pat1[][0] ha total gap.
76 for( pat1=pat1bk+1; pat1->len != -1; pat1++ )
78 for( pat2=pat2bk+1; pat2->len != -1; pat2++ )
80 if( pat1->len+offset1 == pat2->len+offset2 )
82 val += pat1->freq * pat2->freq;
86 // fprintf( stderr, "nocount=%f\n", val );
91 static float **impmtx = NULL;
92 #if 1 // tditeration to naiveHscore_imp de tsukawareru.
93 float imp_match_out_scH( int i1, int j1 )
95 // fprintf( stderr, "imp+match = %f\n", impmtx[i1][j1] * fastathreshold );
96 // fprintf( stderr, "val = %f\n", impmtx[i1][j1] );
97 return( impmtx[i1][j1] );
101 static void imp_match_out_veadH( float *imp, int i1, int lgth2 )
104 float *pt = impmtx[i1];
109 float *pt = impmtx[i1];
110 for( j=0; j<lgth2; j++ )
114 static void imp_match_out_vead_tateH( float *imp, int j1, int lgth1 )
117 for( i=0; i<lgth1; i++ )
118 *imp++ += impmtx[i][j1];
121 #if 1 // tbfast.c kara yobareru.
122 void imp_match_init_strictH( float *imp, int clus1, int clus2, int lgth1, int lgth2, char **seq1, char **seq2, double *eff1, double *eff2, LocalHom ***localhom, int forscore )
124 int i, j, k1, k2, tmpint, start1, start2, end1, end2;
125 static int impalloclen = 0;
128 char *pt, *pt1, *pt2;
129 static char *nocount1 = NULL;
130 static char *nocount2 = NULL;
133 if( impalloclen < lgth1 + 2 || impalloclen < lgth2 + 2 )
135 if( impmtx ) FreeFloatMtx( impmtx );
136 if( nocount1 ) free( nocount1 );
137 if( nocount2 ) free( nocount2 );
138 impalloclen = MAX( lgth1, lgth2 ) + 2;
139 impmtx = AllocateFloatMtx( impalloclen, impalloclen );
140 nocount1 = AllocateCharVec( impalloclen );
141 nocount2 = AllocateCharVec( impalloclen );
144 for( i=0; i<lgth1; i++ )
146 for( j=0; j<clus1; j++ )
147 if( seq1[j][i] == '-' ) break;
148 if( j != clus1 ) nocount1[i] = 1;
149 else nocount1[i] = 0;
151 for( i=0; i<lgth2; i++ )
153 for( j=0; j<clus2; j++ )
154 if( seq2[j][i] == '-' ) break;
155 if( j != clus2 ) nocount2[i] = 1;
156 else nocount2[i] = 0;
160 fprintf( stderr, "nocount2 =\n" );
161 for( i = 0; i<impalloclen; i++ )
163 fprintf( stderr, "nocount2[%d] = %d (%c)\n", i, nocount2[i], seq2[0][i] );
170 fprintf( stderr, "eff1 in _init_strict = \n" );
171 for( i=0; i<clus1; i++ )
172 fprintf( stderr, "eff1[] = %f\n", eff1[i] );
173 for( i=0; i<clus2; i++ )
174 fprintf( stderr, "eff2[] = %f\n", eff2[i] );
177 for( i=0; i<lgth1; i++ ) for( j=0; j<lgth2; j++ )
179 effijx = fastathreshold;
180 for( i=0; i<clus1; i++ )
182 for( j=0; j<clus2; j++ )
184 effij = (float)( eff1[i] * eff2[j] * effijx );
185 tmpptr = localhom[i][j];
188 // fprintf( stderr, "start1 = %d\n", tmpptr->start1 );
189 // fprintf( stderr, "end1 = %d\n", tmpptr->end1 );
190 // fprintf( stderr, "i = %d, seq1 = \n%s\n", i, seq1[i] );
191 // fprintf( stderr, "j = %d, seq2 = \n%s\n", j, seq2[j] );
196 if( *pt++ != '-' ) tmpint++;
197 if( tmpint == tmpptr->start1 ) break;
199 start1 = pt - seq1[i] - 1;
201 if( tmpptr->start1 == tmpptr->end1 ) end1 = start1;
207 // fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
208 if( tmpint == tmpptr->end1 ) break;
209 if( *pt++ != '-' ) tmpint++;
211 end1 = pt - seq1[i] - 0;
215 // fprintf( stderr, "tmpint = %d, end1 = %d pos = %d\n", tmpint, tmpptr->end1, pt-seq1[i] );
216 if( *pt++ != '-' ) tmpint++;
217 if( tmpint == tmpptr->end1 ) break;
219 end1 = pt - seq1[i] - 1;
227 if( *pt++ != '-' ) tmpint++;
228 if( tmpint == tmpptr->start2 ) break;
230 start2 = pt - seq2[j] - 1;
231 if( tmpptr->start2 == tmpptr->end2 ) end2 = start2;
237 if( tmpint == tmpptr->end2 ) break;
238 if( *pt++ != '-' ) tmpint++;
240 end2 = pt - seq2[j] - 0;
244 if( *pt++ != '-' ) tmpint++;
245 if( tmpint == tmpptr->end2 ) break;
247 end2 = pt - seq2[j] - 1;
250 // 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] );
251 // fprintf( stderr, "step 0\n" );
252 if( end1 - start1 != end2 - start2 )
254 // fprintf( stderr, "CHUUI!!, start1 = %d, end1 = %d, start2 = %d, end2 = %d\n", start1, end1, start2, end2 );
258 k1 = start1; k2 = start2;
261 while( *pt1 && *pt2 )
263 if( *pt1 != '-' && *pt2 != '-' )
265 // ½Å¤ß¤òÆó½Å¤Ë¤«¤±¤Ê¤¤¤è¤¦¤ËÃðդ·¤Æ²¼¤µ¤¤¡£
266 // impmtx[k1][k2] += tmpptr->wimportance * fastathreshold;
267 // impmtx[k1][k2] += tmpptr->importance * effij;
268 impmtx[k1][k2] += tmpptr->fimportance * effij;
269 // fprintf( stderr, "#### impmtx[k1][k2] = %f, tmpptr->fimportance=%f, effij=%f\n", impmtx[k1][k2], tmpptr->fimportance, effij );
270 // fprintf( stderr, "mark, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
271 // fprintf( stderr, "%d (%c) - %d (%c) - %f\n", k1, *pt1, k2, *pt2, tmpptr->fimportance * effij );
275 else if( *pt1 != '-' && *pt2 == '-' )
277 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
280 else if( *pt1 == '-' && *pt2 != '-' )
282 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
285 else if( *pt1 == '-' && *pt2 == '-' )
287 // fprintf( stderr, "skip, %d (%c) - %d (%c) \n", k1, *pt1, k2, *pt2 );
291 if( k1 > end1 || k2 > end2 ) break;
294 while( k1 <= end1 && k2 <= end2 )
296 fprintf( stderr, "k1,k2=%d,%d - ", k1, k2 );
297 if( !nocount1[k1] && !nocount2[k2] )
299 impmtx[k1][k2] += tmpptr->wimportance * eff1[i] * eff2[j] * fastathreshold;
300 fprintf( stderr, "marked\n" );
303 fprintf( stderr, "no count\n" );
307 tmpptr = tmpptr->next;
312 if( clus1 == 1 && clus2 == 6 )
314 fprintf( stderr, "\n" );
315 fprintf( stderr, "seq1[0] = %s\n", seq1[0] );
316 fprintf( stderr, "seq2[0] = %s\n", seq2[0] );
317 fprintf( stderr, "impmtx = \n" );
318 for( k2=0; k2<lgth2; k2++ )
319 fprintf( stderr, "%6.3f ", (double)k2 );
320 fprintf( stderr, "\n" );
321 for( k1=0; k1<lgth1; k1++ )
323 fprintf( stderr, "%d ", k1 );
324 for( k2=0; k2<3; k2++ )
325 fprintf( stderr, "%2.1f ", impmtx[k1][k2] );
326 fprintf( stderr, "\n" );
335 static void match_calc( float *match, float **cpmx1, float **cpmx2, int i1, int lgth2, float **floatwork, int **intwork, int initialize )
340 float **cpmxpd = floatwork;
341 int **cpmxpdn = intwork;
342 float *matchpt, *cpmxpdpt, **cpmxpdptpt;
343 int *cpmxpdnpt, **cpmxpdnptpt;
347 for( j=0; j<lgth2; j++ )
350 for( l=0; l<26; l++ )
354 cpmxpd[j][count] = cpmx2[l][j];
355 cpmxpdn[j][count] = l;
359 cpmxpdn[j][count] = -1;
364 for( l=0; l<26; l++ )
367 for( j=0; j<26; j++ )
368 scarr[l] += n_dis[j][l] * cpmx1[j][i1];
371 cpmxpdnptpt = cpmxpdn;
376 cpmxpdnpt = *cpmxpdnptpt++;
377 cpmxpdpt = *cpmxpdptpt++;
378 while( *cpmxpdnpt>-1 )
379 *matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++;
386 float **cpmxpd = floatwork;
387 int **cpmxpdn = intwork;
392 for( j=0; j<lgth2; j++ )
395 for( l=0; l<26; l++ )
399 cpmxpd[count][j] = cpmx2[l][j];
400 cpmxpdn[count][j] = l;
404 cpmxpdn[count][j] = -1;
407 for( l=0; l<26; l++ )
410 for( k=0; k<26; k++ )
411 scarr[l] += n_dis[k][l] * cpmx1[k][i1];
413 for( j=0; j<lgth2; j++ )
416 for( k=0; cpmxpdn[k][j]>-1; k++ )
417 match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j];
422 static void Atracking_localhom( float *impwmpt, float *lasthorizontalw, float *lastverticalw,
423 char **seq1, char **seq2,
424 char **mseq1, char **mseq2,
425 float **cpmx1, float **cpmx2,
426 short **ijp, int icyc, int jcyc )
428 int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
430 char *gaptable1, *gt1bk;
431 char *gaptable2, *gt2bk;
432 lgth1 = strlen( seq1[0] );
433 lgth2 = strlen( seq2[0] );
434 gt1bk = AllocateCharVec( lgth1+lgth2+1 );
435 gt2bk = AllocateCharVec( lgth1+lgth2+1 );
438 for( i=0; i<lgth1; i++ )
440 fprintf( stderr, "lastverticalw[%d] = %f\n", i, lastverticalw[i] );
448 wm = lastverticalw[0];
449 for( i=0; i<lgth1; i++ )
451 if( lastverticalw[i] >= wm )
453 wm = lastverticalw[i];
454 iin = i; jin = lgth2-1;
455 ijp[lgth1][lgth2] = +( lgth1 - i );
458 for( j=0; j<lgth2; j++ )
460 if( lasthorizontalw[j] >= wm )
462 wm = lasthorizontalw[j];
463 iin = lgth1-1; jin = j;
464 ijp[lgth1][lgth2] = -( lgth2 - j );
469 for( i=0; i<lgth1+1; i++ )
473 for( j=0; j<lgth2+1; j++ )
475 ijp[0][j] = -( j + 1 );
478 gaptable1 = gt1bk + lgth1+lgth2;
480 gaptable2 = gt2bk + lgth1+lgth2;
483 iin = lgth1; jin = lgth2;
485 for( k=0; k<=lgth1+lgth2; k++ )
487 if( ijp[iin][jin] < 0 )
489 ifi = iin-1; jfi = jin+ijp[iin][jin];
491 else if( ijp[iin][jin] > 0 )
493 ifi = iin-ijp[iin][jin]; jfi = jin-1;
497 ifi = iin-1; jfi = jin-1;
513 if( iin == lgth1 || jin == lgth2 )
517 *impwmpt += imp_match_out_scH( iin, jin );
519 // fprintf( stderr, "impwm = %f (iin=%d, jin=%d) seq1=%c, seq2=%c\n", *impwmpt, iin, jin, seq1[0][iin], seq2[0][jin] );
521 if( iin <= 0 || jin <= 0 ) break;
525 iin = ifi; jin = jfi;
528 for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
529 for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
535 static float Atracking( float *lasthorizontalw, float *lastverticalw,
536 char **seq1, char **seq2,
537 char **mseq1, char **mseq2,
538 float **cpmx1, float **cpmx2,
539 short **ijp, int icyc, int jcyc )
541 int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k;
543 char *gaptable1, *gt1bk;
544 char *gaptable2, *gt2bk;
545 lgth1 = strlen( seq1[0] );
546 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;
598 for( k=0; k<=lgth1+lgth2; k++ )
600 if( ijp[iin][jin] < 0 )
602 ifi = iin-1; jfi = jin+ijp[iin][jin];
604 else if( ijp[iin][jin] > 0 )
606 ifi = iin-ijp[iin][jin]; jfi = jin-1;
610 ifi = iin-1; jfi = jin-1;
626 if( iin <= 0 || jin <= 0 ) break;
630 iin = ifi; jin = jfi;
633 for( i=0; i<icyc; i++ ) gapireru( mseq1[i], seq1[i], gaptable1 );
634 for( j=0; j<jcyc; j++ ) gapireru( mseq2[j], seq2[j], gaptable2 );
642 float H__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 )
643 /* score no keisan no sai motokaraaru gap no atukai ni mondai ga aru */
647 int lasti, lastj; /* outgap == 0 -> lgth1, outgap == 1 -> lgth1+1 */
650 float wm = 0.0; /* int ?????? */
652 float *currentw, *previousw;
653 // float fpenalty = (float)penalty;
655 float fpenalty_ex = (float)penalty_ex;
660 float *mjpt, *prept, *curpt;
666 static float *w1, *w2;
668 static float *initverticalw; /* kufuu sureba iranai */
669 static float *lastverticalw; /* kufuu sureba iranai */
673 static Gappat **gappat1;
674 static Gappat **gappat2;
683 static float *ogcp1g;
684 static float *ogcp2g;
685 static float *fgcp1g;
686 static float *fgcp2g;
691 static float **cpmx1;
692 static float **cpmx2;
693 static int **intwork;
694 static float **floatwork;
695 static int orlgth1 = 0, orlgth2 = 0;
696 float fpenalty = (float)penalty;
707 fprintf( stderr, "#### eff in SA+++align\n" );
708 fprintf( stderr, "#### seq1[0] = %s\n", seq1[0] );
709 fprintf( stderr, "#### strlen( seq1[0] ) = %d\n", strlen( seq1[0] ) );
710 for( i=0; i<icyc; i++ ) fprintf( stderr, "eff1[%d] = %f\n", i, eff1[i] );
714 mseq1 = AllocateCharMtx( njob, 0 );
715 mseq2 = AllocateCharMtx( njob, 0 );
719 lgth1 = strlen( seq1[0] );
720 lgth2 = strlen( seq2[0] );
722 if( lgth1 == 0 || lgth2 == 0 )
724 fprintf( stderr, "WARNING (Aalignmm): lgth1=%d, lgth2=%d\n", lgth1, lgth2 );
728 if( lgth1 > orlgth1 || lgth2 > orlgth2 )
732 if( orlgth1 > 0 && orlgth2 > 0 )
736 FreeFloatVec( match );
737 FreeFloatVec( initverticalw );
738 FreeFloatVec( lastverticalw );
747 FreeFloatVec( digf1 );
748 FreeFloatVec( digf2 );
749 FreeFloatVec( diaf1 );
750 FreeFloatVec( diaf2 );
751 FreeFloatVec( gapz1 );
752 FreeFloatVec( gapz2 );
753 FreeFloatVec( gapf1 );
754 FreeFloatVec( gapf2 );
755 FreeFloatVec( ogcp1 );
756 FreeFloatVec( ogcp2 );
757 FreeFloatVec( fgcp1 );
758 FreeFloatVec( fgcp2 );
759 FreeFloatVec( ogcp1g );
760 FreeFloatVec( ogcp2g );
761 FreeFloatVec( fgcp1g );
762 FreeFloatVec( fgcp2g );
765 FreeFloatMtx( cpmx1 );
766 FreeFloatMtx( cpmx2 );
768 FreeFloatMtx( floatwork );
769 FreeIntMtx( intwork );
772 ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100;
773 ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100;
776 fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 );
779 w1 = AllocateFloatVec( ll2+2 );
780 w2 = AllocateFloatVec( ll2+2 );
781 match = AllocateFloatVec( ll2+2 );
783 initverticalw = AllocateFloatVec( ll1+2 );
784 lastverticalw = AllocateFloatVec( ll1+2 );
786 m = AllocateFloatVec( ll2+2 );
787 mp = AllocateIntVec( ll2+2 );
789 mseq = AllocateCharMtx( njob, ll1+ll2 );
791 gappat1 = calloc( ll1+2, sizeof( Gappat *) );
792 gappat2 = calloc( ll2+2, sizeof( Gappat *) );
793 digf1 = AllocateFloatVec( ll1+2 );
794 digf2 = AllocateFloatVec( ll2+2 );
795 diaf1 = AllocateFloatVec( ll1+2 );
796 diaf2 = AllocateFloatVec( ll2+2 );
797 gapz1 = AllocateFloatVec( ll1+2 );
798 gapz2 = AllocateFloatVec( ll2+2 );
799 gapf1 = AllocateFloatVec( ll1+2 );
800 gapf2 = AllocateFloatVec( ll2+2 );
801 ogcp1 = AllocateFloatVec( ll1+2 );
802 ogcp2 = AllocateFloatVec( ll2+2 );
803 fgcp1 = AllocateFloatVec( ll1+2 );
804 fgcp2 = AllocateFloatVec( ll2+2 );
805 ogcp1g = AllocateFloatVec( ll1+2 );
806 ogcp2g = AllocateFloatVec( ll2+2 );
807 fgcp1g = AllocateFloatVec( ll1+2 );
808 fgcp2g = AllocateFloatVec( ll2+2 );
810 cpmx1 = AllocateFloatMtx( 26, ll1+2 );
811 cpmx2 = AllocateFloatMtx( 26, ll2+2 );
814 floatwork = AllocateFloatMtx( MAX( ll1, ll2 )+2, 26 );
815 intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, 27 );
817 floatwork = AllocateFloatMtx( 26, MAX( ll1, ll2 )+2 );
818 intwork = AllocateIntMtx( 26, MAX( ll1, ll2 )+2 );
822 fprintf( stderr, "succeeded\n" );
830 for( i=0; i<icyc; i++ )
835 for( j=0; j<jcyc; j++ )
837 mseq2[j] = mseq[icyc+j];
842 if( orlgth1 > commonAlloc1 || orlgth2 > commonAlloc2 )
846 if( commonAlloc1 && commonAlloc2 )
848 FreeShortMtx( commonIP );
851 ll1 = MAX( orlgth1, commonAlloc1 );
852 ll2 = MAX( orlgth2, commonAlloc2 );
855 fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 );
858 commonIP = AllocateShortMtx( ll1+10, ll2+10 );
861 fprintf( stderr, "succeeded\n\n" );
872 for( i=0; i<icyc; i++ )
874 fprintf( stderr, "## totaleff = %f\n", t );
878 cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc );
879 cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc );
883 new_OpeningGapCount_zure( ogcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
884 new_OpeningGapCount_zure( ogcp2g, jcyc, seq2, eff2, lgth2, sgap2, egap1 );
885 new_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1, sgap1, egap1 );
886 new_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2, sgap1, egap2 );
887 getdigapfreq_part( digf1, icyc, seq1, eff1, lgth1, sgap1, egap1 ); // sgap1 ha iranai ?
888 getdigapfreq_part( digf2, jcyc, seq2, eff2, lgth2, sgap2, egap2 ); // sgap1 ha iranai ?
889 getdiaminofreq_part( diaf1, icyc, seq1, eff1, lgth1, sgap1, egap1 ); // sgap1 ha iranai ?
890 getdiaminofreq_part( diaf2, jcyc, seq2, eff2, lgth2, sgap1, egap2 ); // sgap1 ha iranai ?
891 getgapfreq( gapf1, icyc, seq1, eff1, lgth1 ); // atode
892 getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 ); // atode
893 getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 ); // atode
894 getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 ); // atode
898 st_OpeningGapCount( ogcp1g, icyc, seq1, eff1, lgth1 );
899 st_OpeningGapCount( ogcp2g, jcyc, seq2, eff2, lgth2 );
900 st_FinalGapCount_zure( fgcp1g, icyc, seq1, eff1, lgth1 );
901 st_FinalGapCount_zure( fgcp2g, jcyc, seq2, eff2, lgth2 );
902 st_getGapPattern( gappat1, icyc, seq1, eff1, lgth1 );
903 st_getGapPattern( gappat2, jcyc, seq2, eff2, lgth2 );
904 getdigapfreq_st( digf1, icyc, seq1, eff1, lgth1 );
905 getdigapfreq_st( digf2, jcyc, seq2, eff2, lgth2 );
906 getdiaminofreq_x( diaf1, icyc, seq1, eff1, lgth1 );
907 getdiaminofreq_x( diaf2, jcyc, seq2, eff2, lgth2 );
908 getgapfreq( gapf1, icyc, seq1, eff1, lgth1 );
909 getgapfreq( gapf2, jcyc, seq2, eff2, lgth2 );
910 getgapfreq_zure( gapz1, icyc, seq1, eff1, lgth1 );
911 getgapfreq_zure( gapz2, jcyc, seq2, eff2, lgth2 );
915 for( i=0; i<lgth1+1; i++ )
918 for( j=1; gappat1[i][j].len != -1; j++ )
919 fprintf( stderr, "i=%d, j=%d, gap end, freq=%f, len=%d\n", i, j, gappat1[i][j].freq, gappat1[i][j].len );
927 match_calc( initverticalw, cpmx2, cpmx1, 0, lgth1, floatwork, intwork, 1 );
929 imp_match_out_vead_tateH( initverticalw, 0, lgth1 ); // 060306
931 match_calc( currentw, cpmx1, cpmx2, 0, lgth2, floatwork, intwork, 1 );
933 imp_match_out_veadH( currentw, 0, lgth2 ); // 060306
938 imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 );
944 g = diaf1[0] * gappat2[0][0].freq * fpenalty;
945 // g = ogcp1g[0] * ( 1.0-ogcp2g[0] ) * fpenalty * 0.5;
946 // fprintf( stderr, "init-match penal1=%f, %c-%c, diaf1[0] = %f\n", g/fpenalty, seq1[0][0], seq2[0][0], diaf1[0] );
947 initverticalw[0] += g;
950 g = diaf2[0] * gappat1[0][0].freq * fpenalty;
951 // g = ogcp2g[0] * ( 1.0-ogcp1g[0] ) * fpenalty * 0.5;
952 // fprintf( stderr, "init-match penal2=%f, %c-%c, diaf2[0] = %f\n", g/fpenalty, seq1[0][0], seq2[0][0], diaf2[0] );
953 initverticalw[0] += g;
956 g = ( (gappat1[0][0].freq) * (gappat2[0][0].freq) - countnocountmatch( gappat1[0], gappat2[0], i==j ) ) * fpenalty;
957 // fprintf( stderr, "init-match penal2=%f, %c-%c\n", g/fpenalty, seq1[0][0], seq2[0][0] );
958 initverticalw[0] += g;
962 for( i=1; i<lgth1+1; i++ )
964 // initverticalw[i] += ( ogcp1[0] + fgcp1[i-1] ) ;
967 // tmppenal = ( (1.0-gapf2[j-1])*(1.0-ogcp1g[i]+fgcp1g[i]) + gapf2[j-1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
968 // tmppenal = ( (1.0-gapz2[0])*(1.0-ogcp1g[0]+0.0) + gapz2[0]*(1.0-digf1[0] - diaf1[0]) ) * 0.5 * fpenalty; // mada
969 // tmppenal = ( (1.0-0.0)*(1.0-ogcp1g[0]+0.0) + 0.0*(1.0-0.0-0.0) ) * 0.5 * fpenalty; // mada
970 // tmppenal = 0.5 * fpenalty;
971 // tmppenal -= ( (1.0-0.0) * (1.0-diaf1[0]) + 0.0 ) * 0.5 * fpenalty; // 0.
972 // tmppenal -= ( (1.0-gapf2[j-1]) * ogcp1g[i] + gapf2[j-1] ) * 0.5 * fpenalty;
973 // fprintf( stderr, "0,0<-%d,%d, tmppenal 1 = %f\n", i, 0, tmppenal );
974 initverticalw[i] += tmppenal;
976 tmppenal = (1.0-gapf2[0]) * ( diaf1[i] + gappat1[i][0].freq - countnocount( gappat1[i], gappat2[0], 0, i ) ) * fpenalty;
977 // tmppenal = ( (1.0-gapf2[j])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[j]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
978 // tmppenal = ( (1.0-gapz2[1])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapz2[1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
979 // tmppenal = ( (1.0-gapf2[0])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[0]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
980 // tmppenal = 0.5 * fpenalty;
981 // tmppenal -= ( (1.0-gapf2[0]) * (1.0-diaf1[i]) + gapf2[0] ) * 0.5 * fpenalty;
982 // tmppenal -= ( (1.0-gapf2[j]) * fgcp1g[i] + gapf2[j] ) * 0.5 * fpenalty;
983 initverticalw[i] += tmppenal;
984 cumpenal += ( ogcp1g[i-0] + fgcp1g[i] ) * fpenalty * 0.5;
985 // initverticalw[i] += cumpenal - fgcp1g[i] * fpenalty * 0.5;
986 // fprintf( stderr, "0,0<-%d,%d, tmppenal2 = %f, cumpenal=%f, fgcp1g[i]=%f, ogcp1g[i]=%f\n", i, 0, tmppenal, cumpenal, fgcp1g[i], ogcp1g[i] );
990 for( j=1; j<lgth2+1; j++ )
992 // currentw[j] += ( ogcp2[0] + fgcp2[j-1] ) ;
995 // tmppenal = ( (1.0-gapf1[i-1])*(1.0-ogcp2g[j]+fgcp2g[j]) + gapf1[i-1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
996 // tmppenal = ( (1.0-gapz1[0])*(1.0-ogcp2g[0]+0.0) + gapz1[0]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
997 // tmppenal = ( (1.0-0.0)*(1.0-ogcp2g[0]+0.0) + 0.0*(1.0-0.0-0.0) ) * 0.5 * fpenalty; // mada
998 // tmppenal = 0.5 * fpenalty;
999 // tmppenal -= ( (1.0-0.0) * (1.0-diaf2[0]) + 0.0 ) * 0.5 * fpenalty; // 0.
1000 // tmppenal -= ( (1.0-gapf1[0]) * fgcp2g[j] + gapf1[0] ) * 0.5 * fpenalty;
1001 // fprintf( stderr, "0,0<-%d,%d, tmppenal 3 = %f\n", 0, j, tmppenal );
1002 currentw[j] += tmppenal;
1004 tmppenal = (1.0-gapf1[0]) * ( diaf2[j] + gappat2[j][0].freq - countnocount( gappat1[0], gappat2[j], j, 0 ) ) * fpenalty;
1005 // tmppenal = ( 1.0-gapf1[i] ) * ( diaf2[j] + gappat2[j][0].freq - countnocount( gappat1[i], gappat2[j], j-mpi-1, 0 ) ) * fpenalty;
1006 // tmppenal = ( (1.0-gapf1[i])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[i]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1007 // tmppenal = ( (1.0-gapz1[1])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapz1[1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1008 // tmppenal = ( (1.0-gapf1[0])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[0]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1009 // tmppenal = 0.5 * fpenalty;
1010 // tmppenal -= ( (1.0-gapf1[0]) * (1.0-diaf2[j]) + gapf1[0] ) * 0.5 * fpenalty;
1011 // tmppenal -= ( (1.0-gapf1[0]) * ogcp2g[j] + gapf1[i-1] ) * 0.5 * fpenalty;
1012 // fprintf( stderr, "-1,-1<-%d,%d, tmppenal4 = %f\n", 0, j, tmppenal );
1013 currentw[j] += tmppenal;
1014 cumpenal += ( ogcp2g[j-0] + fgcp2g[j] ) * fpenalty * 0.5;
1015 // currentw[j] += cumpenal - fgcp2g[j] * fpenalty * 0.5;
1021 for( j=1; j<lgth2+1; j++ )
1022 currentw[j] -= offset * j / 2.0;
1023 for( i=1; i<lgth1+1; i++ )
1024 initverticalw[i] -= offset * i / 2.0;
1028 m[0] = 0.0; // iranai
1029 for( j=1; j<lgth2+1; ++j )
1031 // m[j] = currentw[j-1] + ogcp1[1];
1035 // tmppenal = ( (1.0-gapz2[j])*(1.0-ogcp1g[1]+fgcp1g[1]) + gapz2[j]*(1.0-digf1[1]-diaf1[1]) ) * 0.5 * fpenalty; // mada
1036 // tmppenal = ( (1.0-gapf2[j-1])*(1.0-ogcp1g[1]+fgcp1g[1]) + gapf2[j-1]*(1.0-digf1[1]-diaf1[1]) ) * 0.5 * fpenalty; // mada
1037 // tmppenal = ( (1.0-gapf2[j-1])*(1.0-ogcp1g[i]+fgcp1g[i]) + gapf2[j-1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
1038 // tmppenal = 0.5 * fpenalty;
1039 // tmppenal -= ( (1.0-0.0) * (1.0-0.0) + 0.0 ) * 0.5 * fpenalty;
1040 // tmppenal -= ( (1.0-gapf2[-1]) * (1.0-diaf1[0]) + gapf2[-1] ) * 0.5 * fpenalty;
1041 // if( tmppenal ) fprintf( stderr, "%c=%c, end j tmppenal=%f\n", seq1[0][0], seq2[0][j-1], tmppenal );
1042 m[j] = currentw[j-1] + tmppenal + fpenalty * 10000; // iinoka???????
1043 // m[j] = currentw[j-1] + tmppenal;
1044 // m[j] = currentw[j-1] + ogcp1[1];
1047 lastverticalw[0] = 0.0; // Falign kara yobaretatoki kounarukanousei ari
1049 lastverticalw[0] = currentw[lgth2-1];
1051 if( outgap ) lasti = lgth1+1; else lasti = lgth1;
1054 fprintf( stderr, "currentw after penal= \n" );
1055 for( i=0; i<lgth2+1; i++ )
1057 fprintf( stderr, "%5.2f ", currentw[i] );
1059 fprintf( stderr, "\n" );
1060 fprintf( stderr, "initverticalw after penal= \n" );
1061 for( i=0; i<lgth1+1; i++ )
1063 fprintf( stderr, "%5.2f ", initverticalw[i] );
1065 fprintf( stderr, "\n" );
1066 fprintf( stderr, "fcgp\n" );
1067 for( i=0; i<lgth1; i++ )
1068 fprintf( stderr, "fgcp1[%d]=%f\n", i, ogcp1[i] );
1069 for( i=0; i<lgth2; i++ )
1070 fprintf( stderr, "fgcp2[%d]=%f\n", i, ogcp2[i] );
1073 for( i=1; i<lasti; i++ )
1076 previousw = currentw;
1079 previousw[0] = initverticalw[i-1];
1081 match_calc( currentw, cpmx1, cpmx2, i, lgth2, floatwork, intwork, 0 );
1083 fprintf( stderr, "\n" );
1084 fprintf( stderr, "i=%d\n", i );
1085 fprintf( stderr, "currentw = \n" );
1086 for( j=0; j<lgth2; j++ )
1088 fprintf( stderr, "%5.2f ", currentw[j] );
1090 fprintf( stderr, "\n" );
1094 // fprintf( stderr, "Calling imp_match_calc (o) lgth = %d, i = %d\n", lgth1, i );
1096 imp_match_out_veadH( currentw, i, lgth2 );
1098 imp_match_out_veadH( currentw, i, lgth2 );
1102 fprintf( stderr, "\n" );
1103 fprintf( stderr, "i=%d\n", i );
1104 fprintf( stderr, "currentw = \n" );
1105 for( j=0; j<lgth2; j++ )
1107 fprintf( stderr, "%5.2f ", currentw[j] );
1109 fprintf( stderr, "\n" );
1111 currentw[0] = initverticalw[i];
1114 // mi = previousw[0] + ogcp2[1]; // machigai
1116 // tmppenal = ( (1.0-gapz1[i])*(1.0-ogcp2g[1]+fgcp2g[1]) + gapz1[i]*(1.0-digf2[1]-diaf2[1]) ) * 0.5 * fpenalty; // mada
1117 // tmppenal = ( (1.0-gapf1[i-1])*(1.0-ogcp2g[1]+fgcp2g[1]) + gapf1[i-1]*(1.0-digf2[1]-diaf2[1]) ) * 0.5 * fpenalty; // mada
1118 // fprintf( stderr, "%c=%c, end i tmppenal=%f, ogcp2g[1]=%f\n", seq1[0][i-1], seq2[0][0], tmppenal, ogcp2g[1] );
1119 mi = previousw[0] + tmppenal + fpenalty * 10000; // iinoka???????
1120 // mi = previousw[0] + tmppenal;
1126 curpt = currentw + 1;
1129 ogcp2pt = ogcp2 + 1;
1130 fgcp1va = fgcp1[i-1];
1133 for( j=1; j<lastj; j++ )
1137 if( i==j ) fprintf( stderr, "%c-%c, wm1=%f\n", seq1[0][i], seq2[0][j], wm );
1141 g = diaf1[i] * gappat2[j][0].freq * fpenalty;
1142 if( g ) fprintf( stderr, "match penal1=%f, %c-%c\n", g/fpenalty, seq1[0][i], seq2[0][j] );
1148 g = diaf2[j] * gappat1[i][0].freq * fpenalty;
1149 if( g ) fprintf( stderr, "match penal2=%f, %c-%c\n", g/fpenalty, seq1[0][i], seq2[0][j] );
1154 g = ( (gappat1[i][0].freq) * (gappat2[j][0].freq) - countnocountmatch( gappat1[i], gappat2[j], i==j ) ) * fpenalty;
1155 if( g ) fprintf( stderr, "match penal3=%f*%f-%f=%f, %c-%c\n", gappat1[i][0].freq, gappat2[j][0].freq, countnocountmatch( gappat1[i], gappat2[j], 0 ), g/fpenalty, seq1[0][i], seq2[0][j] );
1156 // if( g ) fprintf( stderr, "match penal3=%f-%f, %c-%c\n", gappat1[i][0].freq * gappat2[j][0].freq * fpenalty, countnocountmatch( gappat1[i], gappat2[j], 0 ) * fpenalty, seq1[0][i], seq2[0][j] );
1159 // if( i==j+1 ) fprintf( stderr, "%c-%c, wm2=%f\n", seq1[0][i], seq2[0][j], wm );
1165 fprintf( stderr, "%5.0f->", wm );
1168 fprintf( stderr, "%5.0f?", g );
1170 // tmppenal = fpenalty;
1171 tmppenal = diaf2[j] * ( 1.0 - gapf1[i] ) * fpenalty;
1172 if( gappat2[j][0].freq )
1174 // fprintf( stderr, "gap pat wo shiraberu. %c-%c\n", seq1[0][i], seq2[0][j] );
1175 tmppenal += ( gappat2[j][0].freq ) * ( 1.0 - gapf1[i] ) * fpenalty;
1176 tmppenal -= ( countnocountx( gappat1[i], diaf1[i], gappat2[j], j-mpi-1, 1 ) ) * fpenalty;
1178 // tmppenal = ( 1.0-gapf1[i] ) * ( diaf2[j] + gappat2[j][0].freq ) * fpenalty;
1179 // tmppenal -= ( diaf1[i] * gappat2[j][j-mpi-1].freq + countnocountx( gappat1[i], gappat2[j], j-mpi-1, (seq1[0][i] == 'L' && seq2[0][j] == 'F') ) ) * fpenalty;
1180 // if( gappat2[j][0].freq )
1181 // tmppenal -= ( diaf1[i] * gappat2[j][j-mpi-1].freq + countnocountx( gappat1[i], gappat2[j], j-mpi-1, 0 ) ) * fpenalty;
1182 // tmppenal = ( (1.0-gapf1[i])*(1.0-fgcp2g[j]) + gapf1[i]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1183 // tmppenal = ( (1.0-gapz1[i+1])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapz1[i+1]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1184 // tmppenal = ( (1.0-gapf1[i])*(1.0-fgcp2g[j]+ogcp2g[j]) + gapf1[i]*(1.0-digf2[j]-diaf2[j]) ) * 0.5 * fpenalty; // mada
1185 // tmppenal = 0.5 * fpenalty;
1186 // tmppenal -= ( (1.0-gapf1[i])*(1.0-diaf2[j]) + gapf1[i] ) * 0.5 * fpenalty;
1187 // tmppenal -= ( (1.0-gapf1[i])*fgcp2g[j] + gapf1[i] ) * 0.5 * fpenalty;
1188 // tmppenal = *fgcp2pt-fpenalty*0.5*gapf1[i];
1189 // tmppenal = *fgcp2pt;
1190 if( (g=mi+tmppenal) > wm )
1192 fprintf( stderr, "jump i start=%f (i=%d, j=%d, gapf1[i]=%f, digf2[j]=%f), %c-%c, gaplen=%d\n", (g-mi)/fpenalty, i, j, gapf1[i], diaf2[j], seq1[0][i], seq2[0][j], j-mpi-1 );
1193 // fprintf( stderr, "jump i start, zenhan=%f\n", ( 1.0-gapf1[i] ) * ( diaf2[j] + gappat2[j][0].freq ) );
1194 if( gappat2[j][0].freq )
1195 // fprintf( stderr, "jump i start, kanwa(len=%d)=%f\n", j-mpi-1, diaf1[i] * gappat2[j][j-mpi-1].freq );
1197 // if( i==j+1 ) fprintf( stderr, "%c-%c, wm2.1=%f\n", seq1[0][i], seq2[0][j], wm );
1198 *ijppt = -( j - mpi );
1201 if( (g=*prept) > mi )
1203 fprintf( stderr, "jump i end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
1209 // mi += ( ogcp2g[j-0] + fgcp2g[j] ) * fpenalty * 0.5;
1210 // fprintf( stderr, "%c%c/%c%c exp, og=%f,fg=%f\n", '=', '=', seq2[0][j-1], seq2[0][j], ogcp2g[j-0] * fpenalty*0.5, fgcp2g[j] * fpenalty*0.5 );
1217 fprintf( stderr, "%5.0f?", g );
1219 // tmppenal = fpenalty;
1220 tmppenal = diaf1[i] * ( 1.0 - gapf2[j] ) * fpenalty;
1221 if( gappat1[i][0].freq )
1223 // fprintf( stderr, "gap pat wo shiraberu. %c-%c\n", seq1[0][i], seq2[0][j] );
1224 tmppenal += ( gappat1[i][0].freq ) * ( 1.0 - gapf2[j] ) * fpenalty;
1225 // fprintf( stderr, "penalx = %f\n", tmppenal/fpenalty );
1226 tmppenal -= ( countnocountx( gappat2[j], diaf2[j], gappat1[i], i-*mpjpt-1, 1 ) ) * fpenalty;
1227 // fprintf( stderr, "penaly = %f\n", tmppenal/fpenalty );
1229 // tmppenal += gappat1[i][0].freq * ( 1.0 - gapf2[j] ) * fpenalty;
1230 // tmppenal = (1.0-gapf2[j]) * ( diaf1[i] + gappat1[i][0].freq ) * fpenalty;
1231 // if( gappat1[i][0].freq )
1232 // tmppenal -= ( diaf2[j] * gappat1[i][i-*mpjpt-1].freq + countnocountx( gappat2[j], gappat1[i], i-*mpjpt-1, 0 ) ) * fpenalty;
1233 // tmppenal = ( (1.0-gapz2[j+1])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapz2[j+1]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
1234 // tmppenal = ( (1.0-gapf2[j])*(1.0-fgcp1g[i]+ogcp1g[i]) + gapf2[j]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
1235 // tmppenal = ( (1.0-gapf2[j])*(1.0-fgcp1g[i]) + gapf2[j]*(1.0-digf1[i]-diaf1[i]) ) * 0.5 * fpenalty; // mada
1236 // tmppenal = 0.5 * fpenalty;
1237 // tmppenal -= ( (1.0-gapf2[j])*(1.0-diaf1[i]) + gapf2[j] ) * 0.5 * fpenalty;
1238 // tmppenal -= ( (1.0-gapf2[j])*fgcp1g[i] + gapf2[j] ) * 0.5 * fpenalty;
1239 // tmppenal = fgcp1va-fpenalty*0.5*gapf2[j];
1240 // tmppenal = fgcp1va;
1241 if( (g=*mjpt+tmppenal) > wm )
1243 fprintf( stderr, "jump j start=%f, %c-%c, gaplen=%d\n", (g-*mjpt)/fpenalty, seq1[0][i], seq2[0][j], i-*mpjpt-1 );
1245 // if( i==j+1 ) fprintf( stderr, "%c-%c, wm2.2=%f\n", seq1[0][i], seq2[0][j], wm );
1246 *ijppt = +( i - *mpjpt );
1248 if( (g=*prept) > *mjpt )
1250 fprintf( stderr, "jump j end=%f, %c-%c\n", g-*prept, seq1[0][i-1], seq2[0][j-1] );
1256 // m[j] += ( ogcp1g[i-0] + fgcp1g[i] ) * fpenalty * 0.5;
1257 // fprintf( stderr, "%c%c/%c%c exp, og=%f,fg=%f\n", seq1[0][i-1], seq1[0][i], '=', '=', ogcp1g[i-0] * fpenalty*0.5, fgcp1g[i] * fpenalty*0.5 );
1260 m[j] += fpenalty_ex;
1264 fprintf( stderr, "%5.0f ", wm );
1273 // if( i==j+1 ) fprintf( stderr, "%c-%c, wm3=%f\n", seq1[0][i], seq2[0][j], wm );
1275 lastverticalw[i] = currentw[lgth2-1];
1278 // fprintf( stderr, "wm = %f\n", wm );
1283 for( j=1; j<lgth2+1; j++ )
1284 currentw[j] -= offset * ( lgth2 - j ) / 2.0;
1285 for( i=1; i<lgth1+1; i++ )
1286 lastverticalw[i] -= offset * ( lgth1 - i / 2.0);
1291 fprintf( stderr, "\n" );
1292 for( i=0; i<icyc; i++ ) fprintf( stderr,"%s\n", seq1[i] );
1293 fprintf( stderr, "#####\n" );
1294 for( j=0; j<jcyc; j++ ) fprintf( stderr,"%s\n", seq2[j] );
1295 fprintf( stderr, "====>" );
1296 for( i=0; i<icyc; i++ ) strcpy( mseq1[i], seq1[i] );
1297 for( j=0; j<jcyc; j++ ) strcpy( mseq2[j], seq2[j] );
1301 Atracking_localhom( impmatch, currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
1304 Atracking( currentw, lastverticalw, seq1, seq2, mseq1, mseq2, cpmx1, cpmx2, ijp, icyc, jcyc );
1306 // fprintf( stderr, "### impmatch = %f\n", *impmatch );
1308 resultlen = strlen( mseq1[0] );
1309 if( alloclen < resultlen || resultlen > N )
1311 fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N );
1312 ErrorExit( "LENGTH OVER!\n" );
1316 for( i=0; i<icyc; i++ ) strcpy( seq1[i], mseq1[i] );
1317 for( j=0; j<jcyc; j++ ) strcpy( seq2[j], mseq2[j] );
1318 for( i=0; i<lgth1+1; i++ )
1323 for( i=0; i<lgth2+1; i++ )
1329 fprintf( stderr, "\n" );
1330 for( i=0; i<icyc; i++ ) fprintf( stderr, "%s\n", mseq1[i] );
1331 fprintf( stderr, "#####\n" );
1332 for( j=0; j<jcyc; j++ ) fprintf( stderr, "%s\n", mseq2[j] );
1335 fprintf( stderr, "wm = %f\n", wm );