6 void arguments( int argc, char *argv[] )
33 ppenalty = NOTSPECIFIED;
34 ppenalty_ex = NOTSPECIFIED;
35 poffset = NOTSPECIFIED;
36 kimuraR = NOTSPECIFIED;
39 scoremtx = NOTSPECIFIED;
41 while( --argc > 0 && (*++argv)[0] == '-' )
43 while ( (c = *++argv[0]) )
48 ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
49 fprintf( stderr, "ppenalty = %d\n", ppenalty );
53 ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
54 fprintf( stderr, "ppenalty_ex = %d\n", ppenalty_ex );
58 poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
59 fprintf( stderr, "poffset = %d\n", poffset );
116 /* Modified 01/08/27, default: user tree */
120 /* modification end. */
125 fprintf( stderr, "illegal option %c\n", c );
135 cut = atof( (*argv) );
140 fprintf( stderr, "options: Check source file !\n" );
143 if( tbitr == 1 && outgap == 0 )
145 fprintf( stderr, "conflicting options : o, m or u\n" );
148 if( alg == 'C' && outgap == 0 )
150 fprintf( stderr, "conflicting options : C, o\n" );
153 readOtherOptions( &ppid, &fftThreshold, &fftWinSize );
157 void treebase( char **name, int nlen[M], char **seq, char **aseq, char **mseq1, char **mseq2, double **mtx, int ***topol, double **len, double **eff, int alloclen )
163 static char *indication1, *indication2;
164 static char **name1, **name2;
165 static double **partialmtx = NULL;
166 static int ***partialtopol = NULL;
167 static double **partiallen = NULL;
168 static double **partialeff = NULL;
169 static double *effarr = NULL;
170 static double *effarr1 = NULL;
171 static double *effarr2 = NULL;
173 char pair[njob][njob];
177 if( partialtopol == NULL )
179 partialmtx = AllocateDoubleMtx( njob, njob );
180 partialtopol = AllocateIntCub( njob, 2, njob );
181 partialeff = AllocateDoubleMtx( njob, njob );
182 partiallen = AllocateDoubleMtx( njob, 2 );
183 effarr = AllocateDoubleVec( njob );
184 effarr1 = AllocateDoubleVec( njob );
185 effarr2 = AllocateDoubleVec( njob );
186 indication1 = AllocateCharVec( njob*3+100 );
187 indication2 = AllocateCharVec( njob*3+100 );
188 name1 = AllocateCharMtx( njob, B+1 );
189 name2 = AllocateCharMtx( njob, B+1 );
192 pair = AllocateCharMtx( njob, njob );
197 for( i=0; i<njob; i++ ) fprintf( stderr, "eff in tb-%d %f\n", i, eff[i][i] );
199 for( i=0; i<njob; i++ ) effarr[i] = eff[i][i];
200 for( i=0; i<njob; i++ ) strcpy( aseq[i], seq[i] );
203 for( i=0; i<njob; i++ ) fprintf( stderr, "effarr for aseq-%d %f\n", i, effarr[i] );
205 writePre( njob, name, nlen, aseq, 0 );
207 for( i=0; i<njob; i++ ) for( j=0; j<njob; j++ ) pair[i][j] = 0;
208 for( i=0; i<njob; i++ ) pair[i][i] = 1;
209 for( l=0; l<njob-1; l++ )
212 for( i=0; (r1=topol[l][0][i])>-1; i++ )
213 if( pair[s1][r1] != 1 ) exit( 1 );
215 for( i=0; (r2=topol[l][1][i])>-1; i++ )
216 if( pair[s2][r2] != 1 ) exit( 1 );
218 clus1 = conjuction( pair, s1, aseq, mseq1, effarr1, effarr, name, name1, indication1 );
219 clus2 = conjuction( pair, s2, aseq, mseq2, effarr2, effarr, name, name2, indication2 );
220 fprintf( trap_g, "\nSTEP-%d\n", l );
221 fprintf( trap_g, "group1 = %s\n", indication1 );
222 fprintf( trap_g, "group2 = %s\n", indication2 );
224 fprintf( stderr, "STEP %d /%d\n", l+1, njob-1 );
225 fprintf( stderr, "group1 = %.66s", indication1 );
226 if( strlen( indication1 ) > 66 ) fprintf( stderr, "..." );
227 fprintf( stderr, "\n" );
228 fprintf( stderr, "group2 = %.66s", indication2 );
229 if( strlen( indication2 ) > 66 ) fprintf( stderr, "..." );
230 fprintf( stderr, "\n" );
233 for( i=0; i<clus1; i++ ) fprintf( stderr, "STEP%d-eff for mseq1-%d %f\n", l+1, i, effarr1[i] );
235 fprintf( stderr, "before align all\n" );
236 display( aseq, njob );
237 fprintf( stderr, "\n" );
238 fprintf( stderr, "before align 1 %s \n", indication1 );
239 display( mseq1, clus1 );
240 fprintf( stderr, "\n" );
241 fprintf( stderr, "before align 2 %s \n", indication2 );
242 display( mseq2, clus2 );
243 fprintf( stderr, "\n" );
246 pscore = Fgetlag( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen );
248 for( i=0; (r2=topol[l][1][i])>-1; i++ )
254 writePre( njob, name, nlen, aseq, 0 );
256 if( disp ) display( aseq, njob );
257 fprintf( stderr, "\n" );
262 static void WriteOptions( FILE *fp )
264 fprintf( fp, "tree-base method\n" );
265 if( tbrweight == 0 ) fprintf( fp, "unweighted\n" );
266 else if( tbrweight == 3 ) fprintf( fp, "clustalw-like weighting\n" );
267 if( tbitr || tbweight )
269 fprintf( fp, "iterate at each step\n" );
270 if( tbitr && tbrweight == 0 ) fprintf( fp, " unweighted\n" );
271 if( tbitr && tbrweight == 3 ) fprintf( fp, " reversely weighted\n" );
272 if( tbweight ) fprintf( fp, " weighted\n" );
275 if ( scoremtx == 0 ) fprintf( fp, "JTT %dPAM\n", pamN );
276 else if( scoremtx == 1 ) fprintf( fp, "Dayhoff( machigai ga aru )\n" );
277 else if( scoremtx == 2 ) fprintf( fp, "M-Y\n" );
278 else if( scoremtx == -1 ) fprintf( fp, "DNA\n" );
280 if( scoremtx == 0 || scoremtx == -1 )
281 fprintf( fp, "Gap Penalty = %+5.2f, %+5.2f, %+5.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
283 fprintf( fp, "Gap Penalty = %+5.2f\n", (double)ppenalty/1000 );
286 fprintf( fp, "Algorithm A\n" );
287 else if( alg == 'A' )
288 fprintf( fp, "Apgorithm A+\n" );
289 else if( alg == 'S' )
290 fprintf( fp, "Apgorithm S\n" );
291 else if( alg == 'C' )
292 fprintf( fp, "Apgorithm A+/C\n" );
294 fprintf( fp, "Unknown algorithm\n" );
296 if( treemethod == 'x' )
297 fprintf( fp, "Tree = UPGMA (3).\n" );
298 else if( treemethod == 's' )
299 fprintf( fp, "Tree = UPGMA (2).\n" );
300 else if( treemethod == 'p' )
301 fprintf( fp, "Tree = UPGMA (1).\n" );
303 fprintf( fp, "Unknown tree.\n" );
307 fprintf( fp, "FFT on\n" );
309 fprintf( fp, "Basis : 4 nucleotides\n" );
313 fprintf( fp, "Basis : Polarity and Volume\n" );
315 fprintf( fp, "Basis : 20 amino acids\n" );
317 fprintf( fp, "Threshold of anchors = %d%%\n", fftThreshold );
318 fprintf( fp, "window size of anchors = %dsites\n", fftWinSize );
321 fprintf( fp, "FFT off\n" );
326 int main( int argc, char *argv[] )
329 static char **name, **seq;
330 static char **mseq1, **mseq2;
333 static double **pscore;
335 static double **node0, **node1;
343 arguments( argc, argv );
347 name = AllocateCharMtx( njob, B+1 );
348 seq = AllocateCharMtx( njob, nlenmax*5+1 );
349 aseq = AllocateCharMtx( njob, nlenmax*5+1 );
350 bseq = AllocateCharMtx( njob, nlenmax*5+1 );
351 mseq1 = AllocateCharMtx( njob, 0 );
352 mseq2 = AllocateCharMtx( njob, 0 );
353 alloclen = nlenmax*5;
355 topol = AllocateIntCub( njob, 2, njob );
356 len = AllocateDoubleMtx( njob, 2 );
357 pscore = AllocateDoubleMtx( njob, njob );
358 eff = AllocateDoubleMtx( njob, njob );
359 node0 = AllocateDoubleMtx( njob, njob );
360 node1 = AllocateDoubleMtx( njob, njob );
363 Read( name, nlen, seq );
365 readData_pointer( stdin, name, nlen, seq );
368 constants( njob, seq );
371 fprintf( stderr, "params = %d, %d, %d\n", penalty, penalty_ex, offset );
378 WriteOptions( trap_g );
383 fprintf( stderr, "Illeagal character %c\n", c );
387 writePre( njob, name, nlen, seq, 0 );
391 for( i=1; i<njob; i++ )
393 if( nlen[i] != nlen[0] )
395 fprintf( stderr, "Input pre-aligned seqences or make hat2.\n" );
399 for( i=0; i<njob-1; i++ ) for( j=i+1; j<njob; j++ )
402 pscore[i][j] = (double)score_calc1( seq[i], seq[j] );
404 pscore[i][j] = (double)substitution_hosei( seq[i], seq[j] );
409 fprintf( stderr, "Loading 'hat2' ... " );
410 prep = fopen( "hat2", "r" );
411 if( prep == NULL ) ErrorExit( "Make hat2." );
412 readhat2_pointer( prep, njob, name, pscore );
414 fprintf( stderr, "done.\n" );
417 prep = fopen( "hat2_check", "w" );
418 WriteHat2( prep, njob, name, pscore );
424 fprintf( stderr, "Constructing dendrogram ... " );
425 if( treemethod == 'x' )
426 supg( njob, pscore, topol, len );
427 else if( treemethod == 's' )
428 spg( njob, pscore, topol, len );
429 else if( treemethod == 'p' )
430 upg2( njob, pscore, topol, len );
432 ErrorExit( "Incorrect tree\n" );
433 fprintf( stderr, "done.\n" );
435 countnode( njob, topol, node0 );
439 utree = 0; counteff( njob, topol, len, eff ); utree = 1;
443 for( i=0; i<njob; i++ ) eff[i][i] = 1.0;
447 for( i=0; i<njob; i++ ) gappick0( bseq[i], seq[i] );
449 treebase( name, nlen, bseq, aseq, mseq1, mseq2, pscore, topol, len, eff, alloclen );
451 fprintf( trap_g, "done\n" );
454 writePre( njob, name, nlen, aseq, !contin );
455 writeData_pointer( stdout, njob, name, nlen, aseq );
457 fprintf( stderr, "OSHIMAI\n" );