kira_cdh_compat_fastq_reader 0.1.3

Streaming FASTQ reader compatible with CD-HIT input handling (plain and .gz), safe idiomatic Rust API; sync and async.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::fs::File;
use std::io::{self, Read, Seek, SeekFrom};

pub fn looks_like_gzip<R: Read + Seek>(mut r: R) -> io::Result<bool> {
    let mut magic = [0u8; 2];
    let pos = r.seek(SeekFrom::Current(0))?;
    let n = r.read(&mut magic)?;
    r.seek(SeekFrom::Start(pos))?;
    Ok(n >= 2 && magic == [0x1F, 0x8B])
}

pub fn open_file(path: &std::path::Path) -> io::Result<File> {
    std::fs::File::open(path)
}