35inline std::uint64_t
validate_genes(
const std::string& prefix,
const std::vector<std::string>& types) {
37 uint64_t num_genes = 0;
38 for (
auto t : types) {
39 auto candidate = internal::check_genes(prefix + t +
".tsv.gz");
41 num_genes = candidate;
43 }
else if (candidate != num_genes) {
44 throw std::runtime_error(
"inconsistent number of genes between types (" + std::to_string(num_genes) +
" for " + types.front() +
", " + std::to_string(candidate) +
" for " + t +
")");
49 throw std::runtime_error(
"at least one gene name type should be present");
67 const std::string vpath = prefix +
"gene-version.tsv";
68 internal::Version version;
69 if (std::filesystem::exists(vpath)) {
70 version = internal::check_version(vpath);
73 std::vector<std::string> types;
74 if (version < internal::Version(0, 2, 0)) {
79 std::filesystem::path path(prefix);
80 auto dir = path.parent_path();
81 auto raw_prefix = path.filename().string();
83 for (
const auto& entry : std::filesystem::directory_iterator(dir)) {
84 std::string name = entry.path().filename().string();
85 if (name.rfind(raw_prefix, 0) != 0) {
88 if (name.size() < 6) {
91 size_t ext_loc = name.size() - 7;
92 if (name.rfind(
".tsv.gz", ext_loc) != ext_loc) {
95 types.push_back(name.substr(raw_prefix.size(), ext_loc - raw_prefix.size()));
104 const auto manifest_path = prefix +
"gene-types.tsv";
105 byteme::RawFileReader reader(manifest_path.c_str(), {});
106 byteme::SerialBufferedReader<char, internal::I<
decltype(&reader)> > pb(&reader, 65536);
108 throw std::runtime_error(
"expected at least one gene identifier type in '" + manifest_path +
"'");
113 char current = pb.get();
114 while (current !=
'\n') {
115 if ((current >=
'a' && current <=
'z') || (current >=
'A' && current <=
'Z') || (current >=
'0' && current <=
'9')) {
118 throw std::runtime_error(
"gene identifier type should only contain alphanumeric characters in '" + manifest_path +
"'");
121 throw std::runtime_error(
"premature termination of gene identifier type in '" + manifest_path +
"'");
126 if (type.size() == 0) {
127 throw std::runtime_error(
"empty gene identifier type in '" + manifest_path +
"'");
129 types.push_back(std::move(type));