Skip to main content

Fasta

Struct Fasta 

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

A loaded FASTA reference with random-access sequence retrieval.

Wraps a noodles IndexedReader for efficient seek-based access. Contig metadata (names, lengths) is pre-computed from the .fai index at construction time.

Implementations§

Source§

impl Fasta

Source

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

Open a FASTA file and its .fai index.

The .fai file must exist alongside the FASTA (e.g. ref.fa.fai).

§Errors

Returns an error if the FASTA or its index cannot be read.

Source

pub fn dict(&self) -> &SequenceDictionary

Return a reference to the underlying sequence dictionary.

Source

pub fn load_contig( &mut self, contig_name: &str, rng: &mut impl Rng, ) -> Result<Vec<u8>>

Load and return the full sequence of contig_name.

Uses seek-based access via the FAI index for efficiency, avoiding the intermediate Record allocation that query() performs.

Bases are normalized during loading:

  • A, C, G, T (case-insensitive) are stored as uppercase.
  • U (RNA) is converted to T.
  • Any other IUPAC ambiguity code (R, Y, S, W, K, M, B, D, H, V, N) is resolved to a uniformly-random base drawn from that code’s ambiguity set and stored in lowercase. The lowercase marker allows downstream sampling to detect and optionally reject reads that contain too many synthesized bases (see crate::fragment::lowercase_fraction).
  • Any other byte is rejected with an error.

Passing the same rng state produces a deterministic resolution, so two runs seeded identically produce identical reference buffers.

§Errors

Returns an error if the contig is unknown, the FASTA cannot be read, or the contig contains an unrecognized base.

Source

pub fn contig_names(&self) -> Vec<&str>

Return contig names in index order.

Auto Trait Implementations§

§

impl Freeze for Fasta

§

impl RefUnwindSafe for Fasta

§

impl Send for Fasta

§

impl Sync for Fasta

§

impl Unpin for Fasta

§

impl UnsafeUnpin for Fasta

§

impl UnwindSafe for Fasta

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