Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
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-2017.
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 
39 #include <OpenMS/FORMAT/Base64.h>
45 
46 #include <stack>
47 
48 namespace OpenMS
49 {
50  class MetaInfoInterface;
51 
52  namespace Internal
53  {
54 
62  typedef PeakMap MapType;
63  typedef MSSpectrum SpectrumType;
64 
65  class OPENMS_DLLAPI MzXMLHandler :
66  public XMLHandler
67  {
68 public:
71  MzXMLHandler(MapType& exp, const String& filename, const String& version, ProgressLogger& logger);
73 
75  MzXMLHandler(const MapType& exp, const String& filename, const String& version, const ProgressLogger& logger);
76 
78  ~MzXMLHandler() override {}
80 
81  // Docu in base class
82  void endElement(const XMLCh* const uri, const XMLCh* const local_name, const XMLCh* const qname) override;
83 
84  // Docu in base class
85  void startElement(const XMLCh* const uri, const XMLCh* const local_name, const XMLCh* const qname, const xercesc::Attributes& attributes) override;
86 
87  // Docu in base class
88  void characters(const XMLCh* const chars, const XMLSize_t length) override;
89 
91  void writeTo(std::ostream& os) override;
92 
94  void setOptions(const PeakFileOptions& options)
95  {
96  options_ = options;
97  }
98 
101  {
102  return scan_count_;
103  }
104 
107  {
108  consumer_ = consumer;
109  }
110 
111 protected:
112 
117 
121  const MapType* cexp_;
122 
125 
130 
139  {
145  bool skip_data;
146  };
147 
149  std::vector< SpectrumData > spectrum_data_;
151 
154 
157 
160 
163 
166 
167 
169  inline std::ostream& writeAttributeIfExists_(std::ostream& os, const MetaInfoInterface& meta, const String& metakey, const String& attname);
170 
172  inline void writeUserParam_(std::ostream& os, const MetaInfoInterface& meta, int indent = 4, String tag = "nameValue");
173 
180  void doPopulateSpectraWithData_(SpectrumData & spectrum_data);
181 
188  void populateSpectraWithData_();
189 
191  std::vector< boost::shared_ptr< DataProcessing> > data_processing_;
192 
193 
194 private:
196  MzXMLHandler();
197 
199  void init_();
200 
201  // init all the static members, which is necessary because otherwise the undefined order will cause problems
202  void initStaticMembers_();
203 
204  static const XMLCh* s_value_;
205  static const XMLCh* s_count_;
206  static const XMLCh* s_type_;
207  static const XMLCh* s_name_;
208  static const XMLCh* s_version_;
209  static const XMLCh* s_filename_;
210  static const XMLCh* s_filetype_;
211  static const XMLCh* s_filesha1_;
212  static const XMLCh* s_completiontime_;
213  static const XMLCh* s_precision_;
214  static const XMLCh* s_byteorder_;
215  static const XMLCh* s_contentType_;
216  static const XMLCh* s_compressionType_;
217  static const XMLCh* s_precursorintensity_;
218  static const XMLCh* s_precursorcharge_;
219  static const XMLCh* s_windowwideness_;
220  static const XMLCh* s_mslevel_;
221  static const XMLCh* s_peakscount_;
222  static const XMLCh* s_polarity_;
223  static const XMLCh* s_scantype_;
224  static const XMLCh* s_filterline_;
225  static const XMLCh* s_retentiontime_;
226  static const XMLCh* s_startmz_;
227  static const XMLCh* s_endmz_;
228  static const XMLCh* s_first_;
229  static const XMLCh* s_last_;
230  static const XMLCh* s_phone_;
231  static const XMLCh* s_email_;
232  static const XMLCh* s_uri_;
233  static const XMLCh* s_num_;
234  static const XMLCh* s_intensitycutoff_;
235  static const XMLCh* s_centroided_;
236  static const XMLCh* s_deisotoped_;
237  static const XMLCh* s_chargedeconvoluted_;
238  };
239 
240  } // namespace Internal
241 
242 } // namespace OpenMS
243 
static const XMLCh * s_precursorintensity_
Definition: MzXMLHandler.h:217
static const XMLCh * s_uri_
Definition: MzXMLHandler.h:232
A more convenient string class.
Definition: String.h:57
Class to encode and decode Base64.
Definition: Base64.h:67
static const XMLCh * s_precision_
Definition: MzXMLHandler.h:213
static const XMLCh * s_peakscount_
Definition: MzXMLHandler.h:221
UInt spec_write_counter_
spectrum counter (spectra without peaks are not written)
Definition: MzXMLHandler.h:156
static const XMLCh * s_value_
Definition: MzXMLHandler.h:204
UInt peak_count_
Definition: MzXMLHandler.h:140
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Definition: MzXMLHandler.h:65
Base class for XML handlers.
Definition: XMLHandler.h:148
std::vector< boost::shared_ptr< DataProcessing > > data_processing_
data processing auxiliary variable
Definition: MzXMLHandler.h:191
static const XMLCh * s_startmz_
Definition: MzXMLHandler.h:226
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
static const XMLCh * s_deisotoped_
Definition: MzXMLHandler.h:236
static const XMLCh * s_precursorcharge_
Definition: MzXMLHandler.h:218
static const XMLCh * s_retentiontime_
Definition: MzXMLHandler.h:225
const MapType * cexp_
map pointer for writing
Definition: MzXMLHandler.h:121
static const XMLCh * s_intensitycutoff_
Definition: MzXMLHandler.h:234
static const XMLCh * s_contentType_
Definition: MzXMLHandler.h:215
Interfaces::IMSDataConsumer * consumer_
Consumer class to work on spectra.
Definition: MzXMLHandler.h:159
static const XMLCh * s_chargedeconvoluted_
Definition: MzXMLHandler.h:237
static const XMLCh * s_completiontime_
Definition: MzXMLHandler.h:212
static const XMLCh * s_last_
Definition: MzXMLHandler.h:229
String precision_
Definition: MzXMLHandler.h:141
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
static const XMLCh * s_scantype_
Definition: MzXMLHandler.h:223
static const XMLCh * s_byteorder_
Definition: MzXMLHandler.h:214
static const XMLCh * s_polarity_
Definition: MzXMLHandler.h:222
~MzXMLHandler() override
Destructor.
Definition: MzXMLHandler.h:78
static const XMLCh * s_first_
Definition: MzXMLHandler.h:228
UInt getScanCount()
Gets the scan count.
Definition: MzXMLHandler.h:100
MSExperiment PeakMap
Two-dimensional map of raw data points or peaks.
Definition: StandardTypes.h:61
PeakFileOptions options_
Options for loading and storing.
Definition: MzXMLHandler.h:124
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
void setOptions(const PeakFileOptions &options)
Sets the options.
Definition: MzXMLHandler.h:94
static const XMLCh * s_filetype_
Definition: MzXMLHandler.h:210
static const XMLCh * s_filename_
Definition: MzXMLHandler.h:209
static const XMLCh * s_filterline_
Definition: MzXMLHandler.h:224
Int nesting_level_
Definition: MzXMLHandler.h:129
static const XMLCh * s_filesha1_
Definition: MzXMLHandler.h:211
static const XMLCh * s_email_
Definition: MzXMLHandler.h:231
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:55
static const XMLCh * s_version_
Definition: MzXMLHandler.h:208
String compressionType_
Definition: MzXMLHandler.h:142
std::vector< SpectrumData > spectrum_data_
Vector of spectrum data stored for later parallel processing.
Definition: MzXMLHandler.h:149
void setMSDataConsumer(Interfaces::IMSDataConsumer *consumer)
Set the IMSDataConsumer consumer which will consume the read data.
Definition: MzXMLHandler.h:106
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
MapType::PeakType PeakType
Peak type.
Definition: MzXMLHandler.h:114
static const XMLCh * s_endmz_
Definition: MzXMLHandler.h:227
PeakMap MapType
XML handler for MzDataFile.
Definition: MzDataHandler.h:60
SpectrumType spectrum
Definition: MzXMLHandler.h:144
static const XMLCh * s_type_
Definition: MzXMLHandler.h:206
UInt scan_count_
Consumer class to work on spectra.
Definition: MzXMLHandler.h:162
static const XMLCh * s_compressionType_
Definition: MzXMLHandler.h:216
static const XMLCh * s_centroided_
Definition: MzXMLHandler.h:235
The interface of a consumer of spectra and chromatograms.
Definition: IMSDataConsumer.h:67
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
MSSpectrum SpectrumType
Spectrum type.
Definition: MzXMLHandler.h:116
String char_rest_
Definition: MzXMLHandler.h:143
bool skip_spectrum_
Flag that indicates whether this spectrum should be skipped (due to options)
Definition: MzXMLHandler.h:153
Data necessary to generate a single spectrum.
Definition: MzXMLHandler.h:138
Base64 decoder_
Definition: MzXMLHandler.h:128
static const XMLCh * s_mslevel_
Definition: MzXMLHandler.h:220
static const XMLCh * s_windowwideness_
Definition: MzXMLHandler.h:219
static const XMLCh * s_name_
Definition: MzXMLHandler.h:207
Options for loading files containing peak data.
Definition: PeakFileOptions.h:47
const ProgressLogger & logger_
Progress logging class.
Definition: MzXMLHandler.h:165
static const XMLCh * s_num_
Definition: MzXMLHandler.h:233
bool skip_data
Definition: MzXMLHandler.h:145
int Int
Signed integer type.
Definition: Types.h:102
MapType * exp_
map pointer for reading
Definition: MzXMLHandler.h:119
static const XMLCh * s_count_
Definition: MzXMLHandler.h:205
static const XMLCh * s_phone_
Definition: MzXMLHandler.h:230
MSSpectrum SpectrumType
Definition: MzDataHandler.h:61

OpenMS / TOPP release 2.3.0 Documentation generated on Wed Apr 18 2018 19:29:07 using doxygen 1.8.14