33 const std::string type_name =
"gff_file";
34 const auto& gffmap = internal_json::extract_typed_object_from_metadata(metadata.
other, type_name);
36 const std::string version_name =
"version";
37 const std::string& vstring = internal_json::extract_string_from_typed_object(gffmap, version_name, type_name);
38 auto version = ritsuko::parse_version_string(vstring.c_str(), vstring.size(),
true);
39 if (version.major != 1) {
40 throw std::runtime_error(
"unsupported version string '" + vstring +
"'");
43 auto fpath = path /
"file.";
44 const std::string format_name =
"format";
45 const std::string& fstring = internal_json::extract_string_from_typed_object(gffmap, format_name, type_name);
46 if (fstring ==
"GFF2") {
48 }
else if (fstring ==
"GFF3") {
51 throw std::runtime_error(
"unknown value '" + fstring +
"' for 'gff_file.format' property");
55 bool indexed = internal_files::is_indexed(gffmap);
64 internal_files::check_gzip_signature(fpath);
66 if (fstring ==
"GFF3") {
67 const std::string expected =
"##gff-version 3";
68 const size_t expected_len = expected.size();
70 auto reader = internal_other::open_reader<byteme::GzipFileReader>(fpath, [&]{
71 byteme::GzipFileReaderOptions gopt;
72 gopt.buffer_size = expected_len;
75 byteme::PerByteSerial<char> pb(std::move(reader));
76 bool okay = pb.valid();
78 for (
size_t i = 0; i < expected_len; ++i) {
80 throw std::runtime_error(
"incomplete GFF3 file signature for '" + fpath.string() +
"'");
82 if (pb.get() != expected[i]) {
83 throw std::runtime_error(
"incorrect GFF3 file signature for '" + fpath.string() +
"'");
92 internal_files::check_gzip_signature(ixpath);
93 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