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
impl Fasta
Sourcepub fn from_path(path: &Path) -> Result<Self>
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.
Sourcepub fn dict(&self) -> &SequenceDictionary
pub fn dict(&self) -> &SequenceDictionary
Return a reference to the underlying sequence dictionary.
Sourcepub fn load_contig(
&mut self,
contig_name: &str,
rng: &mut impl Rng,
) -> Result<Vec<u8>>
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 toT.- 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 (seecrate::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.
Sourcepub fn contig_names(&self) -> Vec<&str>
pub fn contig_names(&self) -> Vec<&str>
Return contig names in index order.