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

Helper for mzML file format. More...

#include <OpenMS/FORMAT/HANDLERS/MzMLHandlerHelper.h>

Classes

struct  BinaryData
 Representation for binary data in mzML. More...
 

Static Public Member Functions

static std::string getCompressionTerm_ (const PeakFileOptions &opt, MSNumpressCoder::NumpressConfig np_compression, const std::string &indent="", bool use_numpress=false, bool zstd_byte_shuffle=true)
 Returns the appropriate compression term given the PeakFileOptions and the NumpressConfig.
 
static void encodeNumericArray (std::vector< float > &in, const PeakFileOptions &opt, std::string &out)
 Encode a numeric array as Base64 string, applying the compression selected in opt.
 
static void encodeNumericArray (std::vector< double > &in, const PeakFileOptions &opt, std::string &out)
 Encode a numeric array as Base64 string, applying the compression selected in opt.
 
static void encodeNumericArray (std::vector< Int32 > &in, const PeakFileOptions &opt, std::string &out)
 Encode a numeric array as Base64 string, applying the compression selected in opt.
 
static void encodeNumericArray (std::vector< Int64 > &in, const PeakFileOptions &opt, std::string &out)
 Encode a numeric array as Base64 string, applying the compression selected in opt.
 
static void encodeStringArray (const std::vector< std::string > &in, const PeakFileOptions &opt, std::string &out)
 Encode a string array (null-terminated strings) as Base64 string, applying the compression selected in opt.
 
static void encodeNumpressArray (const std::vector< double > &in, const PeakFileOptions &opt, const MSNumpressCoder::NumpressConfig &config, std::string &out)
 Numpress-encode an array and encode the result as Base64 string, applying the compression selected in opt.
 
static void encodeNumpressArray (const std::vector< float > &in, const PeakFileOptions &opt, const MSNumpressCoder::NumpressConfig &config, std::string &out)
 Numpress-encode an array and encode the result as Base64 string, applying the compression selected in opt.
 
static void writeFooter_ (std::ostream &os, const PeakFileOptions &options, const std::vector< std::pair< std::string, Int64 > > &spectra_offsets, const std::vector< std::pair< std::string, Int64 > > &chromatograms_offsets)
 Write the indexed mzML footer the appropriate compression term given the PeakFileOptions and the NumpressConfig.
 
static void decodeBase64Arrays (std::vector< BinaryData > &data_, const bool skipXMLCheck=false)
 Decode Base64 arrays and write into data_ array.
 
static void computeDataProperties_ (const std::vector< BinaryData > &data_, bool &precision_64, SignedSize &index, const std::string &index_name)
 Identify a data array from a list.
 
static bool handleBinaryDataArrayCVParam (std::vector< BinaryData > &data_, const std::string &accession, const std::string &value, const std::string &name, const std::string &unit_accession)
 Handle a given CV parameter found in a binaryDataArray tag.
 

Static Private Member Functions

static void warning (int mode, const std::string &msg, UInt line=0, UInt column=0)
 Also display some warning message when appropriate (see XMLHandler)
 

Detailed Description

Helper for mzML file format.

This class provides common structures and re-useable helper functions for parsing the mzML format. These are mainly used by MzMLHandler and MzMLSpectrumDecoder.

Member Function Documentation

◆ computeDataProperties_()

static void computeDataProperties_ ( const std::vector< BinaryData > &  data_,
bool &  precision_64,
SignedSize &  index,
const std::string &  index_name 
)
static

Identify a data array from a list.

Given a specific array name, find it in the provided list and return its index and precision.

Parameters
[in]data_The list of data arrays
[in]precision_64Whether the identified array has 64 bit precision
[in]indexThe index of the identified array
[in]index_nameThe name of the array to be identified

◆ decodeBase64Arrays()

static void decodeBase64Arrays ( std::vector< BinaryData > &  data_,
const bool  skipXMLCheck = false 
)
static

Decode Base64 arrays and write into data_ array.

Parameters
[in,out]data_The input and output
[in]skipXMLCheckwhether to skip cleaning the Base64 arrays and remove whitespaces

◆ encodeNumericArray() [1/4]

static void encodeNumericArray ( std::vector< double > &  in,
const PeakFileOptions &  opt,
std::string &  out 
)
static

Encode a numeric array as Base64 string, applying the compression selected in opt.

If zstd compression is enabled in opt, the array is byte-shuffled and compressed with zstd (MS:1003781), otherwise it is zlib-compressed if requested (MS:1000574). The data is always stored in little-endian byte order.

Parameters
[in,out]inThe data to encode (may be modified, i.e. endianized)
[in]optThe PeakFileOptions used for writing
[out]outThe resulting Base64 string

◆ encodeNumericArray() [2/4]

static void encodeNumericArray ( std::vector< float > &  in,
const PeakFileOptions &  opt,
std::string &  out 
)
static

Encode a numeric array as Base64 string, applying the compression selected in opt.

If zstd compression is enabled in opt, the array is byte-shuffled and compressed with zstd (MS:1003781), otherwise it is zlib-compressed if requested (MS:1000574). The data is always stored in little-endian byte order.

Parameters
[in,out]inThe data to encode (may be modified, i.e. endianized)
[in]optThe PeakFileOptions used for writing
[out]outThe resulting Base64 string

◆ encodeNumericArray() [3/4]

