Skip to content

FastqRecord

Mojo struct 🡭

@memory_only
struct FastqRecord

A 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 FastqRecord
from blazeseq.fastq.quality_schema import generic_schema
var rec = FastqRecord("read1", "ACGT", "IIII", generic_schema)
print(rec.id())
var scores = rec.phred_scores()

AnyType, Copyable, Hashable, ImplicitlyDestructible, Movable, Sized, Writable

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

def __eq__(self, other: Self) -> Bool

Args:

  • self (Self)
  • other (Self)

Returns:

Bool

def __ne__(self, other: Self) -> Bool

Args:

  • self (Self)
  • other (Self)

Returns:

Bool

def sequence(ref self) -> StringSlice[origin_of(self)]

Return the sequence line as a string slice.

Args:

  • self (Self)

Returns:

StringSlice

def quality(ref self) -> StringSlice[origin_of(self)]

Return the quality line (raw ASCII bytes) as a string slice.

Args:

  • self (Self)

Returns:

StringSlice

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

def definition(ref self) -> Definition

Return Id and optional Description parsed from the id line (first token vs rest).

Args:

  • self (Self)

Returns:

Definition

def byte_len(self) -> Int

Return 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)
def write_to[w: Writer](self, mut writer: w)

Required by Writable trait; delegates to write().

Parameters:

  • w (Writer)

Args:

  • self (Self)
  • writer (w)
def __len__(self) -> Int

Return the sequence length (number of bases).

Args:

  • self (Self)

Returns:

Int

def __hash__[H: Hasher](self, mut hasher: H)

Parameters:

  • H (Hasher)

Args:

  • self (Self)
  • hasher (H)
def __repr__(self) -> String

Args:

  • self (Self)

Returns:

String