Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
IndexedMzMLFileLoader.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_INDEXEDMZMLFILELOADER_H
36 #define OPENMS_FORMAT_INDEXEDMZMLFILELOADER_H
37 
38 #include <OpenMS/FORMAT/MzMLFile.h>
42 
43 namespace OpenMS
44 {
45 
55  class OPENMS_DLLAPI IndexedMzMLFileLoader
56  {
57  public:
58 
61 
64 
66  PeakFileOptions& getOptions();
67 
69  const PeakFileOptions& getOptions() const;
70 
72  void setOptions(const PeakFileOptions &);
73 
84  bool load(const String& filename, OnDiscPeakMap& exp)
85  {
86  return exp.openFile(filename);
87  }
88 
95  void store(const String& filename, OnDiscPeakMap& exp)
96  {
97  // Create a writing data consumer which consumes the experiment (writes it to disk)
98  PlainMSDataWritingConsumer consumer(filename);
99  consumer.setExpectedSize(exp.getNrSpectra(), exp.getNrChromatograms());
100  consumer.setExperimentalSettings(*exp.getExperimentalSettings().get());
101  options_.setWriteIndex(true); // ensure that we write the index
102  consumer.setOptions(options_);
103  for (Size i = 0; i < exp.getNrSpectra(); i++)
104  {
105  MSSpectrum s = exp.getSpectrum(i);
106  consumer.consumeSpectrum(s);
107  }
108  for (Size i = 0; i < exp.getNrChromatograms(); i++)
109  {
111  consumer.consumeChromatogram(c);
112  }
113  }
114 
121  void store(const String& filename, PeakMap& exp)
122  {
123  MzMLFile f;
124  options_.setWriteIndex(true); // ensure that we write the index
125  f.setOptions(options_);
126  f.store(filename, exp);
127  }
128 
129 private:
130 
133 
134  };
135 }
136 
137 #endif // OPENMS_FORMAT_INDEXEDMZMLFILELOADER_H
138 
Size getNrChromatograms() const
get the total number of chromatograms available
Definition: OnDiscMSExperiment.h:163
A more convenient string class.
Definition: String.h:57
virtual void setExperimentalSettings(const ExperimentalSettings &exp)
Set experimental settings for the whole file.
bool openFile(const String &filename, bool skipMetaData=false)
Open a specific file on disk.
Definition: OnDiscMSExperiment.h:93
PeakFileOptions options_
Options for storing.
Definition: IndexedMzMLFileLoader.h:132
Consumer class that writes MS data to disk using the mzML format.
Definition: MSDataWritingConsumer.h:241
The representation of a chromatogram.
Definition: MSChromatogram.h:55
void setOptions(const PeakFileOptions &)
set options for loading/storing
void store(const String &filename, PeakMap &exp)
Store a file from an in-memory data-structure.
Definition: IndexedMzMLFileLoader.h:121
const double c
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
File adapter for MzML files.
Definition: MzMLFile.h:56
MSChromatogram getChromatogram(Size id)
returns a single chromatogram
Definition: OnDiscMSExperiment.h:217
Representation of a mass spectrometry experiment on disk.
Definition: OnDiscMSExperiment.h:69
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
boost::shared_ptr< const ExperimentalSettings > getExperimentalSettings() const
returns the meta information of this experiment (const access)
Definition: OnDiscMSExperiment.h:169
void store(const String &filename, OnDiscPeakMap &exp)
Store a file from an on-disc data-structure.
Definition: IndexedMzMLFileLoader.h:95
MSSpectrum getSpectrum(Size id)
returns a single spectrum
Definition: OnDiscMSExperiment.h:185
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
void setOptions(const PeakFileOptions &opt)
Set the peak file options.
Definition: MzMLHandler.h:160
Size getNrSpectra() const
get the total number of spectra available
Definition: OnDiscMSExperiment.h:157
virtual void consumeChromatogram(ChromatogramType &c)
Consume a chromatogram.
Options for loading files containing peak data.
Definition: PeakFileOptions.h:48
bool load(const String &filename, OnDiscPeakMap &exp)
Load a file.
Definition: IndexedMzMLFileLoader.h:84
void store(const String &filename, const PeakMap &map) const
Stores a map in an MzML file.
virtual void setExpectedSize(Size expectedSpectra, Size expectedChromatograms)
Set expected size of spectra and chromatograms to be written.
A class to load an indexedmzML file.
Definition: IndexedMzMLFileLoader.h:55
virtual void consumeSpectrum(SpectrumType &s)
Consume a spectrum.

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