Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
OnDiscMSExperiment.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 #pragma once
36 
38 
44 #include <OpenMS/FORMAT/MzMLFile.h>
45 
46 #include <vector>
47 #include <algorithm>
48 #include <limits>
49 
50 #include <boost/shared_ptr.hpp>
51 
52 namespace OpenMS
53 {
69  {
70 
72  typedef Peak1D PeakT;
73 
74 public:
75 
82 
92  bool openFile(const String& filename, bool skipMetaData = false)
93  {
94  filename_ = filename;
95  indexed_mzml_file_.openFile(filename);
96  if (filename != "" && !skipMetaData)
97  {
98  loadMetaData_(filename);
99  }
101  }
102 
105  filename_(source.filename_),
108  {
109  }
110 
118  bool operator==(const OnDiscMSExperiment& rhs) const
119  {
120  // check if file and meta information is the same
121  return filename_ == rhs.filename_ &&
122  (*meta_ms_experiment_) == (*rhs.meta_ms_experiment_);
123  // do not check if indexed_mzml_file_ is equal -> they have the same filename...
124  }
125 
127  bool operator!=(const OnDiscMSExperiment& rhs) const
128  {
129  return !(operator==(rhs));
130  }
131 
138  bool isSortedByRT() const
139  {
140  return meta_ms_experiment_->isSorted(false);
141  }
142 
144  inline Size size() const
145  {
146  return getNrSpectra();
147  }
148 
150  inline bool empty() const
151  {
152  return indexed_mzml_file_.getNrSpectra() == 0;
153  }
154 
156  inline Size getNrSpectra() const
157  {
159  }
160 
162  inline Size getNrChromatograms() const
163  {
165  }
166 
168  boost::shared_ptr<const ExperimentalSettings> getExperimentalSettings() const
169  {
170  return boost::static_pointer_cast<const ExperimentalSettings>(meta_ms_experiment_);
171  }
172 
175  {
176  return getSpectrum(n);
177  }
178 
185  {
186  MSSpectrum spectrum(meta_ms_experiment_->operator[](id));
187  indexed_mzml_file_.getMSSpectrumById(static_cast<int>(id), spectrum);
188  return spectrum;
189  }
190 
195  {
197  }
198 
205  {
206  MSChromatogram chromatogram(meta_ms_experiment_->getChromatogram(id));
207  indexed_mzml_file_.getMSChromatogramById(static_cast<int>(id), chromatogram);
208  return chromatogram;
209  }
210 
215  {
217  }
218 
220  void setSkipXMLChecks(bool skip)
221  {
223  }
224 
225 private:
226 
228  OnDiscMSExperiment& operator=(const OnDiscMSExperiment& /* source */);
229 
230  void loadMetaData_(const String& filename)
231  {
232  meta_ms_experiment_ = boost::shared_ptr< PeakMap >(new PeakMap);
233 
234  MzMLFile f;
235  PeakFileOptions options = f.getOptions();
236  options.setFillData(false);
237  f.setOptions(options);
238  f.load(filename, *meta_ms_experiment_.get());
239  }
240 
241 
242 protected:
243 
249  boost::shared_ptr<PeakMap> meta_ms_experiment_;
250  };
251 
253 
254 } // namespace OpenMS
255 
256 
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: openms/include/OpenMS/INTERFACES/DataStructures.h:236
Size getNrChromatograms() const
get the total number of chromatograms available
Definition: OnDiscMSExperiment.h:162
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition: openms/include/OpenMS/INTERFACES/DataStructures.h:156
A more convenient string class.
Definition: String.h:57
size_t getNrSpectra() const
Returns the number of spectra available.
bool openFile(const String &filename, bool skipMetaData=false)
Open a specific file on disk.
Definition: OnDiscMSExperiment.h:92
const OpenMS::MSSpectrum getMSSpectrumById(int id)
Retrieve the raw data for the spectrum at position "id".
The representation of a chromatogram.
Definition: MSChromatogram.h:54
MSSpectrum operator[](Size n)
alias for getSpectrum
Definition: OnDiscMSExperiment.h:174
Peak1D PeakT
Definition: OnDiscMSExperiment.h:72
bool isSortedByRT() const
Checks if all spectra are sorted with respect to ascending RT.
Definition: OnDiscMSExperiment.h:138
OnDiscMSExperiment & operator=(const OnDiscMSExperiment &)
Private Assignment operator -> we cannot copy file streams in IndexedMzMLHandler. ...
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
bool operator==(const OnDiscMSExperiment &rhs) const
Equality operator.
Definition: OnDiscMSExperiment.h:118
bool getParsingSuccess() const
Returns whether parsing was successful.
Size size() const
alias for getNrSpectra
Definition: OnDiscMSExperiment.h:144
Internal::IndexedMzMLHandler indexed_mzml_file_
The index of the underlying data file.
Definition: OnDiscMSExperiment.h:247
void openFile(String filename)
Open a file.
String filename_
The filename of the underlying data file.
Definition: OnDiscMSExperiment.h:245
File adapter for MzML files.
Definition: MzMLFile.h:55
MSChromatogram getChromatogram(Size id)
returns a single chromatogram
Definition: OnDiscMSExperiment.h:204
Representation of a mass spectrometry experiment on disk.
Definition: OnDiscMSExperiment.h:68
const OpenMS::MSChromatogram getMSChromatogramById(int id)
Retrieve the raw data for the chromatogram at position "id".
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
OnDiscMSExperiment()
Constructor.
Definition: OnDiscMSExperiment.h:81
boost::shared_ptr< const ExperimentalSettings > getExperimentalSettings() const
returns the meta information of this experiment (const access)
Definition: OnDiscMSExperiment.h:168
MSExperiment PeakMap
Two-dimensional map of raw data points or peaks.
Definition: StandardTypes.h:61
MSSpectrum getSpectrum(Size id)
returns a single spectrum
Definition: OnDiscMSExperiment.h:184
OpenMS::Interfaces::SpectrumPtr getSpectrumById(Size id)
returns a single spectrum
Definition: OnDiscMSExperiment.h:194
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
OpenMS::Interfaces::ChromatogramPtr getChromatogramById(Size id)
returns a single chromatogram
Definition: OnDiscMSExperiment.h:214
size_t getNrChromatograms() const
Returns the number of chromatograms available.
boost::shared_ptr< PeakMap > meta_ms_experiment_
The meta-data.
Definition: OnDiscMSExperiment.h:249
ChromatogramPeak ChromatogramPeakT
Definition: OnDiscMSExperiment.h:71
OpenMS::Interfaces::SpectrumPtr getSpectrumById(int id)
Retrieve the raw data for the spectrum at position "id".
OnDiscMSExperiment(const OnDiscMSExperiment &source)
Copy constructor.
Definition: OnDiscMSExperiment.h:104
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
void setSkipXMLChecks(bool skip)
Whether to skip some XML checks (removing whitespace from base64 arrays) and be fast instead...
Definition: IndexedMzMLHandler.h:218
OpenMS::OnDiscMSExperiment OnDiscPeakMap
Definition: OnDiscMSExperiment.h:252
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:54
bool empty() const
returns whether spectra are empty
Definition: OnDiscMSExperiment.h:150
Size getNrSpectra() const
get the total number of spectra available
Definition: OnDiscMSExperiment.h:156
void loadMetaData_(const String &filename)
Definition: OnDiscMSExperiment.h:230
Options for loading files containing peak data.
Definition: PeakFileOptions.h:47
OpenMS::Interfaces::ChromatogramPtr getChromatogramById(int id)
Retrieve the raw data for the chromatogram at position "id".
void setFillData(bool only)
sets whether to fill the actual data into the container (spectrum/chromatogram)
bool operator!=(const OnDiscMSExperiment &rhs) const
Inequality operator.
Definition: OnDiscMSExperiment.h:127
Description of the experimental settings.
Definition: ExperimentalSettings.h:58
void setSkipXMLChecks(bool skip)
sets whether to skip some XML checks and be fast instead
Definition: OnDiscMSExperiment.h:220
A low-level class to read an indexedmzML file.
Definition: IndexedMzMLHandler.h:78

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