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[mut=mut])

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

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

Args:

  • id (Span[UInt8, origin])
  • sequence (Span[UInt8, origin])
  • quality (Span[UInt8, origin])
  • phred_offset (UInt8)

Returns:

Self

fn sequence(self) -> StringSlice[origin]

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

Args:

  • self (Self)

Returns:

StringSlice[origin]

fn quality(self) -> StringSlice[origin]

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

Args:

  • self (Self)

Returns:

StringSlice[origin]

fn 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[origin]

fn definition(self) -> Definition

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

Args:

  • self (Self)

Returns:

Definition

fn __len__(self) -> Int

Return the sequence length (number of bases).

Args:

  • self (Self)

Returns:

Int

fn byte_len(self) -> Int

Return total byte length when written in four-line FASTQ form.

Args:

  • self (Self)

Returns:

Int

fn phred_scores(self) -> List[UInt8]

Return Phred quality scores using the record’s phred_offset.

Args:

  • self (Self)

Returns:

List[UInt8]

fn 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[UInt8]

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

Required by Writable trait; delegates to write().

Parameters:

  • w (Writer)

Args:

  • self (Self)
  • writer (w)