FastqRecord
Mojo struct 🡭
FastqRecord
Section titled “FastqRecord”@memory_onlystruct FastqRecordA single FASTQ record (four lines: @id, sequence, +, quality).
Owned representation; safe to store in collections and reuse. Use FastqView
for zero-copy parsing when consuming immediately. The plus line is emitted as ”+”
when writing; only id, sequence, and quality are stored. phred_offset is the
Phred offset (33 or 64) used to decode quality scores.
Attributes:
id: Read identifier (id line content after the ’@’; stored without leading ’@’).
sequence: Sequence line.
quality: Quality line (same length as sequence).
phred_offset: Phred offset for phred_scores() (e.g. 33 for Sanger).
Example:
from blazeseq import FastqRecordfrom blazeseq.fastq.quality_schema import generic_schemavar rec = FastqRecord("read1", "ACGT", "IIII", generic_schema)print(rec.id())var scores = rec.phred_scores()Implemented traits
Section titled “Implemented traits”AnyType, Copyable, Hashable, ImplicitlyDestructible, Movable, Sized, Writable
Methods
Section titled “Methods”__init__
Section titled “__init__”def __init__(out self, id: String, sequence: String, quality: String, schema: QualitySchema = generic_schema)Build from id, sequence, and quality strings; phred_offset from schema (default generic_schema).
Args:
- id (
String) - sequence (
String) - quality (
String) - schema (
QualitySchema) - self (
Self)
Returns:
Self
Raises:
def __init__(out self, id: Span[Byte, MutExternalOrigin], sequence: Span[Byte, MutExternalOrigin], quality: Span[Byte, MutExternalOrigin], phred_offset: Int8 = 33)Args:
- id (
Span) - sequence (
Span) - quality (
Span) - phred_offset (
Int8) - self (
Self)
Returns:
Self
Raises:
def __init__(out self, fast_str: String)Build from a single string containing four newline-separated lines (line 3, plus line, is discarded).
Args:
- fast_str (
String) - self (
Self)
Returns:
Self
Raises:
def __init__(out self, var id: BString, var sequence: BString, var quality: BString, phred_offset: Int8)Args:
- id (
BString) - sequence (
BString) - quality (
BString) - phred_offset (
Int8) - self (
Self)
Returns:
Self
__eq__
Section titled “__eq__”def __eq__(self, other: Self) -> BoolArgs:
- self (
Self) - other (
Self)
Returns:
Bool
__ne__
Section titled “__ne__”def __ne__(self, other: Self) -> BoolArgs:
- self (
Self) - other (
Self)
Returns:
Bool
sequence
Section titled “sequence”def sequence(ref self) -> StringSlice[origin_of(self)]Return the sequence line as a string slice.
Args:
- self (
Self)
Returns:
StringSlice
quality
Section titled “quality”def quality(ref self) -> StringSlice[origin_of(self)]Return the quality line (raw ASCII bytes) as a string slice.
Args:
- self (
Self)
Returns:
StringSlice
phred_scores
Section titled “phred_scores”def phred_scores(self) -> List[UInt8]Return Phred quality scores using the record’s phred_offset (e.g. 33).
Args:
- self (
Self)
Returns:
List
def phred_scores(self, offset: UInt8) -> List[UInt8]Return Phred quality scores using the given offset (e.g. 33 or 64).
Args:
- self (
Self) - offset (
UInt8)
Returns:
List
def id(ref self) -> StringSlice[origin_of(self)]Return the read identifier (id without leading ’@’) as a string slice.
Args:
- self (
Self)
Returns:
StringSlice
definition
Section titled “definition”def definition(ref self) -> DefinitionReturn Id and optional Description parsed from the id line (first token vs rest).
Args:
- self (
Self)
Returns:
Definition
byte_len
Section titled “byte_len”def byte_len(self) -> IntReturn total byte length when written (”@” + id + sequence + quality + ”+ ”).
Args:
- self (
Self)
Returns:
Int
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)
__len__
Section titled “__len__”def __len__(self) -> IntReturn the sequence length (number of bases).
Args:
- self (
Self)
Returns:
Int
__hash__
Section titled “__hash__”def __hash__[H: Hasher](self, mut hasher: H)Parameters:
- H (
Hasher)
Args:
- self (
Self) - hasher (
H)
__repr__
Section titled “__repr__”def __repr__(self) -> StringArgs:
- self (
Self)
Returns:
String