#include "mltaln.h" #define DEBUG 0 #define USEDISTONTREE 1 #if 0 void mdfymtx( char pair[njob][njob], int s1, double **partialmtx, double **mtx ) #else void mdfymtx( char **pair, int s1, double **partialmtx, double **mtx ) #endif { int i, j; int icount, jcount; #if DEBUG FILE *fp; static char name[M][B]; for( i=0; i len-2 ) break; continue; } if( mseq2[k] == '-' ) { tmpscore += penalty; while( mseq2[++k] == '-' ) ; k--; if( k > len-2 ) break; continue; } } /* if( mseq1[0] == '-' || mseq2[0] == '-' ) { for( k=0; k 3 ) code = 36; else code = code1; #else code1 = amino_n[(unsigned char)*seqpt]; code2 = amino_n[(unsigned char)*seqrpt]; if( code1 > 3 ) { code = 36; } else if( code2 > 3 ) { code = code1; } else if( *dirpt == '5' ) { code = 4 + code2 * 4 + code1; } else if( *dirpt == '3' ) { code = 20 + code2 * 4 + code1; } else // if( *dirpt == 'o' ) // nai { code = code1; } #endif // fprintf( stderr, "%c -> code=%d toa=%d, tog=%d, toc=%d, tot=%d, ton=%d, efee=%f\n", *seqpt, code%4, ribosumdis[code][4+0], ribosumdis[code][4+1], ribosumdis[code][4+2], ribosumdis[code][20+3], ribosumdis[code][36], feff ); seqpt++; seqrpt++; dirpt++; (*cpmxptpt++)[code] += feff; } } } void mseqcat( char **seq1, char **seq2, double **eff, double *effarr1, double *effarr2, char name1[M][B], char name2[M][B], int clus1, int clus2 ) { int i, j; for( i=0; i 0.0 ) peff_kozo[m] += peff[m]; } } else //iranai { for( m=0; m-1; j++ ) if( s1 == topol[step][branch][0] ) value++; for( j=0; (s2=topol[i][1][j])>-1; j++ ) if( s2 == topol[step][branch][0] ) value++; } return( value ); } void BranchLeafNode( int nseq, int ***topol, int *node, int step, int branch ) { int i, j, k, s; for( i=0; i-1; j++ ) node[s]++; for( k=0; k-1; j++ ) node[s]++; } void RootLeafNode( int nseq, int ***topol, int *node ) { int i, j, k, s; for( i=0; i-1; j++ ) node[s]++; } void nodeFromABranch( int nseq, int *result, int **pairwisenode, int ***topol, double **len, int step, int num ) { int i, s, count; int *innergroup; int *outergroup1; #if 0 int outergroup2[nseq]; int table[nseq]; #else static int *outergroup2 = NULL; static int *table = NULL; if( outergroup2 == NULL ) { outergroup2 = AllocateIntVec( nseq ); table = AllocateIntVec( nseq ); } #endif innergroup = topol[step][num]; outergroup1 = topol[step][!num]; for( i=0; i-1; i++ ) table[s] = 0; for( i=0; (s=outergroup1[i])>-1; i++ ) table[s] = 0; for( i=0, count=0; i-1; i++ ) { result[s] = pairwisenode[s][outergroup1[0]] + pairwisenode[s][outergroup2[0]] - pairwisenode[outergroup1[0]][outergroup2[0]] - 1; result[s] /= 2; } for( i=0; (s=outergroup1[i])>-1; i++ ) { result[s] = pairwisenode[s][outergroup2[0]] + pairwisenode[s][innergroup[0]] - pairwisenode[innergroup[0]][outergroup2[0]] + 1; result[s] /= 2; } for( i=0; (s=outergroup2[i])>-1; i++ ) { result[s] = pairwisenode[s][outergroup1[0]] + pairwisenode[s][innergroup[0]] - pairwisenode[innergroup[0]][outergroup1[0]] + 1; result[s] /= 2; } #if 0 for( i=0; i-1; i++ ) { pair[r1] = 1; memlist1[k++] = r1; } memlist1[k] = -1; for( i=0, k=0; i 10 && jm > 10 ) exit( 1 ); #endif } } void makeEffMtx( int nseq, double **mtx, double *vec ) { int i, j; for( i=0; i start2, end1 <-> end2 i2 = m1; if( localhom[t1][i2].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[t1]+i2; } } else { swaplist[k1] = 0; for( k2=0; (m2=memlist2[k2])!=-1; k2++ ) { t1 = targetmap[m1]; i2 = m2; if( localhom[t1][i2].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[t1]+i2; } } } return( 0 ); } int msshrinklocalhom_fast_half( int *memlist1, int *memlist2, LocalHom **localhom, LocalHom ***localhomshrink ) { int m1, k1, m2, k2; for( k1=0; (m1=memlist1[k1])!=-1; k1++ ) { for( k2=0; (m2=memlist2[k2])!=-1; k2++ ) { if( m1 < m2 ) { if( localhom[m1][m2-m1].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[m1]+m2-m1; } else { if( localhom[m2][m1-m2].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[m2]+m1-m2; } } } return( 0 ); } int msshrinklocalhom_fast( int *memlist1, int *memlist2, LocalHom **localhom, LocalHom ***localhomshrink ) { int m1, k1, m2, k2; for( k1=0; (m1=memlist1[k1])!=-1; k1++ ) { for( k2=0; (m2=memlist2[k2])!=-1; k2++ ) { if( localhom[m1][m2].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[m1]+m2; } } return( 0 ); } int fastshrinklocalhom_one( int *mem1, int *mem2, int norg, LocalHom **localhom, LocalHom ***localhomshrink ) { int k1, k2; int *intpt1, *intpt2; for( intpt1=mem1, k1=0; *intpt1!=-1; intpt1++, k1++ ) { for( intpt2=mem2, k2=0; *intpt2!=-1; intpt2++, k2++ ) { if( *intpt2 != norg ) { fprintf( stderr, "ERROR! *intpt2 = %d\n", *intpt2 ); exit( 1 ); } if( localhom[*intpt1][0].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[*intpt1]; } } return( 0 ); } int fastshrinklocalhom( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink ) { int k1, k2; int *intpt1, *intpt2; for( intpt1=mem1, k1=0; *intpt1!=-1; intpt1++, k1++ ) { for( intpt2=mem2, k2=0; *intpt2!=-1; intpt2++, k2++ ) { if( localhom[*intpt1][*intpt2].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[*intpt1]+*intpt2; // if( localhomshrink[k1][k2] != NULL ) // printf( "ori localhomshrink[%d][%d].opt = %f\n", k1, k2, localhomshrink[k1][k2]->opt ); } } return( 0 ); } int fastshrinklocalhom_half( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink ) { int k1, k2; int *intpt1, *intpt2; for( intpt1=mem1, k1=0; *intpt1!=-1; intpt1++, k1++ ) { for( intpt2=mem2, k2=0; *intpt2!=-1; intpt2++, k2++ ) { if( *intpt1 < *intpt2 ) { if( localhom[*intpt1][*intpt2-*intpt1].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[*intpt1]+*intpt2-*intpt1; } else { if( localhom[*intpt2][*intpt1-*intpt2].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[*intpt2]+*intpt1-*intpt2; } // if( localhomshrink[k1][k2] != NULL ) // printf( "ori localhomshrink[%d][%d].opt = %f, .importance=%f\n", k1, k2, localhomshrink[k1][k2]->opt, localhomshrink[k1][k2]->importance ); } } return( 0 ); } int fastshrinklocalhom_target( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink, char *swaplist, int *targetmap ) { int k1, k2; int *intpt1, *intpt2; int t1, i2; for( intpt1=mem1, k1=0; *intpt1!=-1; intpt1++, k1++ ) { if( targetmap[*intpt1] == -1 ) { swaplist[k1] = 1; // swaplist[k1] = 0; // DAME!!! for( intpt2=mem2, k2=0; *intpt2!=-1; intpt2++, k2++ ) { if( targetmap[*intpt2] == -1 ) { localhomshrink[k1][k2] = NULL; continue; } t1 = targetmap[*intpt2]; // end1<->end2, start1<->start2 i2 = *intpt1; if( localhom[t1][i2].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[t1]+i2; // if( localhomshrink[k1][k2] != NULL ) // printf( "localhomshrink[%d][%d].opt = %f\n", k1, k2, localhomshrink[k1][k2]->opt ); // else // printf( "localhomshrink[%d][%d] = NULL\n", k1, k2 ); } } else { swaplist[k1] = 0; for( intpt2=mem2, k2=0; *intpt2!=-1; intpt2++, k2++ ) { t1 = targetmap[*intpt1]; i2 = *intpt2; if( localhom[t1][i2].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[t1]+i2; // if( localhomshrink[k1][k2] != NULL ) // printf( "localhomshrink[%d][%d].opt = %f\n", k1, k2, localhomshrink[k1][k2]->opt ); // else // printf( "localhomshrink[%d][%d] = NULL\n", k1, k2 ); } } } return( 0 ); } int msfastshrinklocalhom( int *mem1, int *mem2, LocalHom **localhom, LocalHom ***localhomshrink ) { int k1, k2; int *intpt1, *intpt2; int m1, m2; for( intpt1=mem1, k1=0; *intpt1!=-1; intpt1++, k1++ ) { for( intpt2=mem2, k2=0; *intpt2!=-1; intpt2++, k2++ ) { m1 = MIN(*intpt1,*intpt2); m2 = MAX(*intpt1,*intpt2); if( localhom[m1][m2].opt == -1 ) localhomshrink[k1][k2] = NULL; else localhomshrink[k1][k2] = localhom[m1]+m2; } } return( 0 ); }