7 #include "io_lib_header.h"
8 #include "util_lib_header.h"
9 #include "define_header.h"
10 #include "dp_lib_header.h"
11 #include "dev1_lib_header.h"
13 //Insert functions here
14 void aln2hitMat_help()
16 fprintf ( stdout, "\n+aln2hitMat| _MODE_ : how to compare the two positions of the alignment (default:id)");
17 fprintf ( stdout, "\n.................id : the sequence identity of those two positions");
18 fprintf ( stdout, "\n.............pairscore : the pairwise score of the residues of those two positions");
19 fprintf ( stdout, "\n+aln2hitMat| _MATRIX_ : matrix used for the comparison (idmat, blosum62mt, pam250mt.. default:blosum62mt)\n");
23 void aln2hitMat (Alignment *A, char *phitmat)
25 float **ffpHitScoreMatrix;
32 int isim_count, itotal_count, r1, r2;
34 //Initialization for files
35 char *pcFileName = A->file[0];
36 char prefix[200] ={0};
37 char *hit_matrix_file = vcalloc(200, sizeof (char));
38 char *hit_html_file = vcalloc(200, sizeof (char));
39 int len = (strrchr(pcFileName,'.')?strrchr(pcFileName,'.')-pcFileName:strlen(pcFileName));
41 strncpy(prefix, pcFileName, len);
42 sprintf(hit_matrix_file, "%s%s", prefix, "_aln.hit_matrix");
43 sprintf(hit_html_file, "%s%s", prefix, ".alnhit_html");
45 if ( phitmat && strstr ( phitmat, "help"))
48 if(phitmat == NULL) phitmat = vcalloc(1, sizeof(char)); //such that program could get default value
50 strget_param (phitmat, "_MODE_", "id", "%s", mode);
51 strget_param (phitmat, "_MATRIX_", "blosum62mt", "%s", matrix);
53 fprintf ( stdout, "[START] aln to hit matrix\n");
54 fprintf ( stdout, " Mode:%s\n", mode);
55 fprintf ( stdout, " Matrix:%s\n", matrix);
57 int **mat = read_matrice(matrix);
59 ffpHitScoreMatrix=vcalloc (nl, sizeof (float*));
60 for(i = 0; i < nl; i++)
61 ffpHitScoreMatrix[i]=vcalloc (nl-i, sizeof (float));
63 fprintf (stdout, "Process positions\n", i);
64 for(i = 0; i < nl; i++)
66 fprintf (stdout, "%d, ", i);
67 for(j = i; j < nl; j++)
70 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);
71 else if(strm (mode, "pairscore"))
73 isim_count = itotal_count = 0;
74 for (k=0; k< inseq; k++)
76 r1=tolower(A->seq_al[k][i]);
77 if (is_gap(r1))continue;
78 for (l=0; l< inseq; l++)
80 r2=tolower(A->seq_al[l][j]);
81 if (is_gap (r2))continue;
82 s=mat[r2-'A'][r1-'A'];
88 r1=(isim_count*100)/itotal_count;
89 ffpHitScoreMatrix[i][j-i] = r1;
95 fprintf (stdout, "\n");
96 output_hit_matrix(hit_matrix_file, ffpHitScoreMatrix, nl);
98 //Output Hit Score into color html
99 output_hit_color_html (A, ffpHitScoreMatrix, nl, hit_html_file);
100 vfree(ffpHitScoreMatrix);
101 vfree(hit_matrix_file);
102 vfree(hit_html_file);
103 fprintf ( stdout, "[END] aln to hit matrix\n");
105 /******************************COPYRIGHT NOTICE*******************************/
106 /*© Centro de Regulacio Genomica */
108 /*Cedric Notredame */
109 /*Fri Feb 18 08:27:45 CET 2011 - Revision 596. */
110 /*All rights reserved.*/
111 /*This file is part of T-COFFEE.*/
113 /* T-COFFEE is free software; you can redistribute it and/or modify*/
114 /* it under the terms of the GNU General Public License as published by*/
115 /* the Free Software Foundation; either version 2 of the License, or*/
116 /* (at your option) any later version.*/
118 /* T-COFFEE is distributed in the hope that it will be useful,*/
119 /* but WITHOUT ANY WARRANTY; without even the implied warranty of*/
120 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the*/
121 /* GNU General Public License for more details.*/
123 /* You should have received a copy of the GNU General Public License*/
124 /* along with Foobar; if not, write to the Free Software*/
125 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/
126 /*............................................... |*/
127 /* If you need some more information*/
128 /* cedric.notredame@europe.com*/
129 /*............................................... |*/
133 /******************************COPYRIGHT NOTICE*******************************/