FileReader
Mojo struct 🡭
FileReader
Section titled “FileReader”@memory_onlystruct FileReaderReader that reads from a file on disk. Use with FastqParser for .fastq files.
Example:
from blazeseq import FileReader, FastqParserfrom std.pathlib import Pathvar r = FileReader(Path("data.fastq"))var parser = FastqParser[FileReader](r^, "generic")for record in parser.records(): _ = record.id()Fields
Section titled “Fields”- handle (
FileHandle)
Implemented traits
Section titled “Implemented traits”AnyType, ImplicitlyDestructible, Movable, Reader
Methods
Section titled “Methods”__init__
Section titled “__init__”def __init__(out self, path: Path)Open a file for reading.
Args:
- path (
Path): Path to the file (e.g. Path(“data.fastq”)). - self (
Self)
Returns:
Self
Raises:
Error: If the file cannot be opened.
read_bytes
Section titled “read_bytes”def read_bytes(mut self, amt: Int = -1) -> List[Byte]Read up to amt bytes (or all if amt < 0) as a list of bytes.
Args:
- self (
Self) - amt (
Int)
Returns:
List
Raises:
read_to_buffer
Section titled “read_to_buffer”def read_to_buffer(mut self, mut buf: Span[Byte, MutExternalOrigin], amt: Int, pos: Int = 0) -> UInt64Read up to amt bytes from the file into buf at offset pos. Returns bytes read.
Args:
- self (
Self) - buf (
Span) - amt (
Int) - pos (
Int)
Returns:
UInt64
Raises: