![]() |
OpenMS
|
This class serves for reading and writing PEFF (PSI Extended FASTA Format) files. More...
#include <OpenMS/FORMAT/PEFFFile.h>
Public Member Functions | |
| PEFFFile ()=default | |
| Default constructor. | |
| ~PEFFFile () override=default | |
| Destructor. | |
| void | load (const String &filename, std::vector< PEFFEntry > &entries, std::vector< PEFFDatabaseMetadata > &headers) const |
| Loads a PEFF file and stores entries and headers. | |
| void | store (const String &filename, const std::vector< PEFFEntry > &entries, const PEFFDatabaseMetadata &header) const |
| Stores entries to a PEFF file with the given header. | |
| void | store (const String &filename, const std::vector< PEFFEntry > &entries, const std::vector< PEFFDatabaseMetadata > &headers) const |
| Stores entries to a PEFF file with multiple database headers. | |
| void | readStart (const String &filename) |
| Prepares a PEFF file for streamed reading using readNext(). | |
| bool | readNext (PEFFEntry &entry) |
| Reads the next PEFF entry from the file. | |
| const std::vector< PEFFDatabaseMetadata > & | getHeaders () const |
| Returns the headers parsed during readStart(). | |
| bool | atEnd () const |
| Returns true if the end of the file has been reached. | |
| void | writeStart (const String &filename, const PEFFDatabaseMetadata &header) |
| Prepares a PEFF file for streamed writing using writeNext(). | |
| void | writeStart (const String &filename, const std::vector< PEFFDatabaseMetadata > &headers) |
| Prepares a PEFF file for streamed writing using writeNext(), with multiple headers. | |
| void | writeNext (const PEFFEntry &entry) |
| Writes the next PEFF entry to the file. | |
| void | writeEnd () |
| Closes the output file (called automatically in destructor) | |
Public Member Functions inherited from ProgressLogger | |
| ProgressLogger () | |
| Constructor. | |
| virtual | ~ProgressLogger () |
| Destructor. | |
| ProgressLogger (const ProgressLogger &other) | |
| Copy constructor. | |
| ProgressLogger & | operator= (const ProgressLogger &other) |
| Assignment Operator. | |
| void | setLogType (LogType type) const |
| Sets the progress log that should be used. The default type is NONE! | |
| LogType | getLogType () const |
| Returns the type of progress log being used. | |
| void | setLogger (ProgressLoggerImpl *logger) |
| Sets the logger to be used for progress logging. | |
| void | startProgress (SignedSize begin, SignedSize end, const String &label) const |
| Initializes the progress display. | |
| void | setProgress (SignedSize value) const |
| Sets the current progress. | |
| void | endProgress (UInt64 bytes_processed=0) const |
| void | nextProgress () const |
| increment progress by 1 (according to range begin-end) | |
Static Public Member Functions | |
| static bool | isPEFFFile (const String &filename) |
| Checks if a file appears to be a PEFF file (by checking for # PEFF header). | |
| static String | toProForma (const PEFFEntry &entry) |
| Converts a PEFF entry to ProForma notation. | |
Protected Member Functions | |
| void | parseHeaderLine_ (const String &line, PEFFDatabaseMetadata &header, bool &new_db) |
| Parse a header line (# Key=Value or # //) | |
| void | parseAnnotations_ (const String &description, PEFFEntry &entry) |
| Parse annotations from the description line. | |
| PEFFModification | parseModification_ (const String &tuple) |
| Parse a single modification tuple. | |
| PEFFVariantSimple | parseVariantSimple_ (const String &tuple) |
| Parse a simple variant tuple. | |
| PEFFVariantComplex | parseVariantComplex_ (const String &tuple) |
| Parse a complex variant tuple. | |
| PEFFProcessedRegion | parseProcessedRegion_ (const String &tuple) |
| Parse a processed region tuple. | |
| PEFFDisulfideBond | parseDisulfideBond_ (const String &tuple) |
| Parse a disulfide bond tuple. | |
| std::vector< String > | parseParenList_ (const String &value) |
| Parse a parenthesized list of values. | |
| String | formatHeader_ (const PEFFDatabaseMetadata &header) const |
| Format the header section for output. | |
| String | formatHeader_ (const std::vector< PEFFDatabaseMetadata > &headers) const |
| Format the header section for output (multiple database blocks) | |
| String | formatEntry_ (const PEFFEntry &entry) const |
| Format a single entry for output. | |
| bool | readEntry_ (std::string &id, std::string &description, std::string &seq) |
| Read entry data (identifier, description, sequence) | |
Protected Attributes | |
| std::fstream | infile_ |
| Input file stream. | |
| std::ofstream | outfile_ |
| Output file stream. | |
| std::vector< PEFFDatabaseMetadata > | headers_ |
| Parsed headers. | |
| Size | entries_read_ {0} |
| Number of entries read. | |
| std::streampos | fileSize_ {0} |
| File size for progress. | |
| std::string | seq_ |
| Current sequence buffer. | |
| std::string | id_ |
| Current identifier buffer. | |
| std::string | description_ |
| Current description buffer. | |
Protected Attributes inherited from ProgressLogger | |
| LogType | type_ |
| time_t | last_invoke_ |
| ProgressLoggerImpl * | current_logger_ |
Additional Inherited Members | |
Public Types inherited from ProgressLogger | |
| enum | LogType { CMD , GUI , NONE } |
| Possible log types. More... | |
Static Protected Attributes inherited from ProgressLogger | |
| static int | recursion_depth_ |
This class serves for reading and writing PEFF (PSI Extended FASTA Format) files.
PEFF extends FASTA with rich annotations for modifications, variants, processed regions, and proteoforms. See https://github.com/HUPO-PSI/PEFF for the specification.
You can use aggregate methods load() and store() to read/write a set of protein sequences at the cost of memory.
Or use single read/write of protein sequences using readStart(), readNext() and writeStart(), writeNext(), writeEnd() for more memory efficiency.
|
default |
Default constructor.
|
overridedefault |
Destructor.
| bool atEnd | ( | ) | const |
Returns true if the end of the file has been reached.
|
protected |
Format the header section for output.
|
protected |
Format the header section for output (multiple database blocks)
| const std::vector< PEFFDatabaseMetadata > & getHeaders | ( | ) | const |
Returns the headers parsed during readStart().
Headers are available after calling readStart().
|
static |
Checks if a file appears to be a PEFF file (by checking for # PEFF header).
| filename | The file to check |
| void load | ( | const String & | filename, |
| std::vector< PEFFEntry > & | entries, | ||
| std::vector< PEFFDatabaseMetadata > & | headers | ||
| ) | const |
Loads a PEFF file and stores entries and headers.
| filename | The PEFF file to load |
| entries | Output vector for PEFF entries |
| headers | Output vector for database metadata (one per database in file) |
| Exception::FileNotFound | is thrown if the file does not exist. |
| Exception::ParseError | is thrown if the file format is invalid. |
Parse annotations from the description line.
|
protected |
Parse a disulfide bond tuple.
|
protected |
Parse a header line (# Key=Value or # //)
|
protected |
Parse a single modification tuple.
Parse a parenthesized list of values.
|
protected |
Parse a processed region tuple.
|
protected |
Parse a complex variant tuple.
|
protected |
Parse a simple variant tuple.
|
protected |
Read entry data (identifier, description, sequence)
| bool readNext | ( | PEFFEntry & | entry | ) |
Reads the next PEFF entry from the file.
| entry | Output for the next entry |
| Exception::ParseError | is thrown if parsing fails. |
| void readStart | ( | const String & | filename | ) |
Prepares a PEFF file for streamed reading using readNext().
| filename | The PEFF file to read |
| Exception::FileNotFound | is thrown if the file does not exist. |
| Exception::FileNotReadable | is thrown if the file cannot be read. |
| void store | ( | const String & | filename, |
| const std::vector< PEFFEntry > & | entries, | ||
| const PEFFDatabaseMetadata & | header | ||
| ) | const |
Stores entries to a PEFF file with the given header.
| filename | The output file path |
| entries | The entries to store |
| header | The database metadata header |
| Exception::UnableToCreateFile | is thrown if the file cannot be created. |
| void store | ( | const String & | filename, |
| const std::vector< PEFFEntry > & | entries, | ||
| const std::vector< PEFFDatabaseMetadata > & | headers | ||
| ) | const |
Stores entries to a PEFF file with multiple database headers.
Writes a single file description block followed by one sequence database description block per provided header, then all entries.
| filename | The output file path |
| entries | The entries to store |
| headers | The database metadata headers (one per database in file) |
| Exception::UnableToCreateFile | is thrown if the file cannot be created. |
| Exception::InvalidParameter | is thrown if headers is empty. |
| void writeEnd | ( | ) |
Closes the output file (called automatically in destructor)
| void writeNext | ( | const PEFFEntry & | entry | ) |
Writes the next PEFF entry to the file.
| entry | The entry to write |
| void writeStart | ( | const String & | filename, |
| const PEFFDatabaseMetadata & | header | ||
| ) |
Prepares a PEFF file for streamed writing using writeNext().
| filename | The output file path |
| header | The database metadata header |
| Exception::UnableToCreateFile | is thrown if the file cannot be created. |
| void writeStart | ( | const String & | filename, |
| const std::vector< PEFFDatabaseMetadata > & | headers | ||
| ) |
Prepares a PEFF file for streamed writing using writeNext(), with multiple headers.
Writes a single file description block followed by one database description block per header.
| filename | The output file path |
| headers | The database metadata headers (one per database in file) |
| Exception::UnableToCreateFile | is thrown if the file cannot be created. |
| Exception::InvalidParameter | is thrown if headers is empty. |
|
protected |
Current description buffer.
|
protected |
Number of entries read.
|
protected |
File size for progress.
|
protected |
Parsed headers.
|
protected |
Current identifier buffer.
|
protected |
Input file stream.
|
protected |
Output file stream.
|
protected |
Current sequence buffer.