static void encodeNumericArray ( std::vector< Int32 > &  in,
const PeakFileOptions &  opt,
std::string &  out 
)
static

Encode a numeric array as Base64 string, applying the compression selected in opt.

If zstd compression is enabled in opt, the array is byte-shuffled and compressed with zstd (MS:1003781), otherwise it is zlib-compressed if requested (MS:1000574). The data is always stored in little-endian byte order.

Parameters
[in,out]inThe data to encode (may be modified, i.e. endianized)
[in]optThe PeakFileOptions used for writing
[out]outThe resulting Base64 string

◆ encodeNumericArray() [4/4]

static void encodeNumericArray ( std::vector< Int64 > &  in,
const PeakFileOptions &  opt,
std::string &  out 
)
static

Encode a numeric array as Base64 string, applying the compression selected in opt.

If zstd compression is enabled in opt, the array is byte-shuffled and compressed with zstd (MS:1003781), otherwise it is zlib-compressed if requested (MS:1000574). The data is always stored in little-endian byte order.

Parameters
[in,out]inThe data to encode (may be modified, i.e. endianized)
[in]optThe PeakFileOptions used for writing
[out]outThe resulting Base64 string

◆ encodeNumpressArray() [1/2]

static void encodeNumpressArray ( const std::vector< double > &  in,
const PeakFileOptions &  opt,
const MSNumpressCoder::NumpressConfig &  config,
std::string &  out 
)
static

Numpress-encode an array and encode the result as Base64 string, applying the compression selected in opt.

If zstd compression is enabled in opt, the numpress output is compressed with zstd (MS:1003783 - MS:1003785), otherwise it is zlib-compressed if requested (MS:1002746 - MS:1002748).

Parameters
[in]inThe data to encode
[in]optThe PeakFileOptions used for writing
[in]configThe numpress configuration
[out]outThe resulting Base64 string (empty if numpress encoding failed)

◆ encodeNumpressArray() [2/2]

static void encodeNumpressArray ( const std::vector< float > &  in,
const PeakFileOptions &  opt,
const MSNumpressCoder::NumpressConfig &  config,
std::string &  out 
)
static

Numpress-encode an array and encode the result as Base64 string, applying the compression selected in opt.

If zstd compression is enabled in opt, the numpress output is compressed with zstd (MS:1003783 - MS:1003785), otherwise it is zlib-compressed if requested (MS:1002746 - MS:1002748).

Parameters
[in]inThe data to encode
[in]optThe PeakFileOptions used for writing
[in]configThe numpress configuration
[out]outThe resulting Base64 string (empty if numpress encoding failed)

◆ encodeStringArray()

static void encodeStringArray ( const std::vector< std::string > &  in,
const PeakFileOptions &  opt,
std::string &  out 
)
static

Encode a string array (null-terminated strings) as Base64 string, applying the compression selected in opt.

If zstd compression is enabled in opt, the data is compressed with zstd (MS:1003780), otherwise it is zlib-compressed if requested (MS:1000574).

Parameters
[in]inThe strings to encode
[in]optThe PeakFileOptions used for writing
[out]outThe resulting Base64 string

◆ getCompressionTerm_()

static std::string getCompressionTerm_ ( const PeakFileOptions &  opt,
MSNumpressCoder::NumpressConfig  np_compression,
const std::string &  indent = "",
bool  use_numpress = false,
bool  zstd_byte_shuffle = true 
)
static

Returns the appropriate compression term given the PeakFileOptions and the NumpressConfig.

Parameters
[in]optThe PeakFileOptions used for writing (zlib or zstd compression)
[in]np_compressionThe numpress configuration of the array
[in]indentIndentation prepended to the term
[in]use_numpressWhether numpress compression is applied to the array
[in]zstd_byte_shuffleWhether the array is byte-shuffled before zstd compression (only used if zstd compression is enabled and numpress is not used)

◆ handleBinaryDataArrayCVParam()

static bool handleBinaryDataArrayCVParam ( std::vector< BinaryData > &  data_,
const std::string &  accession,
const std::string &  value,
const std::string &  name,
const std::string &  unit_accession 
)
static

Handle a given CV parameter found in a binaryDataArray tag.

Given a CV parameter, properly set the members of the last entry of data_, this will properly handle all terms describing precision, compression, name of the data and units.

Parameters
[in,out]data_The list of data arrays, whose last entry will be changed
[in]accessionThe CV accession
[in]valueThe CV value
[in]nameThe CV name
[in]unit_accessionThe CV unit accession (if a unit tag is present)

◆ warning()

static void warning ( int  mode,
const std::string &  msg,
UInt  line = 0,
UInt  column = 0 
)
staticprivate

Also display some warning message when appropriate (see XMLHandler)

◆ writeFooter_()

static void writeFooter_ ( std::ostream &  os,
const PeakFileOptions &  options,
const std::vector< std::pair< std::string, Int64 > > &  spectra_offsets,
const std::vector< std::pair< std::string, Int64 > > &  chromatograms_offsets 
)
static

Write the indexed mzML footer the appropriate compression term given the PeakFileOptions and the NumpressConfig.

Parameters
[out]osThe output stream
[in]optionsThe PeakFileOptions used for writing
[in]spectra_offsetsBinary offsets of <spectrum> tags
[in]chromatograms_offsetsBinary offsets of <chromatogram> tags