Expand description
§gwseq-io
Reading and writing bigWig, bigBed, BAM and HiC files.
See ARCHITECTURE.md at the workspace root for the module map and the
reasoning behind the layering.
§Shape
Three readers and one writer, each opened on a path or a URL:
use gwseq_io::bbi::{ValuesRequest, Zoom};
use gwseq_io::genomic::Locs;
use gwseq_io::{open, Reader};
let chr_ids = vec!["chr1".to_string(), "chr2".to_string()];
let starts = vec![1_000_000, 2_000_000];
let ends = vec![1_010_000, 2_010_000];
let Reader::Bbi(bw) = open("track.bigwig", Default::default())? else {
panic!("not a bigwig")
};
let values = bw.read_values(
&ValuesRequest::new(Locs::spans(&chr_ids, &starts, &ends)?)
.bin_size(10.0)
.zoom(Zoom::Auto),
)?; // Array2<f32>, (loci, bins)Requests are builders because the API they mirror has up to fourteen defaulted keyword arguments; a builder is where each default is written down once, for the Python layer, the CLI and Rust callers alike.
§Threads and handles
A reader owns parallel worker threads and one file handle for its
lifetime. close() gives both back and is idempotent; a closed reader
fails every read with Error::Closed, while the headers it read at open
stay available. A reader that is never closed gives everything back when it
is dropped.
Re-exports§
pub use error::Error;pub use error::Result;pub use genomes::get_chr_sizes;
Modules§
- arrays
- Array shaping shared by more than one format.
- bam
- BAM.
- bbi
- bigWig and bigBed.
- bytes
- Little-endian field reads and writes over a byte buffer.
- error
- The crate’s error type.
- genomes
- Chromosome sizes by genome name.
- genomic
- Genomic coordinates: chromosome maps, loci, bins, strands.
- hic
- HiC contact matrices.
- npz
save_to: writing a read straight to a.npzinstead of through Python.- parallel
- Thread pools.
- progress
- Progress reporting.
- source
- Byte sources and sinks.
Structs§
- Open
Options - Everything
opentakes beyond the path.
Enums§
- File
Kind - What a file’s first bytes say it is.
- Reader
- What
openreturns. The format is sniffed from the file’s magic number, not from its extension.
Functions§
- open
- Open a file for reading, dispatching on its magic number.
- sniff
- Sniff the format of a file from its magic number.
- sniff_
source - Sniff the format of an already-open source.