Skip to content

GZFile

Mojo struct 🡭

@memory_only
struct GZFile

Reader for gzip-compressed files (.gz). Implements the Reader trait like FileReader.

Use for .fastq.gz files with FastqParser. Some builds auto-detect uncompressed files and pass through; see module docstring. Same interface as FileReader for drop-in use with parsers.

Example:

from blazeseq import GZFile, FastqParser
var r = GZFile("data.fastq.gz", "rb")
var parser = FastqParser[GZFile](r^, "illumina_1.8")
for record in parser.records():
_ = record.id()
  • handle (c_void_ptr)
  • lib (ZLib)
  • filename (String)
  • mode (String)

AnyType, ImplicitlyDestructible, Movable, Reader

def __init__(out self, filename: String, mode: String)

Open a gzip file (e.g. mode “rb” for read binary).

Args:

  • filename (String): Path to the .gz file.
  • mode (String): Open mode (e.g. “rb”).
  • self (Self)

Returns:

Self

Raises:

Error: If the file cannot be opened.

def __init__(out self, *, deinit take: Self)

Args:

  • take (Self)
  • self (Self)

Returns:

Self

def __del__(deinit self)

Close the file when the object is destroyed.

Args:

  • self (Self)
def read_to_buffer(mut self, mut buf: Span[Byte, MutExternalOrigin], amt: Int, pos: Int) -> UInt64

Read decompressed bytes into buf at offset pos. Returns bytes read (0 at EOF).

Args:

  • self (Self)
  • buf (Span)
  • amt (Int)
  • pos (Int)

Returns:

UInt64

Raises: