8 static char *whereispairalign;
10 static int *alreadyoutput;
11 static int equivthreshold;
12 static int equivwinsize;
13 static int equivshortestlen;
15 static void cutpath( char *s )
18 pos = s + strlen( s );
22 if( *pos == '/' ) break;
28 static char getchainid( char *s )
31 if( isspace( s[0] ) && isalnum( s[1] ) )
37 static void extractfirstword( char *s )
41 if( isspace( *s ) ) break;
47 static char *strip( char *s )
53 if( !isspace( *s ) ) break;
73 static void makeequivdouble( double *d, char *c )
77 *d++ = (double)( *c++ - '0' );
81 static void maskequiv( double *d, int n )
87 halfwin = (int)( equivwinsize / 2 );
92 for( j = i-halfwin; j<i+halfwin; j++ )
94 if( j<0 || n=<j ) continue;
101 if( ok == 0 ) d[i] = 0.0;
105 static void maskequiv( double *d, int n )
110 double *dbk, *dori, *dbkori;
112 dbk = calloc( n, sizeof( double ) );
137 if( len >= equivshortestlen )
140 while( len-- ) d[i-len] = dbk[i-len];
146 if( len >= equivshortestlen )
149 while( len-- ) d[n-len] = dbk[n-len];
156 static void makeequivdouble_tmalign( double *d, char *c, int n )
165 if( ( s=*c++ ) == ':' )
171 // tmpd = (double)( tmpi + 1 - equivthreshold ) / ( 10 - equivthreshold ) * 9.0;
172 // if( tmpd < 0.0 ) tmpd = 0.0;
173 tmpd = (double)( tmpi );
179 // maskequiv( d, n );
182 static void makeequivdouble_threshold( double *d, char *c, int n )
190 tmpi = (int)( *c++ - '0' );
191 tmpd = (double)( tmpi + 1 - equivthreshold ) / ( 10 - equivthreshold ) * 9.0;
192 if( tmpd < 0.0 ) tmpd = 0.0;
201 static void readtmalign( FILE *fp, char *seq1, char *seq2, double *equiv )
203 static char *line = NULL;
204 static char *equivchar = NULL;
208 if( equivchar == NULL )
210 equivchar = calloc( nlenmax * 2 + 1, sizeof( char ) );
211 line = calloc( nlenmax * 2 + 1, sizeof( char ) );
218 // system( "vi _tmalignout" );
223 fprintf( stderr, "Error in TMalign\n" );
226 fgets( line, 999, fp );
227 // fprintf( stdout, "line = :%s:\n", line );
228 if( !strncmp( line+5, "denotes the residue pairs", 20 ) ) break;
230 fgets( line, nlenmax*2, fp );
231 strcat( seq1, strip( line ) );
233 fgets( line, nlenmax*2, fp );
234 strcat( equivchar, strip( line ) );
236 fgets( line, nlenmax*2, fp );
237 strcat( seq2, strip( line ) );
240 printf( "seq1=%s\n", seq1 );
241 printf( "seq2=%s\n", seq2 );
242 printf( "equi=%s\n", equivchar );
246 makeequivdouble_tmalign( equiv, equivchar, n );
249 fprintf( stdout, "\n" );
252 fprintf( stdout, "%1.0f", equiv[i] );
254 fprintf( stdout, "\n" );
258 static void readrash( FILE *fp, char *seq1, char *seq2, double *equiv )
261 static char *equivchar = NULL;
265 if( equivchar == NULL )
267 equivchar = calloc( nlenmax * 2, sizeof( char ) );
275 fgets( line, 999, fp );
276 // fprintf( stdout, "line = :%s:\n", line );
277 if( !strncmp( line, "Query ", 6 ) ) break;
278 if( feof( fp ) ) break;
279 if( !strncmp( line, "QUERY ", 6 ) )
281 strcat( seq1, strip( line+5 ) );
282 fgets( line, 999, fp );
284 if( !strncmp( line, "TEMPL ", 6 ) )
286 strcat( seq2, strip( line+5 ) );
287 fgets( line, 999, fp );
289 if( !strncmp( line, "Equiva", 6 ) )
291 strcat( equivchar, strip( line+11 ) );
292 fgets( line, 999, fp );
296 printf( "seq1=:%s:\n", seq1 );
297 printf( "seq2=:%s:\n", seq2 );
298 printf( "equi=:%s:\n", equivchar );
302 makeequivdouble_threshold( equiv, equivchar, n );
305 fprintf( stdout, "\n" );
308 fprintf( stdout, "%1.0f", equiv[i] );
310 fprintf( stdout, "\n" );
314 static int checkcbeta( FILE *fp )
319 fgets( linec, 999, fp );
320 if( feof( fp ) ) break;
321 if( !strncmp( "ATOM ", linec, 5 ) )
323 if( !strncmp( "CB ", linec+13, 3 ) ) return( 0 );
330 static float calltmalign( char **mseq1, char **mseq2, double *equiv, char *fname1, char *chain1, char *fname2, char *chain2, int alloclen )
334 static char com[10000];
336 char cachedir[10000];
337 char cachefile[10000];
343 sprintf( cachedir, "%s/.tmalignoutcache", getenv( "HOME" ) );
344 sprintf( com, "mkdir -p %s", cachedir );
347 sprintf( cachefile, "%s/%s%s-%s%s", cachedir, fname1, chain1, fname2, chain2 );
350 fp = fopen( cachefile, "r" );
351 if( fp == NULL ) runnow = 1;
354 fgets( com, 100, fp );
355 if( strncmp( com, "successful", 10 ) ) runnow = 1;
367 sprintf( com, "ln -s %s %s.pdb 2>_dum", fname1, fname1 );
369 sprintf( com, "ln -s %s %s.pdb 2>_dum", fname2, fname2 );
372 sprintf( com, "\"%s/TMalign\" %s.pdb %s.pdb > _tmalignout 2>_dum", whereispairalign, fname1, fname2 );
373 fprintf( stderr, "command = %s\n", com );
377 fprintf( stderr, "Error in TMalign\n" );
384 fprintf( stderr, "Cache is not supported!\n" );
388 fp = fopen( "_tmalignout", "r" );
391 fprintf( stderr, "Cannot open _tmalignout\n" );
395 readtmalign( fp, *mseq1, *mseq2, equiv );
399 // fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
400 // fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
402 value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
407 static float callrash( int mem1, int mem2, char **mseq1, char **mseq2, double *equiv, char *fname1, char *chain1, char *fname2, char *chain2, int alloclen )
411 static char com[10000];
413 char cachedir[10000];
414 char cachefile[10000];
418 sprintf( pairid, "%d-%d", mem1, mem2 );
419 // fprintf( stderr, "pairid = %s\n", pairid );
423 sprintf( cachedir, "%s/.rashoutcache", getenv( "HOME" ) );
424 sprintf( com, "mkdir -p %s", cachedir );
427 sprintf( cachefile, "%s/%s%s-%s%s", cachedir, fname1, chain1, fname2, chain2 );
430 fp = fopen( cachefile, "r" );
431 if( fp == NULL ) runnow = 1;
434 fgets( com, 100, fp );
435 if( strncmp( com, "successful", 10 ) ) runnow = 1;
447 sprintf( com, "ln -s %s %s.pdb 2>_dum", fname1, fname1 );
449 sprintf( com, "ln -s %s %s.pdb 2>_dum", fname2, fname2 );
452 #if 0 // 091127, pdp nai!
453 sprintf( com, "env PATH=%s PDP_ASH.pl --qf %s.pdb --qc %s --tf %s.pdb --tc %s > _rashout 2>_dum", whereispairalign, fname1, chain1, fname2, chain2 );
455 sprintf( com, "\"%s/rash\" --qf %s.pdb --qc %s --tf %s.pdb --tc %s --of %s.pdbpair > %s.rashout 2>%s.dum", whereispairalign, fname1, chain1, fname2, chain2, pairid, pairid, pairid );
457 fprintf( stderr, "command = %s\n", com );
461 fprintf( stderr, "Error in structural alignment\n" );
464 sprintf( com, "awk '/^REMARK/,/^TER/' %s.pdbpair > %s.%s-x-%s.%s.pdbpair", pairid, fname1, chain1, fname2, chain2 );
467 sprintf( com, "awk '/^REMARK/,/^TER/{next} 1' %s.pdbpair > %s.%s-x-%s.%s.pdbpair", pairid, fname2, chain2, fname1, chain1 );
470 sprintf( com, "rm %s.pdbpair", pairid );
477 fprintf( stderr, "Use cache!\n" );
478 sprintf( com, "grep -v successful %s > %s.rashout", cachefile, pairid );
482 if( usecache && runnow )
484 sprintf( com, "echo successful > %s", cachefile );
486 sprintf( com, "cat %s.rashout >> %s", pairid, cachefile );
490 sprintf( com, "%s.rashout", pairid );
491 fp = fopen( com, "r" );
494 fprintf( stderr, "Cannot open %s\n", com );
498 readrash( fp, *mseq1, *mseq2, equiv );
502 // fprintf( stderr, "*mseq1 = %s\n", *mseq1 );
503 // fprintf( stderr, "*mseq2 = %s\n", *mseq2 );
506 value = (float)naivepairscore11( *mseq1, *mseq2, penalty );
511 static void preparetmalign( FILE *fp, char ***strfiles, char ***chainids, char ***seqpt, char ***mseq1pt, char ***mseq2pt, double **equivpt, int *alloclenpt )
518 int linenum, istr, nstr;
526 fgets( line, 999, fp );
527 if( feof( fp ) ) break;
528 sline = strip( line );
530 if( sline[0] == '#' || strlen( sline ) < 2 )
536 extractfirstword( sline );
537 checkfp = fopen( sline, "r" );
538 if( checkfp == NULL )
540 fprintf( stderr, "Cannot open %s.\n", sline );
544 fgets( linec, 999, checkfp );
545 if( strncmp( "HEADER ", linec, 7 ) )
547 fprintf( stderr, "Check the format of %s.\n", sline );
551 if( checkcbeta( checkfp ) )
553 fprintf( stderr, "%s has no C-beta atoms.\n", sline );
562 fprintf( stderr, "nstr = %d\n", nstr );
564 *strfiles = AllocateCharMtx( nstr, 1000 );
565 *chainids = AllocateCharMtx( nstr, 2 );
572 fgets( line, 999, fp );
573 if( feof( fp ) ) break;
574 sline = strip( line );
577 (*chainids)[istr][0] = getchainid( sline );
578 (*chainids)[istr][1] = 0;
579 extractfirstword( sline );
580 sprintf( fname, "%s", sline );
582 sprintf( command, "cp %s %s.pdb", sline, fname );
584 sprintf( command, "perl \"%s/clean.pl\" %s.pdb", whereispairalign, fname );
585 res = system( command );
588 fprintf( stderr, "error: Install clean.pl\n" );
591 strcpy( (*strfiles)[istr++], fname );
595 *seqpt = AllocateCharMtx( njob, nlenmax*2+1 );
596 *mseq1pt = AllocateCharMtx( njob, 0 );
597 *mseq2pt = AllocateCharMtx( njob, 0 );
598 *equivpt = AllocateDoubleVec( nlenmax*2+1 );
599 *alloclenpt = nlenmax*2;
600 dumseq = AllocateCharVec( nlenmax*2+1 );
601 alreadyoutput = AllocateIntVec( njob );
602 for( i=0; i<njob; i++ ) alreadyoutput[i] = 0;
604 for( i=0; i<istr; i++ )
606 fprintf( stderr, "i=%d\n", i );
609 (*mseq1pt)[0] = (*seqpt)[i];
610 (*mseq2pt)[0] = dumseq;
612 calltmalign( *mseq1pt, *mseq2pt, *equivpt, (*strfiles)[i], (*chainids)[i], (*strfiles)[i], (*chainids)[i], *alloclenpt );
613 fprintf( stdout, ">%d_%s-%s\n%s\n", i+1, (*strfiles)[i], (*chainids)[i], (*seqpt)[i] );
614 alreadyoutput[i] = 1;
618 static void prepareash( FILE *fp, char ***strfiles, char ***chainids, char ***seqpt, char ***mseq1pt, char ***mseq2pt, double **equivpt, int *alloclenpt )
625 int linenum, istr, nstr;
633 fgets( line, 999, fp );
634 if( feof( fp ) ) break;
635 sline = strip( line );
637 if( sline[0] == '#' || strlen( sline ) < 2 )
643 extractfirstword( sline );
644 checkfp = fopen( sline, "r" );
645 if( checkfp == NULL )
647 fprintf( stderr, "Cannot open %s.\n", sline );
651 fgets( linec, 999, checkfp );
652 if( strncmp( "HEADER ", linec, 7 ) )
654 fprintf( stderr, "Check the format of %s.\n", sline );
658 if( checkcbeta( checkfp ) )
660 fprintf( stderr, "%s has no C-beta atoms.\n", sline );
669 fprintf( stderr, "nstr = %d\n", nstr );
671 *strfiles = AllocateCharMtx( nstr, 1000 );
672 *chainids = AllocateCharMtx( nstr, 2 );
679 fgets( line, 999, fp );
680 if( feof( fp ) ) break;
681 sline = strip( line );
684 (*chainids)[istr][0] = getchainid( sline );
685 (*chainids)[istr][1] = 0;
686 extractfirstword( sline );
687 sprintf( fname, "%s", sline );
689 sprintf( command, "cp %s %s.pdb", sline, fname );
691 sprintf( command, "perl \"%s/clean.pl\" %s.pdb", whereispairalign, fname );
692 res = system( command );
695 fprintf( stderr, "error: Install clean.pl\n" );
698 strcpy( (*strfiles)[istr++], fname );
702 *seqpt = AllocateCharMtx( njob, nlenmax*2+1 );
703 *mseq1pt = AllocateCharMtx( njob, 0 );
704 *mseq2pt = AllocateCharMtx( njob, 0 );
705 *equivpt = AllocateDoubleVec( nlenmax*2+1 );
706 *alloclenpt = nlenmax*2;
707 dumseq = AllocateCharVec( nlenmax*2+1 );
708 alreadyoutput = AllocateIntVec( njob );
709 for( i=0; i<njob; i++ ) alreadyoutput[i] = 0;
711 for( i=0; i<istr; i++ )
713 fprintf( stderr, "i=%d\n", i );
716 (*mseq1pt)[0] = (*seqpt)[i];
717 (*mseq2pt)[0] = dumseq;
719 callrash( i, i, *mseq1pt, *mseq2pt, *equivpt, (*strfiles)[i], (*chainids)[i], (*strfiles)[i], (*chainids)[i], *alloclenpt );
720 fprintf( stdout, ">%d_%s-%s\n%s\n", i+1, (*strfiles)[i], (*chainids)[i], (*seqpt)[i] );
721 alreadyoutput[i] = 1;
725 void arguments( int argc, char *argv[] )
733 equivshortestlen = 1;
767 ppenalty = NOTSPECIFIED;
768 ppenalty_OP = NOTSPECIFIED;
769 ppenalty_ex = NOTSPECIFIED;
770 ppenalty_EX = NOTSPECIFIED;
771 poffset = NOTSPECIFIED;
772 kimuraR = NOTSPECIFIED;
775 fftWinSize = NOTSPECIFIED;
776 fftThreshold = NOTSPECIFIED;
777 RNAppenalty = NOTSPECIFIED;
778 RNApthr = NOTSPECIFIED;
780 while( --argc > 0 && (*++argv)[0] == '-' )
782 while ( ( c = *++argv[0] ) )
788 fprintf( stderr, "inputfile = %s\n", inputfile );
792 ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
796 ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
800 ppenalty_OP = (int)( atof( *++argv ) * 1000 - 0.5 );
804 ppenalty_EX = (int)( atof( *++argv ) * 1000 - 0.5 );
808 poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
812 kimuraR = atoi( *++argv );
813 // fprintf( stderr, "kimuraR = %d\n", kimuraR );
817 nblosum = atoi( *++argv );
819 // fprintf( stderr, "blosum %d\n", nblosum );
823 pamN = atoi( *++argv );
826 fprintf( stderr, "jtt %d\n", pamN );
830 pamN = atoi( *++argv );
833 fprintf( stderr, "TM %d\n", pamN );
837 whereispairalign = *++argv;
838 fprintf( stderr, "whereispairalign = %s\n", whereispairalign );
842 equivthreshold = atoi( *++argv );
846 equivwinsize = atoi( *++argv );
850 equivshortestlen = atoi( *++argv );
854 scale = atof( *++argv );
938 /* Modified 01/08/27, default: user tree */
942 /* modification end. */
945 fftThreshold = atoi( *++argv );
949 fftWinSize = atoi( *++argv );
957 fprintf( stderr, "illegal option %c\n", c );
967 cut = atof( (*argv) );
972 fprintf( stderr, "options: Check source file !\n" );
975 if( tbitr == 1 && outgap == 0 )
977 fprintf( stderr, "conflicting options : o, m or u\n" );
980 if( alg == 'C' && outgap == 0 )
982 fprintf( stderr, "conflicting options : C, o\n" );
987 int countamino( char *s, int end )
991 if( *s++ != '-' ) val++;
995 static void pairalign( char name[M][B], int nlen[M], char **seq, char **aseq, char **mseq1, char **mseq2, double *equiv, double *effarr, char **strfiles, char **chainids, int alloclen )
1000 float pscore = 0.0; // by D.Mathog
1001 static char *indication1, *indication2;
1002 FILE *hat2p, *hat3p;
1003 static double **distancemtx;
1004 static double *effarr1 = NULL;
1005 static double *effarr2 = NULL;
1007 char *hat2file = "hat2";
1008 LocalHom **localhomtable, *tmpptr;
1015 localhomtable = (LocalHom **)calloc( njob, sizeof( LocalHom *) );
1016 for( i=0; i<njob; i++)
1019 localhomtable[i] = (LocalHom *)calloc( njob, sizeof( LocalHom ) );
1020 for( j=0; j<njob; j++)
1022 localhomtable[i][j].start1 = -1;
1023 localhomtable[i][j].end1 = -1;
1024 localhomtable[i][j].start2 = -1;
1025 localhomtable[i][j].end2 = -1;
1026 localhomtable[i][j].opt = -1.0;
1027 localhomtable[i][j].next = NULL;
1028 localhomtable[i][j].nokori = 0;
1032 if( effarr1 == NULL )
1034 distancemtx = AllocateDoubleMtx( njob, njob );
1035 effarr1 = AllocateDoubleVec( njob );
1036 effarr2 = AllocateDoubleVec( njob );
1037 indication1 = AllocateCharVec( 150 );
1038 indication2 = AllocateCharVec( 150 );
1039 checkseq = AllocateCharMtx( njob, alloclen );
1042 pair = AllocateCharMtx( njob, njob );
1047 fprintf( stderr, "##### fftwinsize = %d, fftthreshold = %d\n", fftWinSize, fftThreshold );
1051 for( i=0; i<njob; i++ )
1052 fprintf( stderr, "TBFAST effarr[%d] = %f\n", i, effarr[i] );
1056 // writePre( njob, name, nlen, aseq, 0 );
1058 for( i=0; i<njob; i++ ) for( j=0; j<njob; j++ ) pair[i][j] = 0;
1059 for( i=0; i<njob; i++ ) pair[i][i] = 1;
1061 for( i=0; i<njob; i++ )
1063 strcpy( checkseq[i], seq[i] );
1064 // fprintf( stderr, "checkseq[%d] = %s\n", i, checkseq[i] );
1069 for( i=0; i<ilim; i++ )
1071 fprintf( stderr, "% 5d / %d\r", i, njob );
1074 for( j=i+1; j<njob; j++ )
1079 if( strlen( seq[i] ) == 0 || strlen( seq[j] ) == 0 )
1081 distancemtx[i][j] = pscore;
1086 strcpy( aseq[i], seq[i] );
1087 strcpy( aseq[j], seq[j] );
1088 clus1 = conjuctionfortbfast( pair, i, aseq, mseq1, effarr1, effarr, indication1 );
1089 clus2 = conjuctionfortbfast( pair, j, aseq, mseq2, effarr2, effarr, indication2 );
1090 // fprintf( stderr, "mseq1 = %s\n", mseq1[0] );
1091 // fprintf( stderr, "mseq2 = %s\n", mseq2[0] );
1094 fprintf( stderr, "group1 = %.66s", indication1 );
1095 fprintf( stderr, "\n" );
1096 fprintf( stderr, "group2 = %.66s", indication2 );
1097 fprintf( stderr, "\n" );
1099 // for( l=0; l<clus1; l++ ) fprintf( stderr, "## STEP-eff for mseq1-%d %f\n", l, effarr1[l] );
1106 fprintf( stderr, " Calling tmalign %d-%d/%d \r", i+1, j+1, njob );
1107 pscore = calltmalign( mseq1, mseq2, equiv, strfiles[i], chainids[i], strfiles[j], chainids[j], alloclen );
1111 fprintf( stderr, " Calling PDP_ASH.pl %d-%d/%d \r", i+1, j+1, njob );
1112 pscore = callrash( i, j, mseq1, mseq2, equiv, strfiles[i], chainids[i], strfiles[j], chainids[j], alloclen );
1115 ErrorExit( "ERROR IN SOURCE FILE" );
1119 distancemtx[i][j] = pscore;
1121 fprintf( stderr, "score = %10.2f (%d,%d)\n", pscore, i, j );
1124 putlocalhom_str( mseq1[0], mseq2[0], equiv, scale, localhomtable[i]+j, off1, off2, (int)pscore, strlen( mseq1[0] ) );
1127 if( alreadyoutput[i] == 0 )
1129 alreadyoutput[i] = 1;
1130 gappick0( seq[i], mseq1[0] );
1131 fprintf( stdout, ">%d_%s-%s\n%s\n", i+1, strfiles[i], chainids[i], seq[i] );
1132 strcpy( checkseq[i], seq[i] );
1136 gappick0( seq[i], mseq1[0] );
1137 fprintf( stderr, "checking seq%d\n", i );
1139 // fprintf( stderr, " seq=%s\n", seq[i] );
1140 // fprintf( stderr, "checkseq=%s\n", checkseq[i] );
1142 if( strcmp( checkseq[i], seq[i] ) )
1144 fprintf( stderr, "\n\nWARNING: Sequence changed!!\n" );
1145 fprintf( stderr, "i=%d\n", i );
1146 fprintf( stderr, " seq=%s\n", seq[i] );
1147 fprintf( stderr, "checkseq=%s\n", checkseq[i] );
1151 if( alreadyoutput[j] == 0 )
1153 alreadyoutput[j] = 1;
1154 gappick0( seq[j], mseq2[0] );
1155 fprintf( stdout, ">%d_%s-%s\n%s\n", j+1, strfiles[j], chainids[j], seq[j] );
1156 strcpy( checkseq[j], seq[j] );
1160 gappick0( seq[j], mseq2[0] );
1161 fprintf( stderr, "checking seq%d\n", j );
1162 if( strcmp( checkseq[j], seq[j] ) )
1164 fprintf( stderr, "\n\nWARNING: Sequence changed!!\n" );
1165 fprintf( stderr, "j=%d\n", j );
1166 fprintf( stderr, " seq=%s\n", seq[j] );
1167 fprintf( stderr, "checkseq=%s\n", checkseq[j] );
1174 for( i=0; i<njob; i++ )
1177 for( pt=seq[i]; *pt; pt++ )
1178 pscore += amino_dis[(int)*pt][(int)*pt];
1179 distancemtx[i][i] = pscore;
1184 for( i=0; i<ilim; i++ )
1186 for( j=i+1; j<njob; j++ )
1188 bunbo = MIN( distancemtx[i][i], distancemtx[j][j] );
1190 distancemtx[i][j] = 2.0;
1192 distancemtx[i][j] = ( 1.0 - distancemtx[i][j] / bunbo ) * 2.0;
1196 hat2p = fopen( hat2file, "w" );
1197 if( !hat2p ) ErrorExit( "Cannot open hat2." );
1198 WriteHat2( hat2p, njob, name, distancemtx );
1201 fprintf( stderr, "##### writing hat3\n" );
1202 hat3p = fopen( "hat3", "w" );
1203 if( !hat3p ) ErrorExit( "Cannot open hat3." );
1205 for( i=0; i<ilim; i++ )
1207 for( j=i+1; j<njob; j++ )
1209 for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next )
1211 if( tmpptr->opt == -1.0 ) continue;
1212 fprintf( hat3p, "%d %d %d %7.5f %d %d %d %d k\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2 );
1218 fprintf( stderr, "calling FreeLocalHomTable\n" );
1220 FreeLocalHomTable( localhomtable, njob );
1222 fprintf( stderr, "done. FreeLocalHomTable\n" );
1226 static void WriteOptions( FILE *fp )
1229 if( dorp == 'd' ) fprintf( fp, "DNA\n" );
1232 if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN );
1233 else if( scoremtx == 1 ) fprintf( fp, "BLOSUM %d\n", nblosum );
1234 else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" );
1236 fprintf( stderr, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
1237 if( use_fft ) fprintf( fp, "FFT on\n" );
1239 fprintf( fp, "tree-base method\n" );
1240 if( tbrweight == 0 ) fprintf( fp, "unweighted\n" );
1241 else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" );
1242 if( tbitr || tbweight )
1244 fprintf( fp, "iterate at each step\n" );
1245 if( tbitr && tbrweight == 0 ) fprintf( fp, " unweighted\n" );
1246 if( tbitr && tbrweight == 3 ) fprintf( fp, " reversely weighted\n" );
1247 if( tbweight ) fprintf( fp, " weighted\n" );
1248 fprintf( fp, "\n" );
1251 fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
1254 fprintf( fp, "Algorithm A\n" );
1255 else if( alg == 'A' )
1256 fprintf( fp, "Algorithm A+\n" );
1257 else if( alg == 'S' )
1258 fprintf( fp, "Apgorithm S\n" );
1259 else if( alg == 'C' )
1260 fprintf( fp, "Apgorithm A+/C\n" );
1262 fprintf( fp, "Unknown algorithm\n" );
1266 fprintf( fp, "FFT on\n" );
1268 fprintf( fp, "Basis : 4 nucleotides\n" );
1272 fprintf( fp, "Basis : Polarity and Volume\n" );
1274 fprintf( fp, "Basis : 20 amino acids\n" );
1276 fprintf( fp, "Threshold of anchors = %d%%\n", fftThreshold );
1277 fprintf( fp, "window size of anchors = %dsites\n", fftWinSize );
1280 fprintf( fp, "FFT off\n" );
1285 int main( int argc, char *argv[] )
1288 static char name[M][B], **seq;
1289 static char **mseq1, **mseq2;
1293 static double *equiv;
1301 arguments( argc, argv );
1303 if( equivthreshold < 1 || 9 < equivthreshold )
1305 fprintf( stderr, "-t n, n must be 1..9\n" );
1309 if( ( equivwinsize + 1 ) % 2 != 0 )
1311 fprintf( stderr, "equivwinsize = %d\n", equivwinsize );
1312 fprintf( stderr, "It must be an odd number.\n" );
1318 infp = fopen( inputfile, "r" );
1321 fprintf( stderr, "Cannot open %s\n", inputfile );
1328 nlenmax = 10000; // tekitou
1331 prepareash( infp, &strfiles, &chainids, &seq, &mseq1, &mseq2, &equiv, &alloclen );
1332 else if( alg == 'T' )
1333 preparetmalign( infp, &strfiles, &chainids, &seq, &mseq1, &mseq2, &equiv, &alloclen );
1337 aseq = AllocateCharMtx( njob, nlenmax*2+1 );
1338 bseq = AllocateCharMtx( njob, nlenmax*2+1 );
1339 eff = AllocateDoubleVec( njob );
1341 for( i=0; i<njob; i++ )
1343 fprintf( stderr, "str%d = %s-%s\n", i, strfiles[i], chainids[i] );
1348 fprintf( stderr, "No structure found.\n" );
1353 fprintf( stderr, "Only %d structure found.\n", njob );
1358 fprintf( stderr, "The number of structures must be < %d\n", M );
1359 fprintf( stderr, "Please try sequence-based methods for such large data.\n" );
1366 readData( infp, name, nlen, seq );
1369 constants( njob, seq );
1372 fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
1379 WriteOptions( trap_g );
1381 c = seqcheck( seq );
1384 fprintf( stderr, "Illegal character %c\n", c );
1388 // writePre( njob, name, nlen, seq, 0 );
1390 for( i=0; i<njob; i++ ) eff[i] = 1.0;
1393 for( i=0; i<njob; i++ ) gappick0( bseq[i], seq[i] );
1395 pairalign( name, nlen, bseq, aseq, mseq1, mseq2, equiv, eff, strfiles, chainids, alloclen );
1397 fprintf( trap_g, "done.\n" );
1399 fprintf( stderr, "closing trap_g\n" );
1403 // writePre( njob, name, nlen, aseq, !contin );
1405 writeData( stdout, njob, name, nlen, aseq );
1408 fprintf( stderr, "OSHIMAI\n" );