40 #include <Sequence/PolySNPimpl.hpp> 48 :
public std::binary_function<std::string, std::string, bool>
51 operator()(
const std::string &l,
const std::string &r)
const 59 && std::lexicographical_compare(
60 l.begin(), l.end(), r.begin(), r.end(),
61 [](
const char &__a,
const char __b) {
63 static_cast<unsigned char>(__a))
65 static_cast<unsigned char>(__b)));
70 const bool &haveOutgroup,
71 const unsigned &outgroup,
const bool &totMuts)
72 : _data(data), _nsites(data->numsites()),
73 _nsam(unsigned(data->size())), _outgroup(outgroup),
74 _haveOutgroup(haveOutgroup), _totMuts(totMuts),
75 _totsam(unsigned(data->size())), _DVK(0), _DVH(1.0),
76 _counted_singletons(false), _know_pi(false), _CalculatedDandV(false),
77 _pi(0.), _singletons(0), _walls_Bprime(0), _NumPoly(0), _walls_B(0.),
78 _walls_Q(0.), _calculated_wall_stats(false),
80 _nsites,
Sequence::stateCounter(
'-'))),
81 _derivedCounts(
std::vector<
std::pair<bool, stateCounter>>(
83 std::make_pair<bool, stateCounter>(true, stateCounter(
'-')))),
111 for (
unsigned site = 0; site < _nsites; ++site)
113 for (
unsigned seq = 0; seq < _nsam; ++seq)
118 || (_haveOutgroup && seq != _outgroup))
120 _counts[site]((*_data)[seq][site]);
124 if (_haveOutgroup ==
true)
130 (*_data)[_outgroup][site])
132 || (*_data)[_outgroup][site]
135 _derivedCounts[site].first
141 _derivedCounts[site].first
144 && (*_data)[seq][site]
160 _derivedCounts[site].first =
false;
163 if (_counts[site].nStates() > 1
164 && _counts[site].gap == 0)
167 _preprocessed =
true;
172 unsigned outgroup,
bool totMuts)
174 new
_PolySNPImpl(data, haveOutgroup, outgroup, totMuts)))
190 PolySNP::~PolySNP(
void) {}
229 assert(rep->_preprocessed);
230 std::lock_guard<std::mutex> lock(rep->instance_lock);
231 if (rep->_know_pi ==
false)
234 for (
unsigned i = 0; i < rep->_nsites; ++i)
236 if (rep->_counts[i].gap == 0
237 && rep->_counts[i].nStates() > 1)
239 unsigned samplesize = rep->_totsam;
241 -= rep->_counts[i].n;
248 = (double(samplesize)
249 * (double(samplesize) - 1.0));
250 SSH += (rep->_counts[i].a > 0)
251 ?
double(rep->_counts[i].a)
258 SSH += (rep->_counts[i].g > 0)
259 ?
double(rep->_counts[i].g)
266 SSH += (rep->_counts[i].c > 0)
267 ?
double(rep->_counts[i].c)
274 SSH += (rep->_counts[i].t > 0)
275 ?
double(rep->_counts[i].t)
282 SSH += (rep->_counts[i].zero > 0)
284 rep->_counts[i].zero)
291 SSH += (rep->_counts[i].one > 0)
305 rep->_know_pi =
true;
339 assert(rep->_preprocessed);
341 for (
unsigned i = 0; i < rep->_nsites; ++i)
343 if (rep->_counts[i].gap == 0)
345 unsigned nstates = rep->_counts[i].nStates();
346 unsigned nsam_site = rep->_totsam - rep->_counts[i].n;
348 if (rep->_totMuts ==
true && nstates >= 2)
350 for (
unsigned i = 1; i < nsam_site; ++i)
351 denom += 1.0 /
double(i);
352 W += double(nstates - 1) / denom;
354 else if (rep->_totMuts ==
false && nstates >= 2)
356 for (
unsigned i = 1; i < nsam_site; ++i)
357 denom += 1.0 /
double(i);
403 assert(rep->_preprocessed);
404 if (rep->_NumPoly == 0)
406 if (!rep->_haveOutgroup)
407 return std::numeric_limits<double>::quiet_NaN();
409 bool anc_is_present = 0;
411 for (
unsigned i = 0; i < rep->_nsites; ++i)
413 if (rep->_derivedCounts[i].second.gap == 0)
417 unsigned sumDerCounts = 0;
418 sumDerCounts += rep->_derivedCounts[i].second.a;
419 sumDerCounts += rep->_derivedCounts[i].second.g;
420 sumDerCounts += rep->_derivedCounts[i].second.c;
421 sumDerCounts += rep->_derivedCounts[i].second.t;
422 sumDerCounts += rep->_derivedCounts[i].second.zero;
423 sumDerCounts += rep->_derivedCounts[i].second.one;
424 unsigned ancestralCounts
425 = samplesize - sumDerCounts
426 - rep->_derivedCounts[i].second.n;
435 anc_is_present = (rep->_derivedCounts[i].first ==
true 436 && ancestralCounts > 0)
443 = rep->_derivedCounts[i].second.nStates();
448 -= rep->_derivedCounts[i].second.n;
450 = (double(samplesize)
451 * (double(samplesize) - 1.0));
452 H += (rep->_derivedCounts[i].second.a
463 H += (rep->_derivedCounts[i].second.g
474 H += (rep->_derivedCounts[i].second.c
485 H += (rep->_derivedCounts[i].second.t
496 H += (rep->_derivedCounts[i]
508 H += (rep->_derivedCounts[i].second.one
521 && rep->_haveOutgroup)
529 if (rep->_derivedCounts[i].second.a
533 = rep->_derivedCounts[i]
536 if (rep->_derivedCounts[i].second.g
540 = rep->_derivedCounts[i]
543 if (rep->_derivedCounts[i].second.c
547 = rep->_derivedCounts[i]
550 if (rep->_derivedCounts[i].second.t
554 = rep->_derivedCounts[i]
557 if (rep->_derivedCounts[i].second.zero
561 = rep->_derivedCounts[i]
564 if (rep->_derivedCounts[i].second.one
568 = rep->_derivedCounts[i]
571 for (
int i = 0; i < 2; ++i)
573 double sample_size_adjust
578 * pow(
double(config[i]),
580 / ((
double(samplesize)
581 - sample_size_adjust)
582 * (double(samplesize)
634 if (!rep->_haveOutgroup)
636 return std::numeric_limits<double>::quiet_NaN();
638 assert(rep->_preprocessed);
640 if (rep->_NumPoly == 0)
642 bool anc_is_present = 0;
644 for (
unsigned i = 0; i < rep->_nsites; ++i)
646 if (rep->_derivedCounts[i].first ==
true 647 && rep->_derivedCounts[i].second.gap == 0)
651 unsigned sumDerCounts = 0;
652 sumDerCounts += rep->_derivedCounts[i].second.a;
653 sumDerCounts += rep->_derivedCounts[i].second.g;
654 sumDerCounts += rep->_derivedCounts[i].second.c;
655 sumDerCounts += rep->_derivedCounts[i].second.t;
656 sumDerCounts += rep->_derivedCounts[i].second.zero;
657 sumDerCounts += rep->_derivedCounts[i].second.one;
658 unsigned ancestralCounts
659 = samplesize - sumDerCounts
660 - rep->_derivedCounts[i].second.n;
669 anc_is_present = (rep->_derivedCounts[i].first ==
true 670 && ancestralCounts > 0)
677 = rep->_derivedCounts[i].second.nStates();
682 -= rep->_derivedCounts[i].second.n;
684 = (double(samplesize) - 1.0);
686 += (rep->_derivedCounts[i].second.a
689 rep->_derivedCounts[i]
694 += (rep->_derivedCounts[i].second.g
697 rep->_derivedCounts[i]
702 += (rep->_derivedCounts[i].second.c
705 rep->_derivedCounts[i]
710 += (rep->_derivedCounts[i].second.t
713 rep->_derivedCounts[i]
718 += (rep->_derivedCounts[i]
722 rep->_derivedCounts[i]
727 += (rep->_derivedCounts[i]
731 rep->_derivedCounts[i]
737 && rep->_haveOutgroup)
745 if (rep->_derivedCounts[i].second.a
749 = rep->_derivedCounts[i]
752 if (rep->_derivedCounts[i].second.g
756 = rep->_derivedCounts[i]
759 if (rep->_derivedCounts[i].second.c
763 = rep->_derivedCounts[i]
766 if (rep->_derivedCounts[i].second.t
770 = rep->_derivedCounts[i]
773 if (rep->_derivedCounts[i].second.zero
777 = rep->_derivedCounts[i]
780 if (rep->_derivedCounts[i].second.one
784 = rep->_derivedCounts[i]
787 for (
int i = 0; i < 2; ++i)
789 double sample_size_adjust
794 += (double(config[i]))
795 / (
double(samplesize)
812 assert(rep->_preprocessed);
814 for (
unsigned i = 0; i < rep->_nsites; ++i)
816 if (rep->_counts[i].nStates() > 1 && rep->_counts[i].gap == 0)
829 assert(rep->_preprocessed);
832 for (
unsigned i = 0; i < rep->_nsites; ++i)
834 unsigned nstates = (rep->_counts[i].gap == 0)
835 ? rep->_counts[i].nStates()
850 assert(rep->_preprocessed);
852 for (
unsigned i = 0; i < rep->_nsites; ++i)
854 unsigned curr_nsing = 0;
855 unsigned nstates = rep->_counts[i].nStates();
856 if (rep->_counts[i].gap == 0 && nstates > 1)
858 unsigned nsam = rep->_totsam - rep->_counts[i].n;
859 if (nsam == 2 && nstates == 2)
866 += (rep->_counts[i].a == 1) ? 1u : 0u;
868 += (rep->_counts[i].g == 1) ? 1u : 0u;
870 += (rep->_counts[i].c == 1) ? 1u : 0u;
872 += (rep->_counts[i].t == 1) ? 1u : 0u;
874 += (rep->_counts[i].zero == 1) ? 1u : 0u;
876 += (rep->_counts[i].one == 1) ? 1u : 0u;
892 if (!rep->_haveOutgroup)
894 assert(rep->_preprocessed);
896 for (
unsigned i = 0; i < rep->_nsites; ++i)
898 unsigned nsam = rep->_totsam;
899 unsigned curr_next = 0;
900 if (rep->_derivedCounts[i].first ==
true 901 && rep->_derivedCounts[i].second.gap == 0)
903 nsam -= rep->_derivedCounts[i].second.n;
904 curr_next += (rep->_derivedCounts[i].second.a == 1)
907 curr_next += (rep->_derivedCounts[i].second.g == 1)
910 curr_next += (rep->_derivedCounts[i].second.c == 1)
913 curr_next += (rep->_derivedCounts[i].second.t == 1)
916 curr_next += (rep->_derivedCounts[i].second.zero == 1)
919 curr_next += (rep->_derivedCounts[i].second.one == 1)
923 next += (nsam > 1) ? curr_next : 0u;
938 assert(rep->_preprocessed);
939 if (rep->_NumPoly == 0)
940 return std::numeric_limits<double>::quiet_NaN();
944 if (fabs(Pi - 0.) <= DBL_EPSILON && fabs(W - 0.) <= DBL_EPSILON)
973 assert(rep->_preprocessed);
974 if (rep->_NumPoly == 0)
975 return std::numeric_limits<double>::quiet_NaN();
976 assert(rep->_haveOutgroup ==
true);
985 double thetasq = (likeThorntonAndolfatto ==
false)
986 ? S * (S - 1) / (a * a + b)
989 double vThetal = (rep->_totsam * theta) / (2.0 * (rep->_totsam - 1.0))
990 + (2.0 * pow(rep->_totsam / (rep->_totsam - 1.0), 2.0)
996 = (3.0 * rep->_totsam * (rep->_totsam + 1.0) * theta
997 + 2.0 * (rep->_totsam * rep->_totsam + rep->_totsam + 3.0)
999 / (9 * rep->_totsam * (rep->_totsam - 1.0));
1002 = ((rep->_totsam + 1.0) / (3.0 * (rep->_totsam - 1.0))) * theta
1003 + ((7.0 * rep->_totsam * rep->_totsam + 3.0 * rep->_totsam - 2.0
1004 - 4.0 * rep->_totsam * (rep->_totsam + 1.0) * b_n_plus1)
1005 / (2.0 * pow((rep->_totsam - 1.0), 2.0)))
1008 double Hpr = pi -
thetal;
1009 Hpr /= pow((vThetal + vPi - 2.0 * cov), 0.5);
1021 assert(rep->_preprocessed);
1022 if (rep->_NumPoly == 0)
1023 return std::numeric_limits<double>::quiet_NaN();
1029 else if (!(rep->_totMuts))
1033 double a1, a2, b1, b2, c1, c2, e1, e2;
1037 b1 = (rep->_totsam + 1.0) / (3.0 * (rep->_totsam - 1.0));
1038 b2 = (2.0 * (pow(rep->_totsam, 2.0) + rep->_totsam + 3.0))
1039 / (9.0 * rep->_totsam * (rep->_totsam - 1.0));
1041 c2 = b2 - (rep->_totsam + 2.0) / (a1 * rep->_totsam)
1042 + a2 / pow(a1, 2.0);
1044 e2 = c2 / (pow(a1, 2.0) + a2);
1045 double denominator = pow((e1 * S + e2 * S * (S - 1.0)), 0.5);
1046 return (denominator);
1065 assert(rep->_preprocessed);
1066 std::lock_guard<std::mutex> lock(rep->instance_lock);
1067 if (!(rep->_CalculatedDandV))
1069 if (rep->_NumPoly == 0)
1075 if (rep->_data->size() > 0)
1080 std::set<string, uniqueSeq> unique_haplotypes;
1081 if (rep->_haveOutgroup)
1083 unique_haplotypes.insert(rep->_data->begin(),
1086 unique_haplotypes.insert(
1087 rep->_data->begin() + rep->_outgroup + 1,
1092 unique_haplotypes.insert(rep->_data->begin(),
1095 std::vector<std::string> vuhaps(
1096 unique_haplotypes.size());
1097 rep->_DVK = unsigned(unique_haplotypes.size());
1098 std::move(unique_haplotypes.begin(),
1099 unique_haplotypes.end(), vuhaps.begin());
1100 double homozygosity = 0.0;
1101 for (
auto &uh : vuhaps)
1104 if (rep->_haveOutgroup)
1106 c =
static_cast<double>(std::count_if(
1107 rep->_data->begin(),
1110 [&uh](
const std::string &__s) {
1114 c +=
static_cast<double>(std::count_if(
1116 + rep->_outgroup + 1,
1118 [&uh](
const std::string &__s) {
1125 c =
static_cast<double>(std::count_if(
1126 rep->_data->begin(),
1128 [&uh](
const std::string &__s) {
1133 c /=
static_cast<double>(rep->_totsam);
1134 homozygosity += pow(c, 2.);
1136 rep->_DVH -= homozygosity;
1137 rep->_DVH *= rep->_totsam / (rep->_totsam - 1.0);
1138 rep->_CalculatedDandV = 1;
1151 assert(rep->_preprocessed);
1153 return rep->_walls_B;
1157 PolySNP::WallStats(
void)
const 1159 assert(rep->_preprocessed);
1160 if (!rep->_calculated_wall_stats)
1165 for (std::vector<stateCounter>::const_iterator itr
1166 = rep->_counts.begin();
1167 itr < rep->_counts.end(); ++itr)
1169 if (itr->nStates() == 2 && itr->gap == 0)
1175 std::set<std::basic_string<char>,
1176 Sequence::uniqueSeq>::size_type nhap_curr,
1185 for (
unsigned site1 = 0; site1 < rep->_nsites - 1;
1188 for (
unsigned site2 = site1 + 1;
1189 site2 < rep->_nsites; ++site2)
1191 if (rep->_counts[site1].nStates() == 2
1192 && rep->_counts[site2].nStates()
1197 std::set<string, uniqueSeq>
1200 for (
unsigned i = 0;
1201 i < rep->_nsam; ++i)
1203 if ((!rep->_haveOutgroup)
1204 || (rep->_haveOutgroup
1205 && i != rep->_outgroup))
1221 = unique_haplotypes.size();
1226 ++rep->_walls_Bprime;
1233 ++rep->_walls_Bprime;
1238 nhap_left = nhap_curr;
1244 = double(rep->_walls_Bprime) / (double(S - 1));
1246 = (double(rep->_walls_Bprime) + double(A))
1252 = std::numeric_limits<double>::quiet_NaN();
1253 rep->_walls_Bprime = 0;
1255 = std::numeric_limits<double>::quiet_NaN();
1258 rep->_calculated_wall_stats =
true;
1269 assert(rep->_preprocessed);
1271 return rep->_walls_Bprime;
1282 assert(rep->_preprocessed);
1284 return rep->_walls_Q;
1295 if (rep->_data->empty() || !
NumPoly())
1296 return std::numeric_limits<double>::quiet_NaN();
1298 double variance = 3.0 * rep->_totsam * (rep->_totsam + 1.0) * Pi
1299 + 2.0 * (pow(rep->_totsam, 2.0) + rep->_totsam + 3.0)
1301 variance /= (11.0 * pow(rep->_totsam, 2.0) - 7.0 * rep->_totsam + 6.0);
1313 if (rep->_data->empty() || !
NumPoly())
1314 return std::numeric_limits<double>::quiet_NaN();
1317 = (3.0 * pow(rep->_totsam, 2.0) - 3.0 * rep->_totsam + 2.0) * Pi
1318 + 2.0 * rep->_totsam * (rep->_totsam - 1.0) * pow(Pi, 2.0);
1319 variance /= (11.0 * pow(rep->_totsam, 2.0) - 7.0 * rep->_totsam + 6.0);
1331 if (rep->_data->empty() || !
NumPoly())
1332 return std::numeric_limits<double>::quiet_NaN();
1334 double variance = 2.0 * (3.0 * rep->_totsam - 1.0) * Pi
1335 + 2.0 * (2.0 * rep->_totsam + 3.0) * pow(Pi, 2.0);
1336 variance /= (11.0 * pow(rep->_totsam, 2.0) - 7.0 * rep->_totsam + 6.0);
1347 if (rep->_data->empty() || !
NumPoly())
1348 return std::numeric_limits<double>::quiet_NaN();
1352 double variance = pow(a1, 2.0) * S + a2 * pow(S, 2.0);
1353 variance /= pow(a1, 2.0) * (pow(a1, 2.0) + a2);
1368 assert(rep->_preprocessed);
1370 if (rep->_NumPoly == 0 || !rep->_haveOutgroup)
1371 return std::numeric_limits<double>::quiet_NaN();
1378 + (pow(a, 2.0) / (b + pow(a, 2.0))
1379 * (c - (rep->_totsam + 1.0) / (rep->_totsam - 1.0)));
1380 double uD = a - 1.0 - vD;
1381 double D = NumMut - a * double(ExternalMutations);
1382 D /= pow((uD * NumMut + vD * pow(NumMut, 2.0)), 0.5);
1396 assert(rep->_preprocessed);
1397 if (rep->_NumPoly == 0 || !rep->_haveOutgroup)
1398 return std::numeric_limits<double>::quiet_NaN();
1408 + 2.0 * (pow(rep->_totsam, 2.0) + rep->_totsam + 3.0)
1409 / (9.0 * rep->_totsam * (double(rep->_totsam - 1.0)));
1410 vF -= (2.0 / (rep->_totsam - 1.0));
1411 vF /= (pow(a, 2.0) + b);
1415 + (rep->_totsam + 1.0) / (3.0 * (double(rep->_totsam - 1.0)));
1416 uF -= 4.0 * ((rep->_totsam + 1.0) / (pow(rep->_totsam - 1.0, 2.0)))
1417 * (a_n_plus1 - 2.0 * rep->_totsam / (rep->_totsam + 1.0));
1421 double F = Pi - ExternalMutations;
1422 F /= pow(uF * NumMut + vF * pow(NumMut, 2.0), 0.5);
1434 assert(rep->_preprocessed);
1435 if (rep->_NumPoly == 0)
1436 return std::numeric_limits<double>::quiet_NaN();
1444 double vD = pow(rep->_totsam / (rep->_totsam - 1.0), 2.0) * b;
1445 vD += pow(a, 2.0) * d;
1446 vD -= 2.0 * (rep->_totsam * a * (a + 1.0))
1447 / (pow(
double(rep->_totsam - 1.0), 2.0));
1448 vD /= (pow(a, 2.0) + b);
1450 double uD = (rep->_totsam / (rep->_totsam - 1.0))
1451 * (a - (rep->_totsam / (rep->_totsam - 1.0)))
1454 double DStar = (rep->_totsam / (rep->_totsam - 1.0)) * NumMut
1455 - a *
double(Singletons);
1456 DStar /= pow(uD * NumMut + vD * pow(NumMut, 2.0), 0.5);
1471 assert(rep->_preprocessed);
1472 if (rep->_NumPoly == 0)
1473 return std::numeric_limits<double>::quiet_NaN();
1483 double vF = 2.0 * pow(rep->_totsam, 3.0)
1484 + 110.0 * pow(rep->_totsam, 2.0) - 255.0 * rep->_totsam
1486 vF /= (9.0 * pow(rep->_totsam, 2.0) * (rep->_totsam - 1.0));
1487 vF += (((2.0 * (rep->_totsam - 1.0) * a) / pow(rep->_totsam, 2.0))
1488 - (8.0 * b / rep->_totsam));
1489 vF /= (pow(a, 2.0) + b);
1491 double uF = (4.0 * pow(rep->_totsam, 2.0) + 19.0 * rep->_totsam + 3.0
1492 - 12.0 * (rep->_totsam + 1.0) * a_n_plus1);
1493 uF /= (3.0 * rep->_totsam * (rep->_totsam - 1.0));
1498 - (((rep->_totsam - 1.0) / rep->_totsam)) * double(Singletons);
1499 FStar /= pow((uF * NumMut + vF * pow(NumMut, 2.0)), 0.5);
1511 assert(rep->_preprocessed);
1514 for (i = 1; i < int(rep->_totsam); ++i)
1515 a += 1. /
double(i);
1526 assert(rep->_preprocessed);
1529 for (i = 1; i < int(rep->_totsam) + 1; ++i)
1531 a += 1. / double(i);
1543 assert(rep->_preprocessed);
1546 for (i = 1; i < int(rep->_totsam); ++i)
1547 b += 1. / (pow(
double(i), 2.0));
1559 assert(rep->_preprocessed);
1562 for (i = 1; i < int(rep->_totsam) + 1; ++i)
1563 b += 1. / (pow(
double(i), 2.0));
1580 assert(rep->_preprocessed);
1581 double c = 0.0, a =
a_sub_n();
1582 if (fabs(rep->_totsam - 2.) <= DBL_EPSILON)
1588 c = 2.0 * (rep->_totsam * a - 2.0 * (rep->_totsam - 1.0));
1589 c /= ((rep->_totsam - 1.0) * (rep->_totsam - 2.0));
1602 assert(rep->_preprocessed);
1603 double a_n_plus1, c, d;
1606 d = c + (rep->_totsam - 2.0) / (pow(rep->_totsam - 1.0, 2.0));
1607 d += (2.0 / (rep->_totsam - 1.0))
1608 * (1.5 - ((2.0 * a_n_plus1 - 3.0) / (rep->_totsam - 2.0))
1609 - 1.0 / rep->_totsam);
1624 if (!(rep->_CalculatedDandV))
1641 if (!(rep->_CalculatedDandV))
1657 assert(rep->_preprocessed);
1658 if (rep->_NumPoly == 0)
1659 return std::numeric_limits<double>::quiet_NaN();
1673 assert(rep->_preprocessed);
1674 if (rep->_NumPoly < 2)
1676 unsigned a, b, e, numgametes, Rmin = 0, x = 0;
1679 for (a = x + 1; a < rep->_nsites; ++a)
1682 unsigned states1 = 0;
1685 states1 = rep->_counts[a].nStates();
1687 c11 = (c11 ==
'Z' && rep->_counts[a].a > 0) ?
'A' :
'Z';
1688 c11 = (c11 ==
'Z' && rep->_counts[a].g > 0) ?
'G' : c11;
1689 c11 = (c11 ==
'Z' && rep->_counts[a].c > 0) ?
'C' : c11;
1690 c11 = (c11 ==
'Z' && rep->_counts[a].t > 0) ?
'T' : c11;
1691 c11 = (c11 ==
'Z' && rep->_counts[a].zero > 0) ?
'0' : c11;
1692 c11 = (c11 ==
'Z' && rep->_counts[a].one > 0) ?
'1' : c11;
1694 c12 = (c12 ==
'Z' && c11 !=
'A' && rep->_counts[a].a > 0)
1697 c12 = (c12 ==
'Z' && c11 !=
'G' && rep->_counts[a].g > 0)
1700 c12 = (c12 ==
'Z' && c11 !=
'C' && rep->_counts[a].c > 0)
1703 c12 = (c12 ==
'Z' && c11 !=
'T' && rep->_counts[a].t > 0)
1706 c12 = (c12 ==
'Z' && c11 !=
'0' && rep->_counts[a].zero > 0)
1709 c12 = (c12 ==
'Z' && c11 !=
'1' && rep->_counts[a].one > 0)
1713 for (b = (flag ==
false) ? x : a - 1; b < a; ++b)
1717 unsigned states2 = rep->_counts[b].nStates();
1719 if (states1 == 2 && states2 == 2)
1721 char c21 =
'Z', c22 =
'Z';
1722 c21 = (c21 ==
'Z' && rep->_counts[b].a > 0)
1725 c21 = (c21 ==
'Z' && rep->_counts[b].g > 0)
1728 c21 = (c21 ==
'Z' && rep->_counts[b].c > 0)
1731 c21 = (c21 ==
'Z' && rep->_counts[b].t > 0)
1734 c21 = (c21 ==
'Z' && rep->_counts[b].zero > 0)
1737 c21 = (c21 ==
'Z' && rep->_counts[b].one > 0)
1741 c22 = (c22 ==
'Z' && c21 !=
'A' 1742 && rep->_counts[b].a > 0)
1745 c22 = (c22 ==
'Z' && c21 !=
'G' 1746 && rep->_counts[b].g > 0)
1749 c22 = (c22 ==
'Z' && c21 !=
'C' 1750 && rep->_counts[b].c > 0)
1753 c22 = (c22 ==
'Z' && c21 !=
'T' 1754 && rep->_counts[b].t > 0)
1757 c22 = (c22 ==
'Z' && c21 !=
'0' 1758 && rep->_counts[b].zero > 0)
1761 c22 = (c22 ==
'Z' && c21 !=
'1' 1762 && rep->_counts[b].one > 0)
1766 for (e = 0; e < rep->_nsam; ++e)
1768 if (!rep->_haveOutgroup
1769 || (rep->_haveOutgroup
1770 && e != rep->_outgroup))
1771 if (toupper((*rep->_data)[e][a])
1773 && toupper((*rep->_data)[e][b])
1780 for (e = 0; e < rep->_nsam; ++e)
1782 if (!rep->_haveOutgroup
1783 || (rep->_haveOutgroup
1784 && e != rep->_outgroup))
1785 if (toupper((*rep->_data)[e][a])
1787 && toupper((*rep->_data)[e][b])
1794 for (e = 0; e < rep->_nsam; ++e)
1796 if (!rep->_haveOutgroup
1797 || (rep->_haveOutgroup
1798 && e != rep->_outgroup))
1799 if (toupper((*rep->_data)[e][a])
1801 && toupper((*rep->_data)[e][b])
1808 for (e = 0; e < rep->_nsam; ++e)
1810 if (!rep->_haveOutgroup
1811 || (rep->_haveOutgroup
1812 && e != rep->_outgroup))
1813 if (toupper((*rep->_data)[e][a])
1815 && toupper((*rep->_data)[e][b])
1822 if (numgametes == 4)
1836 std::vector<PairwiseLDstats>
1838 const double &max_marker_distance)
const 1855 assert(rep->_preprocessed);
1856 if (rep->_NumPoly < 2)
1857 return std::vector<PairwiseLDstats>();
1859 rep->_outgroup, mincount,
1860 max_marker_distance);
The base class for polymorphism tables.
bool operator()(const std::pair< key, value > &l, const std::pair< key, value > &r) const
virtual double FuLiF(void) const
double thetal(const AlleleCountMatrix &ac, const std::int8_t refstate)
Zeng et al. .
Methods dealing with recombination.
virtual unsigned NumMutations(void) const
double DandVH(void) const
virtual unsigned NumSingletons(void) const
virtual double ThetaH(void) const
double HudsonsC(void) const
unsigned NumPoly(void) const
virtual double TajimasD(void) const
Sequence::PolyTable, a virtual base class for polymorphism tables.
The namespace in which this library resides.
virtual double ThetaW(void) const
double b_sub_n(void) const
virtual unsigned Minrec(void) const
double VarThetaW(void) const
unsigned DandVK(void) const
declaration of Sequence::PolySNP, a class to analyze SNP data
void DepaulisVeuilleStatistics(void) const
double b_sub_n_plus1(void) const
double SamplingVarPi(void) const
virtual double WallsB(void) const
double a_sub_n_plus1(void) const
std::vector< PairwiseLDstats > Disequilibrium(const Sequence::PolyTable *data, const bool &haveOutgroup=false, const unsigned &outgroup=0, const unsigned &mincount=1, const double max_distance=std::numeric_limits< double >::max()) __attribute__((deprecated))
Calculate pairwise LD for a Sequence::PolyTable.
PolySNP(const Sequence::PolyTable *data, bool haveOutgroup=false, unsigned outgroup=0, bool totMuts=true)
virtual double FuLiFStar(void) const
virtual unsigned NumExternalMutations(void) const
const unsigned SEQMAXUNSIGNED
virtual double Dnominator(void) const
virtual double ThetaL(void) const
double variance(iterator beg, iterator end)
virtual double ThetaPi(void) const
double c_sub_n(void) const
double HudsonsC(const Sequence::PolyTable *data, const bool &haveOutgroup, const unsigned &outgroup) __attribute__((deprecated))
virtual unsigned WallsBprime(void) const
virtual double Hprime(const bool &likeThorntonAndolfatto=false) const
namespace Sequence::Recombination
double a_sub_n(void) const
std::vector< PairwiseLDstats > Disequilibrium(const unsigned &mincount=1, const double &max_marker_distance=std::numeric_limits< double >::max()) const
virtual double WallsQ(void) const
bool Different(const std::string &seq1, const std::string &seq2, const bool &skip_missing=true, const bool &nucleic_acid=true)
double d_sub_n(void) const
double StochasticVarPi(void) const
virtual double FuLiDStar(void) const
declaration of Sequence::stateCounter, a class to keep track of nucleotide counts either at a site in...
delcaration of routines for comparing DNA sequences This file declares a set of functions useful for ...
virtual double FuLiD(void) const