FastaParser
Mojo struct 🡭
FastaParser
Section titled “FastaParser”@memory_onlystruct FastaParser[R: Reader, config: ParserConfig = ParserConfig(False)]Streaming FASTA parser over a Reader.
Multi-line FASTA sequences are normalised so that all line breaks within the sequence body are stripped, producing a single contiguous sequence string per record.
API:
- next_record() → FastaRecord (raises EOFError when exhausted)
- for rec in parser: (standard iteration, propagates
parse errors — see note on
_FastaParserRecordIter)
Aliases
Section titled “Aliases”IteratorType[origin: Origin]: AnyStruct[_FastaParserRecordIter[R, config, origin]] = _FastaParserRecordIter[R, config, origin]
Parameters
Section titled “Parameters”- R (
Reader) - config (
ParserConfig)
Fields
Section titled “Fields”- lines (
LineIterator[R]) - validator (
Validator)
Implemented traits
Section titled “Implemented traits”AnyType, ImplicitlyDestructible, Iterable, Movable
Methods
Section titled “Methods”__init__
Section titled “__init__”def __init__(out self, var reader: R)Args:
- reader (
R) - self (
Self)
Returns:
Self
Raises:
has_more
Section titled “has_more”def has_more(self) -> BoolReturn True if there may be more records to read.
Args:
- self (
Self)
Returns:
Bool
get_buffer_position
Section titled “get_buffer_position”def get_buffer_position(ref self) -> IntReturn the current buffer position.
Args:
- self (
Self)
Returns:
Int
next_record
Section titled “next_record”def next_record(mut self) -> FastaRecordReturn the next FASTA record as an owned FastaRecord.
Raises EOFError when no more records are available. Raises Error on malformed input (empty sequence, missing ’>’).
Args:
- self (
Self)
Returns:
FastaRecord
Raises:
records
Section titled “records”def records(ref self) -> _FastaParserRecordIter[R, config, origin_of(self)]Args:
- self (
Self)
Returns:
_FastaParserRecordIter
__iter__
Section titled “__iter__”def __iter__(ref self) -> _FastaParserRecordIter[R, config, origin_of(self)]Args:
- self (
Self)
Returns:
_FastaParserRecordIter