Skip to main content

PaddedIntervalSampler

Struct PaddedIntervalSampler 

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

A sampler that draws random fragment start positions from padded target regions.

Given a set of target intervals, each interval is padded on the left by a specified amount (to include fragments that start before a target but extend into it), overlapping padded intervals are merged, and start positions are sampled uniformly across the merged regions. The resulting fragments should still be checked for overlap with the original unpadded targets — starts in the pad zone whose drawn fragment length is too short to reach the target will be rejected, but this is rare when the pad matches the expected max fragment length.

Implementations§

Source§

impl PaddedIntervalSampler

Source

pub fn new(intervals: &[(u32, u32)], pad: u32, contig_len: u32) -> Self

Build a sampler from sorted target intervals, padding each on the left.

pad is typically the maximum expected fragment length (e.g. fragment_mean + 4 * fragment_stddev), ensuring that fragments starting before a target but overlapping it are represented in the sampling space. Padded intervals are merged where they overlap and clamped to [0, contig_len).

Source

pub fn sample_start(&self, rng: &mut impl Rng) -> Option<u32>

Sample a random start position uniformly from the padded intervals.

Returns None if there are no intervals.

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