static void pairalign( char name[M][B], int nlen[M], char **seq, char **aseq, char **mseq1, char **mseq2, double *effarr, int alloclen ) { int i, j, ilim; int clus1, clus2; int off1, off2; float pscore = 0.0; // by D.Mathog static char *indication1, *indication2; FILE *hat2p, *hat3p; static double **distancemtx; static double *effarr1 = NULL; static double *effarr2 = NULL; char *pt; char *hat2file = "hat2"; LocalHom **localhomtable, *tmpptr; static char **pair; int intdum; double bunbo; localhomtable = (LocalHom **)calloc( njob, sizeof( LocalHom *) ); for( i=0; i<njob; i++) { localhomtable[i] = (LocalHom *)calloc( njob, sizeof( LocalHom ) ); for( j=0; j<njob; j++) { localhomtable[i][j].start1 = -1; localhomtable[i][j].end1 = -1; localhomtable[i][j].start2 = -1; localhomtable[i][j].end2 = -1; localhomtable[i][j].opt = -1.0; localhomtable[i][j].next = NULL; localhomtable[i][j].nokori = 0; } } if( effarr1 == NULL ) { distancemtx = AllocateDoubleMtx( njob, njob ); effarr1 = AllocateDoubleVec( njob ); effarr2 = AllocateDoubleVec( njob ); indication1 = AllocateCharVec( 150 ); indication2 = AllocateCharVec( 150 ); #if 0 #else pair = AllocateCharMtx( njob, njob ); #endif } #if 0 fprintf( stderr, "##### fftwinsize = %d, fftthreshold = %d\n", fftWinSize, fftThreshold ); #endif #if 0 for( i=0; i<njob; i++ ) fprintf( stderr, "TBFAST effarr[%d] = %f\n", i, effarr[i] ); #endif // writePre( njob, name, nlen, aseq, 0 ); for( i=0; i<njob; i++ ) for( j=0; j<njob; j++ ) pair[i][j] = 0; for( i=0; i<njob; i++ ) pair[i][i] = 1; if( alg == 'H' ) { fprintf( stderr, "Calling FOLDALIGN with option '%s'\n", foldalignopt ); callfoldalign( njob, seq ); fprintf( stderr, "done.\n" ); } if( alg == 'B' ) { fprintf( stderr, "Calling LARA\n" ); calllara( njob, seq, "" ); fprintf( stderr, "done.\n" ); } if( alg == 'T' ) { fprintf( stderr, "Calling SLARA\n" ); calllara( njob, seq, "-s" ); fprintf( stderr, "done.\n" ); } ilim = njob - 1; for( i=0; i<ilim; i++ ) { fprintf( stderr, "% 5d / %d\r", i, njob ); for( j=i+1; j<njob; j++ ) { if( strlen( seq[i] ) == 0 || strlen( seq[j] ) == 0 ) { distancemtx[i][j] = pscore; continue; } strcpy( aseq[i], seq[i] ); strcpy( aseq[j], seq[j] ); clus1 = conjuctionfortbfast( pair, i, aseq, mseq1, effarr1, effarr, indication1 ); clus2 = conjuctionfortbfast( pair, j, aseq, mseq2, effarr2, effarr, indication2 ); // fprintf( stderr, "mseq1 = %s\n", mseq1[0] ); // fprintf( stderr, "mseq2 = %s\n", mseq2[0] ); #if 0 fprintf( stderr, "group1 = %.66s", indication1 ); fprintf( stderr, "\n" ); fprintf( stderr, "group2 = %.66s", indication2 ); fprintf( stderr, "\n" ); #endif // for( l=0; l<clus1; l++ ) fprintf( stderr, "## STEP-eff for mseq1-%d %f\n", l, effarr1[l] ); #if 1 if( use_fft ) { pscore = Falign( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, &intdum, NULL, 0, NULL ); off1 = off2 = 0; } else #endif { switch( alg ) { case( 'a' ): pscore = Aalign( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen ); off1 = off2 = 0; break; case( 'A' ): pscore = G__align11( mseq1, mseq2, alloclen, NULL, 0, NULL ); off1 = off2 = 0; break; #if 0 case( 'V' ): pscore = VAalign11( mseq1, mseq2, alloclen, &off1, &off2, localhomtable[i]+j ); fprintf( stderr, "i,j = %d,%d, score = %f\n", i,j, pscore ); break; case( 'S' ): fprintf( stderr, "aligning %d-%d\n", i, j ); pscore = suboptalign11( mseq1, mseq2, alloclen, &off1, &off2, localhomtable[i]+j ); fprintf( stderr, "i,j = %d,%d, score = %f\n", i,j, pscore ); break; #endif case( 'N' ): pscore = genL__align11( mseq1, mseq2, alloclen, &off1, &off2 ); // fprintf( stderr, "pscore = %f\n", pscore ); break; case( 'L' ): pscore = L__align11( mseq1, mseq2, alloclen, &off1, &off2 ); // fprintf( stderr, "pscore (1) = %f\n", pscore ); // pscore = (float)naivepairscore11( *mseq1, *mseq2, penalty ); // nennnotame // fprintf( stderr, "pscore (2) = %f\n\n", pscore ); break; case( 'H' ): pscore = recallpairfoldalign( mseq1, mseq2, i, j, &off1, &off2, alloclen ); break; case( 'B' ): case( 'T' ): pscore = recalllara( mseq1, mseq2, alloclen ); off1 = off2 = 0; // fprintf( stderr, "lara, pscore = %f\n", pscore ); break; case( 's' ): pscore = callmxscarna( mseq1, mseq2, alloclen ); off1 = off2 = 0; // fprintf( stderr, "scarna, pscore = %f\n", pscore ); break; case( 'M' ): // pscore = MSalign11( mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, NULL, NULL, NULL, NULL ); pscore = MSalign11( mseq1, mseq2, alloclen ); // fprintf( stderr, "pscore = %f\n", pscore ); break; ErrorExit( "ERROR IN SOURCE FILE" ); } } distancemtx[i][j] = pscore; #if SCOREOUT fprintf( stderr, "score = %10.2f (%d,%d)\n", pscore, i, j ); #endif // fprintf( stderr, "pslocal = %d\n", pslocal ); // offset = makelocal( *mseq1, *mseq2, pslocal ); #if 0 fprintf( stderr, "off1 = %d, off2 = %d\n", off1, off2 ); fprintf( stderr, ">%d\n%s\n>%d\n%s\n>\n", i, mseq1[0], j, mseq2[0] ); #endif // putlocalhom2( mseq1[0], mseq2[0], localhomtable[i]+j, countamino( *mseq1, off1 ), countamino( *mseq2, off2 ), pscore, strlen( mseq1[0] ) ); // fprintf( stderr, "pscore = %f\n", pscore ); if( alg == 'H' ) // if( alg == 'H' || alg == 's' || alg == 'B' ) // next version putlocalhom_ext( mseq1[0], mseq2[0], localhomtable[i]+j, off1, off2, (int)pscore, strlen( mseq1[0] ) ); else if( alg != 'S' && alg != 'V' ) putlocalhom2( mseq1[0], mseq2[0], localhomtable[i]+j, off1, off2, (int)pscore, strlen( mseq1[0] ) ); } } for( i=0; i<njob; i++ ) { pscore = 0.0; for( pt=seq[i]; *pt; pt++ ) pscore += amino_dis[(int)*pt][(int)*pt]; distancemtx[i][i] = pscore; } ilim = njob-1; for( i=0; i<ilim; i++ ) { for( j=i+1; j<njob; j++ ) { bunbo = MIN( distancemtx[i][i], distancemtx[j][j] ); if( bunbo == 0.0 ) distancemtx[i][j] = 2.0; else distancemtx[i][j] = ( 1.0 - distancemtx[i][j] / bunbo ) * 2.0; } } hat2p = fopen( hat2file, "w" ); if( !hat2p ) ErrorExit( "Cannot open hat2." ); WriteHat2( hat2p, njob, name, distancemtx ); fclose( hat2p ); fprintf( stderr, "##### writing hat3\n" ); hat3p = fopen( "hat3", "w" ); if( !hat3p ) ErrorExit( "Cannot open hat3." ); ilim = njob-1; for( i=0; i<ilim; i++ ) { for( j=i+1; j<njob; j++ ) { for( tmpptr=localhomtable[i]+j; tmpptr; tmpptr=tmpptr->next ) { if( tmpptr->opt == -1.0 ) continue; fprintf( hat3p, "%d %d %d %7.5f %d %d %d %d %p\n", i, j, tmpptr->overlapaa, tmpptr->opt, tmpptr->start1, tmpptr->end1, tmpptr->start2, tmpptr->end2, (void *)tmpptr->next ); } } } fclose( hat3p ); #if DEBUG fprintf( stderr, "calling FreeLocalHomTable\n" ); #endif FreeLocalHomTable( localhomtable, njob ); #if DEBUG fprintf( stderr, "done. FreeLocalHomTable\n" ); #endif }
void GroupAlign( int nseq1, int nseq2, char **name, int *nlen, char **seq, char **aseq, char **mseq1, char **mseq2, int ***topol, double **len, double *eff, int alloclen ) { int i; int clus1, clus2; int s1, s2; float pscore; static char **name1, **name2; double *effarr = eff; double *effarr1 = NULL; double *effarr2 = NULL; static char *indication1, *indication2; float dumfl = 0.0; int intdum; #if DEBUG double time1, time2; #endif // fprintf( stderr, "in GroupAlign fftWinSize = %d\n", fftWinSize ); // fprintf( stderr, "in GroupAlign fftThreshold = %d\n", fftThreshold ); if( effarr1 == NULL ) { name1 = AllocateCharMtx( nseq1, B ); name2 = AllocateCharMtx( nseq2, B ); indication1 = AllocateCharVec( 150 ); indication2 = AllocateCharVec( 150 ); effarr1 = AllocateDoubleVec( njob ); effarr2 = AllocateDoubleVec( njob ); #if 0 #else #endif } for( i=0; i<njob; i++ ) strcpy( aseq[i], seq[i] ); s1 = 0; s2 = nseq1; // fprintf( stdout, "nseq1 = %d\n", nseq1 ); clus1 = conjuctionforgaln( 0, nseq1, aseq, mseq1, effarr1, effarr, name, name1, indication1 ); clus2 = conjuctionforgaln( nseq1, njob, aseq, mseq2, effarr2, effarr, name, name2, indication2 ); /* fprintf( stderr, "before align all\n" ); display( aseq, njob ); fprintf( stderr, "\n" ); fprintf( stderr, "before align 1 %s \n", indication1 ); display( mseq1, clus1 ); fprintf( stderr, "\n" ); fprintf( stderr, "before align 2 %s \n", indication2 ); display( mseq2, clus2 ); fprintf( stderr, "\n" ); */ commongappick( nseq1, mseq1 ); commongappick( nseq2, mseq2 ); #if DEBUG time1 = getrusage_sec(); fprintf( stderr, "entering Falign\n" ); #endif if( use_fft ) { if( alg == 'M' ) pscore = Falign_udpari_long( NULL, NULL, n_dis_consweight_multi, mseq1, mseq2, effarr1, effarr2, NULL, NULL, clus1, clus2, alloclen, &intdum ); else pscore = Falign( NULL, NULL, n_dis_consweight_multi, mseq1, mseq2, effarr1, effarr2, NULL, NULL, clus1, clus2, alloclen, &intdum, NULL, 0, NULL ); } else { if( alg == 'M' ) pscore = MSalignmm( n_dis_consweight_multi, mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, NULL, NULL, NULL, NULL, NULL, 0, NULL, outgap, outgap ); else pscore = A__align( n_dis_consweight_multi, mseq1, mseq2, effarr1, effarr2, clus1, clus2, alloclen, NULL, &dumfl, NULL, NULL, NULL, NULL, NULL, 0, NULL, outgap, outgap ); } #if DEBUG time2 = getrusage_sec(); fprintf( stdout, "### %d - %d, %f\n", clus1, clus2, time2-time1 ); fflush( stdout ); #endif /* fprintf( stderr, "after align 1 %s \n", indication1 ); display( mseq1, clus1 ); fprintf( stderr, "\n" ); fprintf( stderr, "after align 2 %s \n", indication2 ); display( mseq2, clus2 ); fprintf( stderr, "\n" ); */ fprintf( stderr, "group-to-group %s /%s %f\n", indication1, indication2, pscore ); if( disp ) display( aseq, njob ); fprintf( stderr, "\n" ); /* trap = fopen( "pre", "r+" ); if( !trap ) ErrorExit( 1 ); WriteGapFill( trap, njob, name, nlen, aseq ); fclose( trap ); fprintf( stdout, "nseq1 = %d\n", nseq1 ); */ }