libsequence  1.9.5
AlleleCountMatrix.hpp
1 #ifndef SEQUENCE_ALLELE_COUNT_MATRIX_HPP
2 #define SEQUENCE_ALLELE_COUNT_MATRIX_HPP
3 
4 #include <cstdint>
5 #include <vector>
6 #include <utility>
7 #include <stdexcept>
8 #include <Sequence/VariantMatrix.hpp>
9 
10 namespace Sequence
11 {
15  {
16  private:
17  static std::vector<std::int32_t> init_counts(const VariantMatrix& m);
18 
19  public:
20  const std::vector<std::int32_t> counts;
21  using value_type = std::vector<std::int32_t>::value_type;
22  const std::size_t ncol;
23  const std::size_t nrow;
24  const std::size_t nsam;
25  explicit AlleleCountMatrix(const VariantMatrix& m);
26 
30  template <typename T>
31  AlleleCountMatrix(T&& t, const std::size_t nc_, const std::size_t nr_,
32  const std::size_t n_)
33  : counts(std::forward<T>(t)), ncol{ nc_ }, nrow{ nr_ }, nsam{ n_ }
34  {
35  if (ncol * nrow != counts.size())
36  {
37  throw std::invalid_argument(
38  "incorrect dimensions for AlleleCountMatrix");
39  }
40  }
41  std::pair<std::vector<std::int32_t>::const_iterator,
42  std::vector<std::int32_t>::const_iterator>
43  row(const std::size_t) const;
44  };
45 } // namespace Sequence
46 
47 #endif
STL namespace.
The namespace in which this library resides.
Matrix representation of variation data.
AlleleCountMatrix(T &&t, const std::size_t nc_, const std::size_t nr_, const std::size_t n_)
Matrix representation of allele counts in a VariantMatrix To be constructed.