X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=binaries%2Fsrc%2Fmafft%2Fcore%2Ftbfast.c;fp=binaries%2Fsrc%2Fmafft%2Fcore%2Ftbfast.c;h=0000000000000000000000000000000000000000;hb=6e0ce943f09b5ac30f3eb8dc0f20bc75114669ce;hp=dd7e7b5902b32f9baffbd9a270f6beb49cea22ce;hpb=48f0451143441afce738d887b0cde1fb5cdbc02e;p=jabaws.git diff --git a/binaries/src/mafft/core/tbfast.c b/binaries/src/mafft/core/tbfast.c deleted file mode 100644 index dd7e7b5..0000000 --- a/binaries/src/mafft/core/tbfast.c +++ /dev/null @@ -1,1070 +0,0 @@ -#include "mltaln.h" - -#define DEBUG 0 -#define IODEBUG 0 -#define SCOREOUT 0 - -static int treein; -static int topin; -static int treeout; -static int distout; -static int noalign; - -void arguments( int argc, char *argv[] ) -{ - int c; - - treein = 0; - topin = 0; - rnaprediction = 'm'; - rnakozo = 0; - nevermemsave = 0; - inputfile = NULL; - fftkeika = 0; - constraint = 0; - nblosum = 62; - fmodel = 0; - calledByXced = 0; - devide = 0; - use_fft = 0; // chuui - force_fft = 0; - fftscore = 1; - fftRepeatStop = 0; - fftNoAnchStop = 0; - weight = 3; - utree = 1; - tbutree = 1; - refine = 0; - check = 1; - cut = 0.0; - disp = 0; - outgap = 1; - alg = 'A'; - mix = 0; - tbitr = 0; - scmtd = 5; - tbweight = 0; - tbrweight = 3; - checkC = 0; - treemethod = 'X'; - contin = 0; - scoremtx = 1; - kobetsubunkatsu = 0; - dorp = NOTSPECIFIED; - ppenalty = NOTSPECIFIED; - ppenalty_ex = NOTSPECIFIED; - poffset = NOTSPECIFIED; - kimuraR = NOTSPECIFIED; - pamN = NOTSPECIFIED; - geta2 = GETA2; - fftWinSize = NOTSPECIFIED; - fftThreshold = NOTSPECIFIED; - RNAppenalty = NOTSPECIFIED; - RNAppenalty_ex = NOTSPECIFIED; - RNApthr = NOTSPECIFIED; - TMorJTT = JTT; - consweight_multi = 1.0; - consweight_rna = 0.0; - - while( --argc > 0 && (*++argv)[0] == '-' ) - { - while ( ( c = *++argv[0] ) ) - { - switch( c ) - { - case 'i': - inputfile = *++argv; - fprintf( stderr, "inputfile = %s\n", inputfile ); - --argc; - goto nextoption; - case 'e': - RNApthr = (int)( atof( *++argv ) * 1000 - 0.5 ); - --argc; - goto nextoption; - case 'o': - RNAppenalty = (int)( atof( *++argv ) * 1000 - 0.5 ); - --argc; - goto nextoption; - case 'f': - ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 ); -// fprintf( stderr, "ppenalty = %d\n", ppenalty ); - --argc; - goto nextoption; - case 'g': - ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 ); - fprintf( stderr, "ppenalty_ex = %d\n", ppenalty_ex ); - --argc; - goto nextoption; - case 'h': - poffset = (int)( atof( *++argv ) * 1000 - 0.5 ); -// fprintf( stderr, "poffset = %d\n", poffset ); - --argc; - goto nextoption; - case 'k': - kimuraR = atoi( *++argv ); - fprintf( stderr, "kappa = %d\n", kimuraR ); - --argc; - goto nextoption; - case 'b': - nblosum = atoi( *++argv ); - scoremtx = 1; - fprintf( stderr, "blosum %d / kimura 200\n", nblosum ); - --argc; - goto nextoption; - case 'j': - pamN = atoi( *++argv ); - scoremtx = 0; - TMorJTT = JTT; - fprintf( stderr, "jtt/kimura %d\n", pamN ); - --argc; - goto nextoption; - case 'm': - pamN = atoi( *++argv ); - scoremtx = 0; - TMorJTT = TM; - fprintf( stderr, "tm %d\n", pamN ); - --argc; - goto nextoption; - case 'l': - fastathreshold = atof( *++argv ); - constraint = 2; - --argc; - goto nextoption; - case 'r': - consweight_rna = atof( *++argv ); - rnakozo = 1; - --argc; - goto nextoption; - case 'c': - consweight_multi = atof( *++argv ); - --argc; - goto nextoption; - case 'R': - rnaprediction = 'r'; - break; - case 's': - RNAscoremtx = 'r'; - break; -#if 1 - case 'a': - fmodel = 1; - break; -#endif - case 'y': - distout = 1; - break; - case 't': - treeout = 1; - break; - case 'T': - noalign = 1; - break; - case 'D': - dorp = 'd'; - break; - case 'P': - dorp = 'p'; - break; - case 'O': - fftNoAnchStop = 1; - break; -#if 0 - case 'e': - fftscore = 0; - break; - case 'r': - fmodel = -1; - break; - case 'R': - fftRepeatStop = 1; - break; - case 's': - treemethod = 's'; - break; -#endif - case 'X': - treemethod = 'X'; - break; - case 'E': - treemethod = 'E'; - break; - case 'q': - treemethod = 'q'; - break; -#if 0 - case 'a': - alg = 'a'; - break; -#endif - case 'Q': - alg = 'Q'; - break; - case 'H': - alg = 'H'; - break; - case 'A': - alg = 'A'; - break; - case 'S': - alg = 'S'; - break; - case 'M': - alg = 'M'; - break; - case 'N': - nevermemsave = 1; - break; - case 'B': - break; - case 'C': - alg = 'C'; - break; - case 'F': - use_fft = 1; - break; - case 'G': - force_fft = 1; - use_fft = 1; - break; - case 'U': - treein = 1; - break; - case 'V': - topin = 1; - break; - case 'u': - tbrweight = 0; - weight = 0; - break; - case 'v': - tbrweight = 3; - break; - case 'd': - disp = 1; - break; -#if 0 - case 'o': - outgap = 0; - break; -#endif -/* Modified 01/08/27, default: user tree */ - case 'J': - tbutree = 0; - break; -/* modification end. */ - case 'z': - fftThreshold = atoi( *++argv ); - --argc; - goto nextoption; - case 'w': - fftWinSize = atoi( *++argv ); - --argc; - goto nextoption; - case 'Z': - checkC = 1; - break; - default: - fprintf( stderr, "illegal option %c\n", c ); - argc = 0; - break; - } - } - nextoption: - ; - } - if( argc == 1 ) - { - cut = atof( (*argv) ); - argc--; - } - if( argc != 0 ) - { - fprintf( stderr, "options: Check source file !\n" ); - exit( 1 ); - } - if( tbitr == 1 && outgap == 0 ) - { - fprintf( stderr, "conflicting options : o, m or u\n" ); - exit( 1 ); - } - if( alg == 'C' && outgap == 0 ) - { - fprintf( stderr, "conflicting options : C, o\n" ); - exit( 1 ); - } -} - - -void treebase( int nlen[M], char **aseq, char **mseq1, char **mseq2, int ***topol, double *effarr, int *alloclen, LocalHom **localhomtable, RNApair ***singlerna, double *effarr_kozo ) -{ - int i, l; - int len1, len2; - int clus1, clus2; - float pscore, tscore; - static char *indication1, *indication2; - static double *effarr1 = NULL; - static double *effarr2 = NULL; - static double *effarr1_kozo = NULL; - static double *effarr2_kozo = NULL; - static LocalHom ***localhomshrink = NULL; - static int *fftlog; - int m1, m2; - float dumfl = 0.0; - int ffttry; - RNApair ***grouprna1, ***grouprna2; - - if( rnakozo && rnaprediction == 'm' ) - { - grouprna1 = (RNApair ***)calloc( njob, sizeof( RNApair ** ) ); - grouprna2 = (RNApair ***)calloc( njob, sizeof( RNApair ** ) ); - } - else - { - grouprna1 = grouprna2 = NULL; - } - - if( effarr1 == NULL ) - { - fftlog = AllocateIntVec( njob ); - effarr1 = AllocateDoubleVec( njob ); - effarr2 = AllocateDoubleVec( njob ); - indication1 = AllocateCharVec( 150 ); - indication2 = AllocateCharVec( 150 ); -#if 0 -#else - if( constraint ) - { - localhomshrink = (LocalHom ***)calloc( njob, sizeof( LocalHom ** ) ); - for( i=0; i 66 ) fprintf( stderr, "..." ); - fprintf( stderr, "\n" ); - fprintf( stderr, "group2 = %.66s", indication2 ); - if( strlen( indication2 ) > 66 ) fprintf( stderr, "..." ); - fprintf( stderr, "\n" ); -#endif - - - -// for( i=0; i 10000 || len2 > 10000 ) ) ) - { - fprintf( stderr, "\nlen1=%d, len2=%d, Switching to the memsave mode.\n", len1, len2 ); - alg = 'M'; - if( commonIP ) FreeIntMtx( commonIP ); - commonAlloc1 = 0; - commonAlloc2 = 0; - } - - -// if( fftlog[m1] && fftlog[m2] ) ffttry = ( nlen[m1] > clus1 && nlen[m2] > clus2 ); - if( fftlog[m1] && fftlog[m2] ) ffttry = ( nlen[m1] > clus1 && nlen[m2] > clus2 && clus1 < 1000 && clus2 < 1000 ); - else ffttry = 0; -// ffttry = ( nlen[m1] > clus1 && nlen[m2] > clus2 && clus1 < 5000 && clus2 < 5000 ); // v6.708 -// fprintf( stderr, "f=%d, len1/fftlog[m1]=%f, clus1=%d, len2/fftlog[m2]=%f, clus2=%d\n", ffttry, (float)len1/fftlog[m1], clus1, (float)len2/fftlog[m2], clus2 ); -// fprintf( stderr, "f=%d, clus1=%d, fftlog[m1]=%d, clus2=%d, fftlog[m2]=%d\n", ffttry, clus1, fftlog[m1], clus2, fftlog[m2] ); - if( constraint == 2 ) - { - if( alg == 'M' ) - { - fprintf( stderr, "\n\nMemory saving mode is not supported.\n\n" ); - exit( 1 ); - } - fprintf( stderr, "c" ); - if( alg == 'A' ) - { - imp_match_init_strict( NULL, clus1, clus2, strlen( mseq1[0] ), strlen( mseq2[0] ), mseq1, mseq2, effarr1, effarr2, effarr1_kozo, effarr2_kozo, localhomshrink, 1 ); - if( rnakozo ) imp_rna( clus1, clus2, mseq1, mseq2, effarr1, effarr2, grouprna1, grouprna2, NULL, NULL, NULL ); - pscore = A__align( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, localhomshrink, &dumfl, NULL, NULL, NULL, NULL ); - } - else if( alg == 'H' ) - { - imp_match_init_strictH( NULL, clus1, clus2, strlen( mseq1[0] ), strlen( mseq2[0] ), mseq1, mseq2, effarr1, effarr2, localhomshrink, 1 ); - pscore = H__align( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, localhomshrink, &dumfl, NULL, NULL, NULL, NULL ); - } - else if( alg == 'Q' ) - { - imp_match_init_strictQ( NULL, clus1, clus2, strlen( mseq1[0] ), strlen( mseq2[0] ), mseq1, mseq2, effarr1, effarr2, localhomshrink, 1 ); - if( rnakozo ) imp_rnaQ( clus1, clus2, mseq1, mseq2, effarr1, effarr2, grouprna1, grouprna2, NULL, NULL, NULL ); - pscore = Q__align( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, localhomshrink, &dumfl, NULL, NULL, NULL, NULL ); - } - else if( alg == 'R' ) - { - imp_match_init_strictR( NULL, clus1, clus2, strlen( mseq1[0] ), strlen( mseq2[0] ), mseq1, mseq2, effarr1, effarr2, localhomshrink, 1 ); - pscore = R__align( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, localhomshrink, &dumfl, NULL, NULL, NULL, NULL ); - } - } - else if( force_fft || ( use_fft && ffttry ) ) - { - fprintf( stderr, "f" ); - if( alg == 'M' ) - { - fprintf( stderr, "m" ); - pscore = Falign_udpari_long( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, fftlog+m1 ); - } - else - pscore = Falign( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, fftlog+m1 ); - } - else - { - fprintf( stderr, "d" ); - fftlog[m1] = 0; - switch( alg ) - { - case( 'a' ): - pscore = Aalign( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen ); - break; - case( 'M' ): - fprintf( stderr, "m" ); - pscore = MSalignmm( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, NULL, NULL, NULL, NULL ); - break; - case( 'A' ): - pscore = A__align( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL ); - break; - case( 'Q' ): - pscore = Q__align( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL ); - break; - case( 'R' ): - pscore = R__align( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL ); - break; - case( 'H' ): - pscore = H__align( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL ); - break; - case ( 'C' ): - if( outgap && ( ( clus1 == 1 && clus2 != 1 ) || ( clus1 != 1 && clus2 == 1 ) ) ) - { - pscore = translate_and_Calign( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen ); - } - else - { - pscore = A__align( mseq1, mseq2, effarr1, effarr2, clus1, clus2, *alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL ); - } - break; - default: - ErrorExit( "ERROR IN SOURCE FILE" ); - } - } - - nlen[m1] = 0.5 * ( nlen[m1] + nlen[m2] ); - -#if SCOREOUT - fprintf( stderr, "score = %10.2f\n", pscore ); -#endif - tscore += pscore; -/* - fprintf( stderr, "after align 1 %s \n", indication1 ); - display( mseq1, clus1 ); - fprintf( stderr, "\n" ); - fprintf( stderr, "after align 2 %s \n", indication2 ); - display( mseq2, clus2 ); - fprintf( stderr, "\n" ); -*/ - -// writePre( njob, name, nlen, aseq, 0 ); - - if( disp ) display( aseq, njob ); - } -#if SCOREOUT - fprintf( stderr, "totalscore = %10.2f\n\n", tscore ); -#endif -} - -static void WriteOptions( FILE *fp ) -{ - - if( dorp == 'd' ) fprintf( fp, "DNA\n" ); - else - { - if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN ); - else if( scoremtx == 1 ) fprintf( fp, "BLOSUM %d\n", nblosum ); - else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" ); - } - fprintf( stderr, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 ); - if( use_fft ) fprintf( fp, "FFT on\n" ); - - fprintf( fp, "tree-base method\n" ); - if( tbrweight == 0 ) fprintf( fp, "unweighted\n" ); - else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" ); - if( tbitr || tbweight ) - { - fprintf( fp, "iterate at each step\n" ); - if( tbitr && tbrweight == 0 ) fprintf( fp, " unweighted\n" ); - if( tbitr && tbrweight == 3 ) fprintf( fp, " reversely weighted\n" ); - if( tbweight ) fprintf( fp, " weighted\n" ); - fprintf( fp, "\n" ); - } - - fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 ); - - if( alg == 'a' ) - fprintf( fp, "Algorithm A\n" ); - else if( alg == 'A' ) - fprintf( fp, "Algorithm A+\n" ); - else if( alg == 'S' ) - fprintf( fp, "Apgorithm S\n" ); - else if( alg == 'C' ) - fprintf( fp, "Apgorithm A+/C\n" ); - else - fprintf( fp, "Unknown algorithm\n" ); - - if( treemethod == 'X' ) - fprintf( fp, "Tree = UPGMA (mix).\n" ); - else if( treemethod == 'E' ) - fprintf( fp, "Tree = UPGMA (average).\n" ); - else if( treemethod == 'q' ) - fprintf( fp, "Tree = Minimum linkage.\n" ); - else - fprintf( fp, "Unknown tree.\n" ); - - if( use_fft ) - { - fprintf( fp, "FFT on\n" ); - if( dorp == 'd' ) - fprintf( fp, "Basis : 4 nucleotides\n" ); - else - { - if( fftscore ) - fprintf( fp, "Basis : Polarity and Volume\n" ); - else - fprintf( fp, "Basis : 20 amino acids\n" ); - } - fprintf( fp, "Threshold of anchors = %d%%\n", fftThreshold ); - fprintf( fp, "window size of anchors = %dsites\n", fftWinSize ); - } - else - fprintf( fp, "FFT off\n" ); - fflush( fp ); -} - - -int main( int argc, char *argv[] ) -{ - static int *nlen; - static float *selfscore; - int nogaplen; - static char **name, **seq; - static char **mseq1, **mseq2; - static char **bseq; - static float **iscore, **iscore_kozo; - static double *eff, *eff_kozo, *eff_kozo_mapped = NULL; - int i, j, ien, ik, jk; - static int ***topol, ***topol_kozo; - static float **len, **len_kozo; - FILE *prep; - FILE *infp; - FILE *orderfp; - FILE *hat2p; - - char c; - int alloclen; - LocalHom **localhomtable; - RNApair ***singlerna; - float ssi, ssj, bunbo; - static char *kozoarivec; - int nkozo; - - arguments( argc, argv ); - - - if( inputfile ) - { - infp = fopen( inputfile, "r" ); - if( !infp ) - { - fprintf( stderr, "Cannot open %s\n", inputfile ); - exit( 1 ); - } - } - else - infp = stdin; - - - getnumlen( infp ); - rewind( infp ); - - nkozo = 0; - - if( njob < 2 ) - { - fprintf( stderr, "At least 2 sequences should be input!\n" - "Only %d sequence found.\n", njob ); - exit( 1 ); - } - - seq = AllocateCharMtx( njob, nlenmax+1 ); - mseq1 = AllocateCharMtx( njob, 0 ); - mseq2 = AllocateCharMtx( njob, 0 ); - - name = AllocateCharMtx( njob, B+1 ); - nlen = AllocateIntVec( njob ); - selfscore = AllocateFloatVec( njob ); - - topol = AllocateIntCub( njob, 2, 0 ); - len = AllocateFloatMtx( njob, 2 ); - iscore = AllocateFloatHalfMtx( njob ); - eff = AllocateDoubleVec( njob ); - kozoarivec = AllocateCharVec( njob ); - if( constraint ) - { - localhomtable = (LocalHom **)calloc( njob, sizeof( LocalHom *) ); - for( i=0; inext ) - { - free( (void *)tmppt1 ); - tmppt1 = tmppt2; - } - free( (void *)tmppt1 ); - } - free( (void *)(localhomtable[i]+j) ); - } - free( (void *)localhomtable ); - } -#endif - - fprintf( trap_g, "done.\n" ); - fclose( trap_g ); - - writeData_pointer( prep_g, njob, name, nlen, bseq ); -#if 0 - writeData( stdout, njob, name, nlen, bseq ); - writePre( njob, name, nlen, bseq, !contin ); - writeData_pointer( prep_g, njob, name, nlen, aseq ); -#endif -#if IODEBUG - fprintf( stderr, "OSHIMAI\n" ); -#endif - - if( constraint ) FreeLocalHomTable( localhomtable, njob ); - - SHOWVERSION; - return( 0 ); -}