1 #include <Sequence/StateCounts.hpp> 7 StateCounts::StateCounts()
8 : counts(
std::vector<
std::int32_t>(max_allele + 1, 0)),
9 max_allele_idx{ 0 }, n{ 0u }, refstate(-1)
13 StateCounts::StateCounts(
const std::int8_t refstate_)
14 : counts(
std::vector<
std::int32_t>(max_allele + 1, 0)),
15 max_allele_idx{ 0 },
n{ 0u },
refstate(refstate_)
25 for (std::size_t i = 0; i < row.
size(); ++i)
31 ++
counts[
static_cast<std::size_t
>(ri)];
33 max_allele_idx, static_cast<std::size_t>(ri));
37 throw std::invalid_argument(
38 "reserved value encountered");
44 StateCounts::operator()(
const RowView& row)
49 for (std::size_t i = 0; i < row.
size(); ++i)
55 ++
counts[
static_cast<std::size_t
>(ri)];
57 max_allele_idx, static_cast<std::size_t>(ri));
61 throw std::invalid_argument(
62 "reserved value encountered");
67 std::vector<StateCounts>
69 const std::vector<std::int8_t>& refstates)
72 refstates.begin(), refstates.end(),
75 throw std::invalid_argument(
"reserved value encountered");
77 if (refstates.size() != m.
nsites)
79 throw std::invalid_argument(
"refstates.size() != m.nsites");
81 std::vector<StateCounts> rv;
83 for (std::size_t i = 0; i < m.
nsites; ++i)
88 rv.emplace_back(std::move(c));
93 std::vector<StateCounts>
98 throw std::invalid_argument(
"reserved value encountered");
100 std::vector<StateCounts> rv;
102 for (std::size_t i = 0; i < m.
nsites; ++i)
107 rv.emplace_back(std::move(c));
112 std::vector<StateCounts>
Implementation details for Sequence::RowView and Sequence::ConstRowView.
Track character state occurrence at a site in a VariantMatrix.
std::size_t size() const
Number of elements.
std::vector< StateCounts > process_variable_sites(const VariantMatrix &m, const std::vector< std::int8_t > &refstates)
std::size_t max_allele_idx
The max allelic value seen.
std::vector< std::int32_t > counts
Keep track of (state, count) pairs.
The namespace in which this library resides.
ConstRowView get_RowView(const VariantMatrix &m, const std::size_t row)
Return a ConstRowView from VariantMatrix m at row row. std::out_of_range is thrown if row is out of r...
std::size_t nsites
Number of sites in data set.
std::uint32_t n
The sample size at this site. Excluded missing data.
Matrix representation of variation data.
static const std::int8_t mask
Reserved value for masked data.