OpenMS
MzXMLHandler.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Marc Sturm, Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
17 
18 namespace OpenMS
19 {
20  class MetaInfoInterface;
21  namespace Interfaces
22  {
23  class IMSDataConsumer;
24  }
25 
26  namespace Internal
27  {
28 
29 
37  typedef PeakMap MapType;
38  typedef MSSpectrum SpectrumType;
39 
40  class OPENMS_DLLAPI MzXMLHandler :
41  public XMLHandler
42  {
43 public:
47  MzXMLHandler(MapType& exp, const String& filename, const String& version, ProgressLogger& logger);
48 
50  MzXMLHandler(const MapType& exp, const String& filename, const String& version, const ProgressLogger& logger);
51 
53  ~MzXMLHandler() override {}
55 
57  LOADDETAIL getLoadDetail() const override;
58 
60  void setLoadDetail(const LOADDETAIL d) override;
61 
62  // Docu in base class
63  void endElement(const XMLCh* const uri, const XMLCh* const local_name, const XMLCh* const qname) override;
64 
65  // Docu in base class
66  void startElement(const XMLCh* const uri, const XMLCh* const local_name, const XMLCh* const qname, const xercesc::Attributes& attributes) override;
67 
68  // Docu in base class
69  void characters(const XMLCh* const chars, const XMLSize_t length) override;
70 
72  void writeTo(std::ostream& os) override;
73 
75  void setOptions(const PeakFileOptions& options)
76  {
77  options_ = options;
78  }
79 
82  {
83  return scan_count_;
84  }
85 
88  {
89  consumer_ = consumer;
90  }
91 
92 protected:
93 
98 
102  const MapType* cexp_;
103 
106 
110 
119  {
125  bool skip_data;
126  };
127 
129  std::vector< SpectrumData > spectrum_data_;
131 
134 
137 
140 
143 
146 
147 
150  inline bool writeAttributeIfExists_(std::ostream& os, const MetaInfoInterface& meta, const String& metakey, const String& attname);
151 
153  inline void writeUserParam_(std::ostream& os, const MetaInfoInterface& meta, int indent = 4, const String& tag = "nameValue");
154 
162 
170 
172  std::vector< boost::shared_ptr< DataProcessing> > data_processing_;
173 
174 
175 private:
178 
180  void init_();
181  };
182 
183  } // namespace Internal
184 
185 } // namespace OpenMS
186 
The interface of a consumer of spectra and chromatograms.
Definition: IMSDataConsumer.h:44
Definition: MzXMLHandler.h:42
void init_()
initialize members (call from C'tor)
void doPopulateSpectraWithData_(SpectrumData &spectrum_data)
Fill a single spectrum with data from input.
UInt getScanCount() const
Gets the scan count.
Definition: MzXMLHandler.h:81
String precision_
Definition: MzXMLHandler.h:121
UInt peak_count_
Definition: MzXMLHandler.h:120
UInt spec_write_counter_
spectrum counter (spectra without peaks are not written)
Definition: MzXMLHandler.h:136
MapType * exp_
map pointer for reading
Definition: MzXMLHandler.h:100
LOADDETAIL getLoadDetail() const override
handler which support partial loading, implement this method
void endElement(const XMLCh *const uri, const XMLCh *const local_name, const XMLCh *const qname) override
~MzXMLHandler() override
Destructor.
Definition: MzXMLHandler.h:53
MzXMLHandler()
Not implemented.
void setOptions(const PeakFileOptions &options)
Sets the options.
Definition: MzXMLHandler.h:75
void writeUserParam_(std::ostream &os, const MetaInfoInterface &meta, int indent=4, const String &tag="nameValue")
write metaInfo to xml (usually in nameValue-tag)
void writeTo(std::ostream &os) override
Write the contents to a stream.
Interfaces::IMSDataConsumer * consumer_
Consumer class to work on spectra.
Definition: MzXMLHandler.h:139
MzXMLHandler(const MapType &exp, const String &filename, const String &version, const ProgressLogger &logger)
Constructor for a write-only handler.
const ProgressLogger & logger_
Progress logging class.
Definition: MzXMLHandler.h:145
std::vector< SpectrumData > spectrum_data_
Vector of spectrum data stored for later parallel processing.
Definition: MzXMLHandler.h:129
std::vector< boost::shared_ptr< DataProcessing > > data_processing_
data processing auxiliary variable
Definition: MzXMLHandler.h:172
void setLoadDetail(const LOADDETAIL d) override
handler which support partial loading, implement this method
MSSpectrum SpectrumType
Spectrum type.
Definition: MzXMLHandler.h:97
void setMSDataConsumer(Interfaces::IMSDataConsumer *consumer)
Set the IMSDataConsumer consumer which will consume the read data.
Definition: MzXMLHandler.h:87
PeakFileOptions options_
Options for loading and storing.
Definition: MzXMLHandler.h:105
MapType::PeakType PeakType
Peak type.
Definition: MzXMLHandler.h:95
UInt scan_count_
Consumer class to work on spectra.
Definition: MzXMLHandler.h:142
void populateSpectraWithData_()
Populate all spectra on the stack with data from input.
bool skip_data
Definition: MzXMLHandler.h:125
bool skip_spectrum_
Flag that indicates whether this spectrum should be skipped (due to options)
Definition: MzXMLHandler.h:133
MzXMLHandler(MapType &exp, const String &filename, const String &version, ProgressLogger &logger)
Constructor for a read-only handler.
bool writeAttributeIfExists_(std::ostream &os, const MetaInfoInterface &meta, const String &metakey, const String &attname)
Int nesting_level_
Definition: MzXMLHandler.h:109
void characters(const XMLCh *const chars, const XMLSize_t length) override
const MapType * cexp_
map pointer for writing
Definition: MzXMLHandler.h:102
String char_rest_
Definition: MzXMLHandler.h:123
void startElement(const XMLCh *const uri, const XMLCh *const local_name, const XMLCh *const qname, const xercesc::Attributes &attributes) override
String compressionType_
Definition: MzXMLHandler.h:122
SpectrumType spectrum
Definition: MzXMLHandler.h:124
Data necessary to generate a single spectrum.
Definition: MzXMLHandler.h:119
Base class for XML handlers.
Definition: XMLHandler.h:300
LOADDETAIL
Definition: XMLHandler.h:323
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
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:28
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
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:76
unsigned int UInt
Unsigned integer type.
Definition: Types.h:68
MSExperiment PeakMap
Two-dimensional map of raw data points or peaks.
Definition: StandardTypes.h:35
IMSDataConsumer IMSDataConsumer
Definition: IMSDataConsumer.h:101
MSSpectrum SpectrumType
Definition: MzDataHandler.h:34
PeakMap MapType
XML handler for MzDataFile.
Definition: MzDataHandler.h:33
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22