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 |
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 boost::bind for the necessary arguments
#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 # mutations via algorithm unsigned nm = std::accumulate(p.sbegin(),p.send(),0u, boost::bind(nmuts<countStates>(),_1,_2, false,0)); std::cout << nm << '\n'; //for comparison, use Sequence::PolySNP Sequence::PolySNP a(&p); std::cout << a.NumMutations() << '\n'; }
Definition at line 225 of file PolyFunctional.hpp.
| typedef unsigned Sequence::nmuts< counter >::result_type |
allows boost::bind to be used in a simple way
Definition at line 230 of file PolyFunctional.hpp.
| unsigned Sequence::nmuts< counter >::operator() | ( | unsigned & | nm, | |
| const polymorphicSite & | site, | |||
| const bool & | haveOutgroup = false, |
|||
| const unsigned & | outgroup = 0 | |||
| ) | const [inline] |
| nm | a value of nmuts 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 231 of file PolyFunctional.hpp.
1.6.3