OpenMS
MzMLHandlerHelper.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Hannes Roest $
6 // $Authors: Hannes Roest $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
14 
15 #include <vector>
16 
17 namespace OpenMS
18 {
19  namespace Internal
20  {
21 
29  class OPENMS_DLLAPI MzMLHandlerHelper
30  {
31 
33  static void warning(int mode, const String & msg, UInt line = 0, UInt column = 0);
34 
35  public:
36 
43  struct BinaryData
44  {
45  // ordered by size (alignment) and cache hotness in 'decode'
46 
47  enum {
50  PRE_64
51  } precision;
52 
53  enum {
57  DT_STRING
58  } data_type;
59 
61 
62  bool compression;
63  double unit_multiplier;
64 
67  std::vector<float> floats_32;
68  std::vector<double> floats_64;
69  std::vector<Int32> ints_32;
70  std::vector<Int64> ints_64;
71  std::vector<String> decoded_char;
72 
74 
77  precision(PRE_NONE),
78  data_type(DT_NONE),
79  np_compression(),
80  compression(false),
81  unit_multiplier(1.0),
82  base64(),
83  size(0),
84  floats_32(),
85  floats_64(),
86  ints_32(),
87  ints_64(),
88  decoded_char(),
89  meta()
90  {
91  }
92 
93  BinaryData(const BinaryData&) = default; // Copy constructor
94  BinaryData(BinaryData&&) = default; // Move constructor
95  BinaryData& operator=(const BinaryData&) & = default; // Copy assignment operator
96  BinaryData& operator=(BinaryData&&) & = default; // Move assignment operator
97  ~BinaryData() = default; // Destructor
98 
99  };
100 
105  MSNumpressCoder::NumpressConfig np_compression,
106  const String& indent = "",
107  bool use_numpress = false);
108 
118  static void writeFooter_(std::ostream& os,
119  const PeakFileOptions& options,
120  const std::vector< std::pair<std::string, Int64> > & spectra_offsets,
121  const std::vector< std::pair<std::string, Int64> > & chromatograms_offsets);
122 
129  static void decodeBase64Arrays(std::vector<BinaryData> & data_, const bool skipXMLCheck = false);
130 
141  static void computeDataProperties_(const std::vector<BinaryData>& data_, bool& precision_64, SignedSize& index, const String& index_name);
142 
156  static bool handleBinaryDataArrayCVParam(std::vector<BinaryData>& data_,
157  const String& accession,
158  const String& value,
159  const String& name,
160  const String& unit_accession);
161  };
162 
163 
164  } // namespace Internal
165 } // namespace OpenMS
166 
167 
Helper for mzML file format.
Definition: MzMLHandlerHelper.h:30
static void computeDataProperties_(const std::vector< BinaryData > &data_, bool &precision_64, SignedSize &index, const String &index_name)
Identify a data array from a list.
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 Nump...
static void decodeBase64Arrays(std::vector< BinaryData > &data_, const bool skipXMLCheck=false)
Decode Base64 arrays and write into data_ array.
static void warning(int mode, const String &msg, UInt line=0, UInt column=0)
Also display some warning message when appropriate (see XMLHandler)
static bool handleBinaryDataArrayCVParam(std::vector< BinaryData > &data_, const String &accession, const String &value, const String &name, const String &unit_accession)
Handle a given CV parameter found in a binaryDataArray tag.
static String getCompressionTerm_(const PeakFileOptions &opt, MSNumpressCoder::NumpressConfig np_compression, const String &indent="", bool use_numpress=false)
Returns the appropriate compression term given the PeakFileOptions and the NumpressConfig.
NumpressCompression
Names of compression schemes.
Definition: MSNumpressCoder.h:48
Description of the meta data arrays of MSSpectrum.
Definition: MetaInfoDescription.h:24
Options for loading files containing peak data.
Definition: PeakFileOptions.h:22
A more convenient string class.
Definition: String.h:34
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:104
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Representation for binary data in mzML.
Definition: MzMLHandlerHelper.h:44
double unit_multiplier
multiplier for unit (e.g. 60 for minutes)
Definition: MzMLHandlerHelper.h:63
std::vector< Int32 > ints_32
Definition: MzMLHandlerHelper.h:69
@ PRE_32
32bit precision
Definition: MzMLHandlerHelper.h:49
@ PRE_NONE
unknown precision
Definition: MzMLHandlerHelper.h:48
std::vector< float > floats_32
Definition: MzMLHandlerHelper.h:67
bool compression
zlib compression
Definition: MzMLHandlerHelper.h:62
Size size
Raw data length.
Definition: MzMLHandlerHelper.h:66
std::vector< String > decoded_char
Definition: MzMLHandlerHelper.h:71
String base64
Raw data in base64 encoding.
Definition: MzMLHandlerHelper.h:65
BinaryData()
Constructor.
Definition: MzMLHandlerHelper.h:76
MetaInfoDescription meta
Meta data description.
Definition: MzMLHandlerHelper.h:73
std::vector< Int64 > ints_64
Definition: MzMLHandlerHelper.h:70
std::vector< double > floats_64
Definition: MzMLHandlerHelper.h:68
BinaryData & operator=(BinaryData &&) &=default
@ DT_NONE
unknown data type
Definition: MzMLHandlerHelper.h:54
@ DT_FLOAT
float data type
Definition: MzMLHandlerHelper.h:55
@ DT_INT
integer data type
Definition: MzMLHandlerHelper.h:56
BinaryData & operator=(const BinaryData &) &=default
MSNumpressCoder::NumpressCompression np_compression
numpress options
Definition: MzMLHandlerHelper.h:60
Configuration class for MSNumpress.
Definition: MSNumpressCoder.h:63