Expand description
Low-allocation FASTQ and FASTA parsing.
Dino Seq is a library core for downstream scientific tools that need low-allocation streams of ordinary FASTQ records and multiline FASTA records. The default crate is the raw parser core; gzip and BGZF transports are explicit feature opt-ins.
The default feature set builds on stable Rust with no compression
dependencies. SIMD acceleration is available through the explicit simd
feature on stable Rust targets that expose supported std::arch intrinsics.
§Choosing an entry point
Use FastqReader or FastaReader directly over a concrete
std::fs::File for raw-file hot paths. Use count_fastq_read for
count/stat workloads that do not need record views. Use visit_fastq_bytes
when a complete FASTQ byte buffer is already resident in memory. Use
open_fastq, open_fastq_with_config, open_fasta, or
open_fasta_with_config when file-path convenience and optional
gzip/BGZF magic detection are worth the boxed transport. Use
PairedFastqReader or open_paired_fastq for ordered R1/R2 streams. Use
visit_fasta_bytes for resident multiline FASTA, and
visit_two_line_fasta_bytes or visit_two_line_fasta_read for strict
canonical two-line FASTA fast paths.
§Scope
Dino Seq parses four-line FASTQ records. It validates ordered paired-end reads in separate R1/R2 streams or adjacent interleaved records, but it does not synchronize reordered mates. It does not trim adapters, filter reads, align reads, or generate quality-control reports.
§Lifetimes and allocation
Batches borrow from the reader’s reusable storage. A FastqBatch or
FastaBatch is valid until the next mutable reader call. Clone or copy
record data if it must outlive the batch. This design keeps the parser
low-allocation, but it means callers should process each batch before
advancing the reader.
§Feature flags
gzipenables ordinary gzip auto-detection and streaming decode.bgzfenables BGZF readers, writers, indexing, and adaptive parallel decoding.libdeflateenables optional libdeflate BGZF backends.gzip-libdeflateenablesgzippluslibdeflatefor explicit buffered gzip openers.mmapenables resident file visitors backed by memory maps.transportenables bothgzipandbgzffor callers that want the old all-transport convenience build.simdenables stablestd::archpacking paths where supported.
§Example
use dino_seq::FastqReader;
let data = b"@r1\nACGT\n+\nIIII\n";
let mut reader = FastqReader::new(&data[..]);
let mut records = 0;
while let Some(batch) = reader.next_batch()? {
for record in batch.records() {
assert_eq!(record.seq(), b"ACGT");
records += 1;
}
}
assert_eq!(records, 1);§Paired reads
use dino_seq::PairedFastqReader;
let r1 = b"@frag/1\nACGT\n+\nIIII\n";
let r2 = b"@frag/2\nTGCA\n+\nJJJJ\n";
let mut reader = PairedFastqReader::new(&r1[..], &r2[..]);
let batch = reader.next_pair_batch()?.expect("one paired batch");
let pair = batch.pairs().next().expect("one read pair");
assert_eq!(pair.pair_id(), b"frag");
assert_eq!(pair.first().seq(), b"ACGT");
assert_eq!(pair.second().seq(), b"TGCA");Modules§
- pack
- Base/quality packing and trusted four-line FASTQ pack paths.
Structs§
- Fasta
Batch - A batch of borrowed FASTA records.
- Fasta
Config - Configuration for FASTA readers.
- Fasta
Index - A
.fai-style FASTA index. - Fasta
Index Entry - One
.fai-style FASTA index entry. - Fasta
Partition - One planned reference partition over indexed FASTA sequence coordinates.
- Fasta
Partition Config - Configuration for planning balanced indexed-FASTA reference partitions.
- Fasta
Reader - Slab-style streaming FASTA reader over any
Readinput. - Fasta
Record - Borrowed view of one FASTA record inside a
FastaBatch. - Fasta
Record Ref - Byte ranges for one FASTA record within a batch.
- Fasta
Reference Chunk - Owned reference sequence chunk from an indexed FASTA source.
- Fasta
Reference Chunk Ref - Borrowed reference sequence chunk from an indexed FASTA source.
- Fasta
Reference Chunks - Iterator over owned chunks from an
IndexedFastaReader. - Fasta
Stats - Aggregate statistics for sequence-only FASTA workloads.
- Fasta
Visit Record - Borrowed FASTA record passed to
FastaReader::visit_records. - Fastq
Batch - A batch of borrowed FASTQ records from one reader slab.
- Fastq
Chunk Config - Chunking policy for
FastqReader::next_chunk_with_sink. - Fastq
Chunk Stats - Summary for one chunk emitted by
FastqReader::next_chunk_with_sink. - Fastq
Config - Configuration for FASTQ batch readers.
- Fastq
Pair - Borrowed view of an ordered read pair.
- Fastq
Position - Location of a FASTQ or FASTA parsing error.
- Fastq
Reader - Slab-based FASTQ reader over any
Readinput. - Fastq
Record - Borrowed view of one FASTQ record inside a
FastqBatch. - Fastq
Stats - Aggregate statistics for sequence-only FASTQ workloads.
- Fastq
Visit Record - Borrowed FASTQ record passed to
FastqReader::visit_records. - Indexed
Fasta Reader - Seekable FASTA reader backed by a
.faiindex. - Interleaved
Pairs - Iterator over adjacent pairs in an interleaved
FastqBatch. - Owned
Fasta Batch - Owned FASTA batch that can be moved to worker threads.
- Owned
Fasta Record - Borrowed record view over an
OwnedFastaBatch. - Paired
Fastq Batch - A paired-end batch produced by
PairedFastqReader. - Paired
Fastq Pairs - Iterator over read pairs in a
PairedFastqBatch. - Paired
Fastq Reader - Stateful reader for ordered separate-file paired-end FASTQ streams.
- Paired
Records - Iterator over paired records from two separate
FastqBatchvalues. - Record
Ref - Byte ranges for a four-line FASTQ record within a batch slab.
Enums§
- Detected
Input Kind - Compression/container detected from input file magic.
- Fasta
Shape - Detected FASTA physical layout for resident inputs.
- Fastq
Error - Error type for FASTQ, FASTA, gzip, and BGZF operations.
- Pair
Validation - Identifier validation policy for paired-end data.
- Pairing
Mode - Pairing interpretation for a single FASTQ stream.
Traits§
- Fasta
Record Sink - Sink trait for FASTA record visitors.
- Fasta
Reference Chunk Sink - Sink trait for borrowed indexed FASTA reference chunks.
- Fastq
Chunk Sink Ext - Optional extension point for sinks that can preallocate per chunk.
- Fastq
Record Sink - Caller-provided sink for single-pass FASTQ record processing.
Functions§
- build_
fasta_ index - Build a
.fai-style index over an ordinary FASTA stream. - count_
fasta_ bytes - Count records and bases from resident FASTA bytes.
- count_
fasta_ read - Count records and bases from an ordinary FASTA stream.
- count_
fastq_ bytes - Count records and bases from an already resident FASTQ byte slice.
- count_
fastq_ read - Count records and bases from a FASTQ reader without building record views.
- count_
fastq_ read_ with_ config - Count records and bases from a FASTQ reader with explicit parser settings.
- count_
two_ line_ fasta_ bytes - Count strict two-line FASTA records from resident bytes.
- count_
two_ line_ fasta_ read - Count strict two-line FASTA records from a stream.
- detect_
fasta_ shape - Detect whether resident FASTA bytes are strict two-line FASTA.
- detect_
file_ input_ kind - Detect raw, gzip, or BGZF input by file magic.
- open_
fasta - Open a FASTA file with default configuration.
- open_
fasta_ for_ reference - Open a FASTA reference genome with parser settings tuned for long records.
- open_
fasta_ with_ config - Open a FASTA file with explicit parser configuration.
- open_
fastq - Open a FASTQ file with default configuration.
- open_
fastq_ with_ config - Open a FASTQ file with explicit parser configuration.
- open_
paired_ fastq - Open ordered R1/R2 FASTQ files with default configuration.
- open_
paired_ fastq_ with_ config - Open ordered R1/R2 FASTQ files with the same configuration for both mates.
- open_
paired_ fastq_ with_ configs - Open ordered R1/R2 FASTQ files with separate mate configurations.
- paired_
records - Validate and zip two separate FASTQ batches by ordered mate identifiers.
- plan_
fasta_ partitions - Plan balanced reference partitions from a FASTA index.
- strip_
pair_ suffix - Strip a terminal
/1or/2pair suffix from an identifier token. - visit_
fasta_ bytes - Visit records from an already resident FASTA byte slice.
- visit_
fasta_ bytes_ auto - Visit resident FASTA bytes with automatic two-line fast-path detection.
- visit_
fastq_ bytes - Visit records from an already resident FASTQ byte slice.
- visit_
two_ line_ fasta_ bytes - Visit records from a resident, strict two-line FASTA byte slice.
- visit_
two_ line_ fasta_ read - Visit records from a strict two-line FASTA stream.
Type Aliases§
- Result
- Crate-local result type.