/* Tree-dependent-iteration */ /* Devide to segments */ #include "mltaln.h" extern char **seq_g; extern char **res_g; static int subalignment; static int subalignmentoffset; static int specifictarget; static int intop; static int intree; static double autosubalignment; static void calcmaxdistclass( void ) { int c; double rep; for( c=0; c 0 && (*++argv)[0] == '-' ) { while ( (c = *++argv[0]) ) { switch( c ) { case 'i': inputfile = *++argv; fprintf( stderr, "inputfile = %s\n", inputfile ); --argc; goto nextoption; case 'I': niter = myatoi( *++argv ); fprintf( stderr, "niter = %d\n", niter ); --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 'Q': penalty_shift_factor = atof( *++argv ); if( penalty_shift_factor < 100.0 && penalty_shift_factor != 2.0 ) { fprintf( stderr, "%f, penalty_shift is fixed to penalty x 2 in the iterative refinement phase.\n", penalty_shift_factor ); penalty_shift_factor = 2.0; } --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 = myatoi( *++argv ); fprintf( stderr, "kappa = %d\n", kimuraR ); --argc; goto nextoption; case 'b': nblosum = myatoi( *++argv ); scoremtx = 1; fprintf( stderr, "blosum %d / kimura 200\n", nblosum ); --argc; goto nextoption; case 'j': pamN = myatoi( *++argv ); scoremtx = 0; TMorJTT = JTT; fprintf( stderr, "jtt/kimura %d\n", pamN ); --argc; goto nextoption; case 'm': pamN = myatoi( *++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 'C': nthread = myatoi( *++argv ); fprintf( stderr, "nthread = %d\n", nthread ); --argc; goto nextoption; case 'H': subalignment = 1; subalignmentoffset = myatoi( *++argv ); --argc; goto nextoption; case 't': randomseed = myatoi( *++argv ); fprintf( stderr, "randomseed = %d\n", randomseed ); --argc; goto nextoption; case 'p': argkey = *++argv; if( !strcmp( argkey, "BESTFIRST" ) ) parallelizationstrategy = BESTFIRST; else if( !strcmp( argkey, "BAATARI0" ) ) parallelizationstrategy = BAATARI0; else if( !strcmp( argkey, "BAATARI1" ) ) parallelizationstrategy = BAATARI1; else if( !strcmp( argkey, "BAATARI2" ) ) parallelizationstrategy = BAATARI2; else { fprintf( stderr, "Unknown parallelization strategy, %s\n", argkey ); exit( 1 ); } // exit( 1 ); --argc; goto nextoption; case 's': specificityconsideration = (double)myatof( *++argv ); // fprintf( stderr, "specificityconsideration = %f\n", specificityconsideration ); --argc; goto nextoption; #if 0 case 'S' : scoreout = 1; // for checking parallel calculation break; #else case 'S' : spscoreout = 1; // 2014/Dec/30, sp score break; #endif #if 0 case 's' : RNAscoremtx = 'r'; break; #endif #if 1 case 'a': fmodel = 1; break; #endif case 'N': nevermemsave = 1; break; case 'D': dorp = 'd'; break; case 'P': dorp = 'p'; break; #if 0 case 'Q': alg = 'Q'; break; #endif case 'R': rnaprediction = 'r'; break; case 'O': fftNoAnchStop = 1; break; #if 0 case 'e': fftscore = 0; break; case 'r': fmodel = -1; break; case 'R': fftRepeatStop = 1; break; #endif case 'T': kobetsubunkatsu = 0; break; case 'B': bunkatsu = 0; break; #if 0 case 'c': cooling = 1; break; case 'a': alg = 'a'; break; case 's' : treemethod = 's'; break; case 'H': alg = 'H'; break; #endif case 'A': alg = 'A'; break; case 'M': alg = 'M'; break; case '@': alg = 'd'; break; case 'F': use_fft = 1; break; #if 0 case 't': weight = 4; break; #endif case 'u': weight = 0; break; case 'U': intree = 1; break; case 'V': intop = 1; break; case 'J': utree = 0; break; #if 0 case 'd': disp = 1; break; #endif case 'Z': score_check = 0; break; case 'Y': score_check = 2; break; case 'L': legacygapcost = 1; break; #if 0 case 'n' : treemethod = 'n'; break; #endif case 'n' : outnumber = 1; break; case 'X': treemethod = 'X'; sueff_global = atof( *++argv ); fprintf( stderr, "sueff_global = %f\n", sueff_global ); --argc; goto nextoption; #if 0 case 'E' : treemethod = 'E'; break; case 'q' : treemethod = 'q'; break; #endif case 'E': autosubalignment = atof( *++argv ); fprintf( stderr, "autosubalignment = %f\n", autosubalignment ); --argc; goto nextoption; case 'W': minimumweight = atof( *++argv ); fprintf( stderr, "minimumweight = %f\n", minimumweight ); --argc; goto nextoption; case 'z': fftThreshold = myatoi( *++argv ); --argc; goto nextoption; case 'w': fftWinSize = myatoi( *++argv ); --argc; goto nextoption; case '=': specifictarget = 1; break; case ':': nwildcard = 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 0 if( alg == 'A' && weight == 0 ) ErrorExit( "ERROR : Algorithm A+ and un-weighted\n" ); #endif } int main( int argc, char *argv[] ) { int identity; static int nlen[M]; static char **name, **seq, **aseq, **bseq; static Segment *segment = NULL; static int anchors[MAXSEG]; int i, j; int iseg, nseg; int ***topol; double **len; double **eff; FILE *prep; FILE *infp; FILE *orderfp; int alloclen; int returnvalue; char c; int ocut; char **seq_g_bk; LocalHom **localhomtable = NULL; // by D.Mathog RNApair ***singlerna; int nogaplen; static char **nogap1seq; static char *kozoarivec; int nkozo; int alignmentlength; int **skipthisbranch; int foundthebranch; int nsubalignments, maxmem; int **subtable; int *insubtable; int *preservegaps; char ***subalnpt; int ntarget, *targetmap, *targetmapr; int ilim; arguments( argc, argv ); #ifndef enablemultithread nthread = 0; #endif if( fastathreshold < 0.0001 ) constraint = 0; if( inputfile ) { infp = fopen( inputfile, "r" ); if( !infp ) { fprintf( stderr, "Cannot open %s\n", inputfile ); exit( 1 ); } } else infp = stdin; #if 0 PreRead( stdin, &njob, &nlenmax ); #else getnumlen( infp ); #endif 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 ); } if( subalignment ) { readsubalignmentstable( njob, NULL, NULL, &nsubalignments, &maxmem ); fprintf( stderr, "nsubalignments = %d\n", nsubalignments ); fprintf( stderr, "maxmem = %d\n", maxmem ); subtable = AllocateIntMtx( nsubalignments, maxmem+1 ); insubtable = AllocateIntVec( njob ); preservegaps = AllocateIntVec( njob ); for( i=0; i 30000 ) if( nlenmax > 50000 ) // version >= 6.823 { #if 0 if( constraint ) { fprintf( stderr, "\nnlenmax=%d, nagasugi!\n", nlenmax ); exit( 1 ); } if( nevermemsave ) { fprintf( stderr, "\nnevermemsave=1, nlenmax=%d, nagasugi!\n", nlenmax ); exit( 1 ); } #endif if( !constraint && !nevermemsave && alg != 'M' ) { fprintf( stderr, "\nnlenmax=%d, Switching to the memsave mode\n", nlenmax ); alg = 'M'; } } if( specificityconsideration ) calcmaxdistclass(); for( i=0; i 0.0 && subalignment == 0 ) { // reporterr( "Computing skipthisbranch..\n" ); insubtable = AllocateIntVec( njob ); preservegaps = AllocateIntVec( njob ); subtable = calloc( 1, sizeof( char * ) ); subtable[0] = NULL; // for FreeIntMtx for( i=0; i= njob ) { fprintf( stderr, "No such sequence, %d.\n", subtable[i][j]+1 ); exit( 1 ); } if( alignmentlength != strlen( seq[subtable[i][j]] ) ) { fprintf( stderr, "\n" ); fprintf( stderr, "###############################################################################\n" ); fprintf( stderr, "# ERROR!\n" ); fprintf( stderr, "# Subalignment %d must be aligned.\n", i+1 ); fprintf( stderr, "# Please check the alignment lengths of following sequences.\n" ); fprintf( stderr, "#\n" ); fprintf( stderr, "# %d. %-10.10s -> %d letters (including gaps)\n", subtable[i][0]+1, name[subtable[i][0]]+1, alignmentlength ); fprintf( stderr, "# %d. %-10.10s -> %d letters (including gaps)\n", subtable[i][j]+1, name[subtable[i][j]]+1, (int)strlen( seq[subtable[i][j]] ) ); fprintf( stderr, "#\n" ); fprintf( stderr, "# See http://mafft.cbrc.jp/alignment/software/merge.html for details.\n" ); if( subalignmentoffset ) { fprintf( stderr, "#\n" ); fprintf( stderr, "# You specified seed alignment(s) consisting of %d sequences.\n", subalignmentoffset ); fprintf( stderr, "# In this case, the rule of numbering is:\n" ); fprintf( stderr, "# The aligned seed sequences are numbered as 1 .. %d\n", subalignmentoffset ); fprintf( stderr, "# The input sequences to be aligned are numbered as %d .. %d\n", subalignmentoffset+1, subalignmentoffset+njob ); } fprintf( stderr, "###############################################################################\n" ); fprintf( stderr, "\n" ); exit( 1 ); } insubtable[subtable[i][j]] = 1; } for( j=0; j OK\n" ); break; } } if( !foundthebranch ) { system( "cp infile.tree GuideTree" ); // tekitou fprintf( stderr, "\n" ); fprintf( stderr, "###############################################################################\n" ); fprintf( stderr, "# ERROR!\n" ); fprintf( stderr, "# Subalignment %d does not seem to form a monophyletic cluster\n", i+1 ); fprintf( stderr, "# in the guide tree ('GuideTree' in this directory) internally computed.\n" ); fprintf( stderr, "# If you really want to use this subalignment, pelase give a tree with --treein \n" ); fprintf( stderr, "# http://mafft.cbrc.jp/alignment/software/treein.html\n" ); fprintf( stderr, "# http://mafft.cbrc.jp/alignment/software/merge.html\n" ); if( subalignmentoffset ) { fprintf( stderr, "#\n" ); fprintf( stderr, "# You specified seed alignment(s) consisting of %d sequences.\n", subalignmentoffset ); fprintf( stderr, "# In this case, the rule of numbering is:\n" ); fprintf( stderr, "# The aligned seed sequences are numbered as 1 .. %d\n", subalignmentoffset ); fprintf( stderr, "# The input sequences to be aligned are numbered as %d .. %d\n", subalignmentoffset+1, subalignmentoffset+njob ); } fprintf( stderr, "############################################################################### \n" ); fprintf( stderr, "\n" ); exit( 1 ); } // commongappick( seq[subtable[i]], subalignment[i] ); // irukamo } #if 0 for( i=0; i %d\n\n", skipthisbranch[i][0] ); fprintf( stderr, "group2 = " ); for( j=0; topol[i][1][j] != -1; j++ ) fprintf( stderr, "%d ", topol[i][1][j]+1 ); fprintf( stderr, "\n" ); fprintf( stderr, "SKIP -> %d\n\n", skipthisbranch[i][1] ); } #endif for( i=0; i nlenmax ) nlenmax = nlen[i]; i++; } } if( nlenmax > N || njob > M ) { fprintf( stderr, "ERROR in main\n" ); exit( 1 ); } /* nlenmax = Na; */ rewind( stdin ); value = main1( nlen, argc, argv ); exit( 0 ); } #endif