OpenMS
Loading...
Searching...
No Matches
MzIdentMLFile Class Reference

File adapter for MzIdentML files. More...

#include <OpenMS/FORMAT/MzIdentMLFile.h>

Inheritance diagram for MzIdentMLFile:
[legend]
Collaboration diagram for MzIdentMLFile:
[legend]

Public Member Functions

 MzIdentMLFile ()
 Default constructor.
 
 ~MzIdentMLFile () override
 Destructor.
 
void load (const std::string &filename, std::vector< ProteinIdentification > &poid, PeptideIdentificationList &peid)
 Loads the identifications from a MzIdentML file.
 
void store (const std::string &filename, const std::vector< ProteinIdentification > &poid, const PeptideIdentificationList &peid) const
 Stores the identifications in a MzIdentML file.
 
bool isSemanticallyValid (const std::string &filename, StringList &errors, StringList &warnings)
 Checks if a file is valid with respect to the mapping file and the controlled vocabulary.
 
bool isValid (const std::string &filename, std::ostream &os, std::string &used_version)
 Checks if a file validates against the mzIdentML schema that matches its declared version.
 
std::string detectVersion (const std::string &filename) const
 Detect the mzIdentML version declared in filename (e.g. "1.1.0").
 
- Public Member Functions inherited from XMLFile
 XMLFile ()
 Construct an XMLFile without schema info; schema_location_ remains unset, so isValid cannot be used until derived-class logic initializes schema_location_ before calling isValid.
 
 XMLFile (const std::string &schema_location, const std::string &version)
 Construct with a schema location for later isValid calls.
 
virtual ~XMLFile ()
 Virtual destructor — defaulted; allows safe deletion through a base-class pointer.
 
bool isValid (const std::string &filename, std::ostream &os)
 Check if filename validates against the bound XML schema.
 
const std::string & getVersion () const
 Return the schema version string passed to the parameterised constructor; empty for default-constructed instances.
 
- Public Member Functions inherited from ProgressLogger
 ProgressLogger ()
 Constructor.
 
virtual ~ProgressLogger ()
 Destructor.
 
 ProgressLogger (const ProgressLogger &other)
 Copy constructor.
 
ProgressLoggeroperator= (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 std::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)
 

Additional Inherited Members

- Public Types inherited from ProgressLogger
enum  LogType { CMD , GUI , NONE }
 Possible log types. More...
 
- Protected Member Functions inherited from XMLFile
void parse_ (const std::string &filename, XMLHandler *handler)
 Parse the XML file at filename through handler.
 
void parseBuffer_ (const std::string &buffer, XMLHandler *handler)
 Parse an in-memory XML buffer through handler.
 
void save_ (const std::string &filename, XMLHandler *handler) const
 Stores the contents of the XML handler given by handler in the file given by filename.
 
void enforceEncoding_ (const std::string &encoding)
 Set or clear the XML-encoding override applied to subsequent parse_ / parseBuffer_ calls.
 
- Protected Attributes inherited from XMLFile
std::string schema_location_
 Path of the XML schema for validation; empty when the default constructor was used (isValid then throws NotImplemented).
 
std::string schema_version_
 Schema version string returned by getVersion.
 
std::string enforced_encoding_
 Optional XML encoding override applied to the InputSource in parse_ and parseBuffer_; empty disables the override. Used as a workaround for XTandem output XML which carries an encoding the parser otherwise stumbles on.
 
- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImplcurrent_logger_
 
- Static Protected Attributes inherited from ProgressLogger
static int recursion_depth_
 

Detailed Description

File adapter for MzIdentML files.

This file adapter exposes the internal MzIdentML processing capabilities to the library. The file adapter interface is kept the same as idXML file adapter for downward capability reasons. For now, read-in will be performed with DOM write-out with STREAM

Note
due to the limited capabilities of idXML/PeptideIdentification/ProteinIdentification not all MzIdentML features can be supported. Development for these structures will be discontinued, a new interface with appropriate structures will be provided.
If a critical error occurs due to the missing functionality, Exception::NotImplemented is thrown.
All PSM will be read into PeptideIdentification, even the passThreshold=false, threshold will be read into ProteinIdentification (i.e. one id run), considered at writing also will only be the threshold set in ProteinIdentification
All PSM will be read into PeptideIdentification, even the passThreshold=false

Constructor & Destructor Documentation

◆ MzIdentMLFile()

Default constructor.

◆ ~MzIdentMLFile()

~MzIdentMLFile ( )
override

Destructor.

Member Function Documentation

◆ detectVersion()

std::string detectVersion ( const std::string &  filename) const

Detect the mzIdentML version declared in filename (e.g. "1.1.0").

Reads the version attribute / target namespace from the document header. Falls back to the adapter's default version (1.3.0) if no version can be determined or no matching schema exists.

◆ isSemanticallyValid()

bool isSemanticallyValid ( const std::string &  filename,
StringList errors,
StringList warnings 
)

Checks if a file is valid with respect to the mapping file and the controlled vocabulary.

Parameters
[in]filenameFile name of the file to be checked.
[out]errorsErrors during the validation are returned in this output parameter.
[out]warningsWarnings during the validation are returned in this output parameter.
Exceptions
Exception::FileNotFoundis thrown if the file could not be opened

◆ isValid()

bool isValid ( const std::string &  filename,
std::ostream &  os,
std::string &  used_version 
)

Checks if a file validates against the mzIdentML schema that matches its declared version.

Unlike the base-class Internal::XMLFile::isValid (which always validates against the schema the file adapter was constructed with), this overload first detects the mzIdentML version declared in filename and validates against the corresponding schema (1.1.0, 1.2.0 or 1.3.0). This keeps older, still-valid mzIdentML files from being reported as invalid just because OpenMS now writes 1.3.0. The schema version actually used is returned via used_version.

Parameters
[in]filenameFile name of the file to be checked.
[in,out]osError-message sink for validation errors.
[out]used_versionReceives the schema version the file was validated against.
Exceptions
Exception::FileNotFoundis thrown if the file could not be opened

◆ load()

void load ( const std::string &  filename,
std::vector< ProteinIdentification > &  poid,
PeptideIdentificationList peid 
)

Loads the identifications from a MzIdentML file.

Exceptions
Exception::FileNotFoundis thrown if the file could not be opened
Exception::ParseErroris thrown if an error occurs during parsing

◆ store()

void store ( const std::string &  filename,
const std::vector< ProteinIdentification > &  poid,
const PeptideIdentificationList peid 
) const

Stores the identifications in a MzIdentML file.

Exceptions
Exception::UnableToCreateFileis thrown if the file could not be created