35 #define LINE_LENGTH 256
43 #include "Statistics/similarityMatrix.h" 53 StartTiming(
"similarityMatrix::similarityMatrix() ");
63 StartTiming(
"void similarityMatrix::memoryAllocation(int nPos) ");
74 simMat =
new float *[nPos];
77 for (i = 0; i < nPos; i++) {
78 simMat[i] =
new float[nPos];
81 for (j = 0; j < nPos; j++) {
91 StartTiming(
"similarityMatrix::~similarityMatrix() ");
100 StartTiming(
"void similarityMatrix::memoryDeletion() ");
121 StartTiming(
"bool similarityMatrix::loadSimMatrix(char *filename) ");
127 bool firstColumn =
true;
146 listSym[i] = (
char) toupper((
int) listSym[i]);
148 if ((listSym[i] >=
'A') && (listSym[i] <=
'Z')) {
149 if ((
vhash[listSym[i] -
'A']) != -1) {
153 vhash[listSym[i] -
'A'] = i;
168 first[0] = (
char) toupper((
int) first[0]);
171 if (((first[0] >=
'0' && first[0] <=
'9') ||
172 (first[0] ==
'-' && (first[1] >=
'0' && first[1] <=
'9')))
180 if ((first[0] >=
'A') && (first[0] <=
'Z')) {
183 if ((
vhash[first[0] -
'A']) == -1) {
191 else if ((first[0] >=
'0' && first[0] <=
'9') || (first[0] ==
'-' && (first[1] >=
'0' && first[1] <=
'9'))) {
195 simMat[i][0] = atof(first);
196 first[0] = listSym[i];
203 if ((first[0] >=
'A') && (first[0] <=
'Z') && (i > 0)) {
208 simMat[i][0] = atof(first);
209 first[0] = listSym[i];
237 if ((i != j) && (
distMat[i][j] == 0.0)) {
240 sum = (
float) sqrt(sum);
254 StartTiming(
"void similarityMatrix::defaultAASimMatrix(void) ");
260 for (i = 0; i <
TAMABC; i++)
265 vhash[listAASym[i] -
'A'] = i;
269 simMat[i][j] = defaultAAMatrix[i][j];
275 if ((i != j) && (
distMat[i][j] == 0.0)) {
278 sum = (
float) sqrt(sum);
289 StartTiming(
"void similarityMatrix::defaultNTSimMatrix(void) ");
294 for (i = 0; i <
TAMABC; i++)
299 vhash[listNTSym[i] -
'A'] = i;
303 simMat[i][j] = defaultNTMatrix[i][j];
309 if ((i != j) && (
distMat[i][j] == 0.0)) {
312 sum = (
float) sqrt(sum);
323 StartTiming(
"void similarityMatrix::defaultNTDegeneratedSimMatrix(void) ");
328 for (i = 0; i <
TAMABC; i++)
333 vhash[listNTDegenerateSym[i] -
'A'] = i;
337 simMat[i][j] = defaultNTDegeneratedMatrix[i][j];
342 if ((i != j) && (
distMat[i][j] == 0.0)) {
345 sum = (
float) sqrt(sum);
373 for (i = 0; i <
TAMABC; i++)
380 vhash[listAASym[i] -
'A'] = i;
384 vhash[listNTSym[i] -
'A'] = i;
388 vhash[listNTDegenerateSym[i] -
'A'] = i;
396 switch (matrix_code) {
398 simMat[i][j] = alternative_1_NTDegeneratedMatrix[i][j];
407 if ((i != j) && (
distMat[i][j] == 0.0)) {
410 sum = (
float) sqrt(sum);
421 StartTiming(
"void similarityMatrix::printMatrix() ");
425 std::cerr << std::setw(8) << std::setprecision(4) << std::right <<
simMat[i][j];
426 std::cerr << std::endl;
433 StartTiming(
"float similarityMatrix::getDistance(char a, char b) ");
434 int numa = -1, numb = -1;
437 if ((a >=
'A') && (a <=
'Z')) numa =
vhash[a -
'A'];
444 if ((b >=
'A') && (b <=
'Z')) numb =
vhash[b -
'A'];
void defaultNTDegeneratedSimMatrix()
Method to load the default DEG NT similarity matrix.
void printMatrix()
Method to print the loaded matrix.
void defaultAASimMatrix()
Method to load the default AA similarity matrix.
void memoryDeletion()
Method to deallocate memory allocated on the similarityMatrix::memoryAllocation method. It makes use of the numPositions to effectively remove the memory.
void alternativeSimilarityMatrices(int matrix_code, int datatype)
Method to load alternative similarity matrices also included on the suite. Currently, only one type of alternative matrix is available: matrix_code: 1 datatype SequenceTypes::AA.
#define StartTiming(name)
void removeSpaces(char *in, char *out)
Removing spaces method.
float getDistance(char a, char b)
Method to get the similarity distance between two residues, A and B Characters provided must be both ...
~similarityMatrix()
Destructor.
bool loadSimMatrix(char *filename)
Method to load a custom matrix.
Class that contains information of similarity matrices. These are used to calculate the similarity be...
void initlVect(int *vector, int tam, int valor)
Vector initialization.
void defaultNTSimMatrix()
Method to load the default NT similarity matrix.
Namespace containing all classes related to statistics handling.
reporting::reportManager debug
void report(ErrorCode message, std::string *vars=nullptr)
Method to report an Error. It will be displayed if Level is equal or higher to VerboseLevel::ERROR...
void memoryAllocation(int nPos)
Method to allocate memory for the similiarity matrix.
Utilities class. This class contains shared methods to be used in multiple parts of the code...
similarityMatrix()
Constructor.