1#ifndef SINGLEPP_LOADERS_MARKERS_HPP
2#define SINGLEPP_LOADERS_MARKERS_HPP
4#include "byteme/PerByte.hpp"
5#include "byteme/RawFileReader.hpp"
6#include "byteme/GzipFileReader.hpp"
7#include "byteme/ZlibBufferReader.hpp"
45template<
typename Index_>
49 std::unique_ptr<byteme::PerByteInterface<char> > pbptr;
51 pbptr.reset(
new byteme::PerByteParallel<char, byteme::Reader*>(&reader));
53 pbptr.reset(
new byteme::PerByteSerial<char, byteme::Reader*>(&reader));
57 bool okay = pb.valid();
60 size_t first = 0, second = 0;
61 for (
int l = 0; l < 2; ++l) {
62 auto& current = (l == 0 ? first : second);
63 bool non_empty =
false;
71 throw std::runtime_error(
"empty field detected in the label indices");
74 }
else if (x ==
'\n') {
77 }
else if (!std::isdigit(x)) {
78 throw std::runtime_error(
"label indices should be integers");
87 throw std::runtime_error(
"expected at least three tab-separated fields on each line");
91 if (first >= markers.size()) {
92 markers.resize(first + 1);
94 auto& fmarkers = markers[first];
95 if (second >= fmarkers.size()) {
96 fmarkers.resize(second + 1);
98 auto& values = fmarkers[second];
99 if (!values.empty()) {
100 throw std::runtime_error(
"multiple marker sets listed for a single pairwise comparison");
104 bool non_empty =
false;
110 if (std::isdigit(x)) {
113 current += (x -
'0');
115 }
else if (x ==
'\t') {
117 throw std::runtime_error(
"gene index fields should not be empty");
119 values.push_back(current);
123 }
else if (x ==
'\n') {
127 throw std::runtime_error(
"gene index fields should be integers");
134 throw std::runtime_error(
"gene index fields should not be empty");
136 values.push_back(current);
140 size_t expected_nlabels = markers.size();
141 for (
const auto& m : markers) {
142 expected_nlabels = std::max(expected_nlabels, m.size());
144 markers.resize(expected_nlabels);
145 for (
auto& m : markers) {
146 m.resize(expected_nlabels);
171template<
typename Index_ = singlepp::DefaultIndex>
173 byteme::RawFileReaderOptions read_opt;
175 byteme::RawFileReader reader(path, read_opt);
176 return internal::load_markers<Index_>(reader, options.
parallel);
189template<
typename Index_ = singlepp::DefaultIndex>
191 byteme::GzipFileReaderOptions read_opt;
193 byteme::GzipFileReader reader(path, read_opt);
194 return internal::load_markers<Index_>(reader, options.
parallel);
208template<
typename Index_ = singlepp::DefaultIndex>
210 byteme::ZlibBufferReaderOptions read_opt;
213 byteme::ZlibBufferReader reader(buffer, len, read_opt);
214 return internal::load_markers<Index_>(reader, options.
parallel);
Load pre-processed single reference datasets.
Definition labels.hpp:23
singlepp::Markers< Index_ > load_markers_from_gzip_file(const char *path, const LoadMarkersOptions &options)
Definition markers.hpp:190
singlepp::Markers< Index_ > load_markers_from_zlib_buffer(const unsigned char *buffer, size_t len, const LoadMarkersOptions &options)
Definition markers.hpp:209
singlepp::Markers< Index_ > load_markers_from_text_file(const char *path, const LoadMarkersOptions &options)
Definition markers.hpp:172
std::vector< std::vector< std::vector< Index_ > > > Markers
Options for loading markers.
Definition markers.hpp:28
bool parallel
Definition markers.hpp:32
size_t buffer_size
Definition markers.hpp:37