FastqView
Mojo struct 🡭
FastqView
Section titled “FastqView”@register_passable_trivialstruct FastqView[mut: Bool, //, origin: Origin[mut=mut]]Zero-copy reference to a FASTQ record inside the parser’s buffer.
Lifetime: Valid only until the next parser read or buffer mutation. Do not
store in collections (e.g. List); consume or copy to FastqRecord promptly.
Not thread-safe. Use for maximum parsing throughput when processing
immediately; use FastqRecord when you need to store or reuse records.
Attributes: id, sequence, quality: Spans into the parser buffer (id is identifier without leading ’@’). phred_offset: Phred offset (33 or 64) for quality decoding.
Example:
from blazeseq import FastqParser, FileReaderfrom std.pathlib import Pathvar parser = FastqParser[FileReader](FileReader(Path("data.fastq")), "generic")for view in parser.views(): _ = view.id() _ = view.sequence()Parameters
Section titled “Parameters”- mut (
Bool) - origin (
Origin)
Implemented traits
Section titled “Implemented traits”AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable, RegisterPassable, Sized, TrivialRegisterPassable, Writable
Methods
Section titled “Methods”__init__
Section titled “__init__”def __init__(id: Span[Byte, origin], sequence: Span[Byte, origin], quality: Span[Byte, origin], phred_offset: UInt8 = 33) -> SelfArgs:
- id (
Span) - sequence (
Span) - quality (
Span) - phred_offset (
UInt8)
Returns:
Self
sequence
Section titled “sequence”def sequence(self) -> StringSlice[origin]Return the sequence line as a string slice (valid only while ref is valid).
Args:
- self (
Self)
Returns:
StringSlice
quality
Section titled “quality”def quality(self) -> StringSlice[origin]Return the quality line as a string slice (valid only while ref is valid).
Args:
- self (
Self)
Returns:
StringSlice
def id(self) -> StringSlice[origin]Return the read identifier (id without leading ’@’) as a string slice (valid only while ref is valid).
Args:
- self (
Self)
Returns:
StringSlice
definition
Section titled “definition”def definition(self) -> DefinitionReturn Id and optional Description parsed from the id line (first token vs rest).
Args:
- self (
Self)
Returns:
Definition
__len__
Section titled “__len__”def __len__(self) -> IntReturn the sequence length (number of bases).
Args:
- self (
Self)
Returns:
Int
byte_len
Section titled “byte_len”def byte_len(self) -> IntReturn total byte length when written (”@” + id + sequence + quality + newlines and ”+ ”). Used for calculating buffer capacity.
Args:
- self (
Self)
Returns:
Int
phred_scores
Section titled “phred_scores”def phred_scores(self) -> List[Byte]Return Phred quality scores using the record’s phred_offset.
Args:
- self (
Self)
Returns:
List
def phred_scores(self, offset: UInt8) -> List[Byte]Return Phred quality scores using the given offset (e.g. 33 or 64).
Args:
- self (
Self) - offset (
UInt8)
Returns:
List
def write[w: Writer](self, mut writer: w)Write the record in standard four-line FASTQ format to writer (emits ”@” before id and ”+” for the plus line).
Parameters:
- w (
Writer)
Args:
- self (
Self) - writer (
w)
write_to
Section titled “write_to”def write_to[w: Writer](self, mut writer: w)Required by Writable trait; delegates to write().
Parameters:
- w (
Writer)
Args:
- self (
Self) - writer (
w)