Egglib 2.1.11
C++ library reference manual
DataMatrix.hpp
1 /*
2  Copyright 2009-2010 Stéphane De Mita, Mathieu Siol
3 
4  This file is part of the EggLib library.
5 
6  EggLib is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  EggLib is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with EggLib. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef EGGLIB_DATAMATRIX_HPP
21 #define EGGLIB_DATAMATRIX_HPP
22 
23 
24 #include "CharMatrix.hpp"
25 
26 
27 namespace egglib {
28 
41  class DataMatrix : public CharMatrix {
42 
43  public:
44 
50  DataMatrix();
51 
52 
62  DataMatrix(unsigned int numberOfSequences, unsigned int numberOfSites);
63 
64 
68  DataMatrix(const DataMatrix&);
69 
70 
74  DataMatrix(const CharMatrix&);
75 
76 
80  virtual DataMatrix& operator=(const DataMatrix&);
81 
82 
86  virtual DataMatrix& operator=(const CharMatrix&);
87 
88 
92  virtual ~DataMatrix();
93 
94 
98  unsigned int numberOfSites() const;
99 
100 
104  unsigned int numberOfSequences() const;
105 
106 
110  void set(unsigned int sequence, unsigned int site, int value);
111 
112 
116  int get(unsigned int sequence, unsigned int site) const;
117 
118 
122  inline int fget(unsigned int sequence, unsigned int site) const {
123  return dataMatrix[sequence][site];
124  }
125 
126 
130  void sitePosition(unsigned int site, double value);
131 
132 
136  double sitePosition(unsigned int site) const;
137 
138 
142  void populationLabel(unsigned int sequence, unsigned int value);
143 
144 
148  unsigned int populationLabel(unsigned int sequence) const;
149 
150 
154  void clear();
155 
156 
166  void resize(unsigned int newNumberOfSequences, unsigned int newNumberOfSites);
167 
168 
178  void shift(int minimum);
179 
187  char character(unsigned int sequence, unsigned int site) const;
188 
189 
190 
191  private:
192 
193  // Initializes to default values (for empty object)
194  void init();
195 
196  // Copies from a source object
197  virtual void copy(const CharMatrix&);
198 
199  // Copies from a source object
200  virtual void copy(const DataMatrix&);
201 
202  // Number of lines of the data matrix
203  unsigned int _numberOfSequences;
204 
205  // Number of columns of the data matrix
206  unsigned int _numberOfSites;
207 
208  // Data matrix
209  int **dataMatrix;
210 
211  // Vector of site positions
212  double *positions;
213 
214  // Vector of group indices
215  unsigned int *groups;
216  };
217 }
218 
219 #endif
char character(unsigned int sequence, unsigned int site) const
Gets the character at a given position.
Definition: DataMatrix.cpp:248
unsigned int numberOfSequences() const
Gets number of sequences.
Definition: DataMatrix.cpp:171
void resize(unsigned int newNumberOfSequences, unsigned int newNumberOfSites)
Resizes the data matrix.
Definition: DataMatrix.cpp:41
Data table.
Definition: DataMatrix.hpp:41
int fget(unsigned int sequence, unsigned int site) const
Faster and unsecure version of get.
Definition: DataMatrix.hpp:122
void shift(int minimum)
Shifts allele value.
Definition: DataMatrix.cpp:228
void sitePosition(unsigned int site, double value)
Sets the position of a site.
Definition: DataMatrix.cpp:190
virtual ~DataMatrix()
Destructor.
Definition: DataMatrix.cpp:133
void clear()
Removes all information from the object.
Definition: DataMatrix.cpp:214
void set(unsigned int sequence, unsigned int site, int value)
Sets a value of the data table.
Definition: DataMatrix.cpp:176
DataMatrix()
Default constructor.
Definition: DataMatrix.cpp:27
Definition: ABC.cpp:37
void populationLabel(unsigned int sequence, unsigned int value)
Sets the group label of a sequence.
Definition: DataMatrix.cpp:202
virtual DataMatrix & operator=(const DataMatrix &)
Assignment operator.
Definition: DataMatrix.cpp:119
unsigned int numberOfSites() const
Gets number of sites.
Definition: DataMatrix.cpp:166
Interface for classes usable as a square matrix of characters.
Definition: CharMatrix.hpp:31

Hosted by 
Get EggLib at SourceForge.net. Fast, secure and Free Open Source software downloads