OpenMS  2.5.0
MzMLHandlerHelper.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2020.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Hannes Roest $
32 // $Authors: Hannes Roest $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 
41 #include <vector>
42 
43 namespace OpenMS
44 {
45  namespace Internal
46  {
47 
54  class OPENMS_DLLAPI MzMLHandlerHelper
55  {
56 
58  static void warning(int mode, const String & msg, UInt line = 0, UInt column = 0);
59 
60  public:
61 
67  struct BinaryData
68  {
69  // ordered by size (alignment) and cache hotness in 'decode'
70 
71  enum {
74  PRE_64
75  } precision;
76 
77  enum {
81  DT_STRING
82  } data_type;
83 
85 
86  bool compression;
87  double unit_multiplier;
88 
91  std::vector<float> floats_32;
92  std::vector<double> floats_64;
93  std::vector<Int32> ints_32;
94  std::vector<Int64> ints_64;
95  std::vector<String> decoded_char;
96 
98 
101  precision(PRE_NONE),
102  data_type(DT_NONE),
103  np_compression(),
104  compression(false),
105  unit_multiplier(1.0),
106  base64(),
107  size(0),
108  floats_32(),
109  floats_64(),
110  ints_32(),
111  ints_64(),
112  decoded_char(),
113  meta()
114  {
115  }
116 
117  BinaryData(const BinaryData&) = default; // Copy constructor
118  BinaryData(BinaryData&&) = default; // Move constructor
119  BinaryData& operator=(const BinaryData&) & = default; // Copy assignment operator
120  BinaryData& operator=(BinaryData&&) & = default; // Move assignment operator
121  ~BinaryData() = default; // Destructor
122 
123  };
124 
128  static String getCompressionTerm_(const PeakFileOptions& opt,
129  MSNumpressCoder::NumpressConfig np_compression,
130  String indent = "",
131  bool use_numpress = false);
132 
142  static void writeFooter_(std::ostream& os,
143  const PeakFileOptions& options,
144  const std::vector< std::pair<std::string, Int64> > & spectra_offsets,
145  const std::vector< std::pair<std::string, Int64> > & chromatograms_offsets);
146 
153  static void decodeBase64Arrays(std::vector<BinaryData> & data_, const bool skipXMLCheck = false);
154 
165  static void computeDataProperties_(const std::vector<BinaryData>& data_, bool& precision_64, SignedSize& index, const String& index_name);
166 
180  static bool handleBinaryDataArrayCVParam(std::vector<BinaryData>& data_,
181  const String& accession,
182  const String& value,
183  const String& name,
184  const String& unit_accession);
185  };
186 
187 
188  } // namespace Internal
189 } // namespace OpenMS
190 
191 
OpenMS::Internal::MzMLHandlerHelper::BinaryData::DT_INT
integer data type
Definition: MzMLHandlerHelper.h:80
OpenMS::Internal::MzMLHandlerHelper::BinaryData::BinaryData
BinaryData()
Constructor.
Definition: MzMLHandlerHelper.h:100
OpenMS::Internal::MzMLHandlerHelper::BinaryData::ints_64
std::vector< Int64 > ints_64
Definition: MzMLHandlerHelper.h:94
OpenMS::Internal::MzMLHandlerHelper::BinaryData::decoded_char
std::vector< String > decoded_char
Definition: MzMLHandlerHelper.h:95
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::MetaInfoDescription
Description of the meta data arrays of MSSpectrum.
Definition: MetaInfoDescription.h:48
OpenMS::Internal::MzMLHandlerHelper::BinaryData::DT_FLOAT
float data type
Definition: MzMLHandlerHelper.h:79
OpenMS::Internal::MzMLHandlerHelper::BinaryData::DT_NONE
unknown data type
Definition: MzMLHandlerHelper.h:78
OpenMS::Internal::MzMLHandlerHelper::BinaryData::size
Size size
Raw data length.
Definition: MzMLHandlerHelper.h:90
OpenMS::Internal::MzMLHandlerHelper::BinaryData::floats_64
std::vector< double > floats_64
Definition: MzMLHandlerHelper.h:92
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Internal::MzMLHandlerHelper::BinaryData
Representation for binary data in mzML.
Definition: MzMLHandlerHelper.h:67
OpenMS::Internal::MzMLHandlerHelper::BinaryData::PRE_NONE
unknown precision
Definition: MzMLHandlerHelper.h:72
OpenMS::Internal::MzMLHandlerHelper
Helper for mzML file format.
Definition: MzMLHandlerHelper.h:54
OpenMS::Internal::MzMLHandlerHelper::BinaryData::floats_32
std::vector< float > floats_32
Definition: MzMLHandlerHelper.h:91
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
PeakFileOptions.h
MSNumpressCoder.h
OpenMS::Internal::MzMLHandlerHelper::BinaryData::unit_multiplier
double unit_multiplier
multiplier for unit (e.g. 60 for minutes)
Definition: MzMLHandlerHelper.h:87
OpenMS::Internal::MzMLHandlerHelper::BinaryData::np_compression
MSNumpressCoder::NumpressCompression np_compression
numpress options
Definition: MzMLHandlerHelper.h:84
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
OpenMS::PeakFileOptions
Options for loading files containing peak data.
Definition: PeakFileOptions.h:47
OpenMS::Internal::MzMLHandlerHelper::BinaryData::PRE_32
32bit precision
Definition: MzMLHandlerHelper.h:73
OpenMS::MSNumpressCoder::NumpressConfig
Configuration class for MSNumpress.
Definition: MSNumpressCoder.h:87
OpenMS::MSNumpressCoder::NumpressCompression
NumpressCompression
Names of compression schemes.
Definition: MSNumpressCoder.h:73
OpenMS::Internal::MzMLHandlerHelper::BinaryData::compression
bool compression
zlib compression
Definition: MzMLHandlerHelper.h:86
OpenMS::Internal::MzMLHandlerHelper::BinaryData::base64
String base64
Raw data in base64 encoding.
Definition: MzMLHandlerHelper.h:89
OpenMS::Internal::MzMLHandlerHelper::BinaryData::ints_32
std::vector< Int32 > ints_32
Definition: MzMLHandlerHelper.h:93
OpenMS::Internal::MzMLHandlerHelper::BinaryData::meta
MetaInfoDescription meta
Meta data description.
Definition: MzMLHandlerHelper.h:97
MetaInfoDescription.h