9 static char *whereispairalign;
10 static char *laraparams;
11 static char foldalignopt[1000];
12 static int stdout_align;
13 static int stdout_dist;
14 static int store_localhom;
15 static int store_dist;
17 static void t2u( char *seq )
21 if ( *seq == 'A' ) *seq = 'a';
22 else if( *seq == 'a' ) *seq = 'a';
23 else if( *seq == 'T' ) *seq = 'u';
24 else if( *seq == 't' ) *seq = 'u';
25 else if( *seq == 'U' ) *seq = 'u';
26 else if( *seq == 'u' ) *seq = 'u';
27 else if( *seq == 'G' ) *seq = 'g';
28 else if( *seq == 'g' ) *seq = 'g';
29 else if( *seq == 'C' ) *seq = 'c';
30 else if( *seq == 'c' ) *seq = 'c';
36 static float recallpairfoldalign( char **mseq1, char **mseq2, int m1, int m2, int *of1pt, int *of2pt, int alloclen )
38 static FILE *fp = NULL;
46 fp = fopen( "_foldalignout", "r" );
49 fprintf( stderr, "Cannot open _foldalignout\n" );
54 aln1 = calloc( alloclen, sizeof( char ) );
55 aln2 = calloc( alloclen, sizeof( char ) );
57 readpairfoldalign( fp, *mseq1, *mseq2, aln1, aln2, m1, m2, &of1tmp, &of2tmp, alloclen );
59 if( strstr( foldalignopt, "-global") )
61 fprintf( stderr, "Calling G__align11\n" );
62 value = G__align11( mseq1, mseq2, alloclen );
68 fprintf( stderr, "Calling L__align11\n" );
69 value = L__align11( mseq1, mseq2, alloclen, of1pt, of2pt );
72 // value = (float)naivepairscore11( *mseq1, *mseq2, penalty ); // nennnotame
76 fprintf( stderr, "FOLDALIGN returned no alignment between %d and %d. Sequence alignment is used instead.\n", m1+1, m2+1 );
80 strcpy( *mseq1, aln1 );
81 strcpy( *mseq2, aln2 );
86 // value = naivepairscore11( *mseq1, *mseq2, penalty ); // v6.511 ha kore wo tsukau, global nomi dakara.
88 // fclose( fp ); // saigo dake yatta houga yoi.
90 // fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
91 // fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
100 static void callfoldalign( int nseq, char **mseq )
105 static char com[10000];
107 for( i=0; i<nseq; i++ )
110 fp = fopen( "_foldalignin", "w" );
113 fprintf( stderr, "Cannot open _foldalignin\n" );
116 for( i=0; i<nseq; i++ )
118 fprintf( fp, ">%d\n", i+1 );
119 fprintf( fp, "%s\n", mseq[i] );
123 sprintf( com, "env PATH=%s foldalign210 %s _foldalignin > _foldalignout ", whereispairalign, foldalignopt );
127 fprintf( stderr, "Error in foldalign\n" );
133 static void calllara( int nseq, char **mseq, char *laraarg )
138 static char com[10000];
140 for( i=0; i<nseq; i++ )
142 fp = fopen( "_larain", "w" );
145 fprintf( stderr, "Cannot open _larain\n" );
148 for( i=0; i<nseq; i++ )
150 fprintf( fp, ">%d\n", i+1 );
151 fprintf( fp, "%s\n", mseq[i] );
156 // fprintf( stderr, "calling LaRA\n" );
157 sprintf( com, "env PATH=%s:/bin:/usr/bin mafft_lara -i _larain -w _laraout -o _lara.params %s", whereispairalign, laraarg );
161 fprintf( stderr, "Error in lara\n" );
166 static float recalllara( char **mseq1, char **mseq2, int alloclen )
168 static FILE *fp = NULL;
174 static char com[10000];
180 fp = fopen( "_laraout", "r" );
183 fprintf( stderr, "Cannot open _laraout\n" );
186 ungap1 = AllocateCharVec( alloclen );
187 ungap2 = AllocateCharVec( alloclen );
188 ori1 = AllocateCharVec( alloclen );
189 ori2 = AllocateCharVec( alloclen );
193 strcpy( ori1, *mseq1 );
194 strcpy( ori2, *mseq2 );
196 fgets( com, 999, fp );
197 myfgets( com, 9999, fp );
198 strcpy( *mseq1, com );
199 myfgets( com, 9999, fp );
200 strcpy( *mseq2, com );
202 gappick0( ungap1, *mseq1 );
203 gappick0( ungap2, *mseq2 );
209 if( strcmp( ungap1, ori1 ) || strcmp( ungap2, ori2 ) )
211 fprintf( stderr, "SEQUENCE CHANGED!!\n" );
212 fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
213 fprintf( stderr, "ungap1 = %s\n", ungap1 );
214 fprintf( stderr, "ori1 = %s\n", ori1 );
215 fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
216 fprintf( stderr, "ungap2 = %s\n", ungap2 );
217 fprintf( stderr, "ori2 = %s\n", ori2 );
221 value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
223 // fclose( fp ); // saigo dake yatta houga yoi.
229 static float recallmxscarna( char **mseq1, char **mseq2, int m1, int m2, int alloclen )
232 static char *ungap1 = NULL;
233 static char *ungap2 = NULL;
234 static char *ori1 = NULL;
235 static char *ori2 = NULL;
237 static char com[10000];
243 ungap1 = AllocateCharVec( alloclen );
244 ungap2 = AllocateCharVec( alloclen );
245 ori1 = AllocateCharVec( alloclen );
246 ori2 = AllocateCharVec( alloclen );
249 sprintf( com, "_%d-_%d.fasta", m1, m2 );
250 fp = fopen( com, "r" );
253 fprintf( stderr, "Cannot open %s.\n", com );
257 strcpy( ori1, *mseq1 );
258 strcpy( ori2, *mseq2 );
260 fgets( com, 999, fp );
261 load1SeqWithoutName_new( fp, *mseq1 );
262 fgets( com, 999, fp );
263 load1SeqWithoutName_new( fp, *mseq2 );
265 gappick0( ungap1, *mseq1 );
266 gappick0( ungap2, *mseq2 );
272 if( strcmp( ungap1, ori1 ) || strcmp( ungap2, ori2 ) )
274 fprintf( stderr, "SEQUENCE CHANGED!!\n" );
275 fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
276 fprintf( stderr, "ungap1 = %s\n", ungap1 );
277 fprintf( stderr, "ori1 = %s\n", ori1 );
278 fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
279 fprintf( stderr, "ungap2 = %s\n", ungap2 );
280 fprintf( stderr, "ori2 = %s\n", ori2 );
284 value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
292 static float callmxscarna_giving_bpp( char **mseq1, char **mseq2, char **bpp1, char **bpp2, int alloclen )
296 static char com[10000];
299 fp = fopen( "_bpporg", "w" );
302 fprintf( stderr, "Cannot write to _bpporg\n" );
305 fprintf( fp, ">a\n" );
307 fprintf( fp, "%s", *bpp1++ );
309 fprintf( fp, ">b\n" );
311 fprintf( fp, "%s", *bpp2++ );
314 system( "tr -d '\\r' < _bpporg > _bpp" ); // for cygwin, wakaran
318 fp = fopen( "_mxscarnainorg", "w" );
321 fprintf( stderr, "Cannot open _mxscarnainorg\n" );
324 fprintf( fp, ">1\n" );
325 // fprintf( fp, "%s\n", *mseq1 );
326 write1seq( fp, *mseq1 );
327 fprintf( fp, ">2\n" );
328 // fprintf( fp, "%s\n", *mseq2 );
329 write1seq( fp, *mseq2 );
332 system( "tr -d '\\r' < _mxscarnainorg > _mxscarnain" ); // for cygwin, wakaran
334 sprintf( com, "env PATH=%s mxscarnamod -readbpp _mxscarnain > _mxscarnaout 2>_dum", whereispairalign );
338 fprintf( stderr, "Error in mxscarna\n" );
342 fp = fopen( "_mxscarnaout", "r" );
345 fprintf( stderr, "Cannot open _mxscarnaout\n" );
349 fgets( com, 999, fp );
350 load1SeqWithoutName_new( fp, *mseq1 );
351 fgets( com, 999, fp );
352 load1SeqWithoutName_new( fp, *mseq2 );
356 // fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
357 // fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
359 value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
365 static float callmxscarna_slow( char **mseq1, char **mseq2, int alloclen )
369 static char com[10000];
375 fp = fopen( "_mxscarnain", "w" );
378 fprintf( stderr, "Cannot open _mxscarnain\n" );
381 fprintf( fp, ">1\n" );
382 fprintf( fp, "%s\n", *mseq1 );
383 fprintf( fp, ">2\n" );
384 fprintf( fp, "%s\n", *mseq2 );
387 sprintf( com, "env PATH=%s mxscarnamod _mxscarnain > _mxscarnaout 2>_dum", whereispairalign );
391 fprintf( stderr, "Error in mxscarna\n" );
395 fp = fopen( "_mxscarnaout", "r" );
398 fprintf( stderr, "Cannot open _mxscarnaout\n" );
402 fgets( com, 999, fp );
403 load1SeqWithoutName_new( fp, *mseq1 );
404 fgets( com, 999, fp );
405 load1SeqWithoutName_new( fp, *mseq2 );
409 // fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
410 // fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
412 value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
418 static void readhat4( FILE *fp, char ***bpp )
427 // fprintf( stderr, "reading hat4\n" );
429 // fprintf( stderr, "onechar = %c\n", onechar );
432 fprintf( stderr, "Format error\n" );
435 ungetc( onechar, fp );
436 fgets( oneline, 999, fp );
440 ungetc( onechar, fp );
441 if( onechar == '>' || onechar == EOF )
443 // fprintf( stderr, "Next\n" );
444 *bpp = realloc( *bpp, (bppsize+2) * sizeof( char * ) );
445 (*bpp)[bppsize] = NULL;
448 fgets( oneline, 999, fp );
449 // fprintf( stderr, "oneline=%s\n", oneline );
450 // sscanf( oneline, "%d %d %f", &posi, &posj, &prob );
451 // fprintf( stderr, "%d %d -> %f\n", posi, posj, prob );
452 *bpp = realloc( *bpp, (bppsize+2) * sizeof( char * ) );
453 (*bpp)[bppsize] = calloc( 100, sizeof( char ) );
454 strcpy( (*bpp)[bppsize], oneline );
459 static void preparebpp( int nseq, char ***bpp )
464 fp = fopen( "hat4", "r" );
467 fprintf( stderr, "Cannot open hat4\n" );
470 for( i=0; i<nseq; i++ )
471 readhat4( fp, bpp+i );
475 void arguments( int argc, char *argv[] )
518 ppenalty = NOTSPECIFIED;
519 ppenalty_OP = NOTSPECIFIED;
520 ppenalty_ex = NOTSPECIFIED;
521 ppenalty_EX = NOTSPECIFIED;
522 poffset = NOTSPECIFIED;
523 kimuraR = NOTSPECIFIED;
526 fftWinSize = NOTSPECIFIED;
527 fftThreshold = NOTSPECIFIED;
528 RNAppenalty = NOTSPECIFIED;
529 RNApthr = NOTSPECIFIED;
531 while( --argc > 0 && (*++argv)[0] == '-' )
533 while ( ( c = *++argv[0] ) )
539 fprintf( stderr, "inputfile = %s\n", inputfile );
543 ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
547 ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
551 ppenalty_OP = (int)( atof( *++argv ) * 1000 - 0.5 );
555 ppenalty_EX = (int)( atof( *++argv ) * 1000 - 0.5 );
559 poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
563 kimuraR = atoi( *++argv );
564 // fprintf( stderr, "kimuraR = %d\n", kimuraR );
568 nblosum = atoi( *++argv );
570 // fprintf( stderr, "blosum %d\n", nblosum );
574 pamN = atoi( *++argv );
577 fprintf( stderr, "jtt %d\n", pamN );
581 pamN = atoi( *++argv );
584 fprintf( stderr, "TM %d\n", pamN );
588 ppslocal = (int)( atof( *++argv ) * 1000 + 0.5 );
589 pslocal = (int)( 600.0 / 1000.0 * ppslocal + 0.5);
590 // fprintf( stderr, "ppslocal = %d\n", ppslocal );
591 // fprintf( stderr, "pslocal = %d\n", pslocal );
595 whereispairalign = *++argv;
596 fprintf( stderr, "whereispairalign = %s\n", whereispairalign );
600 laraparams = *++argv;
601 fprintf( stderr, "laraparams = %s\n", laraparams );
699 /* Modified 01/08/27, default: user tree */
703 /* modification end. */
705 // foldalignopt = *++argv;
706 strcat( foldalignopt, " " );
707 strcat( foldalignopt, *++argv );
708 fprintf( stderr, "foldalignopt = %s\n", foldalignopt );
712 fftThreshold = atoi( *++argv );
716 fftWinSize = atoi( *++argv );
723 fprintf( stderr, "illegal option %c\n", c );
733 cut = atof( (*argv) );
738 fprintf( stderr, "options: Check source file !\n" );
741 if( tbitr == 1 && outgap == 0 )
743 fprintf( stderr, "conflicting options : o, m or u\n" );
746 if( alg == 'C' && outgap == 0 )
748 fprintf( stderr, "conflicting options : C, o\n" );
753 int countamino( char *s, int end )
757 if( *s++ != '-' ) val++;
761 static void pairalign( char name[M][B], int nlen[M], char **seq, char **aseq, char **mseq1, char **mseq2, double *effarr, int alloclen )
766 float pscore = 0.0; // by D.Mathog
767 static char *indication1, *indication2;
769 static double **distancemtx;
770 static double *selfscore;
771 static double *effarr1 = NULL;
772 static double *effarr2 = NULL;
774 char *hat2file = "hat2";
775 LocalHom **localhomtable, *tmpptr;
779 char ***bpp; // mxscarna no toki dake
783 localhomtable = (LocalHom **)calloc( njob, sizeof( LocalHom *) );
784 for( i=0; i<njob; i++)
786 localhomtable[i] = (LocalHom *)calloc( njob, sizeof( LocalHom ) );
787 for( j=0; j<njob; j++)
789 localhomtable[i][j].start1 = -1;
790 localhomtable[i][j].end1 = -1;
791 localhomtable[i][j].start2 = -1;
792 localhomtable[i][j].end2 = -1;
793 localhomtable[i][j].opt = -1.0;
794 localhomtable[i][j].next = NULL;
795 localhomtable[i][j].nokori = 0;
800 if( effarr1 == NULL )
802 if( store_dist ) distancemtx = AllocateDoubleMtx( njob, njob );
803 selfscore = AllocateDoubleVec( njob );
804 effarr1 = AllocateDoubleVec( njob );
805 effarr2 = AllocateDoubleVec( njob );
806 indication1 = AllocateCharVec( 150 );
807 indication2 = AllocateCharVec( 150 );
810 pair = AllocateCharMtx( njob, njob );
815 fprintf( stderr, "##### fftwinsize = %d, fftthreshold = %d\n", fftWinSize, fftThreshold );
819 for( i=0; i<njob; i++ )
820 fprintf( stderr, "TBFAST effarr[%d] = %f\n", i, effarr[i] );
824 // writePre( njob, name, nlen, aseq, 0 );
826 for( i=0; i<njob; i++ ) for( j=0; j<njob; j++ ) pair[i][j] = 0;
827 for( i=0; i<njob; i++ ) pair[i][i] = 1;
831 fprintf( stderr, "Calling FOLDALIGN with option '%s'\n", foldalignopt );
832 callfoldalign( njob, seq );
833 fprintf( stderr, "done.\n" );
837 fprintf( stderr, "Running LARA (Bauer et al. http://www.planet-lisa.net/)\n" );
838 calllara( njob, seq, "" );
839 fprintf( stderr, "done.\n" );
843 fprintf( stderr, "Running SLARA (Bauer et al. http://www.planet-lisa.net/)\n" );
844 calllara( njob, seq, "-s" );
845 fprintf( stderr, "done.\n" );
849 fprintf( stderr, "Preparing bpp\n" );
850 // bpp = AllocateCharCub( njob, nlenmax, 0 );
851 bpp = calloc( njob, sizeof( char ** ) );
852 preparebpp( njob, bpp );
853 fprintf( stderr, "done.\n" );
854 fprintf( stderr, "Running MXSCARNA (Tabei et al. http://www.ncrna.org/software/mxscarna)\n" );
857 for( i=0; i<njob; i++ )
860 for( pt=seq[i]; *pt; pt++ )
861 pscore += amino_dis[(int)*pt][(int)*pt];
862 selfscore[i] = pscore;
867 for( i=0; i<ilim; i++ )
869 if( stdout_dist) fprintf( stdout, "%d-%d d=%.3f\n", i+1, i+1, 0.0 );
870 fprintf( stderr, "% 5d / %d\r", i, njob );
871 for( j=i+1; j<njob; j++ )
874 if( strlen( seq[i] ) == 0 || strlen( seq[j] ) == 0 )
876 if( store_dist ) distancemtx[i][j] = 2.0;
877 if( stdout_dist) fprintf( stdout, "%d-%d d=%.3f\n", i+1, j+1, 2.0 );
881 strcpy( aseq[i], seq[i] );
882 strcpy( aseq[j], seq[j] );
883 clus1 = conjuctionfortbfast( pair, i, aseq, mseq1, effarr1, effarr, indication1 );
884 clus2 = conjuctionfortbfast( pair, j, aseq, mseq2, effarr2, effarr, indication2 );
885 // fprintf( stderr, "mseq1 = %s\n", mseq1[0] );
886 // fprintf( stderr, "mseq2 = %s\n", mseq2[0] );
889 fprintf( stderr, "group1 = %.66s", indication1 );
890 fprintf( stderr, "\n" );
891 fprintf( stderr, "group2 = %.66s", indication2 );
892 fprintf( stderr, "\n" );
894 // for( l=0; l<clus1; l++ ) fprintf( stderr, "## STEP-eff for mseq1-%d %f\n", l, effarr1[l] );
899 pscore = Falign( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, &intdum );
900 // fprintf( stderr, "pscore (fft) = %f\n", pscore );
909 pscore = Aalign( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen );
913 pscore = G__align11_noalign( amino_dis, penalty, penalty_ex, mseq1, mseq2, alloclen );
917 pscore = G__align11( mseq1, mseq2, alloclen );
922 pscore = VAalign11( mseq1, mseq2, alloclen, &off1, &off2, localhomtable[i]+j );
923 fprintf( stderr, "i,j = %d,%d, score = %f\n", i,j, pscore );
926 fprintf( stderr, "aligning %d-%d\n", i, j );
927 pscore = suboptalign11( mseq1, mseq2, alloclen, &off1, &off2, localhomtable[i]+j );
928 fprintf( stderr, "i,j = %d,%d, score = %f\n", i,j, pscore );
932 pscore = G__align11_noalign( amino_dis, penalty, penalty_ex, mseq1, mseq2, alloclen );
933 genL__align11( mseq1, mseq2, alloclen, &off1, &off2 );
934 // fprintf( stderr, "pscore = %f\n", pscore );
937 pscore = genG__align11( mseq1, mseq2, alloclen );
941 pscore = G__align11_noalign( amino_dis, penalty, penalty_ex, mseq1, mseq2, alloclen );
942 L__align11( mseq1, mseq2, alloclen, &off1, &off2 );
943 // fprintf( stderr, "pscore (1) = %f\n", pscore );
944 // pscore = (float)naivepairscore11( *mseq1, *mseq2, penalty ); // nennnotame
945 // fprintf( stderr, "pscore (2) = %f\n\n", pscore );
948 pscore = recallpairfoldalign( mseq1, mseq2, i, j, &off1, &off2, alloclen );
952 pscore = recalllara( mseq1, mseq2, alloclen );
954 // fprintf( stderr, "lara, pscore = %f\n", pscore );
957 pscore = callmxscarna_giving_bpp( mseq1, mseq2, bpp[i], bpp[j], alloclen );
958 // pscore = G__align11_noalign( amino_disLN, -1200, -60, mseq1, mseq2, alloclen );
960 // fprintf( stderr, "scarna, pscore = %f\n", pscore );
963 // pscore = MSalign11( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, NULL, NULL, NULL, NULL );
964 pscore = MSalign11( mseq1, mseq2, alloclen );
965 // fprintf( stderr, "pscore (M)= %f\n", pscore );
967 ErrorExit( "ERROR IN SOURCE FILE" );
971 if( alg == 't' || ( mseq1[0][0] != 0 && mseq2[0][0] != 0 ) ) // 't' no jouken ha iranai to omou. if( ( mseq1[0][0] != 0 && mseq2[0][0] != 0 ) )
974 fprintf( stderr, "score = %10.2f (%d,%d)\n", pscore, i, j );
976 // fprintf( stderr, "pslocal = %d\n", pslocal );
977 // offset = makelocal( *mseq1, *mseq2, pslocal );
979 fprintf( stderr, "off1 = %d, off2 = %d\n", off1, off2 );
982 if( !store_localhom )
984 else if( alg == 'H' )
985 putlocalhom_ext( mseq1[0], mseq2[0], localhomtable[i]+j, off1, off2, (int)pscore, strlen( mseq1[0] ) );
986 else if( alg != 'S' && alg != 'V' )
987 putlocalhom2( mseq1[0], mseq2[0], localhomtable[i]+j, off1, off2, (int)pscore, strlen( mseq1[0] ) );
990 if( (bunbo=MIN( selfscore[i], selfscore[j] )) == 0.0 || bunbo < pscore )
993 pscore = ( 1.0 - pscore / bunbo ) * 2.0;
1004 fprintf( stdout, "sequence %d - sequence %d, pairwise score = %.0f\n", i+1, j+1, pscore );
1005 fprintf( stdout, ">%s\n", name[i] );
1006 write1seq( stdout, mseq1[0] );
1007 fprintf( stdout, ">%s\n", name[j] );
1008 write1seq( stdout, mseq2[0] );
1009 fprintf( stdout, "\n" );
1012 if( stdout_dist ) fprintf( stdout, "%d-%d d=%.3f\n", i+1, j+1, pscore );
1013 if( store_dist) distancemtx[i][j] = pscore;
1019 hat2p = fopen( hat2file, "w" );
1020 if( !hat2p ) ErrorExit( "Cannot open hat2." );
1021 WriteHat2( hat2p, njob, name, distancemtx );
1025 hat3p = fopen( "hat3", "w" );
1026 if( !hat3p ) ErrorExit( "Cannot open hat3." );
1027 if( store_localhom )
1029 fprintf( stderr, "##### writing hat3\n" );
1031 for( i=0; i<ilim; i++ )
1033 for( j=i+1; j<njob; j++ )
1035 for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next )
1037 if( tmpptr->opt == -1.0 ) continue;
1039 // if( alg == 'B' || alg == 'T' )
1040 // fprintf( hat3p, "%d %d %d %7.5f %d %d %d %d %p\n", i, j, tmpptr->overlapaa, 1.0, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, (void *)tmpptr->next );
1042 fprintf( hat3p, "%d %d %d %7.5f %d %d %d %d h\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2 );
1047 fprintf( stderr, "calling FreeLocalHomTable\n" );
1049 FreeLocalHomTable( localhomtable, njob );
1051 fprintf( stderr, "done. FreeLocalHomTable\n" );
1059 for( i=0; i<njob; i++ )
1064 if( *ptpt ) free( *ptpt );
1074 static void WriteOptions( FILE *fp )
1077 if( dorp == 'd' ) fprintf( fp, "DNA\n" );
1080 if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN );
1081 else if( scoremtx == 1 ) fprintf( fp, "BLOSUM %d\n", nblosum );
1082 else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" );
1084 fprintf( stderr, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
1085 if( use_fft ) fprintf( fp, "FFT on\n" );
1087 fprintf( fp, "tree-base method\n" );
1088 if( tbrweight == 0 ) fprintf( fp, "unweighted\n" );
1089 else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" );
1090 if( tbitr || tbweight )
1092 fprintf( fp, "iterate at each step\n" );
1093 if( tbitr && tbrweight == 0 ) fprintf( fp, " unweighted\n" );
1094 if( tbitr && tbrweight == 3 ) fprintf( fp, " reversely weighted\n" );
1095 if( tbweight ) fprintf( fp, " weighted\n" );
1096 fprintf( fp, "\n" );
1099 fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
1102 fprintf( fp, "Algorithm A\n" );
1103 else if( alg == 'A' )
1104 fprintf( fp, "Algorithm A+\n" );
1105 else if( alg == 'S' )
1106 fprintf( fp, "Apgorithm S\n" );
1107 else if( alg == 'C' )
1108 fprintf( fp, "Apgorithm A+/C\n" );
1110 fprintf( fp, "Unknown algorithm\n" );
1114 fprintf( fp, "FFT on\n" );
1116 fprintf( fp, "Basis : 4 nucleotides\n" );
1120 fprintf( fp, "Basis : Polarity and Volume\n" );
1122 fprintf( fp, "Basis : 20 amino acids\n" );
1124 fprintf( fp, "Threshold of anchors = %d%%\n", fftThreshold );
1125 fprintf( fp, "window size of anchors = %dsites\n", fftWinSize );
1128 fprintf( fp, "FFT off\n" );
1133 int main( int argc, char *argv[] )
1136 static char name[M][B], **seq;
1137 static char **mseq1, **mseq2;
1146 arguments( argc, argv );
1150 infp = fopen( inputfile, "r" );
1153 fprintf( stderr, "Cannot open %s\n", inputfile );
1165 fprintf( stderr, "At least 2 sequences should be input!\n"
1166 "Only %d sequence found.\n", njob );
1171 fprintf( stderr, "The number of sequences must be < %d\n", M );
1172 fprintf( stderr, "Please try the splittbfast program for such large data.\n" );
1176 seq = AllocateCharMtx( njob, nlenmax*9+1 );
1177 aseq = AllocateCharMtx( njob, nlenmax*9+1 );
1178 bseq = AllocateCharMtx( njob, nlenmax*9+1 );
1179 mseq1 = AllocateCharMtx( njob, 0 );
1180 mseq2 = AllocateCharMtx( njob, 0 );
1181 alloclen = nlenmax*9;
1183 eff = AllocateDoubleVec( njob );
1186 Read( name, nlen, seq );
1188 readData( infp, name, nlen, seq );
1192 constants( njob, seq );
1195 fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
1202 WriteOptions( trap_g );
1204 c = seqcheck( seq );
1207 fprintf( stderr, "Illegal character %c\n", c );
1211 // writePre( njob, name, nlen, seq, 0 );
1213 for( i=0; i<njob; i++ ) eff[i] = 1.0;
1216 for( i=0; i<njob; i++ ) gappick0( bseq[i], seq[i] );
1218 pairalign( name, nlen, bseq, aseq, mseq1, mseq2, eff, alloclen );
1220 fprintf( trap_g, "done.\n" );
1222 fprintf( stderr, "closing trap_g\n" );
1226 // writePre( njob, name, nlen, aseq, !contin );
1228 writeData( stdout, njob, name, nlen, aseq );
1231 fprintf( stderr, "OSHIMAI\n" );