Egglib 2.1.11
C++ library reference manual
BaseDiversity.hpp
1 /*
2  Copyright 2009 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_BASEDIVERSITY_HPP
21 #define EGGLIB_BASEDIVERSITY_HPP
22 
23 #include "CharMatrix.hpp"
24 #include "SitePolymorphism.hpp"
25 #include <string>
26 
50 namespace egglib {
51 
60  class BaseDiversity {
61 
62  public:
63 
67  BaseDiversity();
68 
72  virtual ~BaseDiversity();
73 
87  virtual void reserve(unsigned int numberOfSites);
88 
90  const SitePolymorphism* get_site(unsigned int index) const;
91 
93  unsigned int get_position(unsigned int index) const;
94 
98  static const std::string dnaMapping;
99 
100 
104  static const std::string rnaMapping;
105 
106 
110  static const std::string aaMapping;
111 
112 
114  virtual void reset();
115 
116 
117  protected:
118 
119  virtual void init();
120  virtual void clear();
121 
122  //
123  void importSites(CharMatrix& data, bool allowMultipleMutations,
124  double minimumExploitableData, unsigned int ignoreFrequency,
125  std::string characterMapping, bool useZeroAsAncestral,
126  bool ignoreOutgroup);
127 
128  //
129  void analyzeSite(CharMatrix& data, unsigned int index, double maxMissingData, bool ignoreOutgroup); // analyzes a site, adds a Site to the Site container if the site is polymorphic
130  unsigned int getPopIndex(unsigned int label) const; // returns v_npop if not found
131 
132  SitePolymorphism** v_sites; // holder of polymorphic site addresses
133  bool* v_orientables; // stores whether the sites are orientable or not
134  unsigned int* v_sitePositions; // stores position of sites
135 
136  unsigned int v_reserved;
137  unsigned int v_ns; // maximum number of sequences analyzed (max of sites' ns)
138  unsigned int v_S; // number of polymorphic sites
139  unsigned int v_So; // number of orientable sites
140  unsigned int v_eta; // number of mutation (whatever multiple)
141  double v_nseff; // average number of analyzed sequence
142  unsigned int v_lseff; // number of analyzed sites
143  double v_nseffo; // average number of analyzed sequences for analyzes with outgroup
144  unsigned int v_lseffo; // number of analyzed sites for analyzes with outgroup
145  unsigned int v_npop; // number of populations
146  unsigned int *v_popLabel; // label of each pop
147 
148  // options
149  bool p_allowMultipleMutations;
150  double p_minimumExploitableData;
151  std::string p_characterMapping;
152  unsigned int p_pos_sep_mapping;
153  bool p_useZeroAsAncestral;
154  unsigned int p_ignoreFrequency;
155 
156 
157  private:
158 
159  BaseDiversity(const BaseDiversity& source) { }
160 
161  BaseDiversity& operator=(const BaseDiversity& source) {
162  return *this;
163  }
164 
165  };
166 }
167 
168 #endif
unsigned int get_position(unsigned int index) const
Gets a site position.
Definition: BaseDiversity.cpp:103
BaseDiversity()
Constructor.
Definition: BaseDiversity.cpp:87
Base class of diversity classes.
Definition: BaseDiversity.hpp:60
virtual void reserve(unsigned int numberOfSites)
Reserve sufficient memory for a given number of polymorphic sites.
Definition: BaseDiversity.cpp:110
Implements diversity analysis at the site level.
Definition: SitePolymorphism.hpp:41
static const std::string aaMapping
Predefined mapping string for amino acid data.
Definition: BaseDiversity.hpp:110
static const std::string rnaMapping
Predefined mapping string for RNA data.
Definition: BaseDiversity.hpp:104
virtual ~BaseDiversity()
Destructor.
Definition: BaseDiversity.cpp:92
Definition: ABC.cpp:37
static const std::string dnaMapping
Predefined mapping string for DNA data.
Definition: BaseDiversity.hpp:98
const SitePolymorphism * get_site(unsigned int index) const
Gets a site.
Definition: BaseDiversity.cpp:96
virtual void reset()
Clears and re-initializes object.
Definition: BaseDiversity.cpp:81
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