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 #ifndef OPENMS_KERNEL_ONDISCMSEXPERIMENT_H
36 #define OPENMS_KERNEL_ONDISCMSEXPERIMENT_H
37 
39 
45 #include <OpenMS/FORMAT/MzMLFile.h>
46 
47 #include <vector>
48 #include <algorithm>
49 #include <limits>
50 
51 #include <boost/shared_ptr.hpp>
52 
53 namespace OpenMS
54 {
70  {
71 
73  typedef Peak1D PeakT;
74 
75 public:
76 
83 
93  bool openFile(const String& filename, bool skipMetaData = false)
94  {
95  filename_ = filename;
96  indexed_mzml_file_.openFile(filename);
97  if (filename != "" && !skipMetaData)
98  {
99  loadMetaData_(filename);
100  }
102  }
103 
106  filename_(source.filename_),
109  {
110  }
111 
119  bool operator==(const OnDiscMSExperiment& rhs) const
120  {
121  // check if file and meta information is the same
122  return filename_ == rhs.filename_ &&
123  (*meta_ms_experiment_) == (*rhs.meta_ms_experiment_);
124  // do not check if indexed_mzml_file_ is equal -> they have the same filename...
125  }
126 
128  bool operator!=(const OnDiscMSExperiment& rhs) const
129  {
130  return !(operator==(rhs));
131  }
132 
139  bool isSortedByRT() const
140  {
141  return meta_ms_experiment_->isSorted(false);
142  }
143 
145  inline Size size() const
146  {
147  return getNrSpectra();
148  }
149 
151  inline bool empty() const
152  {
153  return indexed_mzml_file_.getNrSpectra() == 0;
154  }
155 
157  inline Size getNrSpectra() const
158  {
160  }
161 
163  inline Size getNrChromatograms() const
164  {
166  }
167 
169  boost::shared_ptr<const ExperimentalSettings> getExperimentalSettings() const
170  {
171  return boost::static_pointer_cast<const ExperimentalSettings>(meta_ms_experiment_);
172  }
173 
176  {
177  return getSpectrum(n);
178  }
179 
186  {
188  MSSpectrum spectrum(meta_ms_experiment_->operator[](id));
189 
190  // recreate a spectrum from the data arrays!
191  OpenMS::Interfaces::BinaryDataArrayPtr mz_arr = sptr->getMZArray();
192  OpenMS::Interfaces::BinaryDataArrayPtr int_arr = sptr->getIntensityArray();
193  spectrum.reserve(mz_arr->data.size());
194  for (Size i = 0; i < mz_arr->data.size(); i++)
195  {
196  PeakT p;
197  p.setMZ(mz_arr->data[i]);
198  p.setIntensity(int_arr->data[i]);
199  spectrum.push_back(p);
200  }
201  return spectrum;
202  }
203 
208  {
210  }
211 
218  {
220  MSChromatogram chromatogram(meta_ms_experiment_->getChromatogram(id));
221 
222  // recreate a chromatogram from the data arrays!
223  OpenMS::Interfaces::BinaryDataArrayPtr rt_arr = cptr->getTimeArray();
224  OpenMS::Interfaces::BinaryDataArrayPtr int_arr = cptr->getIntensityArray();
225  chromatogram.reserve(rt_arr->data.size());
226  for (Size i = 0; i < rt_arr->data.size(); i++)
227  {
228  ChromatogramPeakT p;
229  p.setRT(rt_arr->data[i]);
230  p.setIntensity(int_arr->data[i]);
231  chromatogram.push_back(p);
232  }
233 
234  return chromatogram;
235  }
236 
241  {
243  }
244 
246  void setSkipXMLChecks(bool skip)
247  {
249  }
250 
251 private:
252 
254  OnDiscMSExperiment& operator=(const OnDiscMSExperiment& /* source */);
255 
256  void loadMetaData_(const String& filename)
257  {
258  meta_ms_experiment_ = boost::shared_ptr< PeakMap >(new PeakMap);
259 
260  MzMLFile f;
261  PeakFileOptions options = f.getOptions();
262  options.setFillData(false);
263  f.setOptions(options);
264  f.load(filename, *meta_ms_experiment_.get());
265  }
266 
267 
268 protected:
269 
275  boost::shared_ptr<PeakMap> meta_ms_experiment_;
276  };
277 
279 
280 } // namespace OpenMS
281 
282 #endif // OPENMS_KERNEL_ONDISCMSEXPERIMENT_H
283 
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: openms/include/OpenMS/INTERFACES/DataStructures.h:237
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:117
Size getNrChromatograms() const
get the total number of chromatograms available
Definition: OnDiscMSExperiment.h:163
void setSkipXMLChecks(bool skip)
Whether to skip some XML checks (removing whitespace from base64 arrays) and be fast instead...
Definition: IndexedMzMLFile.h:168
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition: openms/include/OpenMS/INTERFACES/DataStructures.h:157
A more convenient string class.
Definition: String.h:57
bool openFile(const String &filename, bool skipMetaData=false)
Open a specific file on disk.
Definition: OnDiscMSExperiment.h:93
The representation of a chromatogram.
Definition: MSChromatogram.h:55
MSSpectrum operator[](Size n)
alias for getSpectrum
Definition: OnDiscMSExperiment.h:175
size_t getNrChromatograms() const
Returns the number of chromatograms available.
boost::shared_ptr< BinaryDataArray > BinaryDataArrayPtr
Definition: openms/include/OpenMS/INTERFACES/DataStructures.h:81
Peak1D PeakT
Definition: OnDiscMSExperiment.h:73
bool isSortedByRT() const
Checks if all spectra are sorted with respect to ascending RT.
Definition: OnDiscMSExperiment.h:139
OnDiscMSExperiment & operator=(const OnDiscMSExperiment &)
Private Assignment operator -> we cannot copy file streams in IndexedMzMLFile.
OpenMS::Interfaces::ChromatogramPtr getChromatogramById(int id)
Retrieve the raw data for the chromatogram at position "id".
size_t getNrSpectra() const
Returns the number of spectra available.
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:120
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:111
bool operator==(const OnDiscMSExperiment &rhs) const
Equality operator.
Definition: OnDiscMSExperiment.h:119
void openFile(String filename)
Open a file.
Size size() const
alias for getNrSpectra
Definition: OnDiscMSExperiment.h:145
String filename_
The filename of the underlying data file.
Definition: OnDiscMSExperiment.h:271
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
OnDiscMSExperiment()
Constructor.
Definition: OnDiscMSExperiment.h:82
boost::shared_ptr< const ExperimentalSettings > getExperimentalSettings() const
returns the meta information of this experiment (const access)
Definition: OnDiscMSExperiment.h:169
MSExperiment PeakMap
Two-dimensional map of raw data points or peaks.
Definition: StandardTypes.h:59
A low-level class to read an indexedmzML file.
Definition: IndexedMzMLFile.h:74
MSSpectrum getSpectrum(Size id)
returns a single spectrum
Definition: OnDiscMSExperiment.h:185
OpenMS::Interfaces::SpectrumPtr getSpectrumById(Size id)
returns a single spectrum
Definition: OnDiscMSExperiment.h:207
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:55
OpenMS::Interfaces::ChromatogramPtr getChromatogramById(Size id)
returns a single chromatogram
Definition: OnDiscMSExperiment.h:240
boost::shared_ptr< PeakMap > meta_ms_experiment_
The meta-data.
Definition: OnDiscMSExperiment.h:275
ChromatogramPeak ChromatogramPeakT
Definition: OnDiscMSExperiment.h:72
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:105
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:108
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
OpenMS::OnDiscMSExperiment OnDiscPeakMap
Definition: OnDiscMSExperiment.h:278
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:55
bool empty() const
returns whether spectra are empty
Definition: OnDiscMSExperiment.h:151
Size getNrSpectra() const
get the total number of spectra available
Definition: OnDiscMSExperiment.h:157
void loadMetaData_(const String &filename)
Definition: OnDiscMSExperiment.h:256
Options for loading files containing peak data.
Definition: PeakFileOptions.h:48
IndexedMzMLFile indexed_mzml_file_
The index of the underlying data file.
Definition: OnDiscMSExperiment.h:273
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:128
Description of the experimental settings.
Definition: ExperimentalSettings.h:59
void setSkipXMLChecks(bool skip)
sets whether to skip some XML checks and be fast instead
Definition: OnDiscMSExperiment.h:246
bool getParsingSuccess() const
Returns whether parsing was successful.

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