Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "binseq"
version = "0.9.1"
version = "0.9.2"
edition = "2024"
description = "A high efficiency binary format for sequencing data"
license = "MIT"
Expand Down
19 changes: 12 additions & 7 deletions src/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,30 @@ use crate::{
/// An enum abstraction for BINSEQ readers that can process records in parallel
///
/// This is a convenience enum that can be used for general workflows where the
/// distinction between BQ and VBQ readers is not important.
/// distinction between BINSEQ readers is not important.
///
/// For more specialized workflows see [`bq::MmapReader`] and [`vbq::MmapReader`].
/// For more specialized workflows see [`bq::MmapReader`], [`vbq::MmapReader`], and [`cbq::MmapReader`].
pub enum BinseqReader {
Bq(bq::MmapReader),
Vbq(vbq::MmapReader),
Cbq(cbq::MmapReader),
}
impl BinseqReader {
pub fn new(path: &str) -> Result<Self> {
let pathbuf = Path::new(path);
match pathbuf.extension() {
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self> {
match path.as_ref().extension() {
Some(ext) => match ext.to_str() {
Some("bq") => Ok(Self::Bq(bq::MmapReader::new(path)?)),
Some("vbq") => Ok(Self::Vbq(vbq::MmapReader::new(path)?)),
Some("cbq") => Ok(Self::Cbq(cbq::MmapReader::new(path)?)),
_ => Err(ExtensionError::UnsupportedExtension(path.to_string()).into()),
_ => Err(ExtensionError::UnsupportedExtension(
path.as_ref().to_string_lossy().to_string(),
)
.into()),
},
None => Err(ExtensionError::UnsupportedExtension(path.to_string()).into()),
None => Err(ExtensionError::UnsupportedExtension(
path.as_ref().to_string_lossy().to_string(),
)
.into()),
}
}
Comment thread
noamteyssier marked this conversation as resolved.

Expand Down
Loading