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

mzPeak file reader and writer (HUPO-PSI mzPeak: Parquet tables in a ZIP archive or a directory). More...

#include <OpenMS/FORMAT/MzPeakFile.h>

Inheritance diagram for MzPeakFile:
ProgressLogger

Public Member Functions

 MzPeakFile ()
 
 ~MzPeakFile () override
 
PeakFileOptions & getOptions ()
 Mutable access to the options for loading/storing.
 
const PeakFileOptions & getOptions () const
 Non-mutable access to the options for loading/storing.
 
void setOptions (const PeakFileOptions &)
 set options for loading/storing
 
void load (const std::string &filename, PeakMap &exp)
 Loads a run from an mzPeak archive or directory into exp.
 
void transform (const std::string &filename, Interfaces::IMSDataConsumer *consumer)
 Streams the spectra (and chromatograms) of an mzPeak archive or directory into consumer.
 
void store (const std::string &filename, const PeakMap &exp) const
 Stores a run as an mzPeak archive (ZIP) at filename.
 
- 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 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)
 

Static Public Member Functions

static bool isMzPeak (const std::string &path)
 Whether path looks like an mzPeak run: a directory holding 'mzpeak_index.json', or a file that is a ZIP archive (whose members are checked when it is opened). False for anything that does not exist.
 
static bool isSupported ()
 Whether OpenMS was built with mzPeak support (OPENMS_ENABLE_MZPEAK)
 

Private Attributes

PeakFileOptions options_
 

Additional Inherited Members

- Public Types inherited from ProgressLogger
enum  LogType { CMD , GUI , NONE }
 Possible log types. More...
 
- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImpl * current_logger_
 
- Static Protected Attributes inherited from ProgressLogger
static std::atomic< int > recursion_depth_
 

Detailed Description

mzPeak file reader and writer (HUPO-PSI mzPeak: Parquet tables in a ZIP archive or a directory).

Reads an mzPeak run into an MSExperiment or streams it into an Interfaces::IMSDataConsumer (as MzMLFile::transform() does), and writes an MSExperiment as an mzPeak archive. The format is implemented by the vendored mzPeak C++ library (src/openms/thirdparty/mzpeak, see its README.OpenMS.md for the library commit and the format version), which is available when OpenMS is built with OPENMS_ENABLE_MZPEAK (the WITH_MZPEAK define); without it, load(), transform() and store() throw Exception::NotImplemented.

An mzPeak run is a ZIP archive ('.mzpeak' file) with an index ('mzpeak_index.json') and Parquet members, or a directory with the same members; isMzPeak() tells the two from other files and directories.

Reading: spectra (m/z, intensity, per-peak ion mobility arrays), their retention time (in seconds, converted from the minutes the format stores), MS level, native ID, polarity, centroid/profile representation, scan windows, ion mobility (drift time with its unit), precursors (isolation window, selected ion m/z, charge, intensity, ion mobility, activation methods and energy) and chromatograms; run-level metadata (run start time, source files, instrument model). The scan-level PeakFileOptions (MS levels, RT range, precursor m/z range) are applied before the peaks are decoded; the peak-level options (m/z, intensity, ion mobility ranges) after. The spectra are decoded in parallel with the OpenMP threads of the calling thread (one reader per thread, as the library's thread-safety model requires).

Writing: m/z, intensity, representation, MS level, retention time, polarity, native ID, precursors (isolation window, selected ion, charge, intensity) and the spectrum's ion mobility; run-level metadata (run start time, source files with their checksum, file format and native ID format). Not written (yet), with a warning: other data arrays, activation methods and energies, and chromatograms; without one: scan windows and instrument metadata. An experiment with a per-peak ion mobility array is refused (Exception::IllegalArgument), as storing it without one would change what its peaks are.

Constructor & Destructor Documentation

◆ MzPeakFile()

◆ ~MzPeakFile()

~MzPeakFile ( )
override

Member Function Documentation

◆ getOptions() [1/2]

PeakFileOptions & getOptions ( )

Mutable access to the options for loading/storing.

◆ getOptions() [2/2]

const PeakFileOptions & getOptions ( ) const

Non-mutable access to the options for loading/storing.

◆ isMzPeak()

static bool isMzPeak ( const std::string &  path)
static

Whether path looks like an mzPeak run: a directory holding 'mzpeak_index.json', or a file that is a ZIP archive (whose members are checked when it is opened). False for anything that does not exist.

◆ isSupported()

static bool isSupported ( )
static

Whether OpenMS was built with mzPeak support (OPENMS_ENABLE_MZPEAK)

◆ load()

void load ( const std::string &  filename,
PeakMap &  exp 
)

Loads a run from an mzPeak archive or directory into exp.

Exceptions
Exception::FileNotFoundis thrown if the file could not be opened
Exception::ParseErroris thrown if an error occurs during parsing
Exception::NotImplementedis thrown if OpenMS was built without mzPeak support

◆ setOptions()

void setOptions ( const PeakFileOptions &  )

set options for loading/storing

◆ store()

void store ( const std::string &  filename,
const PeakMap &  exp 
) const

Stores a run as an mzPeak archive (ZIP) at filename.

Exceptions
Exception::UnableToCreateFileis thrown if the file could not be created
Exception::NotImplementedis thrown if OpenMS was built without mzPeak support

◆ transform()

void transform ( const std::string &  filename,
Interfaces::IMSDataConsumer *  consumer 
)

Streams the spectra (and chromatograms) of an mzPeak archive or directory into consumer.

The consumer gets the experimental settings and the expected sizes first, then the spectra in file order, decoded in batches with the OpenMP threads of the calling thread, then the chromatograms.

Exceptions
Exception::FileNotFoundis thrown if the file could not be opened
Exception::ParseErroris thrown if an error occurs during parsing
Exception::NotImplementedis thrown if OpenMS was built without mzPeak support

Member Data Documentation

◆ options_

PeakFileOptions options_
private