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
impl PaddedIntervalSampler
Sourcepub fn new(intervals: &[(u32, u32)], pad: u32, contig_len: u32) -> Self
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).
Sourcepub fn sample_start(&self, rng: &mut impl Rng) -> Option<u32>
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.