OpenMS
2.7.0
|
File adapter for MzML files. More...
#include <OpenMS/FORMAT/MzMLFile.h>
Classes | |
struct | SpecInfo |
Public Member Functions | |
MzMLFile () | |
Default constructor. More... | |
~MzMLFile () override | |
Destructor. More... | |
PeakFileOptions & | getOptions () |
Mutable access to the options for loading/storing. More... | |
const PeakFileOptions & | getOptions () const |
Non-mutable access to the options for loading/storing. More... | |
void | setOptions (const PeakFileOptions &) |
set options for loading/storing More... | |
void | load (const String &filename, PeakMap &map) |
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled using PeakFileOptions). More... | |
void | loadBuffer (const std::string &buffer, PeakMap &map) |
Loads a map from a MzML file stored in a buffer (in memory). More... | |
void | loadSize (const String &filename, Size &scount, Size &ccount) |
Only count the number of spectra and chromatograms from a file. More... | |
void | store (const String &filename, const PeakMap &map) const |
Stores a map in an MzML file. More... | |
void | storeBuffer (std::string &output, const PeakMap &map) const |
Stores a map in an output string. More... | |
void | transform (const String &filename_in, Interfaces::IMSDataConsumer *consumer, bool skip_full_count=false, bool skip_first_pass=false) |
Transforms a map while loading using the supplied MSDataConsumer. More... | |
void | transform (const String &filename_in, Interfaces::IMSDataConsumer *consumer, PeakMap &map, bool skip_full_count=false, bool skip_first_pass=false) |
Transforms a map while loading using the supplied MSDataConsumer. More... | |
bool | isValid (const String &filename, std::ostream &os=std::cerr) |
Checks if a file validates against the XML schema. More... | |
bool | isSemanticallyValid (const String &filename, StringList &errors, StringList &warnings) |
Checks if a file is valid with respect to the mapping file and the controlled vocabulary. More... | |
std::map< UInt, SpecInfo > | getCentroidInfo (const String &filename, const Size first_n_spectra_only=10) |
Check type of spectra based on their metadata (if available) or by inspecting the peaks itself. More... | |
Public Member Functions inherited from XMLFile | |
XMLFile () | |
Default constructor. More... | |
XMLFile (const String &schema_location, const String &version) | |
Constructor that sets the schema location. More... | |
virtual | ~XMLFile () |
Destructor. More... | |
bool | isValid (const String &filename, std::ostream &os) |
Checks if a file validates against the XML schema. More... | |
const String & | getVersion () const |
return the version of the schema More... | |
Public Member Functions inherited from ProgressLogger | |
ProgressLogger () | |
Constructor. More... | |
virtual | ~ProgressLogger () |
Destructor. More... | |
ProgressLogger (const ProgressLogger &other) | |
Copy constructor. More... | |
ProgressLogger & | operator= (const ProgressLogger &other) |
Assignment Operator. More... | |
void | setLogType (LogType type) const |
Sets the progress log that should be used. The default type is NONE! More... | |
LogType | getLogType () const |
Returns the type of progress log being used. More... | |
void | startProgress (SignedSize begin, SignedSize end, const String &label) const |
Initializes the progress display. More... | |
void | setProgress (SignedSize value) const |
Sets the current progress. More... | |
void | endProgress () const |
Ends the progress display. More... | |
void | nextProgress () const |
increment progress by 1 (according to range begin-end) More... | |
Protected Member Functions | |
void | transformFirstPass_ (const String &filename_in, Interfaces::IMSDataConsumer *consumer, bool skip_full_count) |
Perform first pass through the file and retrieve the meta-data to initialize the consumer. More... | |
void | safeParse_ (const String &filename, Internal::XMLHandler *handler) |
Safe parse that catches exceptions and handles them accordingly. More... | |
Protected Member Functions inherited from XMLFile | |
void | parse_ (const String &filename, XMLHandler *handler) |
Parses the XML file given by filename using the handler given by handler . More... | |
void | parseBuffer_ (const std::string &buffer, XMLHandler *handler) |
Parses the in-memory buffer given by buffer using the handler given by handler . More... | |
void | save_ (const String &filename, XMLHandler *handler) const |
Stores the contents of the XML handler given by handler in the file given by filename . More... | |
void | enforceEncoding_ (const String &encoding) |
Private Attributes | |
PeakFileOptions | options_ |
Options for loading / storing. More... | |
String | indexed_schema_location_ |
Location of indexed mzML schema. More... | |
Additional Inherited Members | |
Public Types inherited from ProgressLogger | |
enum | LogType { CMD , GUI , NONE } |
Possible log types. More... | |
Static Protected Member Functions inherited from ProgressLogger | |
static String | logTypeToFactoryName_ (LogType type) |
Return the name of the factory product used for this log type. More... | |
Protected Attributes inherited from XMLFile | |
String | schema_location_ |
XML schema file location. More... | |
String | schema_version_ |
Version string. More... | |
String | enforced_encoding_ |
Encoding string that replaces the encoding (system dependent or specified in the XML). Disabled if empty. Used as a workaround for XTandem output xml. More... | |
Protected Attributes inherited from ProgressLogger | |
LogType | type_ |
time_t | last_invoke_ |
ProgressLoggerImpl * | current_logger_ |
Static Protected Attributes inherited from ProgressLogger | |
static int | recursion_depth_ |
File adapter for MzML files.
This implementation does currently not support the whole functionality of MzML.
struct OpenMS::MzMLFile::SpecInfo |
MzMLFile | ( | ) |
Default constructor.
|
override |
Destructor.
std::map<UInt, SpecInfo> getCentroidInfo | ( | const String & | filename, |
const Size | first_n_spectra_only = 10 |
||
) |
Check type of spectra based on their metadata (if available) or by inspecting the peaks itself.
By default, only the first first_n_spectra_only
, which are NOT 'unknown' are checked to save time. The current PeakFileOptions, e.g. which MS-level to read/skip, are honored, e.g. skipped spectra do not count towards first_n_spectra_only
.
You can use this function to estimate the spectrum type, but it should be done for each MS-level separately. Otherwise you might get mixed (PROFILE+CENTROIDED) results.
filename | File name of the mzML file to be checked |
first_n_spectra_only | Only inspect this many spectra (UNKNOWN spectra do not count) and then end parsing the file |
Exception::FileNotFound | is thrown if the file could not be opened |
PeakFileOptions& getOptions | ( | ) |
Mutable access to the options for loading/storing.
Referenced by NucleicAcidSearchEngine::main_().
const PeakFileOptions& getOptions | ( | ) | const |
Non-mutable access to the options for loading/storing.
bool isSemanticallyValid | ( | const String & | filename, |
StringList & | errors, | ||
StringList & | warnings | ||
) |
Checks if a file is valid with respect to the mapping file and the controlled vocabulary.
filename | File name of the file to be checked. |
errors | Errors during the validation are returned in this output parameter. |
warnings | Warnings during the validation are returned in this output parameter. |
Exception::FileNotFound | is thrown if the file could not be opened |
bool isValid | ( | const String & | filename, |
std::ostream & | os = std::cerr |
||
) |
Checks if a file validates against the XML schema.
Exception::FileNotFound | is thrown if the file cannot be found. |
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled using PeakFileOptions).
filename | The filename with the data |
map | Is an MSExperiment |
Exception::FileNotFound | is thrown if the file could not be opened |
Exception::ParseError | is thrown if an error occurs during parsing |
Referenced by CachedSwathFileConsumer::ensureMapsAreFilled_(), TOPPGNPSExport::main_(), and NucleicAcidSearchEngine::main_().
void loadBuffer | ( | const std::string & | buffer, |
PeakMap & | map | ||
) |
Loads a map from a MzML file stored in a buffer (in memory).
[in] | buffer | The buffer with the data (i.e. string with content of an mzML file) |
[out] | map | Is an MSExperiment |
Exception::ParseError | is thrown if an error occurs during parsing |
Only count the number of spectra and chromatograms from a file.
This method honors PeakOptions (if specified) for spectra, i.e. only spectra within the specified RT range and MS levels are counted. If PeakOptions have no filters set (the default), then spectra and chromatogram counts are taken from the counts attribute of the spectrumList/chromatogramList tags (the parsing skips all intermediate data and ends as soon as both counts are available).
|
protected |
Safe parse that catches exceptions and handles them accordingly.
void setOptions | ( | const PeakFileOptions & | ) |
set options for loading/storing
Referenced by IndexedMzMLFileLoader::store().
Stores a map in an MzML file.
map
has to be an MSExperiment or have the same interface.
Exception::UnableToCreateFile | is thrown if the file could not be created |
Referenced by NucleicAcidSearchEngine::main_(), TOPPViewBase::runTOPPTool_(), and IndexedMzMLFileLoader::store().
void storeBuffer | ( | std::string & | output, |
const PeakMap & | map | ||
) | const |
Stores a map in an output string.
output
An empty string to store the result map
has to be an MSExperiment
void transform | ( | const String & | filename_in, |
Interfaces::IMSDataConsumer * | consumer, | ||
bool | skip_full_count = false , |
||
bool | skip_first_pass = false |
||
) |
Transforms a map while loading using the supplied MSDataConsumer.
The result will not be stored directly but is available through the events triggered by the parser and caught by the provided IMSDataConsumer object.
This function should be used if processing and storage of the result can be performed directly in the provided IMSDataConsumer object.
filename_in | Filename of input mzML file to transform |
consumer | Consumer class to operate on the input filename (implementing a transformation) |
skip_full_count | Whether to skip computing the correct number of spectra and chromatograms in the input file |
void transform | ( | const String & | filename_in, |
Interfaces::IMSDataConsumer * | consumer, | ||
PeakMap & | map, | ||
bool | skip_full_count = false , |
||
bool | skip_first_pass = false |
||
) |
Transforms a map while loading using the supplied MSDataConsumer.
The result will be stored in the provided map.
This function should be used if a specific pre-processing should be applied to the data before storing them in a map (e.g. if data-reduction should be applied to the data before loading all data into memory).
filename_in | Filename of input mzML file to transform |
consumer | Consumer class to operate on the input filename (implementing a transformation) |
map | Map to store the resulting spectra and chromatograms |
skip_full_count | Whether to skip computing the correct number of spectra and chromatograms in the input file |
|
protected |
Perform first pass through the file and retrieve the meta-data to initialize the consumer.
|
private |
Location of indexed mzML schema.
|
private |
Options for loading / storing.