Skip to content

rammappy.fasta

FastaStreamer

Streaming FASTA parser. Push bytes via push; pop completed (name, seq) pairs via next_record; flush the in-flight record (if any) at end-of-input via finalize.

__new__(*args, **kwargs) builtin

Create and return a new object. See help(type) for accurate signature.

finalize() method descriptor

Flush the trailing partial line + the in-flight record. Call once after the last push. The flushed record (if any) is appended to the queue — drain with next_record.

next_record() method descriptor

Pop a completed record from the internal queue.

push(chunk) method descriptor

Feed a chunk of bytes. Records that complete inside this chunk are queued for next_record.

FastqStreamer

Streaming FASTQ parser. 4-line records: @name, sequence, +, quality. Quality scores are consumed and discarded; only (name, seq) is yielded.

__new__(*args, **kwargs) builtin

Create and return a new object. See help(type) for accurate signature.

finalize() method descriptor

Flush the trailing partial line + the in-flight record.

next_record() method descriptor

Pop a completed record from the internal queue.

push(chunk) method descriptor

Feed a chunk of bytes.

FastxReader

A reader for parsing FASTA/FASTQ files.

The FastxReader allows parsing of uncompressed or gzip-compressed FASTA/FASTQ files and acts as a Python iterator, yielding sequence records.

Examples:

>>> from rammappy import FastxReader
>>> reader = FastxReader("test.fa")
>>> for record in reader:
...     print(f"{record.name}: {record.sequence}")

__iter__() method descriptor

Implement iter(self).

__new__(*args, **kwargs) builtin

Create and return a new object. See help(type) for accurate signature.

__next__() method descriptor

Implement next(self).

read_batch(batch_size) method descriptor

Read sequences until cumulative bases exceed batch_size. Returns (seqs, is_eof). Caller can call again for the next batch.

Record

A sequence record from a FASTA or FASTQ file.

__new__(*args, **kwargs) builtin

Create and return a new object. See help(type) for accurate signature.

__repr__() method descriptor

Return repr(self).

parse_fasta_bytes(data) builtin

Parse FASTA from a byte slice (works with mmap or regular buffers) Returns a list of (name, sequence) pairs.

read_fasta(path) builtin

Read all sequences from a FASTA file into memory. Returns a list of (name, sequence) pairs.