Calculate nucleotide diversity from a polymorphic site. More...
#include <Sequence/PolyFunctional.hpp>
Public Member Functions | |
| double | operator() (double &_ssh, const polymorphicSite &site, const bool &haveOutgroup=false, const unsigned &outgroup=0) const |
Calculate nucleotide diversity from a polymorphic site.
A function object to keep track of "ssh", the sum of site heterozygosity, aka pi, aka nucleotide diversity. It can be used with std::accumulate to do calculations accross a range of sites, i.e.:
#include <numeric> #include <algorithm> #include <iostream> #include <boost/bind.hpp> #include <Sequence/FastaExplicit.hpp> #include <Sequence/PolySites.hpp> #include <Sequence/PolySNP.hpp> #include <Sequence/stateCounter.hpp> #include <Sequence/PolyFunctional.hpp> int main() { std::vector< Sequence::Fasta > data; Sequence::Alignment::GetData(data,std::cin); Sequence::PolySites p(data); //calculate nucleotide diversity using STL double pi = std::accumulate(p.sbegin(),p.send(),0.,ssh()); std::cout << pi << '\n'; //calculate nucleotide diversity using Sequence::PolySNP Sequence::PolySNP a(&p); std::cout << a.ThetaPi() << '\n'; }
Definition at line 153 of file PolyFunctional.hpp.
| double Sequence::ssh::operator() | ( | double & | _ssh, | |
| const polymorphicSite & | site, | |||
| const bool & | haveOutgroup = false, |
|||
| const unsigned & | outgroup = 0 | |||
| ) | const [inline] |
| _ssh | a value of ssh to increment | |
| site | an object representing the value type of PolyTable::const_site_iterator | |
| haveOutgroup | true of one of the elements of site is an outgroup state, false otherwise | |
| outgroup | the index of the outgroup sequence in site |
Definition at line 156 of file PolyFunctional.hpp.
1.6.3