PEFFFile#

class pyopenms.PEFFFile#

Bases: ProgressLogger

File adapter for PEFF (PSI Extended FASTA Format) files PEFF extends FASTA with rich annotations for modifications, variants, processed regions, and proteoforms. Usage:

# Batch loading: load() returns a tuple (entries, headers)
peff = PEFFFile()
entries, headers = peff.load("proteins.peff")
for entry in entries:
    print(entry.identifier, len(entry.modifications))
# Streaming (memory-efficient for large files)
peff = PEFFFile()
peff.readStart("proteins.peff")
entry = PEFFEntry()
while peff.readNext(entry):
    print(entry.identifier)
__init__() → None#

Methods

__init__()

atEnd()

Returns True if the end of the file has been reached

endProgress([bytes_processed])

Ends the progress display

getHeaders()

Returns a copy of the headers parsed during readStart()

getLogType()

Returns the type of progress log being used

isPEFFFile(filename)

load(filename)

Loads a PEFF file and stores entries and headers

nextProgress()

Increment progress by 1 (according to range begin-end)

readNext(entry)

Reads the next PEFF entry from the file

readStart(filename)

Prepares a PEFF file 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, header)

Overloaded function.

toProForma(entry)

writeEnd()

Closes the output file (called automatically in the destructor)

writeNext(entry)

Writes the next PEFF entry to the file

writeStart(filename, header)

Prepares a PEFF file for streamed writing using writeNext()

Attributes

CMD = 0#
GUI = 1#
NONE = 2#
atEnd() → bool#

Returns True if the end of the file has been reached

endProgress(bytes_processed: int = 0) → None#

Ends the progress display

getHeaders() → list[pyopenms.PEFFDatabaseMetadata]#

Returns a copy of the headers parsed during readStart()

getLogType() → pyopenms.ProgressLogger.LogType#

Returns the type of progress log being used

static isPEFFFile(filename: str) → bool#
load(filename: str) → tuple[list[pyopenms.PEFFEntry], list[pyopenms.PEFFDatabaseMetadata]]#

Loads a PEFF file and stores entries and headers

Parameters:

filename – The PEFF file to load

Returns:

Tuple of (entries, headers): the PEFF entries and the database metadata

nextProgress() → None#

Increment progress by 1 (according to range begin-end)

readNext(entry: pyopenms.PEFFEntry) → bool#

Reads the next PEFF entry from the file

Parameters:

entry – Output for the next entry

Returns:

True if an entry was read, False if EOF was reached

Raises:

Exception:ParseError is thrown if parsing fails

readStart(filename: str) → None#

Prepares a PEFF file for streamed reading using readNext()

Parameters:

filename – The PEFF file to read

Raises:

Exception:FileNotFound is thrown if the file does not exist Exception:FileNotReadable is thrown if the file cannot be read

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.PEFFEntry], header: pyopenms.PEFFDatabaseMetadata) → None#
store(filename: str, entries: collections.abc.Sequence[pyopenms.PEFFEntry], headers: collections.abc.Sequence[pyopenms.PEFFDatabaseMetadata]) → None

Overloaded function.

  1. store(filename: str, entries: collections.abc.Sequence[pyopenms.PEFFEntry], header: pyopenms.PEFFDatabaseMetadata) -> None

Store PEFF file with single header

  1. store(filename: str, entries: collections.abc.Sequence[pyopenms.PEFFEntry], headers: collections.abc.Sequence[pyopenms.PEFFDatabaseMetadata]) -> None

Store PEFF file with multiple headers

static toProForma(entry: pyopenms.PEFFEntry) → str#
writeEnd() → None#

Closes the output file (called automatically in the destructor)

writeNext(entry: pyopenms.PEFFEntry) → None#

Writes the next PEFF entry to the file

writeStart(filename: str, header: pyopenms.PEFFDatabaseMetadata) → None#
writeStart(filename: str, headers: collections.abc.Sequence[pyopenms.PEFFDatabaseMetadata]) → None

Prepares a PEFF file for streamed writing using writeNext()