FASTAFile#
- class pyopenms.FASTAFile#
Bases:
ProgressLoggerFile adapter for FASTA files
Provides methods to load and store protein/peptide sequences in FASTA format. Supports both batch loading (load/store) and streaming (readStart/readNext/writeStart/writeNext).
Usage:
# Batch loading entries = [] FASTAFile().load("proteins.fasta", entries) for entry in entries: print(entry.identifier, entry.sequence) # Streaming (memory-efficient for large files) ff = FASTAFile() ff.readStart("proteins.fasta") entry = FASTAEntry() while ff.readNext(entry): print(entry.identifier)
- __init__() None#
Methods
__init__()atEnd()Boolean function to check if streams is at end of file
endProgress([bytes_processed])Ends the progress display
Returns the type of progress log being used
load(filename, data)Overloaded function.
Increment progress by 1 (according to range begin-end)
readNext()Overloaded function.
readStart(filename)Prepares a FASTA file given by 'filename' for streamed reading using readNext()
setLogType(type)Sets the progress log that should be used.
setProgress(value)Sets the current progress
startProgress(begin, end, label)store(filename, entries)Overloaded function.
writeEnd()Closes the file (flush).
writeNext(entry)Writes the given FASTAEntry to the file.
writeStart(filename)Prepares a FASTA file given by 'filename' for streamed writing using writeNext()
Attributes
- CMD = 0#
- GUI = 1#
- NONE = 2#
- atEnd() bool#
Boolean function to check if streams is at end of file
- endProgress(bytes_processed: int = 0) None#
Ends the progress display
- getLogType() pyopenms.ProgressLogger.LogType#
Returns the type of progress log being used
- load(filename: str, data: list) None#
- load(filename: str) list[pyopenms.FASTAEntry]
Overloaded function.
load(filename: str, data: list) -> None
Load a FASTA file. Appends FASTAEntry objects to output list
load(filename: str) -> list[pyopenms.FASTAEntry]
Load a FASTA file. Returns list of FASTAEntry objects
- nextProgress() None#
Increment progress by 1 (according to range begin-end)
- readNext() tuple#
- readNext(entry: pyopenms.FASTAEntry) bool
Overloaded function.
readNext() -> tuple
Reads the next FASTA entry from file. Returns (success, FASTAEntry) tuple
readNext(entry: pyopenms.FASTAEntry) -> bool
Reads the next FASTA entry from file into the given FASTAEntry. Returns True if entry was read, False if EOF
- readStart(filename: str) None#
Prepares a FASTA file given by ‘filename’ for streamed reading using readNext()
- Raises:
Exception:FileNotFound is thrown if the file does not exists
- Raises:
Exception:ParseError is thrown if the file does not suit to the standard
- setLogType(type: pyopenms.ProgressLogger.LogType) None#
Sets the progress log that should be used. The default type is NONE!
- setProgress(value: int) None#
Sets the current progress
- startProgress(begin: int, end: int, label: str) None#
- store(filename: str, entries: collections.abc.Sequence[pyopenms.FASTAEntry]) None#
- store(filename: str, entries: list) None
Overloaded function.
store(filename: str, entries: collections.abc.Sequence[pyopenms.FASTAEntry]) -> None
Store a FASTA file. Takes list of FASTAEntry objects
store(filename: str, entries: list) -> None
Store a FASTA file. Takes list of FASTAEntry objects or (identifier, description, sequence) tuples
- writeEnd() None#
Closes the file (flush). Called implicitly when FASTAFile object does out of scope
- writeNext(entry: pyopenms.FASTAEntry) None#
Writes the given FASTAEntry to the file. Call writeStart() before and writeEnd() after
- writeStart(filename: str) None#
Prepares a FASTA file given by ‘filename’ for streamed writing using writeNext()
- Raises:
Exception:UnableToCreateFile is thrown if the process is not able to write to the file (disk full?)