#include "mltaln.h" #include "dp.h" #define MACHIGAI 0 #define OUTGAP0TRY 1 #define DEBUG 0 #define XXXXXXX 0 #define USE_PENALTY_EX 0 #define FASTMATCHCALC 1 #if 0 static void st_OpeningGapCount( double *ogcp, int clus, char **seq, double *eff, int len ) { int i, j, gc, gb; double feff; for( i=0; i impmtx=%f\n", i1, j1, impmtx[i1][j1] ); return( impmtx[i1][j1] ); #if 0 if( i1 == l1 || j1 == l2 ) return( 0.0 ); return( impmtx[i1+start1][j1+start2] ); #endif } static void part_imp_match_out_vead_gapmap( double *imp, int i1, int lgth2, int start2, int *gapmap2 ) { #if FASTMACHCALC double *pt = imp; int *gapmappt = gapmap2; while( lgth2-- ) *pt++ += impmtx[i1][start2+*gapmappt++]; #else int j; for( j=0; j-1 ) *matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++; matchpt++; } } free( scarr ); #else int j, k, l; // double scarr[26]; double **cpmxpd = doublework; int **cpmxpdn = intwork; double *scarr; scarr = calloc( nalphabets, sizeof( double ) ); // simple if( initialize ) { int count = 0; for( j=0; j-1; k++ ) match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j]; } #endif } static void fillzero( double *s, int l ) { while( l-- ) *s++ = 0.0; } static void match_calc_del( int **which, double ***matrices, double *match, int n1, char **seq1, double *eff1, int n2, char **seq2, double *eff2, int i1, int lgth2, int mid, int nmask, int *mask1, int *mask2 ) { // osoi! int i, j, k, m; int c1, c2; // fprintf( stderr, "\nmatch_calc_dynamicmtx... %d", i1 ); // fprintf( stderr, "\nseq1[0]=%s\n", seq1[0] ); // fprintf( stderr, "\nseq2[0]=%s\n", seq2[0] ); // for( i=0; i ", match[k], mid ); match[k] -= matrices[mid][c1][c2] * eff1[i] * eff2[j]; // fprintf( stderr, "match[k] = %f (mid=%d)\n", match[k], mid ); } } // fprintf( stderr, "done\n" ); return; } static void match_calc_add( double **scoreingmtx, double *match, double **cpmx1, double **cpmx2, int i1, int lgth2, double **doublework, int **intwork, int initialize ) { #if FASTMATCHCALC // fprintf( stderr, "\nmatch_calc... %d", i1 ); int j, l; // double scarr[26]; double **cpmxpd = doublework; int **cpmxpdn = intwork; double *matchpt, *cpmxpdpt, **cpmxpdptpt; int *cpmxpdnpt, **cpmxpdnptpt; double *scarr; scarr = calloc( nalphabets, sizeof( double ) ); if( initialize ) { int count = 0; for( j=0; j-1 ) *matchpt += scarr[*cpmxpdnpt++] * *cpmxpdpt++; matchpt++; } } free( scarr ); // fprintf( stderr, "done\n" ); #else int j, k, l; // double scarr[26]; double **cpmxpd = doublework; int **cpmxpdn = intwork; double *scarr; scarr = calloc( nalphabets, sizeof( double ) ); // simple if( initialize ) { int count = 0; for( j=0; j-1; k++ ) match[j] += scarr[cpmxpdn[k][j]] * cpmxpd[k][j]; } free( scarr ); #endif } static void Atracking_localhom( double *impwmpt, double *lasthorizontalw, double *lastverticalw, char **seq1, char **seq2, char **mseq1, char **mseq2, int **ijp, int icyc, int jcyc, int start1, int end1, int start2, int end2, int *gapmap1, int *gapmap2, int *warpis, int *warpjs, int warpbase ) { int i, j, l, iin, jin, ifi, jfi, lgth1, lgth2, k, limk; // char gap[] = "-"; char *gap; double wm; gap = newgapstr; lgth1 = strlen( seq1[0] ); lgth2 = strlen( seq2[0] ); #if 0 for( i=0; i= wm ) { wm = lastverticalw[i]; iin = i; jin = lgth2-1; ijp[lgth1][lgth2] = +( lgth1 - i ); } } for( j=0; j= wm ) { wm = lasthorizontalw[j]; iin = lgth1-1; jin = j; ijp[lgth1][lgth2] = -( lgth2 - j ); } } } for( i=0; i= warpbase ) { ifi = warpis[ijp[iin][jin]-warpbase]; jfi = warpjs[ijp[iin][jin]-warpbase]; } else if( ijp[iin][jin] < 0 ) { ifi = iin-1; jfi = jin+ijp[iin][jin]; } else if( ijp[iin][jin] > 0 ) { ifi = iin-ijp[iin][jin]; jfi = jin-1; } else { ifi = iin-1; jfi = jin-1; } if( ifi == -warpbase && jfi == -warpbase ) { l = iin; while( --l >= 0 ) { for( i=0; i= 0 ) { for( i=0; i= wm ) { wm = lastverticalw[i]; iin = i; jin = lgth2-1; ijp[lgth1][lgth2] = +( lgth1 - i ); } } for( j=0; j= wm ) { wm = lasthorizontalw[j]; iin = lgth1-1; jin = j; ijp[lgth1][lgth2] = -( lgth2 - j ); } } } for( i=0; i= warpbase ) { ifi = warpis[ijp[iin][jin]-warpbase]; jfi = warpjs[ijp[iin][jin]-warpbase]; } else if( ijp[iin][jin] < 0 ) { ifi = iin-1; jfi = jin+ijp[iin][jin]; } else if( ijp[iin][jin] > 0 ) { ifi = iin-ijp[iin][jin]; jfi = jin-1; } else { ifi = iin-1; jfi = jin-1; } if( ifi == -warpbase && jfi == -warpbase ) { l = iin; while( --l >= 0 ) { for( i=0; i= 0 ) { for( i=0; i lgth1, outgap == 1 -> lgth1+1 */ int lgth1, lgth2; int resultlen; double wm = 0.0; /* int ?????? */ double g; double *currentw, *previousw; #if 1 double *wtmp; int *ijppt; double *mjpt, *prept, *curpt; int *mpjpt; #endif static TLS double mi, *m; static TLS int **ijp; static TLS int mpi, *mp; static TLS double *w1, *w2; static TLS double *match; static TLS double *initverticalw; /* kufuu sureba iranai */ static TLS double *lastverticalw; /* kufuu sureba iranai */ static TLS char **mseq1; static TLS char **mseq2; static TLS char **mseq; static TLS double *ogcp1; static TLS double *ogcp2; static TLS double *fgcp1; static TLS double *fgcp2; static TLS double **cpmx1; static TLS double **cpmx2; static TLS double *gapfreq1; static TLS double *gapfreq2; static TLS int **intwork; static TLS double **doublework; static TLS int orlgth1 = 0, orlgth2 = 0; double fpenalty = (double)penalty; double fpenalty_shift = (double)penalty_shift; #if USE_PENALTY_EX double fpenalty_ex = (double)penalty_ex; #endif double *fgcp2pt; double *ogcp2pt; double fgcp1va; double ogcp1va; double *gf2pt; double *gf2ptpre; double gf1va; double gf1vapre; double headgapfreq1; double headgapfreq2; int *warpis = NULL; int *warpjs = NULL; int *warpi = NULL; int *warpj = NULL; int *prevwarpi = NULL; int *prevwarpj = NULL; double *wmrecords = NULL; double *prevwmrecords = NULL; int warpn = 0; int warpbase; double curm = 0.0; double *wmrecordspt, *wmrecords1pt, *prevwmrecordspt; int *warpipt, *warpjpt; if( seq1 == NULL ) { if( orlgth1 ) { // fprintf( stderr, "## Freeing local arrays in A__align\n" ); orlgth1 = 0; orlgth2 = 0; part_imp_match_init_strict( NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL ); free( mseq1 ); free( mseq2 ); FreeFloatVec( w1 ); FreeFloatVec( w2 ); FreeFloatVec( match ); FreeFloatVec( initverticalw ); FreeFloatVec( lastverticalw ); FreeFloatVec( m ); FreeIntVec( mp ); FreeCharMtx( mseq ); FreeFloatVec( ogcp1 ); FreeFloatVec( ogcp2 ); FreeFloatVec( fgcp1 ); FreeFloatVec( fgcp2 ); FreeFloatMtx( cpmx1 ); FreeFloatMtx( cpmx2 ); FreeFloatVec( gapfreq1 ); FreeFloatVec( gapfreq2 ); FreeFloatMtx( doublework ); FreeIntMtx( intwork ); } else { // fprintf( stderr, "## Not allocated\n" ); } return( 0.0 ); } // fprintf( stderr, "IN partA__align\n" ); lgth1 = strlen( seq1[0] ); lgth2 = strlen( seq2[0] ); #if 1 // if( lgth1 == 0 ) fprintf( stderr, "WARNING: lgth1=0 in partA__align\n" ); // if( lgth2 == 0 ) fprintf( stderr, "WARNING: lgth2=0 in partA__align\n" ); if( lgth1 == 0 && lgth2 == 0 ) return( 0.0 ); if( lgth1 == 0 ) { for( i=0; i orlgth1 || lgth2 > orlgth2 ) { int ll1, ll2; if( orlgth1 > 0 && orlgth2 > 0 ) { FreeFloatVec( w1 ); FreeFloatVec( w2 ); FreeFloatVec( match ); FreeFloatVec( initverticalw ); FreeFloatVec( lastverticalw ); FreeFloatVec( m ); FreeIntVec( mp ); FreeCharMtx( mseq ); FreeFloatVec( ogcp1 ); FreeFloatVec( ogcp2 ); FreeFloatVec( fgcp1 ); FreeFloatVec( fgcp2 ); FreeFloatMtx( cpmx1 ); FreeFloatMtx( cpmx2 ); FreeFloatVec( gapfreq1 ); FreeFloatVec( gapfreq2 ); FreeFloatMtx( doublework ); FreeIntMtx( intwork ); } ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100; ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100; #if DEBUG fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 ); #endif w1 = AllocateFloatVec( ll2+2 ); w2 = AllocateFloatVec( ll2+2 ); match = AllocateFloatVec( ll2+2 ); initverticalw = AllocateFloatVec( ll1+2 ); lastverticalw = AllocateFloatVec( ll1+2 ); m = AllocateFloatVec( ll2+2 ); mp = AllocateIntVec( ll2+2 ); mseq = AllocateCharMtx( njob, ll1+ll2 ); ogcp1 = AllocateFloatVec( ll1+2 ); ogcp2 = AllocateFloatVec( ll2+2 ); fgcp1 = AllocateFloatVec( ll1+2 ); fgcp2 = AllocateFloatVec( ll2+2 ); cpmx1 = AllocateFloatMtx( nalphabets, ll1+2 ); cpmx2 = AllocateFloatMtx( nalphabets, ll2+2 ); gapfreq1 = AllocateFloatVec( ll1+2 ); gapfreq2 = AllocateFloatVec( ll2+2 ); #if FASTMATCHCALC doublework = AllocateFloatMtx( MAX( ll1, ll2 )+2, nalphabets ); intwork = AllocateIntMtx( MAX( ll1, ll2 )+2, nalphabets ); #else doublework = AllocateFloatMtx( nalphabets, MAX( ll1, ll2 )+2 ); intwork = AllocateIntMtx( nalphabets, MAX( ll1, ll2 )+2 ); #endif #if DEBUG fprintf( stderr, "succeeded\n" ); #endif orlgth1 = ll1 - 100; orlgth2 = ll2 - 100; } for( i=0; i commonAlloc1 || orlgth2 > commonAlloc2 ) { int ll1, ll2; if( commonAlloc1 && commonAlloc2 ) { FreeIntMtx( commonIP ); } ll1 = MAX( orlgth1, commonAlloc1 ); ll2 = MAX( orlgth2, commonAlloc2 ); #if DEBUG fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 ); #endif commonIP = AllocateIntMtx( ll1+10, ll2+10 ); #if DEBUG fprintf( stderr, "succeeded\n\n" ); #endif commonAlloc1 = ll1; commonAlloc2 = ll2; } ijp = commonIP; cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc ); cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc ); if( sgap1 ) { new_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1, sgap1 ); new_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2, sgap2 ); new_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1, egap1 ); new_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2, egap2 ); outgapcount( &headgapfreq1, icyc, sgap1, eff1 ); outgapcount( &headgapfreq2, jcyc, sgap2, eff2 ); outgapcount( gapfreq1+lgth1, icyc, egap1, eff1 ); outgapcount( gapfreq2+lgth2, jcyc, egap2, eff2 ); } else { st_OpeningGapCount( ogcp1, icyc, seq1, eff1, lgth1 ); st_OpeningGapCount( ogcp2, jcyc, seq2, eff2, lgth2 ); st_FinalGapCount( fgcp1, icyc, seq1, eff1, lgth1 ); st_FinalGapCount( fgcp2, jcyc, seq2, eff2, lgth2 ); headgapfreq1 = 0.0; headgapfreq2 = 0.0; gapfreq1[lgth1] = 0.0; gapfreq2[lgth2] = 0.0; } if( legacygapcost == 0 ) { gapcountf( gapfreq1, seq1, icyc, eff1, lgth1 ); gapcountf( gapfreq2, seq2, jcyc, eff2, lgth2 ); for( i=0; i tbfast.c if( localhom ) imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 ); #endif if( outgap == 1 ) { for( i=1; i", wm ); #endif // g = mi + *fgcp2pt * gapfreq1[i]; if( (g = mi + *fgcp2pt * gf1va) > wm ) { wm = g; *ijppt = -( j - mpi ); } // g = *prept + *ogcp2pt * gapfreq1[i-1]; if( (g = *prept + *ogcp2pt * gf1vapre) >= mi ) { mi = g; mpi = j-1; } #if USE_PENALTY_EX mi += fpenalty_ex; #endif // g = *mjpt + fgcp1va * gapfreq2[j]; if( (g = *mjpt + fgcp1va * *gf2pt) > wm ) { wm = g; *ijppt = +( i - *mpjpt ); } // g = *prept + ogcp1va * gapfreq2[j-1]; if( (g = *prept + ogcp1va * *gf2ptpre) >= *mjpt ) { *mjpt = g; *mpjpt = i-1; } #if USE_PENALTY_EX m[j] += fpenalty_ex; #endif if( trywarp ) { #if USE_PENALTY_EX if( ( g=*prevwmrecordspt++ + fpenalty_shift + fpenalty_ex * ( i - prevwarpi[j-1] + j - prevwarpj[j-1] ) ) > wm ) // naka ha osokute kamawanai #else if( ( g=*prevwmrecordspt++ + fpenalty_shift ) > wm ) // naka ha osokute kamawanai #endif { // fprintf( stderr, "WARP in partA__align\n" ); if( warpn && prevwarpi[j-1] == warpis[warpn-1] && prevwarpj[j-1] == warpjs[warpn-1] ) { *ijppt = warpbase + warpn - 1; } else { *ijppt = warpbase + warpn; warpis = realloc( warpis, sizeof(int) * ( warpn+1 ) ); warpjs = realloc( warpjs, sizeof(int) * ( warpn+1 ) ); warpis[warpn] = prevwarpi[j-1]; warpjs[warpn] = prevwarpj[j-1]; warpn++; } wm = g; } curm = *curpt + wm; if( *wmrecords1pt > *wmrecordspt ) { *wmrecordspt = *wmrecords1pt; *warpipt = *(warpipt-1); *warpjpt = *(warpjpt-1); } if( curm > *wmrecordspt ) { *wmrecordspt = curm; *warpipt = i; *warpjpt = j; } wmrecordspt++; wmrecords1pt++; warpipt++; warpjpt++; } #if 0 fprintf( stderr, "%5.0f ", wm ); #endif *curpt += wm; ijppt++; mjpt++; prept++; mpjpt++; curpt++; fgcp2pt++; ogcp2pt++; gf2ptpre++; gf2pt++; } lastverticalw[i] = currentw[lgth2-1]; if( trywarp ) { fltncpy( prevwmrecords, wmrecords, lastj ); intncpy( prevwarpi, warpi, lastj ); intncpy( prevwarpj, warpj, lastj ); } } if( trywarp ) { // fprintf( stderr, "wm = %f\n", wm ); // fprintf( stderr, "warpn = %d\n", warpn ); free( wmrecords ); free( prevwmrecords ); free( warpi ); free( warpj ); free( prevwarpi ); free( prevwarpj ); } #if OUTGAP0TRY if( !outgap ) { for( j=1; j" ); for( i=0; i N ) { fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N ); ErrorExit( "LENGTH OVER!\n" ); } for( i=0; i lgth1, outgap == 1 -> lgth1+1 */ int lgth1, lgth2; int resultlen; double wm = 0.0; /* int ?????? */ double g; double *currentw, *previousw; #if 1 double *wtmp; int *ijppt; double *mjpt, *prept, *curpt; int *mpjpt; #endif static TLS double mi, *m; static TLS int **ijp; static TLS int mpi, *mp; static TLS double *w1, *w2; static TLS double *match; static TLS double *initverticalw; /* kufuu sureba iranai */ static TLS double *lastverticalw; /* kufuu sureba iranai */ static TLS char **mseq1; static TLS char **mseq2; static TLS char **mseq; static TLS double *ogcp1; static TLS double *ogcp2; static TLS double *fgcp1; static TLS double *fgcp2; static TLS double ***cpmx1s; static TLS double ***cpmx2s; static TLS double *gapfreq1; static TLS double *gapfreq2; static TLS int ***intwork; static TLS double ***doublework; static TLS int orlgth1 = 0, orlgth2 = 0; double fpenalty = (double)penalty; double fpenalty_shift = (double)penalty_shift; #if USE_PENALTY_EX double fpenalty_ex = (double)penalty_ex; #endif double *fgcp2pt; double *ogcp2pt; double fgcp1va; double ogcp1va; double *gf2pt; double *gf2ptpre; double gf1va; double gf1vapre; double headgapfreq1; double headgapfreq2; int *warpis = NULL; int *warpjs = NULL; int *warpi = NULL; int *warpj = NULL; int *prevwarpi = NULL; int *prevwarpj = NULL; double *wmrecords = NULL; double *prevwmrecords = NULL; int warpn = 0; int warpbase; double curm = 0.0; double *wmrecordspt, *wmrecords1pt, *prevwmrecordspt; int *warpipt, *warpjpt; int *nmask, **masklist1, **masklist2; if( seq1 == NULL ) { if( orlgth1 ) { // fprintf( stderr, "## Freeing local arrays in A__align\n" ); orlgth1 = 0; orlgth2 = 0; part_imp_match_init_strict( NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL ); free( mseq1 ); free( mseq2 ); FreeFloatVec( w1 ); FreeFloatVec( w2 ); FreeFloatVec( match ); FreeFloatVec( initverticalw ); FreeFloatVec( lastverticalw ); FreeFloatVec( m ); FreeIntVec( mp ); FreeCharMtx( mseq ); FreeFloatVec( ogcp1 ); FreeFloatVec( ogcp2 ); FreeFloatVec( fgcp1 ); FreeFloatVec( fgcp2 ); FreeFloatCub( cpmx1s ); FreeFloatCub( cpmx2s ); FreeFloatVec( gapfreq1 ); FreeFloatVec( gapfreq2 ); FreeFloatCub( doublework ); FreeIntCub( intwork ); } else { // fprintf( stderr, "## Not allocated\n" ); } return( 0.0 ); } masklist1 = AllocateIntMtx( maxdistclass, 0 ); masklist2 = AllocateIntMtx( maxdistclass, 0 ); nmask = calloc( maxdistclass, sizeof( int ) ); for( c=0; c orlgth1 || lgth2 > orlgth2 ) { int ll1, ll2; if( orlgth1 > 0 && orlgth2 > 0 ) { FreeFloatVec( w1 ); FreeFloatVec( w2 ); FreeFloatVec( match ); FreeFloatVec( initverticalw ); FreeFloatVec( lastverticalw ); FreeFloatVec( m ); FreeIntVec( mp ); FreeCharMtx( mseq ); FreeFloatVec( ogcp1 ); FreeFloatVec( ogcp2 ); FreeFloatVec( fgcp1 ); FreeFloatVec( fgcp2 ); FreeFloatCub( cpmx1s ); FreeFloatCub( cpmx2s ); FreeFloatVec( gapfreq1 ); FreeFloatVec( gapfreq2 ); FreeFloatCub( doublework ); FreeIntCub( intwork ); } ll1 = MAX( (int)(1.3*lgth1), orlgth1 ) + 100; ll2 = MAX( (int)(1.3*lgth2), orlgth2 ) + 100; #if DEBUG fprintf( stderr, "\ntrying to allocate (%d+%d)xn matrices ... ", ll1, ll2 ); #endif w1 = AllocateFloatVec( ll2+2 ); w2 = AllocateFloatVec( ll2+2 ); match = AllocateFloatVec( ll2+2 ); initverticalw = AllocateFloatVec( ll1+2 ); lastverticalw = AllocateFloatVec( ll1+2 ); m = AllocateFloatVec( ll2+2 ); mp = AllocateIntVec( ll2+2 ); mseq = AllocateCharMtx( njob, ll1+ll2 ); ogcp1 = AllocateFloatVec( ll1+2 ); ogcp2 = AllocateFloatVec( ll2+2 ); fgcp1 = AllocateFloatVec( ll1+2 ); fgcp2 = AllocateFloatVec( ll2+2 ); cpmx1s = AllocateFloatCub( maxdistclass, nalphabets, ll1+2 ); cpmx2s = AllocateFloatCub( maxdistclass, nalphabets, ll2+2 ); gapfreq1 = AllocateFloatVec( ll1+2 ); gapfreq2 = AllocateFloatVec( ll2+2 ); doublework = AllocateFloatCub( maxdistclass, MAX( ll1, ll2 )+2, nalphabets ); intwork = AllocateIntCub( maxdistclass, MAX( ll1, ll2 )+2, nalphabets ); #if DEBUG fprintf( stderr, "succeeded\n" ); #endif orlgth1 = ll1 - 100; orlgth2 = ll2 - 100; } for( i=0; i commonAlloc1 || orlgth2 > commonAlloc2 ) { int ll1, ll2; if( commonAlloc1 && commonAlloc2 ) { FreeIntMtx( commonIP ); } ll1 = MAX( orlgth1, commonAlloc1 ); ll2 = MAX( orlgth2, commonAlloc2 ); #if DEBUG fprintf( stderr, "\n\ntrying to allocate %dx%d matrices ... ", ll1+1, ll2+1 ); #endif commonIP = AllocateIntMtx( ll1+10, ll2+10 ); #if DEBUG fprintf( stderr, "succeeded\n\n" ); #endif commonAlloc1 = ll1; commonAlloc2 = ll2; } ijp = commonIP; // cpmx_calc_new( seq1, cpmx1, eff1, lgth1, icyc ); // cpmx_calc_new( seq2, cpmx2, eff2, lgth2, jcyc ); for( c=0; c tbfast.c if( localhom ) imp_match_calc( currentw, icyc, jcyc, lgth1, lgth2, seq1, seq2, eff1, eff2, localhom, 1, 0 ); #endif if( outgap == 1 ) { for( i=1; i", wm ); #endif // g = mi + *fgcp2pt * gapfreq1[i]; if( (g = mi + *fgcp2pt * gf1va) > wm ) { wm = g; *ijppt = -( j - mpi ); } // g = *prept + *ogcp2pt * gapfreq1[i-1]; if( (g = *prept + *ogcp2pt * gf1vapre) >= mi ) { mi = g; mpi = j-1; } #if USE_PENALTY_EX mi += fpenalty_ex; #endif // g = *mjpt + fgcp1va * gapfreq2[j]; if( (g = *mjpt + fgcp1va * *gf2pt) > wm ) { wm = g; *ijppt = +( i - *mpjpt ); } // g = *prept + ogcp1va * gapfreq2[j-1]; if( (g = *prept + ogcp1va * *gf2ptpre) >= *mjpt ) { *mjpt = g; *mpjpt = i-1; } #if USE_PENALTY_EX m[j] += fpenalty_ex; #endif if( trywarp ) { #if USE_PENALTY_EX if( ( g=*prevwmrecordspt++ + fpenalty_shift + fpenalty_ex * ( i - prevwarpi[j-1] + j - prevwarpj[j-1] ) ) > wm ) // naka ha osokute kamawanai #else if( ( g=*prevwmrecordspt++ + fpenalty_shift ) > wm ) // naka ha osokute kamawanai #endif { if( warpn && prevwarpi[j-1] == warpis[warpn-1] && prevwarpj[j-1] == warpjs[warpn-1] ) { *ijppt = warpbase + warpn - 1; } else { *ijppt = warpbase + warpn; warpis = realloc( warpis, sizeof(int) * ( warpn+1 ) ); warpjs = realloc( warpjs, sizeof(int) * ( warpn+1 ) ); warpis[warpn] = prevwarpi[j-1]; warpjs[warpn] = prevwarpj[j-1]; warpn++; } wm = g; } curm = *curpt + wm; if( *wmrecords1pt > *wmrecordspt ) { *wmrecordspt = *wmrecords1pt; *warpipt = *(warpipt-1); *warpjpt = *(warpjpt-1); } if( curm > *wmrecordspt ) { *wmrecordspt = curm; *warpipt = i; *warpjpt = j; } wmrecordspt++; wmrecords1pt++; warpipt++; warpjpt++; } #if 0 fprintf( stderr, "%5.0f ", wm ); #endif *curpt += wm; ijppt++; mjpt++; prept++; mpjpt++; curpt++; fgcp2pt++; ogcp2pt++; gf2ptpre++; gf2pt++; } lastverticalw[i] = currentw[lgth2-1]; if( trywarp ) { fltncpy( prevwmrecords, wmrecords, lastj ); intncpy( prevwarpi, warpi, lastj ); intncpy( prevwarpj, warpj, lastj ); } } if( trywarp ) { // fprintf( stderr, "wm = %f\n", wm ); // fprintf( stderr, "warpn = %d\n", warpn ); free( wmrecords ); free( prevwmrecords ); free( warpi ); free( warpj ); free( prevwarpi ); free( prevwarpj ); } #if OUTGAP0TRY if( !outgap ) { for( j=1; j" ); for( i=0; i N ) { fprintf( stderr, "alloclen=%d, resultlen=%d, N=%d\n", alloclen, resultlen, N ); ErrorExit( "LENGTH OVER!\n" ); } for( i=0; i