Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
MSDataWritingConsumer.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: Hannes Roest $
32 // $Authors: Hannes Roest $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_FORMAT_DATAACCESS_MSDATAWRITINGCONSUMER_H
36 #define OPENMS_FORMAT_DATAACCESS_MSDATAWRITINGCONSUMER_H
37 
39 
40 #include <OpenMS/FORMAT/MzMLFile.h>
43 
44 #include <vector>
45 #include <string>
46 #include <fstream>
47 #include <boost/shared_ptr.hpp>
48 
49 namespace OpenMS
50 {
89  class OPENMS_DLLAPI MSDataWritingConsumer :
90  public Internal::MzMLHandler,
92  {
93 
94  public:
95  typedef PeakMap MapType;
98 
104  explicit MSDataWritingConsumer(String filename);
105 
107  virtual ~MSDataWritingConsumer();
108 
110 
111 
118  virtual void setExperimentalSettings(const ExperimentalSettings& exp);
119 
130  virtual void setExpectedSize(Size expectedSpectra, Size expectedChromatograms);
131 
140  virtual void consumeSpectrum(SpectrumType & s);
141 
150  virtual void consumeChromatogram(ChromatogramType & c);
152 
161  virtual void addDataProcessing(DataProcessing d);
162 
166  virtual Size getNrSpectraWritten();
167 
171  virtual Size getNrChromatogramsWritten();
172 
173  private:
174 
176 
177 
182  virtual void processSpectrum_(SpectrumType & s) = 0;
183 
189  virtual void processChromatogram_(ChromatogramType & c) = 0;
191 
197  virtual void doCleanup_();
198 
199  protected:
200 
202  std::ofstream ofs_;
203 
220 
223 
227  std::vector<std::vector< ConstDataProcessingPtr > > dps_;
230  };
231 
241  class OPENMS_DLLAPI PlainMSDataWritingConsumer :
242  public MSDataWritingConsumer
243  {
246 
247  public:
248 
249  explicit PlainMSDataWritingConsumer(String filename) : MSDataWritingConsumer(filename) {}
250  };
251 
259  class OPENMS_DLLAPI NoopMSDataWritingConsumer :
260  public MSDataWritingConsumer
261  {
262  public:
263 
264  explicit NoopMSDataWritingConsumer(String filename) : MSDataWritingConsumer(filename) {}
266  void consumeSpectrum(SpectrumType & /* s */) {}
268 
269  private:
270 
271  void doCleanup_() {}
274  };
275 
276 
277 } //end namespace OpenMS
278 
279 #endif // OPENMS_FORMAT_DATAACCESS_MSDATAWRITINGCONSUMER_H
280 
Description of the applied preprocessing steps.
Definition: DataProcessing.h:52
A more convenient string class.
Definition: String.h:57
bool writing_spectra_
Stores whether we are currently writing spectra.
Definition: MSDataWritingConsumer.h:207
Consumer class that writes MS data to disk using the mzML format.
Definition: MSDataWritingConsumer.h:241
void processChromatogram_(MapType::ChromatogramType &)
Process a chromatogram before storing to disk.
Definition: MSDataWritingConsumer.h:245
The representation of a chromatogram.
Definition: MSChromatogram.h:55
Semantically validates MzXML files.
Definition: MzMLValidator.h:49
Consumer class that perform no operation.
Definition: MSDataWritingConsumer.h:259
std::ofstream ofs_
File stream (to write mzML)
Definition: MSDataWritingConsumer.h:202
Size spectra_expected_
Number of spectra expected.
Definition: MSDataWritingConsumer.h:215
const double c
ExperimentalSettings settings_
Experimental settings to use for the whole file.
Definition: MSDataWritingConsumer.h:225
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool writing_chromatograms_
Stores whether we are currently writing chromatograms.
Definition: MSDataWritingConsumer.h:209
std::vector< std::vector< ConstDataProcessingPtr > > dps_
Vector of data processing objects -> will be filled by writeHeader_.
Definition: MSDataWritingConsumer.h:227
bool add_dataprocessing_
Whether to add dataprocessing term to the data before writing.
Definition: MSDataWritingConsumer.h:219
Definition: MzMLHandler.h:114
void setExperimentalSettings(const ExperimentalSettings &)
Set experimental settings for the whole file.
Definition: MSDataWritingConsumer.h:265
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
PlainMSDataWritingConsumer(String filename)
Definition: MSDataWritingConsumer.h:249
void processSpectrum_(MapType::SpectrumType &)
Process a spectrum before storing to disk.
Definition: MSDataWritingConsumer.h:244
MapType::SpectrumType SpectrumType
Definition: MSDataWritingConsumer.h:96
boost::shared_ptr< DataProcessing > DataProcessingPtr
Definition: DataProcessing.h:127
void consumeSpectrum(SpectrumType &)
Consume a spectrum.
Definition: MSDataWritingConsumer.h:266
void consumeChromatogram(ChromatogramType &)
Consume a chromatogram.
Definition: MSDataWritingConsumer.h:267
void processSpectrum_(MapType::SpectrumType &)
Process a spectrum before storing to disk.
Definition: MSDataWritingConsumer.h:272
MapType::ChromatogramType ChromatogramType
Definition: MSDataWritingConsumer.h:97
Internal::MzMLValidator * validator_
Validator that knows about CV terms.
Definition: MSDataWritingConsumer.h:222
bool started_writing_
Stores whether we have already started writing any data.
Definition: MSDataWritingConsumer.h:205
void doCleanup_()
Cleanup function called by the destructor.
Definition: MSDataWritingConsumer.h:271
void processChromatogram_(MapType::ChromatogramType &)
Process a chromatogram before storing to disk.
Definition: MSDataWritingConsumer.h:273
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
PeakMap MapType
Definition: MSDataWritingConsumer.h:95
Consumer class that writes MS data to disk using the mzML format.
Definition: MSDataWritingConsumer.h:89
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
The interface of a consumer of spectra and chromatograms.
Definition: IMSDataConsumer.h:68
Size chromatograms_expected_
Number of chromatograms expected.
Definition: MSDataWritingConsumer.h:217
NoopMSDataWritingConsumer(String filename)
Definition: MSDataWritingConsumer.h:264
Size chromatograms_written_
Number of chromatograms written.
Definition: MSDataWritingConsumer.h:213
Description of the experimental settings.
Definition: ExperimentalSettings.h:59
Size spectra_written_
Number of spectra written.
Definition: MSDataWritingConsumer.h:211
DataProcessingPtr additional_dataprocessing_
The dataprocessing to be added to each spectrum/chromatogram.
Definition: MSDataWritingConsumer.h:229

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:02 using doxygen 1.8.13