Skip to content

FastqView

Mojo struct 🡭

@register_passable_trivial
struct 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, FileReader
from std.pathlib import Path
var parser = FastqParser[FileReader](FileReader(Path("data.fastq")), "generic")
for view in parser.views():
_ = view.id()
_ = view.sequence()
  • mut (Bool)
  • origin (Origin)

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable, RegisterPassable, Sized, TrivialRegisterPassable, Writable

def __init__(id: Span[Byte, origin], sequence: Span[Byte, origin], quality: Span[Byte, origin], phred_offset: UInt8 = 33) -> Self

Args:

  • id (Span)
  • sequence (Span)
  • quality (Span)
  • phred_offset (UInt8)

Returns:

Self

def sequence(self) -> StringSlice[origin]

Return the sequence line as a string slice (valid only while ref is valid).

Args:

  • self (Self)

Returns:

StringSlice

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

def definition(self) -> Definition

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

Args:

  • self (Self)

Returns:

Definition

def __len__(self) -> Int

Return the sequence length (number of bases).

Args:

  • self (Self)

Returns:

Int

def byte_len(self) -> Int

Return total byte length when written (”@” + id + sequence + quality + newlines and ”+ ”). Used for calculating buffer capacity.

Args:

  • self (Self)

Returns:

Int

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

Required by Writable trait; delegates to write().

Parameters:

  • w (Writer)

Args:

  • self (Self)
  • writer (w)