OpenMS
Loading...
Searching...
No Matches
MzDataHandler.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: Timo Sachsenberg $
6// $Authors: Marc Sturm $
7// --------------------------------------------------------------------------
8
9#pragma once
10
16
17#include <sstream>
18
19namespace OpenMS
20{
21 namespace Internal
22 {
35
36 class OPENMS_DLLAPI MzDataHandler :
37 public XMLHandler
38 {
39public:
43 MzDataHandler(MapType & exp, const std::string & filename, const std::string & version, ProgressLogger & logger);
44
46 MzDataHandler(const MapType & exp, const std::string & filename, const std::string & version, const ProgressLogger & logger);
47
49 ~MzDataHandler() override
50 {
51 }
52
54
55
56 // Docu in base class
57 void endElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname) override;
58
59 // Docu in base class
60 void startElement(const XMLCh * const /*uri*/, const XMLCh * const /*local_name*/, const XMLCh * const qname, const xercesc::Attributes & attributes) override;
61
62 // Docu in base class
63 void characters(const XMLCh * const chars, const XMLSize_t length) override;
64
66 void writeTo(std::ostream & os) override;
67
69 void setOptions(const PeakFileOptions & options)
70 {
71 options_ = options;
72 }
73
74private:
75 void init_();
76
77protected:
78
83
87 const MapType * cexp_;
88
91
99 std::vector<std::pair<std::string, MetaInfoDescription> > meta_id_descs_;
101 std::vector<std::string> data_to_decode_;
103 std::vector<float> data_to_encode_;
104 std::vector<std::vector<float> > decoded_list_;
105 std::vector<std::vector<double> > decoded_double_list_;
106 std::vector<std::string> precisions_;
107 std::vector<std::string> endians_;
109
112
115
117 void fillData_();
118
120
121
132 inline void writeCVS_(std::ostream & os, double value, const std::string & acc, const std::string & name, UInt indent = 4) const;
133
145 inline void writeCVS_(std::ostream & os, const std::string & value, const std::string & acc, const std::string & name, UInt indent = 4) const;
146
160 inline void writeCVS_(std::ostream & os, UInt value, UInt map, const std::string & acc, const std::string & name, UInt indent = 4);
161
163 inline void writeUserParam_(std::ostream & os, const MetaInfoInterface & meta, UInt indent = 4);
164
172 void cvParam_(const std::string & name, const std::string & value);
174
180 inline void writeBinary_(std::ostream & os, Size size, const std::string & tag, const std::string & name = "", SignedSize id = -1);
181
182 //Data processing auxiliary variable
183 std::shared_ptr< DataProcessing > data_processing_;
184
185 };
186
187 //--------------------------------------------------------------------------------
188 } // namespace Internal
189
190} // namespace OpenMS
191
char16_t XMLCh
Definition ClassTest.h:30
Definition MzDataHandler.h:38
std::vector< std::vector< double > > decoded_double_list_
Definition MzDataHandler.h:105
UInt peak_count_
The number of peaks in the current spectrum (according to the length attribute – which should not be ...
Definition MzDataHandler.h:95
~MzDataHandler() override
Destructor.
Definition MzDataHandler.h:49
MapType * exp_
map pointer for reading
Definition MzDataHandler.h:85
std::vector< std::pair< std::string, MetaInfoDescription > > meta_id_descs_
An array of pairs MetaInfodescriptions and their ids.
Definition MzDataHandler.h:99
void setOptions(const PeakFileOptions &options)
Sets the options.
Definition MzDataHandler.h:69
void writeTo(std::ostream &os) override
Writes the contents to a stream.
MzDataHandler(MapType &exp, const std::string &filename, const std::string &version, ProgressLogger &logger)
Constructor for a write-only handler.
const ProgressLogger & logger_
Progress logger.
Definition MzDataHandler.h:114
void writeCVS_(std::ostream &os, UInt value, UInt map, const std::string &acc, const std::string &name, UInt indent=4)
write cvParam element to stream
std::vector< float > data_to_encode_
floating point numbers which have to be encoded and written
Definition MzDataHandler.h:103
SpectrumType spec_
The current spectrum.
Definition MzDataHandler.h:97
std::vector< std::string > precisions_
Definition MzDataHandler.h:106
MSSpectrum SpectrumType
Spectrum type.
Definition MzDataHandler.h:82
PeakFileOptions options_
Options that can be set for loading/storing.
Definition MzDataHandler.h:90
MapType::PeakType PeakType
Peak type.
Definition MzDataHandler.h:80
void writeCVS_(std::ostream &os, const std::string &value, const std::string &acc, const std::string &name, UInt indent=4) const
write cvParam containing strings to stream
void cvParam_(const std::string &name, const std::string &value)
read attributes of MzData's cvParamType
bool skip_spectrum_
Flag that indicates whether this spectrum should be skipped (due to options)
Definition MzDataHandler.h:111
std::vector< std::vector< float > > decoded_list_
Definition MzDataHandler.h:104
void writeCVS_(std::ostream &os, double value, const std::string &acc, const std::string &name, UInt indent=4) const
write cvParam containing strings to stream
void startElement(const XMLCh *const, const XMLCh *const, const XMLCh *const qname, const xercesc::Attributes &attributes) override
MzDataHandler(const MapType &exp, const std::string &filename, const std::string &version, const ProgressLogger &logger)
Constructor for a read-only handler.
std::vector< std::string > endians_
Definition MzDataHandler.h:107
std::shared_ptr< DataProcessing > data_processing_
Definition MzDataHandler.h:183
void characters(const XMLCh *const chars, const XMLSize_t length) override
void endElement(const XMLCh *const, const XMLCh *const, const XMLCh *const qname) override
void writeUserParam_(std::ostream &os, const MetaInfoInterface &meta, UInt indent=4)
Writing the MetaInfo as UserParam to the file.
void fillData_()
fills the current spectrum with peaks and meta data
const MapType * cexp_
map pointer for writing
Definition MzDataHandler.h:87
void writeBinary_(std::ostream &os, Size size, const std::string &tag, const std::string &name="", SignedSize id=-1)
write binary data to stream (first one)
std::vector< std::string > data_to_decode_
encoded data which is read and has to be decoded
Definition MzDataHandler.h:101
Base class for XML handlers.
Definition XMLHandler.h:315
The representation of a chromatogram.
Definition MSChromatogram.h:30
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition MetaInfoInterface.h:35
A 1-dimensional raw data point or peak.
Definition Peak1D.h:30
Options for loading files containing peak data.
Definition PeakFileOptions.h:22
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
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
MSChromatogram ChromatogramType
Definition MzDataHandler.h:34
MSSpectrum SpectrumType
Definition MzDataHandler.h:33
PeakMap MapType
XML handler for MzDataFile.
Definition MzDataHandler.h:32
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19