libsequence  1.9.5
ssh Struct Reference

Calculate nucleotide diversity from a polymorphic site. More...

#include <Sequence/PolyFunctional.hpp>

Detailed Description

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 <functional>
#include <Sequence/FastaExplicit.hpp>
int main()
{
std::vector< Sequence::Fasta > data;
Sequence::Alignment::GetData(data,std::cin);
//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
std::cout << a.ThetaPi()
<< '\n';
}

The documentation for this struct was generated from the following file: