OpenMS
Loading...
Searching...
No Matches
OnDiscMSExperiment.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Hannes Roest $
6// $Authors: Hannes Roest $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12
19
20#include <vector>
21#include <limits>
22
23#include <memory>
24
25namespace OpenMS
26{
70 class OPENMS_DLLAPI OnDiscMSExperiment
71 {
72
74 typedef Peak1D PeakT;
75
76public:
77
83 OnDiscMSExperiment() = default;
84
94 bool openFile(const String& filename, bool skipMetaData = false);
95
98 filename_(source.filename_),
99 indexed_mzml_file_(source.indexed_mzml_file_),
100 meta_ms_experiment_(source.meta_ms_experiment_),
101 options_(source.options_)
102 {
103 }
104
112 bool operator==(const OnDiscMSExperiment& rhs) const
113 {
114 if (meta_ms_experiment_ == nullptr || rhs.meta_ms_experiment_ == nullptr)
115 {
116 return filename_ == rhs.filename_ &&
117 meta_ms_experiment_ == rhs.meta_ms_experiment_;
118 }
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 if (!meta_ms_experiment_) return false;
141
142 return meta_ms_experiment_->isSorted(false);
143 }
144
146 inline Size size() const
147 {
148 return getNrSpectra();
149 }
150
152 inline bool empty() const
153 {
154 return getNrSpectra() == 0;
155 }
156
158 inline Size getNrSpectra() const
159 {
160 return indexed_mzml_file_.getNrSpectra();
161 }
162
165 {
166 return indexed_mzml_file_.getNrChromatograms();
167 }
168
170 std::shared_ptr<const ExperimentalSettings> getExperimentalSettings() const
171 {
172 return std::static_pointer_cast<const ExperimentalSettings>(meta_ms_experiment_);
173 }
174
175 std::shared_ptr<PeakMap> getMetaData() const
176 {
177 return meta_ms_experiment_;
178 }
179
182 {
183 return getSpectrum(n);
184 }
185
194
199 {
200 return indexed_mzml_file_.getSpectrumById((int)id);
201 }
202
211
218
224 MSSpectrum getSpectrumByNativeId(const std::string& id);
225
230
232 void setSkipXMLChecks(bool skip);
233
236
239
241 void setOptions(const PeakFileOptions& options);
242
243private:
244
247
248 void loadMetaData_(const String& filename);
249
251
252 MSSpectrum getMetaSpectrumById_(const std::string& id);
253
254protected:
255
261 std::shared_ptr<PeakMap> meta_ms_experiment_;
263 std::unordered_map< std::string, Size > chromatograms_native_ids_;
265 std::unordered_map< std::string, Size > spectra_native_ids_;
268 };
269
271
272} // namespace OpenMS
273
274
A 1-dimensional raw data point or peak for chromatograms.
Definition ChromatogramPeak.h:29
A low-level class to read an indexedmzML file.
Definition IndexedMzMLHandler.h:54
The representation of a chromatogram.
Definition MSChromatogram.h:30
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Representation of a mass spectrometry experiment on disk.
Definition OnDiscMSExperiment.h:71
MSSpectrum getSpectrum(Size id)
returns a single spectrum
void setSkipXMLChecks(bool skip)
sets whether to skip some XML checks and be fast instead
MSSpectrum getMetaSpectrumById_(const std::string &id)
Internal::IndexedMzMLHandler indexed_mzml_file_
The index of the underlying data file.
Definition OnDiscMSExperiment.h:259
OpenMS::Interfaces::SpectrumPtr getSpectrumById(Size id)
returns a single spectrum (without applying PeakFileOptions filters)
Definition OnDiscMSExperiment.h:198
bool operator!=(const OnDiscMSExperiment &rhs) const
Inequality operator.
Definition OnDiscMSExperiment.h:127
OpenMS::Interfaces::ChromatogramPtr getChromatogramById(Size id)
returns a single chromatogram
void setOptions(const PeakFileOptions &options)
set options for loading/storing
const PeakFileOptions & getOptions() const
Non-mutable access to the options for loading/storing.
Size getNrSpectra() const
get the total number of spectra available
Definition OnDiscMSExperiment.h:158
bool isSortedByRT() const
Checks if all spectra are sorted with respect to ascending RT.
Definition OnDiscMSExperiment.h:138
String filename_
The filename of the underlying data file.
Definition OnDiscMSExperiment.h:257
void loadMetaData_(const String &filename)
bool empty() const
returns whether spectra are empty
Definition OnDiscMSExperiment.h:152
Size getNrChromatograms() const
get the total number of chromatograms available
Definition OnDiscMSExperiment.h:164
PeakFileOptions options_
Options for loading / storing.
Definition OnDiscMSExperiment.h:267
MSSpectrum operator[](Size n)
alias for getSpectrum
Definition OnDiscMSExperiment.h:181
MSChromatogram getChromatogram(Size id)
returns a single chromatogram
std::shared_ptr< PeakMap > meta_ms_experiment_
The meta-data.
Definition OnDiscMSExperiment.h:261
bool operator==(const OnDiscMSExperiment &rhs) const
Equality operator.
Definition OnDiscMSExperiment.h:112
Peak1D PeakT
Definition OnDiscMSExperiment.h:74
PeakFileOptions & getOptions()
Mutable access to the options for loading/storing.
std::shared_ptr< PeakMap > getMetaData() const
Definition OnDiscMSExperiment.h:175
bool openFile(const String &filename, bool skipMetaData=false)
Open a specific file on disk.
OnDiscMSExperiment()=default
Constructor.
OnDiscMSExperiment & operator=(const OnDiscMSExperiment &)
Private Assignment operator -> we cannot copy file streams in IndexedMzMLHandler.
MSChromatogram getChromatogramByNativeId(const std::string &id)
returns a single chromatogram
ChromatogramPeak ChromatogramPeakT
Definition OnDiscMSExperiment.h:73
std::unordered_map< std::string, Size > spectra_native_ids_
Mapping of spectra native ids to offsets.
Definition OnDiscMSExperiment.h:265
Size size() const
alias for getNrSpectra
Definition OnDiscMSExperiment.h:146
std::shared_ptr< const ExperimentalSettings > getExperimentalSettings() const
returns the meta information of this experiment (const access)
Definition OnDiscMSExperiment.h:170
MSSpectrum getSpectrumByNativeId(const std::string &id)
returns a single spectrum
std::unordered_map< std::string, Size > chromatograms_native_ids_
Mapping of chromatogram native ids to offsets.
Definition OnDiscMSExperiment.h:263
MSChromatogram getMetaChromatogramById_(const std::string &id)
OnDiscMSExperiment(const OnDiscMSExperiment &source)
Copy constructor.
Definition OnDiscMSExperiment.h:97
A 1-dimensional raw data point or peak.
Definition Peak1D.h:30
Options for loading files containing peak data.
Definition PeakFileOptions.h:22
A more convenient string class.
Definition String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
std::shared_ptr< Chromatogram > ChromatogramPtr
Definition openms/include/OpenMS/INTERFACES/DataStructures.h:130
std::shared_ptr< Spectrum > SpectrumPtr
Definition openms/include/OpenMS/INTERFACES/DataStructures.h:210
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
OpenMS::OnDiscMSExperiment OnDiscPeakMap
Definition IndexedMzMLFileLoader.h:17