double *compute_matrix_p ( double *n,int Nseq) { /* reads in a frquency list of various amino acids: sum freq(aa)=1 (gaps are ignored) aa[1]=x1 aa[2]=x2 .... Outputs a similar list with frequencies 'Blurred' using a pam250 mt */ static int **matrix; double *R; int a, b; double v,min, tot; if ( !matrix) { matrix=read_matrice ( "pam250mt"); } R=vcalloc ( 26, sizeof (double)); for ( a=0; a<26; a++) { if (!is_aa(a+'a'))continue; if ( n[a]==0)continue; for ( b=0; b< 26; b++) { if (!is_aa(b+'a'))continue; v=n[a]*(matrix[a][b]); if ( v>0) { R[b]+=v+(10*n[a]); } } } min=R[0]; for ( min=R[0],a=0; a< 26; a++)min=MIN(min,R[a]); for ( tot=0, a=0; a< 26; a++) {R[a]-=min;tot+=R[a];} for ( a=0; a< 26; a++)if ( is_aa(a+'a')){R[a]=R[a]*((float)(100)/(float)tot);} return R; }
int get_beta_sub_cost (Alignment *A, int**pos1, int ns1, int*list1, int col1, int**pos2, int ns2, int*list2, int col2, Constraint_list *CL) { static int **mat; int s1, r1, s2, r2; float score; if (!mat && CL->matrices_list[1][0])mat=read_matrice (CL->matrices_list[1]); else if ( !CL->matrices_list[1][0])return UNDEFINED; s1=A->order[list1[0]][0]; r1=pos1[list1[0]][col1]; s2=A->order[list2[0]][0]; r2=pos1[list2[0]][col2]; if ( r1<0 || r2<0)return 0; score=mat[(CL->S)->seq[s1][r1-1]-'A'][(CL->S)->seq[s2][r2-1]-'A']*SCORE_K; return (int)score; }
void aln2hitMat (Alignment *A, char *phitmat) { float **ffpHitScoreMatrix; int i, j, k, l, s; int nl = A->len_aln; int inseq = A->nseq; int itmpScore; char matrix[100]; char mode[100]; int isim_count, itotal_count, r1, r2; //Initialization for files char *pcFileName = A->file[0]; char prefix[200] ={0}; char *hit_matrix_file =(char*) vcalloc(200, sizeof (char)); char *hit_html_file =(char*) vcalloc(200, sizeof (char)); int len = (strrchr(pcFileName,'.')?strrchr(pcFileName,'.')-pcFileName:strlen(pcFileName)); strncpy(prefix, pcFileName, len); sprintf(hit_matrix_file, "%s%s", prefix, "_aln.hit_matrix"); sprintf(hit_html_file, "%s%s", prefix, ".alnhit_html"); if ( phitmat && strstr ( phitmat, "help")) aln2hitMat_help(); if(phitmat == NULL) phitmat = (char*) vcalloc(1, sizeof(char)); //such that program could get default value strget_param (phitmat, "_MODE_", "id", "%s", mode); strget_param (phitmat, "_MATRIX_", "blosum62mt", "%s", matrix); fprintf ( stdout, "[START] aln to hit matrix\n"); fprintf ( stdout, " Mode:%s\n", mode); fprintf ( stdout, " Matrix:%s\n", matrix); int **mat = read_matrice(matrix); ffpHitScoreMatrix=(float**)vcalloc (nl, sizeof (float*)); for(i = 0; i < nl; i++) ffpHitScoreMatrix[i]=(float*)vcalloc (nl-i, sizeof (float)); fprintf (stdout, "Process positions\n", i); for(i = 0; i < nl; i++) { fprintf (stdout, "%d, ", i); for(j = i; j < nl; j++) { if(strm (mode, "id")) ffpHitScoreMatrix[i][j-i]=generic_get_seq_sim (aln_column2string(A, i), aln_column2string(A, j), (A->cdna_cache)?A->cdna_cache[0]:NULL, matrix); else if(strm (mode, "pairscore")) { isim_count = itotal_count = 0; for (k=0; k< inseq; k++) { r1=tolower(A->seq_al[k][i]); if (is_gap(r1))continue; for (l=0; l< inseq; l++) { r2=tolower(A->seq_al[l][j]); if (is_gap (r2))continue; s=mat[r2-'A'][r1-'A']; s=(s<=0)?0:1; isim_count += s; itotal_count++; } } r1=(isim_count*100)/itotal_count; ffpHitScoreMatrix[i][j-i] = r1; } else aln2hitMat_help(); } } fprintf (stdout, "\n"); output_hit_matrix(hit_matrix_file, ffpHitScoreMatrix, nl); //Output Hit Score into color html output_hit_color_html (A, ffpHitScoreMatrix, nl, hit_html_file); vfree(ffpHitScoreMatrix); vfree(hit_matrix_file); vfree(hit_html_file); fprintf ( stdout, "[END] aln to hit matrix\n"); }