1 #ifndef SEQUENCE_VARIANT_MATRIX_MSFORMAT_HPP__ 2 #define SEQUENCE_VARIANT_MATRIX_MSFORMAT_HPP__ 5 #include <Sequence/VariantMatrix.hpp> 18 template <
typename streamtype>
23 while (!input_stream.eof())
31 input_stream >> S >> temp;
32 std::vector<double> pos(S);
33 for (std::size_t i = 0; i < S; ++i)
35 input_stream >> pos[i];
37 std::vector<std::int8_t> data;
39 while (!input_stream.eof()
40 &&
static_cast<char>(input_stream.peek()) !=
'/')
42 input_stream >> next_token >> std::ws;
43 data.push_back((next_token ==
'0') ? 0 : 1);
45 input_stream >> std::ws;
47 decltype(data) data_t(data.size(), -1);
48 std::size_t nsam = data.size() /
static_cast<std::size_t
>(S);
50 for (std::size_t i = 0; i < static_cast<std::size_t>(S); ++i)
52 for (std::size_t j = 0; j < nsam; ++j)
54 data_t[k++] = data[i + j * S];
60 template <
typename output_stream>
71 o <<
"//\nsegsites: " << m.
nsites <<
"\npositions: ";
77 for (std::size_t i = 0; i < m.
nsam; ++i)
80 for (
auto state : col)
82 o << static_cast<int>(state);
VariantMatrix from_msformat(streamtype &input_stream)
Create VariantMatrix from "ms"-like input format.
The namespace in which this library resides.
std::size_t nsites
Number of sites in data set.
std::vector< double > positions
Position of sites.
Matrix representation of variation data.
std::size_t nsam
Sample size of data set.
ConstColView get_ConstColView(VariantMatrix &m, const std::size_t col)
Return a ConstColView from VariantMatrix m at col col. std::out_of_range is thcoln if col is out of r...
void to_msformat(const VariantMatrix &m, output_stream &o)
Write VariantMatrix in "ms" format.