Egglib 2.1.11
C++ library reference manual
SitePolymorphism.hpp
1 /*
2  Copyright 2008-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 
21 #ifndef EGGLIB_SITEPOLYMORPHISM_HPP
22 #define EGGLIB_SITEPOLYMORPHISM_HPP
23 
24 
25 
26 namespace egglib {
27 
28 
42 
43  public:
44 
49 
50 
56  SitePolymorphism(unsigned int npop);
57 
58 
62  virtual ~SitePolymorphism();
63 
64 
68  SitePolymorphism(const SitePolymorphism& source);
69 
70 
75 
76 
82  void numberOfPopulations(unsigned int npop);
83 
84 
95  void load(unsigned int populationIndex, char character);
96 
97 
105  void outgroup(char state);
106 
107 
111  unsigned int numberOfAlleles() const;
112 
113 
119  char allele(unsigned int index) const;
120 
121 
128  unsigned int alleleFrequency(unsigned int alleleIndex) const;
129 
130 
137  unsigned int alleleFrequency(unsigned int popIndex, unsigned int alleleIndex) const;
138 
139 
148  unsigned int derivedAlleleFrequency() const;
149 
150 
154  unsigned int ns() const;
155 
156 
162  unsigned int ns(unsigned int popIndex) const;
163 
164 
173  bool isOrientable() const;
174 
175  bool isPolymorphic(unsigned int popIndex) const;
176  bool hasSpecificAllele(unsigned int popIndex, bool restrictToDerived) const;
177  bool haveFixedDifference(unsigned int pop1, unsigned int pop2) const;
178  bool haveCommonAllele(unsigned int pop1, unsigned int pop2) const;
179  bool haveSharedAllele(unsigned int pop1, unsigned int pop2) const;
180 
181 
182 
183 
184  protected:
185 
186  // helpers
187  void init();
188  void clear();
189  void copy(const SitePolymorphism& site);
190 
191 
192  // data
193  unsigned int m_numberOfPopulations;
194  unsigned int m_numberOfStates;
195  char * m_states;
196  unsigned int ** m_frequencies;
197  unsigned int m_numberOfOutgroups;
198  char * m_outgroups;
199  unsigned int m_ns;
200  unsigned int * m_pop_ns;
201 
202  bool m_cache_orientable;
203 
204  };
205 }
206 
207 #endif
char allele(unsigned int index) const
Gets an allele (unsecure)
Definition: SitePolymorphism.cpp:196
unsigned int numberOfAlleles() const
Number of different alleles.
Definition: SitePolymorphism.cpp:201
virtual ~SitePolymorphism()
Destroys an object.
Definition: SitePolymorphism.cpp:35
Implements diversity analysis at the site level.
Definition: SitePolymorphism.hpp:41
unsigned int derivedAlleleFrequency() const
Sums the frequency of derived allele(s)
Definition: SitePolymorphism.cpp:220
bool isOrientable() const
Checks if the site can be oriented.
Definition: SitePolymorphism.cpp:241
void load(unsigned int populationIndex, char character)
Adds a character.
Definition: SitePolymorphism.cpp:160
void numberOfPopulations(unsigned int npop)
Sets the number of populations.
Definition: SitePolymorphism.cpp:142
void outgroup(char state)
Loads outgroup state.
Definition: SitePolymorphism.cpp:188
unsigned int ns() const
Number of sequences that were analyzed.
Definition: SitePolymorphism.cpp:231
SitePolymorphism()
Builds an object.
Definition: SitePolymorphism.cpp:30
unsigned int alleleFrequency(unsigned int alleleIndex) const
Gets a frequency (unsecure)
Definition: SitePolymorphism.cpp:206
SitePolymorphism & operator=(const SitePolymorphism &source)
Assignment operator.
Definition: SitePolymorphism.cpp:52
Definition: ABC.cpp:37

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