libsequence  1.9.5
SummStats.cc
2 #include <Sequence/SimData.hpp>
3 #include <algorithm>
4 #include <numeric>
5 #include <cctype>
6 #include <stdexcept>
7 using namespace std;
8 
9 namespace Sequence
10 {
11  double Dij(const polymorphicSite & p, const std::vector< unsigned > & config, const unsigned & i, const unsigned & j)
12  {
13  unsigned rv = 0;
14  unsigned N = 0;
15  unsigned start1 = accumulate(config.begin(),config.begin()+i,0u),
16  start2 = accumulate(config.begin(),config.begin()+j,0u);
17  for( unsigned x = start1 ; x < start1 + config[i] ; ++x )
18  {
19  for(unsigned y = start2 ; y < start2 + config[j] ; ++y)
20  {
21  char ch1 = char(std::toupper(p.second[x])),ch2=char(std::toupper(p.second[y]));
22  if(ch1 != 'N' && ch2 != 'N')
23  {
24  rv += (ch1 != ch2) ? 1u : 0u;
25  }
26  else
27  {
28  ++N;
29  }
30  }
31  }
32  return double(rv)/(double(config[i]+config[j]-N));
33  }
34 
35  double Gmin(const polySiteVector & , const std::vector< unsigned > & )
36  {
37  throw std::runtime_error("not implemented yet");
38  unsigned mdxy = numeric_limits<unsigned>::max();
39  return mdxy;
40  }
41 }//ns Sequence
STL namespace.
The namespace in which this library resides.
std::vector< polymorphicSite > polySiteVector
Site-major variation tables in ASCII format.
Declaration of Sequence::SimData, a class representing polymorphism data from coalescent simulations ...
std::pair< double, std::string > polymorphicSite