OpenMS  3.0.0
MzXMLHandler.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-2022.
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: Timo Sachsenberg $
32 // $Authors: Marc Sturm, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
43 
44 namespace OpenMS
45 {
46  class MetaInfoInterface;
47  namespace Interfaces
48  {
49  class IMSDataConsumer;
50  }
51 
52  namespace Internal
53  {
54 
55 
63  typedef PeakMap MapType;
64  typedef MSSpectrum SpectrumType;
65 
66  class OPENMS_DLLAPI MzXMLHandler :
67  public XMLHandler
68  {
69 public:
72  MzXMLHandler(MapType& exp, const String& filename, const String& version, ProgressLogger& logger);
74 
76  MzXMLHandler(const MapType& exp, const String& filename, const String& version, const ProgressLogger& logger);
77 
79  ~MzXMLHandler() override {}
81 
83  LOADDETAIL getLoadDetail() const override;
84 
86  void setLoadDetail(const LOADDETAIL d) override;
87 
88  // Docu in base class
89  void endElement(const XMLCh* const uri, const XMLCh* const local_name, const XMLCh* const qname) override;
90 
91  // Docu in base class
92  void startElement(const XMLCh* const uri, const XMLCh* const local_name, const XMLCh* const qname, const xercesc::Attributes& attributes) override;
93 
94  // Docu in base class
95  void characters(const XMLCh* const chars, const XMLSize_t length) override;
96 
98  void writeTo(std::ostream& os) override;
99 
101  void setOptions(const PeakFileOptions& options)
102  {
103  options_ = options;
104  }
105 
108  {
109  return scan_count_;
110  }
111 
114  {
115  consumer_ = consumer;
116  }
117 
118 protected:
119 
124 
128  const MapType* cexp_;
129 
132 
136 
145  {
151  bool skip_data;
152  };
153 
155  std::vector< SpectrumData > spectrum_data_;
157 
160 
163 
166 
169 
172 
173 
176  inline bool writeAttributeIfExists_(std::ostream& os, const MetaInfoInterface& meta, const String& metakey, const String& attname);
177 
179  inline void writeUserParam_(std::ostream& os, const MetaInfoInterface& meta, int indent = 4, String tag = "nameValue");
180 
187  void doPopulateSpectraWithData_(SpectrumData & spectrum_data);
188 
195  void populateSpectraWithData_();
196 
198  std::vector< boost::shared_ptr< DataProcessing> > data_processing_;
199 
200 
201 private:
203  MzXMLHandler();
204 
206  void init_();
207  };
208 
209  } // namespace Internal
210 
211 } // namespace OpenMS
212 
OpenMS::Internal::MzXMLHandler::SpectrumType
MSSpectrum SpectrumType
Spectrum type.
Definition: MzXMLHandler.h:123
OpenMS::Internal::MzXMLHandler::data_processing_
std::vector< boost::shared_ptr< DataProcessing > > data_processing_
data processing auxiliary variable
Definition: MzXMLHandler.h:198
OpenMS::Internal::MzXMLHandler::SpectrumData::spectrum
SpectrumType spectrum
Definition: MzXMLHandler.h:150
OpenMS::Internal::MzXMLHandler::logger_
const ProgressLogger & logger_
Progress logging class.
Definition: MzXMLHandler.h:171
OpenMS::Internal::XMLHandler
Base class for XML handlers.
Definition: XMLHandler.h:323
OpenMS::Interfaces::IMSDataConsumer
The interface of a consumer of spectra and chromatograms.
Definition: IMSDataConsumer.h:69
OpenMS::Internal::MapType
PeakMap MapType
XML handler for MzDataFile.
Definition: MzDataHandler.h:59
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::Internal::MzXMLHandler::getScanCount
UInt getScanCount() const
Gets the scan count.
Definition: MzXMLHandler.h:107
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
OpenMS::Internal::MzXMLHandler::options_
PeakFileOptions options_
Options for loading and storing.
Definition: MzXMLHandler.h:131
XMLHandler.h
OpenMS::Internal::MzXMLHandler::spec_write_counter_
UInt spec_write_counter_
spectrum counter (spectra without peaks are not written)
Definition: MzXMLHandler.h:162
OpenMS::Internal::MzXMLHandler::SpectrumData
Data necessary to generate a single spectrum.
Definition: MzXMLHandler.h:144
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::Internal::MzXMLHandler::SpectrumData::peak_count_
UInt peak_count_
Definition: MzXMLHandler.h:146
OpenMS::Internal::MzXMLHandler::SpectrumData::precision_
String precision_
Definition: MzXMLHandler.h:147
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:52
ProgressLogger.h
OpenMS::Internal::MzXMLHandler::consumer_
Interfaces::IMSDataConsumer * consumer_
Consumer class to work on spectra.
Definition: MzXMLHandler.h:165
OpenMS::MetaInfoInterface
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:60
OpenMS::Internal::SpectrumType
MSSpectrum SpectrumType
Definition: MzDataHandler.h:60
OpenMS::Internal::MzXMLHandler::~MzXMLHandler
~MzXMLHandler() override
Destructor.
Definition: MzXMLHandler.h:79
OpenMS::Internal::MzXMLHandler::scan_count_
UInt scan_count_
Consumer class to work on spectra.
Definition: MzXMLHandler.h:168
OpenMS::PeakMap
MSExperiment PeakMap
Two-dimensional map of raw data points or peaks.
Definition: StandardTypes.h:61
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:53
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::Interfaces::IMSDataConsumer
IMSDataConsumer IMSDataConsumer
Definition: IMSDataConsumer.h:127
OpenMS::Internal::MzXMLHandler::cexp_
const MapType * cexp_
map pointer for writing
Definition: MzXMLHandler.h:128
PeakFileOptions.h
OpenMS::Internal::MzXMLHandler::SpectrumData::char_rest_
String char_rest_
Definition: MzXMLHandler.h:149
MSExperiment.h
OpenMS::Internal::MzXMLHandler::PeakType
MapType::PeakType PeakType
Peak type.
Definition: MzXMLHandler.h:121
OpenMS::Internal::MzXMLHandler::nesting_level_
Int nesting_level_
Definition: MzXMLHandler.h:135
OpenMS::Internal::MzXMLHandler::setOptions
void setOptions(const PeakFileOptions &options)
Sets the options.
Definition: MzXMLHandler.h:101
OpenMS::Internal::MzXMLHandler::SpectrumData::skip_data
bool skip_data
Definition: MzXMLHandler.h:151
OpenMS::PeakFileOptions
Options for loading files containing peak data.
Definition: PeakFileOptions.h:47
String.h
OpenMS::Internal::MzXMLHandler::spectrum_data_
std::vector< SpectrumData > spectrum_data_
Vector of spectrum data stored for later parallel processing.
Definition: MzXMLHandler.h:155
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
OpenMS::Internal::MzXMLHandler
Definition: MzXMLHandler.h:66
OpenMS::Internal::MzXMLHandler::setMSDataConsumer
void setMSDataConsumer(Interfaces::IMSDataConsumer *consumer)
Set the IMSDataConsumer consumer which will consume the read data.
Definition: MzXMLHandler.h:113
StandardTypes.h
OpenMS::Internal::MzXMLHandler::SpectrumData::compressionType_
String compressionType_
Definition: MzXMLHandler.h:148
OpenMS::Internal::MzXMLHandler::exp_
MapType * exp_
map pointer for reading
Definition: MzXMLHandler.h:126
OpenMS::Internal::MzXMLHandler::skip_spectrum_
bool skip_spectrum_
Flag that indicates whether this spectrum should be skipped (due to options)
Definition: MzXMLHandler.h:159