5 #include <Sequence/AlleleCountMatrix.hpp> 7 using count_type = std::vector<Sequence::AlleleCounts>;
12 typename count_type::value_type
13 add_counts(
const T& row,
const std::size_t nsam,
const bool nonref,
14 const std::int8_t refstate)
16 if (nonref && refstate == -1)
18 return count_type::value_type{ -1, -1 };
20 std::size_t refindex =
static_cast<std::size_t
>(refstate);
22 && refindex >= static_cast<std::size_t>(row.second - row.first))
24 throw std::invalid_argument(
"reference state out of range");
26 typename count_type::value_type rv{ 0, 0 };
28 for (
auto i = row.first; i != row.second; ++i)
35 && static_cast<std::size_t>(i - row.first)
42 rv.nmissing =
static_cast<int>(nsam) - nnon_missing;
53 for (std::size_t i = 0; i < m.nrow; ++i)
56 rv.emplace_back(add_counts(r, m.nsam,
false, -1));
63 const std::vector<std::int8_t>& refstates)
65 if (refstates.size() != m.nrow)
67 throw std::invalid_argument(
"number of reference states does " 68 "not equal number of sites");
71 for (std::size_t i = 0; i < m.nrow; ++i)
74 rv.emplace_back(add_counts(r, m.nsam,
true, refstates[i]));
81 const std::int8_t refstate)
84 for (std::size_t i = 0; i < m.nrow; ++i)
87 rv.emplace_back(add_counts(r, m.nsam,
true, refstate));
std::vector< AlleleCounts > allele_counts(const AlleleCountMatrix &m)
Count number of alleles at each site.
The namespace in which this library resides.
Count alleles at variable sites.
Matrix representation of allele counts in a VariantMatrix To be constructed.
std::vector< AlleleCounts > non_reference_allele_counts(const AlleleCountMatrix &m, const std::int8_t refstate)
Count number of non-reference alleles at each site.