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 fprintf( stderr, "\n" );
192 for( i=0; i<njob-1; i++ )
194 for( j=i+1; j<njob; j++ )
199 if( strlen( pseq[0] ) != strlen( pseq[1] ) )
201 fprintf( stderr, "## ERROR ###\n" );
202 fprintf( stderr, "Not aligned, %s - %s\n", name[i], name[j] );
203 fprintf( stderr, "## ERROR ###\n" );
208 fprintf( stderr, "adding %d-%d\r", i, j );
209 putlocalhom2( pseq[0], pseq[1], localhomtable[i]+j, 0, 0, (int)pscore, strlen( pseq[0] ) );
210 for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next )
212 if( tmpptr->opt == -1.0 ) continue;
213 if( tmpptr->start1 == -1 ) continue;
214 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 );
218 fprintf( stderr, "\n" );
222 fprintf( stderr, "calling FreeLocalHomTable\n" );
224 FreeLocalHomTable( localhomtable, njob );
226 fprintf( stderr, "done. FreeLocalHomTable\n" );
230 static void WriteOptions( FILE *fp )
233 if( dorp == 'd' ) fprintf( fp, "DNA\n" );
236 if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN );
237 else if( scoremtx == 1 ) fprintf( fp, "BLOSUM %d\n", nblosum );
238 else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" );
240 fprintf( stderr, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
241 if( use_fft ) fprintf( fp, "FFT on\n" );
243 fprintf( fp, "tree-base method\n" );
244 if( tbrweight == 0 ) fprintf( fp, "unweighted\n" );
245 else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" );
246 if( tbitr || tbweight )
248 fprintf( fp, "iterate at each step\n" );
249 if( tbitr && tbrweight == 0 ) fprintf( fp, " unweighted\n" );
250 if( tbitr && tbrweight == 3 ) fprintf( fp, " reversely weighted\n" );
251 if( tbweight ) fprintf( fp, " weighted\n" );
255 fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
258 fprintf( fp, "Algorithm A\n" );
259 else if( alg == 'A' )
260 fprintf( fp, "Algorithm A+\n" );
261 else if( alg == 'S' )
262 fprintf( fp, "Apgorithm S\n" );
263 else if( alg == 'C' )
264 fprintf( fp, "Apgorithm A+/C\n" );
266 fprintf( fp, "Unknown algorithm\n" );
268 if( treemethod == 'x' )
269 fprintf( fp, "Tree = UPGMA (3).\n" );
270 else if( treemethod == 's' )
271 fprintf( fp, "Tree = UPGMA (2).\n" );
272 else if( treemethod == 'p' )
273 fprintf( fp, "Tree = UPGMA (1).\n" );
275 fprintf( fp, "Unknown tree.\n" );
279 fprintf( fp, "FFT on\n" );
281 fprintf( fp, "Basis : 4 nucleotides\n" );
285 fprintf( fp, "Basis : Polarity and Volume\n" );
287 fprintf( fp, "Basis : 20 amino acids\n" );
289 fprintf( fp, "Threshold of anchors = %d%%\n", fftThreshold );
290 fprintf( fp, "window size of anchors = %dsites\n", fftWinSize );
293 fprintf( fp, "FFT off\n" );
298 int main( int argc, char *argv[] )
301 static char name[M][B], **seq;
309 arguments( argc, argv );
313 infp = fopen( inputfile, "r" );
316 fprintf( stderr, "Cannot open %s\n", inputfile );
328 fprintf( stderr, "At least 2 sequences should be input!\n"
329 "Only %d sequence found.\n", njob );
333 seq = AllocateCharMtx( njob, nlenmax*9+1 );
334 bseq = AllocateCharMtx( njob, nlenmax*9+1 );
335 alloclen = nlenmax*9;
337 eff = AllocateDoubleVec( njob );
340 Read( name, nlen, seq );
342 readData( infp, name, nlen, seq );
346 constants( njob, seq );
349 fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
356 WriteOptions( trap_g );
361 fprintf( stderr, "Illeagal character %c\n", c );
365 // writePre( njob, name, nlen, seq, 0 );
367 for( i=0; i<njob; i++ ) eff[i] = 1.0;
370 for( i=0; i<njob; i++ ) gappick0( bseq[i], seq[i] );
373 for( i=0; i<njob; i++ ) fprintf( stdout, ">_seed_%s\n%s\n", name[i]+1, bseq[i] );
375 pairalign( name, nlen, seq, eff, alloclen );
377 fprintf( trap_g, "done.\n" );
379 fprintf( stderr, "closing trap_g\n" );
384 fprintf( stderr, "OSHIMAI\n" );