Skip to content

Commit 70e84cb

Browse files
committed
detect bcf
1 parent 4f6f68e commit 70e84cb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/sniff.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::io::Read;
66
pub enum FileType {
77
Bed,
88
Vcf,
9+
Bcf,
910
}
1011

1112
#[derive(Debug)]
@@ -16,6 +17,8 @@ pub enum Compression {
1617
None,
1718
}
1819

20+
// TODO: https://github.com/quinlan-lab/bedder-rs/blob/ffddd2b3a2075594a5375fb81b8672f4f5039acf/src/sniff.rs
21+
1922
pub fn sniff<R: io::BufRead>(
2023
rdr: &mut R,
2124
) -> Result<(FileType, Compression), Box<dyn std::error::Error>> {
@@ -53,8 +56,10 @@ pub fn sniff<R: io::BufRead>(
5356
_ => &dec_buf,
5457
};
5558
// now we guess filel type based on whats in buf
56-
let ft = if buf.starts_with(b"##fileformat=VCFv4") {
59+
let ft = if buf.starts_with(b"##fileformat=VCF") {
5760
FileType::Vcf
61+
} else if buf.starts_with(b"BCF") && (buf[3] == 0x2 || buf[3] == 0x4) {
62+
FileType::Bcf
5863
} else {
5964
FileType::Bed
6065
};

0 commit comments

Comments
 (0)