Skip to main content

write_bigwig_streaming

Function write_bigwig_streaming 

Source
pub fn write_bigwig_streaming<P>(
    path: &Path,
    chrom_sizes: Vec<(String, u32)>,
    queue_depth: usize,
    produce: P,
) -> Result<(), Box<dyn Error>>
where P: FnOnce(&mut dyn FnMut(&str, usize, f64) -> Result<()>) -> Result<()> + Send + 'static,
Expand description

Write a bigWig, pulling scores from produce as they are needed.

bigtools takes an iterator, but the scoring loop pushes, so the producer runs on its own thread and feeds a bounded channel. The bound is what makes this streaming rather than merely deferred: when the writer falls behind, the producer blocks instead of queueing the genome up in memory.