6 #define TSUYOSAFACTOR 100
10 static int seedoffset;
16 if( *pt == '\n' ) *pt = 0;
20 void arguments( int argc, char *argv[] )
59 ppenalty = NOTSPECIFIED;
60 ppenalty_OP = NOTSPECIFIED;
61 ppenalty_ex = NOTSPECIFIED;
62 ppenalty_EX = NOTSPECIFIED;
63 poffset = NOTSPECIFIED;
64 kimuraR = NOTSPECIFIED;
67 fftWinSize = NOTSPECIFIED;
68 fftThreshold = NOTSPECIFIED;
70 while( --argc > 0 && (*++argv)[0] == '-' )
72 while ( ( c = *++argv[0] ) )
78 fprintf( stderr, "seed = %s\n", inputfile );
82 nhomologs = atoi( *++argv );
83 fprintf( stderr, "nhomologs = %d\n", nhomologs );
87 seedoffset = atoi( *++argv );
88 fprintf( stderr, "seedoffset = %d\n", seedoffset );
98 fprintf( stderr, "illegal option %c\n", c );
108 cut = atof( (*argv) );
113 fprintf( stderr, "options: Check source file !\n" );
116 if( tbitr == 1 && outgap == 0 )
118 fprintf( stderr, "conflicting options : o, m or u\n" );
121 if( alg == 'C' && outgap == 0 )
123 fprintf( stderr, "conflicting options : C, o\n" );
128 int countamino( char *s, int end )
132 if( *s++ != '-' ) val++;
136 static void pairalign( char name[M][B], int nlen[M], char **seq, double *effarr, int alloclen )
140 float pscore = 0.0; // by D.Mathog
141 static double *effarr1 = NULL;
142 static double *effarr2 = NULL;
145 LocalHom **localhomtable, *tmpptr;
148 if( nhomologs < 1 ) nhomologs = 1; // tsuyosa=0.0 wo sakeru
149 tsuyosa = (double)nhomologs * nhomologs * TSUYOSAFACTOR;
150 fprintf( stderr, "tsuyosa = %f\n", tsuyosa );
151 localhomtable = (LocalHom **)calloc( njob, sizeof( LocalHom *) );
152 for( i=0; i<njob; i++)
154 localhomtable[i] = (LocalHom *)calloc( njob, sizeof( LocalHom ) );
155 for( j=0; j<njob; j++)
157 localhomtable[i][j].start1 = -1;
158 localhomtable[i][j].end1 = -1;
159 localhomtable[i][j].start2 = -1;
160 localhomtable[i][j].end2 = -1;
161 localhomtable[i][j].opt = -1.0;
162 localhomtable[i][j].next = NULL;
166 if( effarr1 == NULL )
168 effarr1 = AllocateDoubleVec( njob );
169 effarr2 = AllocateDoubleVec( njob );
170 pseq = AllocateCharMtx( 2, 0 );
171 aseq = AllocateCharVec( nlenmax*9+1 );
178 fprintf( stderr, "##### fftwinsize = %d, fftthreshold = %d\n", fftWinSize, fftThreshold );
182 for( i=0; i<njob; i++ )
183 fprintf( stderr, "TBFAST effarr[%d] = %f\n", i, effarr[i] );
187 // writePre( njob, name, nlen, aseq, 0 );
189 hat3p = fopen( "hat3", "w" );
190 if( !hat3p ) ErrorExit( "Cannot open hat3." );
191 for( i=0; i<njob-1; i++ )
193 for( j=i+1; j<njob; j++ )
198 if( strlen( pseq[0] ) != strlen( pseq[1] ) )
200 fprintf( stderr, "## ERROR ###\n" );
201 fprintf( stderr, "Not aligned, %s - %s\n", name[i], name[j] );
202 fprintf( stderr, "## ERROR ###\n" );
207 fprintf( stderr, "adding %d-%d\n", i, j );
208 putlocalhom2( pseq[0], pseq[1], localhomtable[i]+j, 0, 0, (int)pscore, strlen( pseq[0] ) );
209 for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next )
211 if( tmpptr->opt == -1.0 ) continue;
212 if( tmpptr->start1 == -1 ) continue;
213 fprintf( hat3p, "%d %d %d %6.3f %d %d %d %d k\n", i+seedoffset, j+seedoffset, tmpptr->overlapaa, tmpptr->opt * tsuyosa, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2 );
220 fprintf( stderr, "calling FreeLocalHomTable\n" );
222 FreeLocalHomTable( localhomtable, njob );
224 fprintf( stderr, "done. FreeLocalHomTable\n" );
228 static void WriteOptions( FILE *fp )
231 if( dorp == 'd' ) fprintf( fp, "DNA\n" );
234 if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN );
235 else if( scoremtx == 1 ) fprintf( fp, "BLOSUM %d\n", nblosum );
236 else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" );
238 fprintf( stderr, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
239 if( use_fft ) fprintf( fp, "FFT on\n" );
241 fprintf( fp, "tree-base method\n" );
242 if( tbrweight == 0 ) fprintf( fp, "unweighted\n" );
243 else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" );
244 if( tbitr || tbweight )
246 fprintf( fp, "iterate at each step\n" );
247 if( tbitr && tbrweight == 0 ) fprintf( fp, " unweighted\n" );
248 if( tbitr && tbrweight == 3 ) fprintf( fp, " reversely weighted\n" );
249 if( tbweight ) fprintf( fp, " weighted\n" );
253 fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
256 fprintf( fp, "Algorithm A\n" );
257 else if( alg == 'A' )
258 fprintf( fp, "Algorithm A+\n" );
259 else if( alg == 'S' )
260 fprintf( fp, "Apgorithm S\n" );
261 else if( alg == 'C' )
262 fprintf( fp, "Apgorithm A+/C\n" );
264 fprintf( fp, "Unknown algorithm\n" );
266 if( treemethod == 'x' )
267 fprintf( fp, "Tree = UPGMA (3).\n" );
268 else if( treemethod == 's' )
269 fprintf( fp, "Tree = UPGMA (2).\n" );
270 else if( treemethod == 'p' )
271 fprintf( fp, "Tree = UPGMA (1).\n" );
273 fprintf( fp, "Unknown tree.\n" );
277 fprintf( fp, "FFT on\n" );
279 fprintf( fp, "Basis : 4 nucleotides\n" );
283 fprintf( fp, "Basis : Polarity and Volume\n" );
285 fprintf( fp, "Basis : 20 amino acids\n" );
287 fprintf( fp, "Threshold of anchors = %d%%\n", fftThreshold );
288 fprintf( fp, "window size of anchors = %dsites\n", fftWinSize );
291 fprintf( fp, "FFT off\n" );
296 int main( int argc, char *argv[] )
299 static char name[M][B], **seq;
307 arguments( argc, argv );
311 infp = fopen( inputfile, "r" );
314 fprintf( stderr, "Cannot open %s\n", inputfile );
326 fprintf( stderr, "At least 2 sequences should be input!\n"
327 "Only %d sequence found.\n", njob );
331 seq = AllocateCharMtx( njob, nlenmax*9+1 );
332 bseq = AllocateCharMtx( njob, nlenmax*9+1 );
333 alloclen = nlenmax*9;
335 eff = AllocateDoubleVec( njob );
338 Read( name, nlen, seq );
340 readData( infp, name, nlen, seq );
344 constants( njob, seq );
347 fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
354 WriteOptions( trap_g );
359 fprintf( stderr, "Illeagal character %c\n", c );
363 // writePre( njob, name, nlen, seq, 0 );
365 for( i=0; i<njob; i++ ) eff[i] = 1.0;
368 for( i=0; i<njob; i++ ) gappick0( bseq[i], seq[i] );
371 for( i=0; i<njob; i++ ) fprintf( stdout, ">_seed_%s\n%s\n", name[i]+1, bseq[i] );
373 pairalign( name, nlen, seq, eff, alloclen );
375 fprintf( trap_g, "done.\n" );
377 fprintf( stderr, "closing trap_g\n" );
382 fprintf( stderr, "OSHIMAI\n" );