Skip to main content

TargetRegions

Struct TargetRegions 

Source
pub struct TargetRegions { /* private fields */ }
Expand description

A collection of genomic target regions loaded from a BED file, indexed for efficient overlap queries.

Internally stores one COITree per contig for O(log N) overlap detection. BED coordinates are 0-based half-open [start, end), but coitrees uses end-inclusive intervals, so we store [start, end-1] internally.

Debug is implemented manually because COITree does not implement Debug.

Implementations§

Source§

impl TargetRegions

Source

pub fn from_path(path: &Path, dict: &SequenceDictionary) -> Result<Self>

Load target regions from a BED file.

The file may be plain text or gzipped. Coordinates are validated against dict — unknown contigs or out-of-range coordinates cause an error.

§Errors

Returns an error if the file cannot be read, contains invalid entries, or references contigs not present in the dictionary.

Source

pub fn total_territory(&self) -> u64

Return the total number of bases covered by all target regions.

Note: if the BED file contains overlapping intervals, overlapping bases are counted multiple times. Callers that need exact territory should provide a non-overlapping BED.

Source

pub fn contig_territory(&self, contig_index: usize) -> u64

Return the target territory (in bases) for a specific contig.

Source

pub fn overlaps(&self, contig_index: usize, start: u32, end: u32) -> bool

Check whether the interval [start, end) (0-based half-open) on the given contig overlaps any target region.

Source

pub fn contig_intervals(&self, contig_index: usize) -> &[(u32, u32)]

Return the sorted target intervals for a contig in 0-based half-open coordinates [start, end).

Source

pub fn effective_territory(&self, fragment_mean: usize) -> u64

Compute the effective territory for coverage calculation, accounting for the fact that fragments extend beyond target boundaries.

For a target of width W, a fragment of length L placed uniformly to overlap the target has an on-target fraction of W / (W + L - 1). The effective territory per target is therefore W + L - 1 — the catchment zone of fragment start positions — and the total effective territory is the sum across all targets. Using this as effective_size in the standard coverage formula N = C * effective_size / bases_per_read yields the correct number of reads for the desired mean target coverage.

Source

pub fn contig_effective_territory( &self, contig_index: usize, fragment_mean: usize, ) -> u64

Compute the effective territory for a single contig.

See effective_territory for the rationale.

Source

pub fn dict(&self) -> &SequenceDictionary

Return a reference to the underlying sequence dictionary.

Trait Implementations§

Source§

impl Debug for TargetRegions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V