Function noodles_csi::binning_index::optimize_chunks

source ·
pub fn optimize_chunks(
    chunks: &[Chunk],
    min_offset: VirtualPosition
) -> Vec<Chunk>
Expand description

Optimizes a list of chunks into a list of non-overlapping chunks.

Unlike merge_chunks, min_offset (typically from the linear index) is given to remove chunks that cannot be in the query.

§Examples

use noodles_bgzf as bgzf;
use noodles_csi::binning_index::{index::reference_sequence::bin::Chunk, optimize_chunks};

let chunks = [
    Chunk::new(bgzf::VirtualPosition::from(2), bgzf::VirtualPosition::from(3)),
    Chunk::new(bgzf::VirtualPosition::from(5), bgzf::VirtualPosition::from(8)),
    Chunk::new(bgzf::VirtualPosition::from(7), bgzf::VirtualPosition::from(13)),
    Chunk::new(bgzf::VirtualPosition::from(21), bgzf::VirtualPosition::from(34)),
];
let min_offset = bgzf::VirtualPosition::from(5);

let actual = optimize_chunks(&chunks, min_offset);

let expected = [
    Chunk::new(bgzf::VirtualPosition::from(5), bgzf::VirtualPosition::from(13)),
    Chunk::new(bgzf::VirtualPosition::from(21), bgzf::VirtualPosition::from(34)),
];

assert_eq!(actual, expected);