26 class ChromatogramPeak;
78 typedef std::vector<SpectrumType>
Base;
84 typedef std::vector<SpectrumType>::iterator
Iterator;
134 bool empty() const noexcept;
159 void reserveSpaceSpectra(
Size s);
160 void reserveSpaceChromatograms(
Size s);
170 template <class Container>
171 void get2DData(Container& cont)
const
173 for (
typename Base::const_iterator spec = spectra_.begin(); spec != spectra_.end(); ++spec)
175 if (spec->getMSLevel() != 1)
179 typename Container::value_type s;
180 for (
typename SpectrumType::const_iterator it = spec->begin(); it != spec->end(); ++it)
183 cont.back().
setRT(spec->getRT());
184 cont.back().setMZ(it->getMZ());
185 cont.back().setIntensity(it->getIntensity());
201 template <
class Container>
204 set2DData<false, Container>(container);
221 template <
class Container>
228 for (
typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
231 if (current_rt != iter->getRT() || spectrum ==
nullptr)
234 if (current_rt > iter->getRT())
238 current_rt = iter->getRT();
239 spectrum = createSpec_(current_rt, store_metadata_names);
265 template <
bool add_mass_traces,
class Container>
272 for (
typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
275 if (current_rt != iter->getRT() || spectrum ==
nullptr)
278 if (current_rt > iter->getRT())
282 current_rt = iter->getRT();
283 spectrum = createSpec_(current_rt);
334 std::vector<float>& rt,
335 std::vector<std::vector<float>>& mz,
336 std::vector<std::vector<float>>& intensity)
const;
358 std::vector<float>& rt,
359 std::vector<std::vector<float>>& mz,
360 std::vector<std::vector<float>>& intensity,
361 std::vector<std::vector<float>>& ion_mobility)
const;
382 std::vector<float>& rt,
383 std::vector<float>& mz,
384 std::vector<float>& intensity)
const;
406 std::vector<float>& rt,
407 std::vector<float>& mz,
408 std::vector<float>& intensity,
409 std::vector<float>& ion_mobility)
const;
491 template <
typename Iterator>
494 using ValueType =
typename std::iterator_traits<Iterator>::value_type;
495 using IntensityType =
decltype(std::declval<ValueType>().getIntensity());
496 static_assert(std::is_member_function_pointer_v<
decltype(&ValueType::getIntensity)>,
497 "Iterator value type must have getIntensity() member function");
500 for (
auto it = begin; it != end; ++it) {
501 sum += it->getIntensity();
555template<
class MzReductionFunctionType>
556std::vector<std::vector<MSExperiment::CoordinateType>>
aggregate(
557 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
558 unsigned int ms_level,
559 MzReductionFunctionType func_mz_reduction)
const
562 if (mz_rt_ranges.empty())
569 std::vector<std::reference_wrapper<const MSSpectrum>> spectra_view;
570 spectra_view.reserve(spectra_.size());
571 std::copy_if(spectra_.begin(), spectra_.end(),
572 std::back_inserter(spectra_view),
573 [ms_level](
const auto& spec) {
574 return spec.getMSLevel() == ms_level;
578 if (spectra_view.empty()) {
584 auto getCoveredSpectra = [](
585 const std::vector<std::reference_wrapper<const MSSpectrum>>& spectra_view,
586 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges)
587 -> std::vector<std::pair<size_t, size_t>>
589 std::vector<std::pair<size_t, size_t>> res;
590 res.reserve(mz_rt_ranges.size());
592 for (
const auto & mz_rt : mz_rt_ranges)
596 auto start_it = std::lower_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMin(),
597 [](
const auto& spec,
double rt)
598 { return spec.get().getRT() < rt; });
600 auto stop_it = std::upper_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMax(),
601 [](
double rt,
const auto& spec)
602 { return rt < spec.get().getRT(); });
605 std::distance(spectra_view.begin(), start_it),
606 std::distance(spectra_view.begin(), stop_it)
614 const std::vector<std::pair<size_t, size_t>> rt_ranges_idcs = getCoveredSpectra(spectra_view, mz_rt_ranges);
617 std::vector<std::vector<MSExperiment::CoordinateType>> result(mz_rt_ranges.size());
620 std::vector<std::vector<size_t>> spec_idx_to_range_idx(spectra_view.size());
623 for (
size_t i = 0; i < rt_ranges_idcs.size(); ++i)
625 const auto& [start, stop] = rt_ranges_idcs[i];
626 result[i].resize(stop - start);
628 for (
size_t j = start; j < stop; ++j)
630 spec_idx_to_range_idx[j].push_back(i);
634 #pragma omp parallel for schedule(dynamic)
635 for (
Int64 i = 0; i < (
Int64)spec_idx_to_range_idx.size(); ++i)
637 if (spec_idx_to_range_idx[i].empty())
continue;
639 const auto& spec = spectra_view[i].get();
640 auto spec_begin = spec.cbegin();
641 auto spec_end = spec.cend();
643 for (
size_t range_idx : spec_idx_to_range_idx[i])
645 const auto& mz_range = mz_rt_ranges[range_idx].first;
648 auto start_it = spec.PosBegin(spec_begin, mz_range.getMinMZ(), spec_end);
649 auto end_it = start_it;
651 while (end_it != spec_end && end_it->getPosition() <= mz_range.getMaxMZ())
659 result[range_idx][i - rt_ranges_idcs[range_idx].first] =
660 func_mz_reduction(start_it, end_it);
667std::vector<std::vector<MSExperiment::CoordinateType>>
aggregate(
668 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
669 unsigned int ms_level)
const
686template<
class MzReductionFunctionType>
688 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
689 unsigned int ms_level,
690 MzReductionFunctionType func_mz_reduction)
const
693 if (mz_rt_ranges.empty())
700 std::vector<std::reference_wrapper<const MSSpectrum>> spectra_view;
701 spectra_view.reserve(spectra_.size());
702 std::copy_if(spectra_.begin(), spectra_.end(),
703 std::back_inserter(spectra_view),
704 [ms_level](
const auto& spec) {
705 return spec.getMSLevel() == ms_level;
709 if (spectra_view.empty()) {
715 auto getCoveredSpectra = [](
716 const std::vector<std::reference_wrapper<const MSSpectrum>>& spectra_view,
717 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges)
718 -> std::vector<std::pair<size_t, size_t>>
720 std::vector<std::pair<size_t, size_t>> res;
721 res.reserve(mz_rt_ranges.size());
723 for (
const auto & mz_rt : mz_rt_ranges)
725 auto start_it = std::lower_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMin(),
726 [](
const auto& spec,
double rt)
727 { return spec.get().getRT() < rt; });
729 auto stop_it = std::upper_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMax(),
730 [](
double rt,
const auto& spec)
731 { return rt < spec.get().getRT(); });
734 std::distance(spectra_view.begin(), start_it),
735 std::distance(spectra_view.begin(), stop_it)
742 const std::vector<std::pair<size_t, size_t>> rt_ranges_idcs = getCoveredSpectra(spectra_view, mz_rt_ranges);
745 std::vector<MSChromatogram> result(mz_rt_ranges.size());
748 std::vector<std::vector<size_t>> spec_idx_to_range_idx(spectra_view.size());
751 for (
size_t i = 0; i < rt_ranges_idcs.size(); ++i)
753 const auto& [start, stop] = rt_ranges_idcs[i];
754 result[i].resize(stop - start);
755 result[i].getProduct().setMZ(
756 (mz_rt_ranges[i].first.getMinMZ() + mz_rt_ranges[i].first.getMaxMZ()) / 2.0);
757 for (
size_t j = start; j < stop; ++j)
759 spec_idx_to_range_idx[j].push_back(i);
763 #pragma omp parallel for schedule(dynamic)
764 for (
Int64 i = 0; i < (
Int64)spec_idx_to_range_idx.size(); ++i)
766 if (spec_idx_to_range_idx[i].empty())
continue;
768 const auto& spec = spectra_view[i].get();
769 const double rt = spec.getRT();
770 auto spec_begin = spec.cbegin();
771 auto spec_end = spec.cend();
773 for (
size_t range_idx : spec_idx_to_range_idx[i])
775 const auto& mz_range = mz_rt_ranges[range_idx].first;
778 auto start_it = spec.PosBegin(spec_begin, mz_range.getMinMZ(), spec_end);
779 auto end_it = start_it;
781 while (end_it != spec_end && end_it->getPosition() <= mz_range.getMaxMZ())
787 result[range_idx][i - rt_ranges_idcs[range_idx].first] =
792 for (
auto& r : result) r.updateRanges();
799 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
800 unsigned int ms_level)
const
815 unsigned int ms_level,
816 const std::string& mz_agg)
const
819 if (ranges.
cols() != 4)
822 "Range matrix must have 4 columns [mz_min, mz_max, rt_min, rt_max]");
826 std::vector<std::pair<RangeMZ, RangeRT>> mz_rt_ranges;
827 mz_rt_ranges.reserve((
Size)ranges.
rows());
831 mz_rt_ranges.emplace_back(
832 RangeMZ(ranges(i, 0), ranges(i, 1)),
833 RangeRT(ranges(i, 2), ranges(i, 3))
841 return aggregate(mz_rt_ranges, ms_level,
842 [](
auto begin_it,
auto end_it)
844 return std::accumulate(begin_it, end_it, 0.0,
848 else if (mz_agg ==
"max")
850 return aggregate(mz_rt_ranges, ms_level,
851 [](
auto begin_it,
auto end_it)->
double
853 if (begin_it == end_it)
return 0.0;
854 return std::max_element(begin_it, end_it,
859 else if (mz_agg ==
"min")
861 return aggregate(mz_rt_ranges, ms_level,
862 [](
auto begin_it,
auto end_it)->
double
864 if (begin_it == end_it)
return 0.0;
865 return std::min_element(begin_it, end_it,
870 else if (mz_agg ==
"mean")
872 return aggregate(mz_rt_ranges, ms_level,
873 [](
auto begin_it,
auto end_it)
875 if (begin_it == end_it)
return 0.0;
876 double sum = std::accumulate(begin_it, end_it, 0.0,
878 return sum /
static_cast<double>(std::distance(begin_it, end_it));
884 "Invalid aggregation function", mz_agg);
898 unsigned int ms_level,
899 const std::string& mz_agg)
const
902 if (ranges.
cols() != 4)
905 "Range matrix must have 4 columns [mz_min, mz_max, rt_min, rt_max]");
909 std::vector<std::pair<RangeMZ, RangeRT>> mz_rt_ranges;
910 mz_rt_ranges.reserve((
Size)ranges.
rows());
914 mz_rt_ranges.emplace_back(
915 RangeMZ(ranges(i, 0), ranges(i, 1)),
916 RangeRT(ranges(i, 2), ranges(i, 3))
923 return extractXICs(mz_rt_ranges, ms_level,
924 [](
auto begin_it,
auto end_it)
926 return std::accumulate(begin_it, end_it, 0.0,
930 else if (mz_agg ==
"max")
932 return extractXICs(mz_rt_ranges, ms_level,
933 [](
auto begin_it,
auto end_it)->
double
935 if (begin_it == end_it)
return 0.0;
936 return std::max_element(begin_it, end_it,
941 else if (mz_agg ==
"min")
943 return extractXICs(mz_rt_ranges, ms_level,
944 [](
auto begin_it,
auto end_it)->
double
946 if (begin_it == end_it)
return 0.0;
947 return std::min_element(begin_it, end_it,
952 else if (mz_agg ==
"mean")
954 return extractXICs(mz_rt_ranges, ms_level,
955 [](
auto begin_it,
auto end_it)
957 if (begin_it == end_it)
return 0.0;
958 double sum = std::accumulate(begin_it, end_it, 0.0,
960 return sum /
static_cast<double>(std::distance(begin_it, end_it));
966 "Invalid aggregation function", mz_agg);
1038 combined_ranges_.clearRanges();
1039 spectrum_ranges_.clearRanges();
1040 chromatogram_ranges_.clearRanges();
1044 double getMinRT()
const {
return combined_ranges_.getMinRT(); }
1047 double getMaxRT()
const {
return combined_ranges_.getMaxRT(); }
1050 double getMinMZ()
const {
return combined_ranges_.getMinMZ(); }
1053 double getMaxMZ()
const {
return combined_ranges_.getMaxMZ(); }
1331 template<
typename ContainerValueType,
bool addMassTraces>
1338 template<
typename ContainerValueType>
1345 spectrum->insert(spectrum->end(),
PeakType());
1346 spectrum->back().setIntensity(item->getIntensity());
1347 spectrum->back().setPosition(item->getMZ());
1352 addData_(spectrum, item);
1353 for (StringList::const_iterator itm = store_metadata_names.begin(); itm != store_metadata_names.end(); ++itm)
1355 float val = std::numeric_limits<float>::quiet_NaN();
1356 if (item->metaValueExists(*itm)) val = item->getMetaValue(*itm);
1362 template<
typename ContainerValueType>
1368 if (item->metaValueExists(
"num_of_masstraces"))
1370 Size mts = item->getMetaValue(
"num_of_masstraces");
1371 int charge = (item->getCharge()==0 ? 1 : item->getCharge());
1372 for (
Size i = 0; i < mts; ++i)
1375 if (!item->metaValueExists(meta_name))
1377 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
String(
"Meta value '") + meta_name +
"' expected but not found in container.");
1379 ContainerValueType p;
1380 p.setIntensity(item->getMetaValue(meta_name));
1381 p.setPosition(item->getMZ() + Constants::C13C12_MASSDIFF_U / charge * i);
A 1-dimensional raw data point or peak for chromatograms.
Definition ChromatogramPeak.h:29
Range manager for chromatograms.
Definition ChromatogramRangeManager.h:31
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition Exception.h:317
Invalid value exception.
Definition Exception.h:306
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:30
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
std::vector< std::vector< MSExperiment::CoordinateType > > aggregate(const std::vector< std::pair< RangeMZ, RangeRT > > &mz_rt_ranges, unsigned int ms_level) const
Definition MSExperiment.h:667
MSExperiment(MSExperiment &&)=default
Move constructor.
ConstIterator IMBegin(CoordinateType im) const
Fast search for spectrum range begin.
RangeManagerType combined_ranges_
Combined range manager that provides overall ranges across both spectra and chromatograms (maintained...
Definition MSExperiment.h:1293
ConstIterator getClosestSpectrumInRT(const double RT, UInt ms_level) const
Returns the closest(=nearest) spectrum in retention time to the given RT of a certain MS level.
std::vector< SpectrumType > spectra_
spectra
Definition MSExperiment.h:1285
std::vector< SpectrumType > Base
STL base class type.
Definition MSExperiment.h:78
void setChromatograms(std::vector< MSChromatogram > &&chromatograms)
Base::iterator iterator
Definition MSExperiment.h:97
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.
double getMaxRT() const
Get the maximum RT value from the combined ranges (includes both chromatogram and spectra ranges)
Definition MSExperiment.h:1047
~MSExperiment() override
D'tor.
PeakType::CoordinateType CoordinateType
Coordinate type of peak positions.
Definition MSExperiment.h:62
RasterAggregation
Aggregation mode for rasterization functions.
Definition MSExperiment.h:415
void swap(MSExperiment &from)
Swaps the content of this map with the content of from.
MSChromatogram ChromatogramType
Chromatogram type.
Definition MSExperiment.h:76
void addSpectrum(const MSSpectrum &spectrum)
adds a spectrum to the list
std::vector< MSChromatogram > extractXICs(const std::vector< std::pair< RangeMZ, RangeRT > > &mz_rt_ranges, unsigned int ms_level, MzReductionFunctionType func_mz_reduction) const
Extracts extracted ion chromatograms (XICs) from the MSExperiment.
Definition MSExperiment.h:687
void get2DPeakDataPerSpectrum(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, Size ms_level, std::vector< float > &rt, std::vector< std::vector< float > > &mz, std::vector< std::vector< float > > &intensity) const
PeakType::IntensityType IntensityType
Intensity type of peaks.
Definition MSExperiment.h:64
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:222
std::vector< SpectrumType >::iterator Iterator
Mutable iterator.
Definition MSExperiment.h:84
bool clearMetaDataArrays()
Clears the meta data arrays of all contained spectra (float, integer and string arrays)
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(),...
void get2DPeakDataIMPerSpectrum(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, Size ms_level, std::vector< float > &rt, std::vector< std::vector< float > > &mz, std::vector< std::vector< float > > &intensity, std::vector< std::vector< float > > &ion_mobility) const
ConstIterator RTBegin(CoordinateType rt) const
Fast search for spectrum range begin.
Size getNrSpectra() const
get the total number of spectra available
SpectrumType * createSpec_(PeakType::CoordinateType rt, const StringList &metadata_names)
UInt64 getSize() const
returns the total number of peaks (spectra and chromatograms included)
double getMaxMZ() const
Get the maximum m/z value from the combined ranges (includes both chromatogram and spectra ranges)
Definition MSExperiment.h:1053
ConstIterator RTEnd(CoordinateType rt) const
Fast search for spectrum range end (returns the past-the-end iterator)
void addChromatogram(MSChromatogram &&chrom)
void rasterizeRTMZ(float *output, Size rt_bins, Size mz_bins, CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, UInt ms_level, RasterAggregation aggregation=RasterAggregation::SUM) const
Rasterizes peak data from spectra into a 2D intensity matrix for visualization.
Iterator getClosestSpectrumInRT(const double RT, UInt ms_level)
double getMinMobility() const
Get the minimum mobility value from the combined ranges (includes both chromatogram and spectra range...
Definition MSExperiment.h:1062
SpectrumRangeManager SpectrumRangeManagerType
Spectrum range manager type for tracking ranges with MS level separation.
Definition MSExperiment.h:69
MSExperiment & operator=(const MSExperiment &source)
Assignment operator.
std::vector< MSChromatogram > & getChromatograms()
returns the chromatogram list (mutable)
double getMinIntensity() const
Get the minimum intensity value from the combined ranges (includes both chromatogram and spectra rang...
Definition MSExperiment.h:1056
std::vector< MSChromatogram > extractXICs(const std::vector< std::pair< RangeMZ, RangeRT > > &mz_rt_ranges, unsigned int ms_level) const
Definition MSExperiment.h:798
MSChromatogram & getChromatogram(Size id)
returns a single chromatogram
ChromatogramPeakT ChromatogramPeakType
Chromatogram peak type.
Definition MSExperiment.h:60
AreaIterator areaBegin(const RangeManagerType &range, UInt ms_level=1)
Returns an 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)
AreaIterator areaBegin(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, UInt ms_level=1)
Returns an area iterator for area.
MSSpectrum SpectrumType
Spectrum Type.
Definition MSExperiment.h:74
double getMinMZ() const
Get the minimum m/z value from the combined ranges (includes both chromatogram and spectra ranges)
Definition MSExperiment.h:1050
Size getNrChromatograms() const
get the total number of chromatograms available
PeakT PeakType
Peak type.
Definition MSExperiment.h:58
Iterator getClosestSpectrumInRT(const double RT)
SpectrumType * createSpec_(PeakType::CoordinateType rt)
std::vector< std::vector< MSExperiment::CoordinateType > > aggregateFromMatrix(const Matrix< double > &ranges, unsigned int ms_level, const std::string &mz_agg) const
Wrapper for aggregate function that takes a matrix of m/z and RT ranges.
Definition MSExperiment.h:813
const ExperimentalSettings & getExperimentalSettings() const
returns the meta information of this experiment (const access)
Base::value_type value_type
Definition MSExperiment.h:96
Size size() const noexcept
The number of spectra.
MSExperiment()
Constructor.
bool operator!=(const MSExperiment &rhs) const
Equality operator.
std::vector< MSChromatogram > extractXICsFromMatrix(const Matrix< double > &ranges, unsigned int ms_level, const std::string &mz_agg) const
Wrapper for extractXICs function that takes a matrix of m/z and RT ranges.
Definition MSExperiment.h:896
Peak1D PeakT
Definition MSExperiment.h:52
ConstAreaIterator areaEndConst() const
Returns a non-mutable invalid area iterator marking the end of an area.
const ChromatogramRangeManagerType & chromatogramRanges() const
Returns a const reference to the chromatogram range manager.
Definition MSExperiment.h:1316
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition MSExperiment.h:202
void setSpectra(std::vector< MSSpectrum > &&spectra)
void getPrimaryMSRunPath(StringList &toFill) const
get the file path to the first MS run
MSExperiment & operator=(const ExperimentalSettings &source)
Assignment operator.
double getMaxMobility() const
Get the maximum mobility value from the combined ranges (includes both chromatogram and spectra range...
Definition MSExperiment.h:1065
void get2DPeakData(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, Size ms_level, std::vector< float > &rt, std::vector< float > &mz, std::vector< float > &intensity) const
void setSpectra(const std::vector< MSSpectrum > &spectra)
sets the spectrum list
void get2DPeakDataIM(CoordinateType min_rt, CoordinateType max_rt, CoordinateType min_mz, CoordinateType max_mz, Size ms_level, std::vector< float > &rt, std::vector< float > &mz, std::vector< float > &intensity, std::vector< float > &ion_mobility) const
const RangeManagerType & combinedRanges() const
Returns a const reference to the combined range manager.
Definition MSExperiment.h:1326
void sortChromatograms(bool sort_rt=true)
Sorts the data points of the chromatograms by m/z.
double getMaxIntensity() const
Get the maximum intensity value from the combined ranges (includes both chromatogram and spectra rang...
Definition MSExperiment.h:1059
int getFirstProductSpectrum(int zero_based_index) const
Returns the index of the first product spectrum given an index.
Iterator RTBegin(CoordinateType rt)
Fast search for spectrum range begin.
void clearRanges()
Clear all ranges in all range managers.
Definition MSExperiment.h:1036
const std::vector< MSChromatogram > & getChromatograms() const
returns the chromatogram list
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:90
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:88
double getMinRT() const
Get the minimum RT value from the combined ranges (includes both chromatogram and spectra ranges)
Definition MSExperiment.h:1044
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).
ExperimentalSettings & getExperimentalSettings()
returns the meta information of this experiment (mutable access)
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
Combined RangeManager type to store the overall range of all spectra and chromatograms (for backward ...
Definition MSExperiment.h:66
ConstIterator getClosestSpectrumInRT(const double RT) const
Returns the closest(=nearest) spectrum in retention time to the given RT.
ChromatogramRangeManager ChromatogramRangeManagerType
Chromatogram range manager type for tracking chromatogram-specific ranges.
Definition MSExperiment.h:72
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition MSExperiment.h:266
ChromatogramPeak ChromatogramPeakT
Definition MSExperiment.h:53
void sortSpectra(bool sort_mz=true)
Sorts the data points by retention time.
MSExperiment & operator=(MSExperiment &&) &=default
Move assignment operator.
void reset()
Clear all internal data (spectra, ranges, metadata)
void addSpectrum(MSSpectrum &&spectrum)
std::vector< std::vector< MSExperiment::CoordinateType > > aggregate(const std::vector< std::pair< RangeMZ, RangeRT > > &mz_rt_ranges, unsigned int ms_level, MzReductionFunctionType func_mz_reduction) const
Aggregates data over specified m/z and RT ranges at a given MS level using a custom reduction functio...
Definition MSExperiment.h:556
void updateRanges()
Updates the m/z, intensity, mobility, and retention time ranges of all spectra and chromatograms.
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)
SpectrumRangeManagerType spectrum_ranges_
Spectrum range manager for tracking m/z, intensity, RT, and ion mobility ranges of spectra with MS le...
Definition MSExperiment.h:1287
ConstIterator getPrecursorSpectrum(ConstIterator iterator) const
Returns the precursor spectrum of the scan pointed to by iterator.
Base::const_iterator const_iterator
Definition MSExperiment.h:98
void setSqlRunID(UInt64 id)
sets the run-ID which is used when storing an sqMass file
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:86
const SpectrumRangeManagerType & spectrumRanges() const
Returns a const reference to the spectrum range manager.
Definition MSExperiment.h:1305
std::vector< UInt > getMSLevels() const
returns a sorted array of MS levels (calculated on demand)
void clear(bool clear_meta_data)
Clears all data and meta data.
const std::vector< MSSpectrum > & getSpectra() const
returns the spectrum list
MSSpectrum & getSpectrum(Size id)
returns a single spectrum
ConstIterator getFirstProductSpectrum(ConstIterator iterator) const
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:1283
std::vector< MSSpectrum > & getSpectra()
returns the spectrum list (mutable)
ChromatogramRangeManagerType chromatogram_ranges_
Chromatogram range manager for tracking RT, intensity, and m/z ranges of chromatograms.
Definition MSExperiment.h:1290
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
const FloatDataArrays & getFloatDataArrays() const
Returns a const reference to the float meta data arrays.
void setRT(double rt)
Sets the absolute retention time (in seconds)
A 2D matrix class with efficient buffer access for NumPy interoperability.
Definition Matrix.h:35
Size cols() const
Number of columns.
Definition Matrix.h:84
Size rows() const
Number of rows.
Definition Matrix.h:81
A 1-dimensional raw data point or peak.
Definition Peak1D.h:30
double CoordinateType
Coordinate type.
Definition Peak1D.h:42
IntensityType getIntensity() const
Definition Peak1D.h:84
float IntensityType
Intensity type.
Definition Peak1D.h:38
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition RangeManager.h:568
Advanced range manager for MS spectra with separate ranges for each MS level.
Definition SpectrumRangeManager.h:44
A more convenient string class.
Definition String.h:34
int64_t Int64
Signed integer type (64bit)
Definition Types.h:40
uint64_t UInt64
Unsigned integer type (64bit)
Definition Types.h:47
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
std::vector< String > StringList
Vector of String.
Definition ListUtils.h:44
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
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:1342
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:1350
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
specialization for adding feature mass traces (does not support metadata_names currently)
Definition MSExperiment.h:1366
Helper class to add either general data points in set2DData or use mass traces from meta values.
Definition MSExperiment.h:1333
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
static void addData_(SpectrumType *spectrum, const ContainerValueType *item, const StringList &store_metadata_names)
Calculates the sum of intensities for a range of elements.
Definition MSExperiment.h:489
auto operator()(Iterator begin, Iterator end) const
Definition MSExperiment.h:492
Definition RangeManager.h:358
Definition RangeManager.h:295