Skip to main content

ReferenceView

Struct ReferenceView 

Source
pub struct ReferenceView<'a> { /* private fields */ }
Expand description

A borrowed, zero-copy view over the persisted 2-bit forward reference (Reference2bit). Decodes bases on demand from the mmap — no full-reference allocation — so consumers (the aligner DP window in B4b, variants’ ref_base in B4c) read the reference from the .idx alone. Uses global (concatenated) coordinates; (contig, pos) mapping stays with ContigSet. The little-endian host requirement is the same as FmIndexView (checked in new).

Implementations§

Source§

impl<'a> ReferenceView<'a>

Source

pub fn len(&self) -> usize

Number of reference bases.

Source

pub fn is_empty(&self) -> bool

Whether the reference is empty.

Source

pub fn base_at(&self, global: usize) -> u8

The ASCII base at global position global. Mirrors CompressedDNA::base_at: a set ambiguity bit decodes to N, otherwise the 2-bit code maps to A/C/G/T.

Source

pub fn decode_window(&self, start: usize, end: usize, out: &mut Vec<u8>)

Decode [start, end.min(len)) into out (cleared first). end is clamped to len, so an over-range request never panics; start <= end is the caller’s contract. Bounded by the window size — never the whole genome.

Source

pub fn decode_window_arc(&self, start: usize, end: usize) -> Arc<[u8]>

Decode [start, end.min(len)) directly into an Arc<[u8]>, with no separate owned Vec materialized first. Arc::from(Vec<u8>) REALLOCATES — source and Arc buffers are both fully resident during the copy, so a per-contig decode briefly holds two copies of the contig (the reference- decode transient that broke the predicted-peak bound). Collecting a TrustedLen range straight into the Arc writes into its allocation in place, so peak resident reference memory is ONE copy. Byte-identical to decode_window; bounded by the window size.

Trait Implementations§

Source§

impl<'a> Debug for ReferenceView<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ReferenceView<'a>

§

impl<'a> RefUnwindSafe for ReferenceView<'a>

§

impl<'a> Send for ReferenceView<'a>

§

impl<'a> Sync for ReferenceView<'a>

§

impl<'a> Unpin for ReferenceView<'a>

§

impl<'a> UnsafeUnpin for ReferenceView<'a>

§

impl<'a> UnwindSafe for ReferenceView<'a>

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.