class

Fastx::Fastq::Reader

Inherits Reference < Object

Constructors

new(filename : String | Path)

Creates a new FASTQ reader for the specified file. Automatically detects gzip compression from .gz extension.

Source
new(io : IO)

Creates a new FASTQ reader for an already opened IO stream. IO-based readers do not perform gzip auto-detection. The reader takes ownership of the IO and closes it when the reader is closed.

Source

Class methods

open(filename : String | Path, &)

Opens a FASTQ file, yields the reader to the block, and automatically closes it.

Source
open(io : IO, &)

Opens a FASTQ stream, yields the reader to the block, and automatically closes it.

Source

Instance methods

close

Closes the reader and its underlying IO.

Source
closed?

Returns true if the file handle is closed.

Source
each

Iterates over each FASTQ record, yielding identifier, sequence, and quality as owned String copies that remain valid after iteration.

Source
each_bytes

Iterates over each FASTQ record, yielding identifier, sequence, and quality as borrowed Bytes (Slice(UInt8)).

The yielded slices point into internal buffers that are reused on every iteration. They are backed by reader-owned reusable buffers, not guaranteed zero-copy views of the input stream, and are only valid until the next record is read. To keep a value beyond the current iteration, copy it (String.new(bytes) or bytes.dup) or use #each.

Source
each_record_lines

Iterates over conventional four-line FASTQ records while streaming each record's sequence and quality lines without accumulating the full fields in memory. This is the lowest-memory FASTQ reading API.

The yielded identifier is an owned String. SequenceLines#each and QualityLines#each yield borrowed Bytes slices into an internal buffer; each slice is only valid until the next line is read. Copy it (String.new(bytes) or bytes.dup) to keep it.

The sequence line is consumed before quality (automatically, if the caller skips it) so sequence/quality length equality can be validated.

The specific method name leaves #each_record available for a possible future record-oriented API.

Source