libsequence  1.9.5
Sequence::nmuts< counter > Class Template Reference

Calculate the number of mutations at a polymorphic site. More...

#include <Sequence/PolyFunctional.hpp>

Public Types

typedef unsigned result_type
 

Public Member Functions

unsigned operator() (unsigned &nm, const polymorphicSite &site, const bool &haveOutgroup=false, const unsigned &outgroup=0) const
 

Detailed Description

template<typename counter>
class Sequence::nmuts< counter >

Calculate the number of mutations at a polymorphic site.

Function object to keep track of the number of mutations in a range of polymorphic sites. The template argument specifies the counting behavior, i.e. countStates or countDerivedStates. It is designed to be used with std::accumulate, and will need std::bind for the necessary arguments

#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 # mutations via algorithm
unsigned nm = std::accumulate(p.sbegin(),p.send(),0u,
std::bind(nmuts<countStates>(),std::placeholders::_1,std::placeholders::_2,
false,0));
std::cout << nm
<< '\n';
//for comparison, use Sequence::PolySNP
std::cout << a.NumMutations() << '\n';
}

Definition at line 224 of file PolyFunctional.hpp.

Member Typedef Documentation

◆ result_type

template<typename counter >
typedef unsigned Sequence::nmuts< counter >::result_type

allows std::bind to be used in a simple way

Definition at line 229 of file PolyFunctional.hpp.

Member Function Documentation

◆ operator()()

template<typename counter >
unsigned Sequence::nmuts< counter >::operator() ( unsigned &  nm,
const polymorphicSite site,
const bool &  haveOutgroup = false,
const unsigned &  outgroup = 0 
) const
inline
Parameters
nma value of nmuts to increment
sitean object representing the value type of PolyTable::const_site_iterator
haveOutgrouptrue of one of the elements of site is an outgroup state, false otherwise
outgroupthe index of the outgroup sequence in site

Definition at line 230 of file PolyFunctional.hpp.


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