Skip to content

Commit

Permalink
Add basic recognition of D4 quantitative interval format
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarshall committed Oct 5, 2021
1 parent 5a806f5 commit 95e2d6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions hts.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ static enum htsFormatCategory format_category(enum htsExactFormat fmt)
return index_file;

case bed:
case d4_format:
return region_list;

case htsget:
Expand Down Expand Up @@ -634,6 +635,13 @@ int hts_detect_format(hFILE *hfile, htsFormat *fmt)
fmt->version.major = 1, fmt->version.minor = -1;
return 0;
}
else if (len >= 8 && memcmp(s, "d4\xdd\xdd", 4) == 0) {
fmt->category = region_list;
fmt->format = d4_format;
// How to decode the D4 Format Version bytes is not yet specified
// so we don't try to set fmt->version.{major,minor}.
return 0;
}
else if (cmp_nonblank("{\"htsget\":", s, &s[len]) == 0) {
fmt->category = unknown_category;
fmt->format = htsget;
Expand Down Expand Up @@ -718,6 +726,7 @@ char *hts_format_description(const htsFormat *format)
case gzi: kputs("GZI", &str); break;
case tbi: kputs("Tabix", &str); break;
case bed: kputs("BED", &str); break;
case d4_format: kputs("D4", &str); break;
case htsget: kputs("htsget", &str); break;
case hts_crypt4gh_format: kputs("crypt4gh", &str); break;
case empty_format: kputs("empty", &str); break;
Expand Down Expand Up @@ -1597,6 +1606,7 @@ const char *hts_format_file_extension(const htsFormat *format) {
case gzi: return "gzi";
case tbi: return "tbi";
case bed: return "bed";
case d4_format: return "d4";
case fasta_format: return "fa";
case fastq_format: return "fq";
default: return "?";
Expand Down
1 change: 1 addition & 0 deletions htslib/hts.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ enum htsExactFormat {
empty_format, // File is empty (or empty after decompression)
fasta_format, fastq_format, fai_format, fqi_format,
hts_crypt4gh_format,
d4_format,
format_maximum = 32767
};

Expand Down

0 comments on commit 95e2d6d

Please sign in to comment.