pub struct FastaReader { /* private fields */ }Expand description
Streaming FASTA reader that yields one record at a time.
Uses a fixed 1 MB BufReader internally — never grows to chromosome size.
Handles plain and gzipped FASTA files (via get_dynamic_reader).
Uppercases all sequence bytes (ASCII only).
§Why not seq_io?
We previously used the seq_io crate for FASTA parsing in the store pipeline.
seq_io is a well-tested, high-performance parser, but its fasta::Reader is
record-oriented: it buffers the entire FASTA record (header + all sequence lines)
in an internal buffer before returning a RefRecord. For typical genomes this is
fine, but for large vertebrates (e.g., palmate newt chromosomes at ~2 GB), the
reader’s internal buffer grows to chromosome size. Combined with the raw_bytes
Vec built from it, the reading thread holds two full copies of the chromosome
simultaneously — pure waste that contributed to OOM on HPC.
This reader uses a fixed-size BufReader (1 MB) and builds raw_bytes directly
line by line, so only one chromosome-sized allocation exists at a time. FASTA is
a simple enough format (lines starting with > are headers, everything else is
sequence data) that a custom reader is low-risk.
See guides/core/refgetstore_oom_diagnosis.md for the full investigation.
Implementations§
Source§impl FastaReader
impl FastaReader
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
Sourcepub fn next_record(&mut self) -> Result<Option<FastaRecord>>
pub fn next_record(&mut self) -> Result<Option<FastaRecord>>
Read the next FASTA record. Returns None at EOF.