pub struct IntervalSet { /* private fields */ }Expand description
A collection of genomic intervals with overlap query support.
Queries use O(n) linear scan by default. Call IntervalSet::build_index()
to construct per-chromosome interval trees for O(log n + k) queries.
Implementations§
Source§impl IntervalSet
impl IntervalSet
Sourcepub fn from_intervals(intervals: Vec<GenomicInterval>) -> Self
pub fn from_intervals(intervals: Vec<GenomicInterval>) -> Self
Create an interval set from existing intervals.
Sourcepub fn push(&mut self, interval: GenomicInterval)
pub fn push(&mut self, interval: GenomicInterval)
Add an interval. Marks the set as unsorted and invalidates the index.
Sourcepub fn build_index(&mut self)
pub fn build_index(&mut self)
Build per-chromosome interval tree indices for O(log n + k) queries.
This is called automatically on first query if the set is sorted,
but can also be called explicitly. Invalidated by push().
Sourcepub fn overlapping(&self, query: &GenomicInterval) -> Vec<&GenomicInterval>
pub fn overlapping(&self, query: &GenomicInterval) -> Vec<&GenomicInterval>
Return all intervals that overlap the query.
Uses the interval tree index if available, otherwise falls back to O(n) scan.
Sourcepub fn containing(&self, chrom: &str, position: u64) -> Vec<&GenomicInterval>
pub fn containing(&self, chrom: &str, position: u64) -> Vec<&GenomicInterval>
Return all intervals containing a given position.
Uses the interval tree index if available, otherwise falls back to O(n) scan.
Sourcepub fn merge_overlapping(&self) -> IntervalSet
pub fn merge_overlapping(&self) -> IntervalSet
Merge all overlapping intervals and return a new, sorted set.
Adjacent intervals on the same chromosome that overlap or abut are merged into a single interval.
Sourcepub fn intervals(&self) -> &[GenomicInterval]
pub fn intervals(&self) -> &[GenomicInterval]
Borrow the intervals as a slice.
Sourcepub fn into_intervals(self) -> Vec<GenomicInterval>
pub fn into_intervals(self) -> Vec<GenomicInterval>
Consume the set and return the inner intervals.