33 const auto& gffmap = internal_json::extract_typed_object_from_metadata(metadata.
other,
"gff_file");
35 const std::string& vstring = internal_json::extract_string_from_typed_object(gffmap,
"version",
"gff_file");
36 auto version = ritsuko::parse_version_string(vstring.c_str(), vstring.size(),
true);
37 if (version.major != 1) {
38 throw std::runtime_error(
"unsupported version string '" + vstring +
"'");
41 auto fpath = path /
"file.";
43 const std::string& fstring = internal_json::extract_string_from_typed_object(gffmap,
"format",
"gff_file");
44 if (fstring ==
"GFF2") {
46 }
else if (fstring ==
"GFF3") {
49 throw std::runtime_error(
"unknown value '" + fstring +
"' for 'gff_file.format' property");
53 bool indexed = internal_files::is_indexed(gffmap);
62 internal_files::check_gzip_signature(fpath);
64 if (fstring ==
"GFF3") {
65 const std::string expected =
"##gff-version 3";
66 const size_t expected_len = expected.size();
68 auto reader = internal_other::open_reader<byteme::GzipFileReader>(fpath, expected_len);
69 byteme::PerByte<> pb(&reader);
70 bool okay = pb.valid();
72 for (
size_t i = 0; i < expected_len; ++i) {
74 throw std::runtime_error(
"incomplete GFF3 file signature for '" + fpath.string() +
"'");
76 if (pb.get() != expected[i]) {
77 throw std::runtime_error(
"incorrect GFF3 file signature for '" + fpath.string() +
"'");
86 internal_files::check_gzip_signature(ixpath);
87 internal_files::check_signature<byteme::GzipFileReader>(ixpath,
"TBI\1", 4,
"tabix");
void validate(const std::filesystem::path &path, const ObjectMetadata &metadata, Options &options)
Definition gff_file.hpp:32
std::function< void(const std::filesystem::path &, const ObjectMetadata &, Options &, bool)> gff_file_strict_check
Definition utils_public.hpp:215