similarityMatrix.h
Go to the documentation of this file.
1 /* *****************************************************************************
2 
3  trimAl v2.0: a tool for automated alignment trimming in large-scale
4  phylogenetics analyses.
5 
6  readAl v2.0: a tool for automated alignment conversion among different
7  formats.
8 
9  2009-2019
10  Fernandez-Rodriguez V. (victor.fernandez@bsc.es)
11  Capella-Gutierrez S. (salvador.capella@bsc.es)
12  Gabaldon, T. (tgabaldon@crg.es)
13 
14  This file is part of trimAl/readAl.
15 
16  trimAl/readAl are free software: you can redistribute it and/or modify
17  it under the terms of the GNU General Public License as published by
18  the Free Software Foundation, the last available version.
19 
20  trimAl/readAl are distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  GNU General Public License for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with trimAl/readAl. If not, see <http://www.gnu.org/licenses/>.
27 
28 ***************************************************************************** */
29 
30 #ifndef SIMILARITYMATRIX_H
31 #define SIMILARITYMATRIX_H
32 
33 #include <iostream>
34 #include <cstring>
35 #include <cstdlib>
36 #include <iomanip>
37 #include <fstream>
38 #include <cstring>
39 #include <cctype>
40 #include <cmath>
41 
42 
43 namespace statistics {
44 /**
45  * \brief Class that contains information of similarity matrices.\n
46  * These are used to calculate the similarity between residues on the same column.
47  * <br>
48  * Default matrices for AA, NT and DEG NT are provided, along with method for loading custom matrices.
49  */
51 
52  int *vhash;
53  float **simMat;
54  float **distMat;
56 
57  private:
58  /**
59  * \brief Method to allocate memory for the similiarity matrix
60  * \param nPos Number of different possible residues in the alignment.\n
61  * This are, on the default matrices:
62  * -# AA: 20 residues
63  * -# NT: 5 residues
64  * -# DEG NT: 15 residues
65  */
66  void memoryAllocation(int nPos);
67 
68  /**
69  * \brief Method to deallocate memory allocated on the similarityMatrix::memoryAllocation method.\n
70  * It makes use of the #numPositions to effectively remove the memory.
71  */
72  void memoryDeletion();
73 
74  public:
75  /** \brief Constructor **/
77 
78  /** \brief Destructor **/
80 
81  /**
82  * \brief Method to load a custom matrix
83  * \param filename Path to file containing the matrix to load
84  * \return \b True if loaded \n \b False if an error ocurred**/
85  bool loadSimMatrix(char *filename);
86 
87  /**
88  * \brief Method to load the default AA similarity matrix
89  */
90  void defaultAASimMatrix();
91 
92  /**
93  * \brief Method to load the default NT similarity matrix
94  */
95  void defaultNTSimMatrix();
96 
97  /**
98  * \brief Method to load the default DEG NT similarity matrix
99  */
101 
102  /**
103  * \brief Method to load alternative similarity matrices also included on the suite.
104  * Currently, only one type of alternative matrix is available: \n
105  * \b matrix_code: 1 \b datatype SequenceTypes::AA
106  * \param matrix_code ID of the matrix
107  * \param datatype Numberical representation of the data type.
108  * See #SequenceTypes
109  */
110  void alternativeSimilarityMatrices(int matrix_code, int datatype);
111 
112  /**
113  * \brief Method to get the similarity distance between two residues, A and B\n
114  * Characters provided must be both uppercase, please, refer to utils::toUpper
115  * \param a First residue to compare
116  * \param b Second residue to compare
117  * \return Distance between A and B based on the similarity matrix loaded.
118  */
119  float getDistance(char a, char b);
120 
121  /**
122  * \brief Method to print the loaded matrix.
123  */
124  void printMatrix();
125  };
126 }
127 #endif
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.
float getDistance(char a, char b)
Method to get the similarity distance between two residues, A and B Characters provided must be both ...
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 defaultNTSimMatrix()
Method to load the default NT similarity matrix.
Namespace containing all classes related to statistics handling.
Definition: Similarity.h:44
void memoryAllocation(int nPos)
Method to allocate memory for the similiarity matrix.