24 class ChromatogramPeak;
71 typedef std::vector<SpectrumType>
Base;
76 typedef std::vector<SpectrumType>::iterator
Iterator;
123 return spectra_.size();
135 return spectra_.empty();
158 return spectra_.begin();
163 return spectra_.begin();
168 return spectra_.end();
173 return spectra_.end();
189 template <
class Container>
192 for (
typename Base::const_iterator spec = spectra_.begin(); spec != spectra_.end(); ++spec)
194 if (spec->getMSLevel() != 1)
198 typename Container::value_type s;
199 for (
typename SpectrumType::const_iterator it = spec->begin(); it != spec->end(); ++it)
202 cont.back().setRT(spec->getRT());
203 cont.back().setMZ(it->getMZ());
204 cont.back().setIntensity(it->getIntensity());
220 template <
class Container>
223 set2DData<false, Container>(container);
240 template <
class Container>
247 for (
typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
250 if (current_rt != iter->getRT() || spectrum ==
nullptr)
253 if (current_rt > iter->getRT())
257 current_rt = iter->getRT();
258 spectrum = createSpec_(current_rt, store_metadata_names);
284 template <
bool add_mass_traces,
class Container>
291 for (
typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
294 if (current_rt != iter->getRT() || spectrum ==
nullptr)
297 if (current_rt > iter->getRT())
301 current_rt = iter->getRT();
302 spectrum = createSpec_(current_rt);
315 AreaIterator areaBegin(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz,
UInt ms_level = 1);
335 std::vector<float>& rt,
336 std::vector<std::vector<float>>& mz,
337 std::vector<std::vector<float>>& intensity)
const
340 for (
auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz); it != areaEndConst(); ++it)
344 t = (float)it.getRT();
347 mz.back().push_back((
float)it->getMZ());
348 intensity.back().push_back(it->getIntensity());
354 std::vector<float>& rt,
355 std::vector<std::vector<float>>& mz,
356 std::vector<std::vector<float>>& intensity,
357 std::vector<std::vector<float>>& ion_mobility)
const
360 for (
auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz); it != areaEndConst(); ++it)
364 t = (float)it.getRT();
368 const MSSpectrum& spectrum = it.getSpectrum();
370 float peak_IM{-1.0f};
373 const auto& im_data = spectrum.
getIMData();
374 const Size peak_index = it.getPeakIndex().peak;
380 ion_mobility.back().push_back(peak_IM);
381 mz.back().push_back((
float)it->getMZ());
382 intensity.back().push_back(it->getIntensity());
392 std::vector<float>& rt,
393 std::vector<float>& mz,
394 std::vector<float>& intensity)
const
396 for (
auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz); it != areaEndConst(); ++it)
398 rt.push_back((
float)it.getRT());
399 mz.push_back((
float)it->getMZ());
400 intensity.push_back(it->getIntensity());
410 std::vector<float>& rt,
411 std::vector<float>& mz,
412 std::vector<float>& intensity,
413 std::vector<float>& ion_mobility)
const
415 for (
auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz); it != areaEndConst(); ++it)
417 rt.push_back((
float)it.getRT());
418 mz.push_back((
float)it->getMZ());
419 intensity.push_back(it->getIntensity());
421 const MSSpectrum& spectrum = it.getSpectrum();
423 float peak_IM = -1.0;
426 const auto& im_data = spectrum.
getIMData();
427 const Size& peak_index = it.getPeakIndex().peak;
433 ion_mobility.push_back(peak_IM);
680 template<
typename ContainerValueType,
bool addMassTraces>
687 template<
typename ContainerValueType>
694 spectrum->insert(spectrum->end(),
PeakType());
695 spectrum->back().setIntensity(item->getIntensity());
696 spectrum->back().setPosition(item->getMZ());
701 addData_(spectrum, item);
702 for (StringList::const_iterator itm = store_metadata_names.begin(); itm != store_metadata_names.end(); ++itm)
704 float val = std::numeric_limits<float>::quiet_NaN();
705 if (item->metaValueExists(*itm)) val = item->getMetaValue(*itm);
711 template<
typename ContainerValueType>
717 if (item->metaValueExists(
"num_of_masstraces"))
719 Size mts = item->getMetaValue(
"num_of_masstraces");
720 int charge = (item->getCharge()==0 ? 1 : item->getCharge());
721 for (
Size i = 0; i < mts; ++i)
724 if (!item->metaValueExists(meta_name))
726 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
String(
"Meta value '") + meta_name +
"' expected but not found in container.");
728 ContainerValueType p;
729 p.setIntensity(item->getMetaValue(meta_name));
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:28
Precondition failed exception.
Definition: Exception.h:128
Description of the experimental settings.
Definition: ExperimentalSettings.h:36
Forward iterator for an area of peaks in an experiment.
Definition: AreaIterator.h:36
The representation of a chromatogram.
Definition: MSChromatogram.h:31
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
const std::vector< UInt > & getMSLevels() const
returns an array of MS levels
const ExperimentalSettings & getExperimentalSettings() const
returns the meta information of this experiment (const access)
MSExperiment(MSExperiment &&)=default
Move constructor.
ConstIterator IMBegin(CoordinateType im) const
Fast search for spectrum range begin.
std::vector< SpectrumType > spectra_
spectra
Definition: MSExperiment.h:675
const std::vector< MSChromatogram > & getChromatograms() const
returns the chromatogram list
std::vector< SpectrumType > Base
STL base class type.
Definition: MSExperiment.h:71
void setChromatograms(std::vector< MSChromatogram > &&chromatograms)
Base::iterator iterator
Definition: MSExperiment.h:90
bool containsScanOfLevel(size_t ms_level) const
returns true if at least one of the spectra has the specified level
ConstAreaIterator areaBeginConst(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, UInt ms_level=1) const
Returns a non-mutable area iterator for area.
~MSExperiment() override
D'tor.
PeakType::CoordinateType CoordinateType
Coordinate type of peak positions.
Definition: MSExperiment.h:59
void get2DData(Container &cont) const
Reads out a 2D Spectrum.
Definition: MSExperiment.h:190
void swap(MSExperiment &from)
Swaps the content of this map with the content of from.
MSChromatogram ChromatogramType
Chromatogram type.
Definition: MSExperiment.h:69
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
PeakType::IntensityType IntensityType
Intensity type of peaks.
Definition: MSExperiment.h:61
Iterator begin()
Definition: MSExperiment.h:156
void set2DData(const Container &container, const StringList &store_metadata_names)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:241
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition: MSExperiment.h:77
bool clearMetaDataArrays()
Clears the meta data arrays of all contained spectra (float, integer and string arrays)
SpectrumType * createSpec_(PeakType::CoordinateType rt)
ConstAreaIterator areaBeginConst(const RangeManagerType &range, UInt ms_level=1) const
Returns a non-mutable area iterator for all peaks in range. If a dimension is empty(),...
ConstIterator RTBegin(CoordinateType rt) const
Fast search for spectrum range begin.
Size getNrSpectra() const
get the total number of spectra available
UInt64 getSize() const
returns the total number of peaks
MSExperiment & operator=(MSExperiment &&) &=default
Move assignment operator.
ConstIterator RTEnd(CoordinateType rt) const
Fast search for spectrum range end (returns the past-the-end iterator)
RangeManagerContainer< RangeRT, RangeMZ, RangeIntensity, RangeMobility > RangeManagerContainerType
RangeManager type.
Definition: MSExperiment.h:65
void addChromatogram(MSChromatogram &&chrom)
ExperimentalSettings & getExperimentalSettings()
returns the meta information of this experiment (mutable access)
void reserveSpaceChromatograms(Size s)
void get2DPeakData(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, std::vector< float > &rt, std::vector< std::vector< float >> &mz, std::vector< std::vector< float >> &intensity, std::vector< std::vector< float >> &ion_mobility) const
Definition: MSExperiment.h:353
SpectrumType * createSpec_(PeakType::CoordinateType rt, const StringList &metadata_names)
ChromatogramPeakT ChromatogramPeakType
Chromatogram peak type.
Definition: MSExperiment.h:57
MSSpectrum & getSpectrum(Size id)
returns a single spectrum
void get2DPeakDataIon(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, std::vector< float > &rt, std::vector< float > &mz, std::vector< float > &intensity, std::vector< float > &ion_mobility) const
Definition: MSExperiment.h:405
CoordinateType getMinMZ() const
returns the minimal m/z value
AreaIterator areaBegin(const RangeManagerType &range, UInt ms_level=1)
Returns a area iterator for all peaks in range. If a dimension is empty(), it is ignored (i....
Iterator RTEnd(CoordinateType rt)
Fast search for spectrum range end (returns the past-the-end iterator)
MSExperiment & operator=(const MSExperiment &source)
Assignment operator.
MSSpectrum SpectrumType
Spectrum Type.
Definition: MSExperiment.h:67
bool empty() const
Are there any spectra (does not consider chromatograms)
Definition: MSExperiment.h:133
Size getNrChromatograms() const
get the total number of chromatograms available
ConstIterator end() const
Definition: MSExperiment.h:171
CoordinateType getMaxRT() const
returns the maximal retention time value
void get2DPeakData(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, std::vector< float > &rt, std::vector< std::vector< float >> &mz, std::vector< std::vector< float >> &intensity) const
Definition: MSExperiment.h:334
Base::value_type value_type
Definition: MSExperiment.h:89
MSExperiment()
Constructor.
bool operator!=(const MSExperiment &rhs) const
Equality operator.
CoordinateType getMaxMZ() const
returns the maximal m/z value
Peak1D PeakT
Definition: MSExperiment.h:49
ConstAreaIterator areaEndConst() const
Returns an non-mutable invalid area iterator marking the end of an area.
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:221
void setSpectra(std::vector< MSSpectrum > &&spectra)
void getPrimaryMSRunPath(StringList &toFill) const
get the file path to the first MS run
std::vector< UInt > ms_levels_
MS levels of the data.
Definition: MSExperiment.h:669
void resize(Size n)
Resize to n spectra.
Definition: MSExperiment.h:127
std::vector< MSChromatogram > & getChromatograms()
returns the chromatogram list (mutable)
void setSpectra(const std::vector< MSSpectrum > &spectra)
sets the spectrum list
void updateRanges(Int ms_level)
Updates the m/z, intensity, retention time and MS level ranges of all spectra with a certain ms level...
void get2DPeakData(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, std::vector< float > &rt, std::vector< float > &mz, std::vector< float > &intensity) const
Definition: MSExperiment.h:387
void sortChromatograms(bool sort_rt=true)
Sorts the data points of the chromatograms by m/z.
Iterator RTBegin(CoordinateType rt)
Fast search for spectrum range begin.
Internal::AreaIterator< const PeakT, const PeakT &, const PeakT *, ConstIterator, SpectrumType::ConstIterator > ConstAreaIterator
Immutable area iterator type (for traversal of a rectangular subset of the peaks)
Definition: MSExperiment.h:83
void setChromatograms(const std::vector< MSChromatogram > &chromatograms)
sets the chromatogram list
Internal::AreaIterator< PeakT, PeakT &, PeakT *, Iterator, SpectrumType::Iterator > AreaIterator
Mutable area iterator type (for traversal of a rectangular subset of the peaks)
Definition: MSExperiment.h:81
CoordinateType getMinRT() const
returns the minimal retention time value
const SpectrumType & operator[](Size n) const
Random access to n'th spectrum.
Definition: MSExperiment.h:151
const MSChromatogram calculateTIC(float rt_bin_size=0, UInt ms_level=1) const
Computes the total ion chromatogram (TIC) for a given MS level (use ms_level = 0 for all levels).
const std::vector< MSSpectrum > & getSpectra() const
returns the spectrum list
Iterator end()
Definition: MSExperiment.h:166
UInt64 total_size_
Number of all data points.
Definition: MSExperiment.h:671
bool isSorted(bool check_mz=true) const
Checks if all spectra are sorted with respect to ascending RT.
MSExperiment(const MSExperiment &source)
Copy constructor.
RangeManager< RangeRT, RangeMZ, RangeIntensity, RangeMobility > RangeManagerType
RangeManager type.
Definition: MSExperiment.h:63
std::vector< MSSpectrum > & getSpectra()
returns the spectrum list (mutable)
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:285
ChromatogramPeak ChromatogramPeakT
Definition: MSExperiment.h:50
void sortSpectra(bool sort_mz=true)
Sorts the data points by retention time.
Size size() const
The number of spectra.
Definition: MSExperiment.h:121
void reset()
Clear all internal data (spectra, ranges, metadata)
ConstIterator begin() const
Definition: MSExperiment.h:161
void addSpectrum(MSSpectrum &&spectrum)
void reserveSpaceSpectra(Size s)
bool hasZeroIntensities(size_t ms_level) const
returns true if any MS spectra of trthe specified level contain at least one peak with intensity of 0...
bool operator==(const MSExperiment &rhs) const
Equality operator.
ConstIterator IMEnd(CoordinateType im) const
Fast search for spectrum range end (returns the past-the-end iterator)
ConstIterator getPrecursorSpectrum(ConstIterator iterator) const
Returns the precursor spectrum of the scan pointed to by iterator.
void reserve(Size n)
Reserve space for n spectra.
Definition: MSExperiment.h:139
Base::const_iterator const_iterator
Definition: MSExperiment.h:91
void updateRanges() override
void setSqlRunID(UInt64 id)
sets the run-ID which is used when storing an sqMass file
MSExperiment & operator=(const ExperimentalSettings &source)
Assignment operator.
UInt64 getSqlRunID() const
void addChromatogram(const MSChromatogram &chromatogram)
adds a chromatogram to the list
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:79
bool hasPeptideIdentifications() const
do any of the spectra have a PeptideID?
void clear(bool clear_meta_data)
Clears all data and meta data.
SpectrumType & operator[](Size n)
Random access to n'th spectrum.
Definition: MSExperiment.h:145
int getPrecursorSpectrum(int zero_based_index) const
Returns the index of the precursor spectrum for spectrum at index zero_based_index.
std::vector< MSChromatogram > chromatograms_
chromatograms
Definition: MSExperiment.h:673
AreaIterator areaEnd()
Returns an invalid area iterator marking the end of an area.
bool isIMFrame() const
Are all MSSpectra in this experiment part of an IM Frame? I.e. they all have the same RT,...
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
bool containsIMData() const
std::pair< Size, DriftTimeUnit > getIMData() const
Get the Ion mobility data array's index and its associated unit.
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:28
double CoordinateType
Coordinate type.
Definition: Peak1D.h:40
float IntensityType
Intensity type.
Definition: Peak1D.h:36
Definition: RangeManager.h:876
A more convenient string class.
Definition: String.h:34
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:51
int Int
Signed integer type.
Definition: Types.h:76
unsigned int UInt
Unsigned integer type.
Definition: Types.h:68
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
const double C13C12_MASSDIFF_U
Definition: Constants.h:95
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Peak2D PeakType
Definition: MassTrace.h:21
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
general method for adding data points
Definition: MSExperiment.h:691
static void addData_(SpectrumType *spectrum, const ContainerValueType *item, const StringList &store_metadata_names)
general method for adding data points, including metadata arrays (populated from metainfointerface)
Definition: MSExperiment.h:699
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
specialization for adding feature mass traces (does not support metadata_names currently)
Definition: MSExperiment.h:715
Helper class to add either general data points in set2DData or use mass traces from meta values.
Definition: MSExperiment.h:682
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
static void addData_(SpectrumType *spectrum, const ContainerValueType *item, const StringList &store_metadata_names)