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-2015.
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 
53  class OPENMS_DLLAPI IndexedMzMLFileLoader
54  {
55  public:
56 
59 
62 
64  PeakFileOptions& getOptions();
65 
67  const PeakFileOptions& getOptions() const;
68 
70  void setOptions(const PeakFileOptions &);
71 
82  bool load(const String& filename, OnDiscMSExperiment<>& exp)
83  {
84  return exp.openFile(filename);
85  }
86 
93  void store(const String& filename, OnDiscMSExperiment<>& exp)
94  {
95  // Create a writing data consumer which consumes the experiment (writes it to disk)
96  PlainMSDataWritingConsumer consumer(filename);
97  consumer.setExpectedSize(exp.getNrSpectra(), exp.getNrChromatograms());
98  consumer.setExperimentalSettings(*exp.getExperimentalSettings().get());
99  options_.setWriteIndex(true); // ensure that we write the index
100  consumer.setOptions(options_);
101  for (Size i = 0; i < exp.getNrSpectra(); i++)
102  {
103  MSSpectrum<> s = exp.getSpectrum(i);
104  consumer.consumeSpectrum(s);
105  }
106  for (Size i = 0; i < exp.getNrChromatograms(); i++)
107  {
109  consumer.consumeChromatogram(c);
110  }
111  }
112 
119  void store(const String& filename, MSExperiment<>& exp)
120  {
121  MzMLFile f;
122  options_.setWriteIndex(true); // ensure that we write the index
123  f.setOptions(options_);
124  f.store(filename, exp);
125  }
126 
127 private:
128 
131 
132  };
133 }
134 
135 #endif
void store(const String &filename, MSExperiment<> &exp)
Store a file from an in-memory data-structure.
Definition: IndexedMzMLFileLoader.h:119
MSChromatogram< ChromatogramPeakT > getChromatogram(Size id)
returns a single chromatogram
Definition: OnDiscMSExperiment.h:214
Size getNrChromatograms() const
get the total number of chromatograms available
Definition: OnDiscMSExperiment.h:160
A more convenient string class.
Definition: String.h:57
virtual void setExperimentalSettings(const ExperimentalSettings &exp)
Set experimental settings for the whole file.
Definition: MSDataWritingConsumer.h:137
PeakFileOptions options_
Options for storing.
Definition: IndexedMzMLFileLoader.h:130
Consumer class that writes MS data to disk using the mzML format.
Definition: MSDataWritingConsumer.h:375
The representation of a chromatogram.
Definition: MSChromatogram.h:52
void store(const String &filename, OnDiscMSExperiment<> &exp)
Store a file from an on-disc data-structure.
Definition: IndexedMzMLFileLoader.h:93
void setOptions(const PeakFileOptions &)
set options for loading/storing
const double c
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
File adapter for MzML files.
Definition: MzMLFile.h:55
Representation of a mass spectrometry experiment on disk.
Definition: OnDiscMSExperiment.h:67
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
bool load(const String &filename, OnDiscMSExperiment<> &exp)
Load a file.
Definition: IndexedMzMLFileLoader.h:82
bool openFile(const String &filename)
Definition: OnDiscMSExperiment.h:84
void store(const String &filename, const MapType &map) const
Stores a map in a MzML file.
Definition: MzMLFile.h:109
boost::shared_ptr< const ExperimentalSettings > getExperimentalSettings() const
returns the meta information of this experiment (const access)
Definition: OnDiscMSExperiment.h:166
MSSpectrum< PeakT > getSpectrum(Size id)
returns a single spectrum
Definition: OnDiscMSExperiment.h:182
Size getNrSpectra() const
get the total number of spectra available
Definition: OnDiscMSExperiment.h:154
void setOptions(const PeakFileOptions &opt)
Set the peak file options.
Definition: MzMLHandler.h:222
virtual void consumeChromatogram(ChromatogramType &c)
Consume a chromatogram.
Definition: MSDataWritingConsumer.h:220
Options for loading files containing peak data.
Definition: PeakFileOptions.h:48
virtual void setExpectedSize(Size expectedSpectra, Size expectedChromatograms)
Set expected size of spectra and chromatograms to be written.
Definition: MSDataWritingConsumer.h:152
A class to load an indexedmzML file.
Definition: IndexedMzMLFileLoader.h:53
virtual void consumeSpectrum(SpectrumType &s)
Consume a spectrum.
Definition: MSDataWritingConsumer.h:166

OpenMS / TOPP release 2.0.0 Documentation generated on Sat May 16 2015 16:13:21 using doxygen 1.8.9.1