OpenMS
Loading...
Searching...
No Matches
MSExperiment.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: Timo Sachsenberg $
6// $Authors: Marc Sturm, Tom Waschischeck $
7// --------------------------------------------------------------------------
8
9#pragma once
10
19
20#include <vector>
21
22
23namespace OpenMS
24{
25 class Peak1D;
26 class ChromatogramPeak;
27
29
48 class OPENMS_DLLAPI MSExperiment final : public ExperimentalSettings
49 {
50
51public:
52 typedef Peak1D PeakT;
54
56
57
58 typedef PeakT PeakType;
67
70
78 typedef std::vector<SpectrumType> Base;
80
82
83
84 typedef std::vector<SpectrumType>::iterator Iterator;
86 typedef std::vector<SpectrumType>::const_iterator ConstIterator;
92
94 // Attention: these refer to the spectra vector only!
96 typedef Base::value_type value_type;
97 typedef Base::iterator iterator;
98 typedef Base::const_iterator const_iterator;
99
102
104 MSExperiment(const MSExperiment & source);
105
108
111
114
117
119 ~MSExperiment() override;
120
122 bool operator==(const MSExperiment & rhs) const;
123
125 bool operator!=(const MSExperiment & rhs) const;
126
128 Size size() const noexcept;
129
131 void resize(Size n);
132
134 bool empty() const noexcept;
135
137 void reserve(Size n);
138
140 SpectrumType& operator[](Size n);
141
143 const SpectrumType& operator[](Size n) const;
144
145 Iterator begin() noexcept;
146
147 ConstIterator begin() const noexcept;
148
149 ConstIterator cbegin() const noexcept;
150
151 Iterator end();
152
153 ConstIterator end() const noexcept;
154
155 ConstIterator cend() const noexcept;
157
158 // Aliases / chromatograms
159 void reserveSpaceSpectra(Size s);
160 void reserveSpaceChromatograms(Size s);
161
163
164
170 template <class Container>
171 void get2DData(Container& cont) const
172 {
173 for (typename Base::const_iterator spec = spectra_.begin(); spec != spectra_.end(); ++spec)
174 {
175 if (spec->getMSLevel() != 1)
176 {
177 continue;
178 }
179 typename Container::value_type s; // explicit object here, since instantiation within push_back() fails on VS<12
180 for (typename SpectrumType::const_iterator it = spec->begin(); it != spec->end(); ++it)
181 {
182 cont.push_back(s);
183 cont.back().setRT(spec->getRT());
184 cont.back().setMZ(it->getMZ());
185 cont.back().setIntensity(it->getIntensity());
186 }
187 }
188 }
189
201 template <class Container>
202 void set2DData(const Container& container)
203 {
204 set2DData<false, Container>(container);
205 }
206
221 template <class Container>
222 void set2DData(const Container& container, const StringList& store_metadata_names)
223 {
224 // clean up the container first
225 clear(true);
226 SpectrumType* spectrum = nullptr;
227 typename PeakType::CoordinateType current_rt = -std::numeric_limits<typename PeakType::CoordinateType>::max();
228 for (typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
229 {
230 // check if the retention time has changed
231 if (current_rt != iter->getRT() || spectrum == nullptr)
232 {
233 // append new spectrum
234 if (current_rt > iter->getRT())
235 {
236 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Input container is not sorted!");
237 }
238 current_rt = iter->getRT();
239 spectrum = createSpec_(current_rt, store_metadata_names);
240 }
241
242 // add either data point or mass traces (depending on template argument value)
243 ContainerAdd_<typename Container::value_type, false>::addData_(spectrum, &(*iter), store_metadata_names);
244 }
245 }
246
265 template <bool add_mass_traces, class Container>
266 void set2DData(const Container& container)
267 {
268 // clean up the container first
269 clear(true);
270 SpectrumType* spectrum = nullptr;
271 typename PeakType::CoordinateType current_rt = -std::numeric_limits<typename PeakType::CoordinateType>::max();
272 for (typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
273 {
274 // check if the retention time has changed
275 if (current_rt != iter->getRT() || spectrum == nullptr)
276 {
277 // append new spectrum
278 if (current_rt > iter->getRT())
279 {
280 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Input container is not sorted!");
281 }
282 current_rt = iter->getRT();
283 spectrum = createSpec_(current_rt);
284 }
285
286 // add either data point or mass traces (depending on template argument value)
288 }
289 }
290
292
293
295
296
298 CoordinateType min_mz, CoordinateType max_mz, UInt ms_level = 1);
299
301 AreaIterator areaBegin(const RangeManagerType& range, UInt ms_level = 1);
302
305
308
310 ConstAreaIterator areaBeginConst(const RangeManagerType& range, UInt ms_level = 1) const;
311
314
315 /* @brief Retrieves the peak data in the given mz-rt range and store data spectrum-wise in separate arrays.
316 *
317 * For fast pyOpenMS access to peak data in format: [rt, [mz, intensity]]
318 *
319 * @param[in] min_rt The minimum retention time.
320 * @param[in] max_rt The maximum retention time.
321 * @param[in] min_mz The minimum m/z value.
322 * @param[in] max_mz The maximum m/z value.
323 * @param[in] ms_level The MS level of the spectra to consider.
324 * @param[out] rt The vector to store the retention times in.
325 * @param[out] mz The vector to store the m/z values in.
326 * @param[out] intensity The vector to store the intensities in.
327 */
329 CoordinateType min_rt,
330 CoordinateType max_rt,
331 CoordinateType min_mz,
332 CoordinateType max_mz,
333 Size ms_level,
334 std::vector<float>& rt,
335 std::vector<std::vector<float>>& mz,
336 std::vector<std::vector<float>>& intensity) const;
337
338 /* @brief Retrieves the peak data in the given mz-rt range and store data spectrum-wise in separate arrays.
339 *
340 * For fast pyOpenMS access to MS1 peak data in format: [rt, [mz, intensity, ion mobility]]
341 *
342 * @param[in] min_rt The minimum retention time.
343 * @param[in] max_rt The maximum retention time.
344 * @param[in] min_mz The minimum m/z value.
345 * @param[in] max_mz The maximum m/z value.
346 * @param[in] ms_level The MS level of the spectra to consider.
347 * @param[out] rt The vector to store the retention times in.
348 * @param[out] mz The vector to store the m/z values in.
349 * @param[out] intensity The vector to store the intensities in.
350 * @param[out] ion_mobility The vector to store the ion mobility values in.
351 */
353 CoordinateType min_rt,
354 CoordinateType max_rt,
355 CoordinateType min_mz,
356 CoordinateType max_mz,
357 Size ms_level,
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;
362
363 /* @brief Retrieves the peak data in the given mz-rt range and store in separate arrays.
364 *
365 * For fast pyOpenMS access to MS1 peak data in format: [rt, mz, intensity]
366 *
367 * @param[in] min_rt The minimum retention time.
368 * @param[in] max_rt The maximum retention time.
369 * @param[in] min_mz The minimum m/z value.
370 * @param[in] max_mz The maximum m/z value.
371 * @param[in] ms_level The MS level of the spectra to consider.
372 * @param[out] rt The vector to store the retention times in.
373 * @param[out] mz The vector to store the m/z values in.
374 * @param[out] intensity The vector to store the intensities in.
375 */
377 CoordinateType min_rt,
378 CoordinateType max_rt,
379 CoordinateType min_mz,
380 CoordinateType max_mz,
381 Size ms_level,
382 std::vector<float>& rt,
383 std::vector<float>& mz,
384 std::vector<float>& intensity) const;
385
386
387 /* @brief Retrieves the peak data in the given mz-rt range and store in separate arrays.
388 *
389 * For fast pyOpenMS access to MS1 peak data in format: [rt, mz, intensity, ion mobility]
390 *
391 * @param[in] min_rt The minimum retention time.
392 * @param[in] max_rt The maximum retention time.
393 * @param[in] min_mz The minimum m/z value.
394 * @param[in] max_mz The maximum m/z value.
395 * @param[in] ms_level The MS level of the spectra to consider.
396 * @param[out] rt The vector to store the retention times in.
397 * @param[out] mz The vector to store the m/z values in.
398 * @param[out] intensity The vector to store the intensities in.
399 */
401 CoordinateType min_rt,
402 CoordinateType max_rt,
403 CoordinateType min_mz,
404 CoordinateType max_mz,
405 Size ms_level,
406 std::vector<float>& rt,
407 std::vector<float>& mz,
408 std::vector<float>& intensity,
409 std::vector<float>& ion_mobility) const;
410
415 {
416 SUM,
417 MAX
418 };
419
469 float* output,
470 Size rt_bins,
471 Size mz_bins,
472 CoordinateType min_rt,
473 CoordinateType max_rt,
474 CoordinateType min_mz,
475 CoordinateType max_mz,
476 UInt ms_level,
477 RasterAggregation aggregation = RasterAggregation::SUM) const;
478
490
491 template <typename Iterator>
492 auto operator()(Iterator begin, Iterator end) const {
493 // Static assert to verify iterator type has intensity accessor
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");
498
499 IntensityType sum{};
500 for (auto it = begin; it != end; ++it) {
501 sum += it->getIntensity();
502 }
503 return sum;
504 }
505};
506
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
560{
561 // Early exit if there are no ranges
562 if (mz_rt_ranges.empty())
563 {
564 // likely an error, but we return an empty vector instead of throwing an exception for now
565 return {};
566 }
567
568 // Create a view of the spectra with given MS level
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;
575 });
576
577 // Early exit if there are no spectra with the given MS level
578 if (spectra_view.empty()) { // could be valid use or an error -> we return an empty vector
579 return {};
580 }
581
582 // Get the indices of the spectra covered by the RT ranges by considering the MS level
583 // If start and stop are the same, the range is 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>>
588 {
589 std::vector<std::pair<size_t, size_t>> res;
590 res.reserve(mz_rt_ranges.size());
591
592 for (const auto & mz_rt : mz_rt_ranges)
593 {
594 // std::cout << "rt range: " << mz_rt.second.getMin() << " - " << mz_rt.second.getMax() << std::endl;
595 // std::cout << "specs start:" << spectra_view[0].get().getRT() << " specs end:" << spectra_view[spectra_view.size() - 1].get().getRT() << std::endl;
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; });
599
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(); });
603
604 res.emplace_back(
605 std::distance(spectra_view.begin(), start_it),
606 std::distance(spectra_view.begin(), stop_it)
607 );
608 // std::cout << "start: " << std::distance(spectra_view.begin(), start_it) << " stop: " << std::distance(spectra_view.begin(), stop_it) << std::endl;
609 }
610 return res;
611 };
612
613 // For each range, gets (spectrum start index, spectrum stop index). The spectra covered by each RT range.
614 const std::vector<std::pair<size_t, size_t>> rt_ranges_idcs = getCoveredSpectra(spectra_view, mz_rt_ranges);
615
616 // Initialize result vector
617 std::vector<std::vector<MSExperiment::CoordinateType>> result(mz_rt_ranges.size());
618
619 // Initialize counts per spectrum index and total mappings
620 std::vector<std::vector<size_t>> spec_idx_to_range_idx(spectra_view.size());
621
622 // Build spectrum to range index mapping
623 for (size_t i = 0; i < rt_ranges_idcs.size(); ++i)
624 {
625 const auto& [start, stop] = rt_ranges_idcs[i];
626 result[i].resize(stop - start);
627 // std::cout << "start: " << start << " stop: " << stop << std::endl;
628 for (size_t j = start; j < stop; ++j)
629 {
630 spec_idx_to_range_idx[j].push_back(i);
631 }
632 }
633
634 #pragma omp parallel for schedule(dynamic)
635 for (Int64 i = 0; i < (Int64)spec_idx_to_range_idx.size(); ++i) // OpenMP on windows still requires signed loop variable
636 {
637 if (spec_idx_to_range_idx[i].empty()) continue; // no ranges for this spectrum? skip it
638
639 const auto& spec = spectra_view[i].get();
640 auto spec_begin = spec.cbegin();
641 auto spec_end = spec.cend();
642
643 for (size_t range_idx : spec_idx_to_range_idx[i])
644 {
645 const auto& mz_range = mz_rt_ranges[range_idx].first;
646
647 // Find data points within MZ range
648 auto start_it = spec.PosBegin(spec_begin, mz_range.getMinMZ(), spec_end);
649 auto end_it = start_it;
650
651 while (end_it != spec_end && end_it->getPosition() <= mz_range.getMaxMZ())
652 {
653 ++end_it;
654 }
655
656 // std::cout << "calculating reduction on range: " << range_idx << " for spectrum: " << i << " and peaks " << std::distance(spec.begin(), start_it) << " - " << std::distance(spec.begin(), end_it) << std::endl;
657
658 // Calculate result using provided reduction function
659 result[range_idx][i - rt_ranges_idcs[range_idx].first] =
660 func_mz_reduction(start_it, end_it);
661 }
662 }
663 return result;
664 }
665
666// Overload without func_mz_reduction parameter (default to SumIntensityReduction). Needed because of template deduction issues
667std::vector<std::vector<MSExperiment::CoordinateType>> aggregate(
668 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
669 unsigned int ms_level) const
670{
671 return aggregate(mz_rt_ranges, ms_level, SumIntensityReduction());
672}
673
686template<class MzReductionFunctionType>
687std::vector<MSChromatogram> extractXICs(
688 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
689 unsigned int ms_level,
690 MzReductionFunctionType func_mz_reduction) const
691{
692 // Early exit if there are no ranges
693 if (mz_rt_ranges.empty())
694 {
695 // likely an error, but we return an empty vector instead of throwing an exception for now
696 return {};
697 }
698
699 // Create a view of the spectra with given MS level
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;
706 });
707
708 // Early exit if there are no spectra with the given MS level
709 if (spectra_view.empty()) { // could be valid use or an error -> we return an empty vector
710 return {};
711 }
712
713 // Get the indices of the spectra covered by the RT ranges by considering the MS level
714 // If start and stop are the same, the range is 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>>
719 {
720 std::vector<std::pair<size_t, size_t>> res;
721 res.reserve(mz_rt_ranges.size());
722
723 for (const auto & mz_rt : mz_rt_ranges)
724 {
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; });
728
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(); });
732
733 res.emplace_back(
734 std::distance(spectra_view.begin(), start_it),
735 std::distance(spectra_view.begin(), stop_it)
736 );
737 }
738 return res;
739 };
740
741 // For each range, gets (spectrum start index, spectrum stop index). The spectra covered by each RT range.
742 const std::vector<std::pair<size_t, size_t>> rt_ranges_idcs = getCoveredSpectra(spectra_view, mz_rt_ranges);
743
744 // Initialize result vector
745 std::vector<MSChromatogram> result(mz_rt_ranges.size());
746
747 // Initialize counts per spectrum index and total mappings
748 std::vector<std::vector<size_t>> spec_idx_to_range_idx(spectra_view.size());
749
750 // Build spectrum to range index mapping
751 for (size_t i = 0; i < rt_ranges_idcs.size(); ++i)
752 {
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)
758 {
759 spec_idx_to_range_idx[j].push_back(i);
760 }
761 }
762
763 #pragma omp parallel for schedule(dynamic)
764 for (Int64 i = 0; i < (Int64)spec_idx_to_range_idx.size(); ++i) // OpenMP on windows still requires signed loop variable
765 {
766 if (spec_idx_to_range_idx[i].empty()) continue; // no ranges for this spectrum? skip
767
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();
772
773 for (size_t range_idx : spec_idx_to_range_idx[i])
774 {
775 const auto& mz_range = mz_rt_ranges[range_idx].first;
776
777 // Find data points within MZ range
778 auto start_it = spec.PosBegin(spec_begin, mz_range.getMinMZ(), spec_end);
779 auto end_it = start_it;
780
781 while (end_it != spec_end && end_it->getPosition() <= mz_range.getMaxMZ())
782 {
783 ++end_it;
784 }
785
786 // Calculate result using provided reduction function
787 result[range_idx][i - rt_ranges_idcs[range_idx].first] =
788 ChromatogramPeak(rt, func_mz_reduction(start_it, end_it));
789 }
790 }
791
792 for (auto& r : result) r.updateRanges(); // TODO: prob.. faster to look at first and last peaks as range is sorted
793
794 return result;
795 }
796
797// Overload without func_mz_reduction parameter (needed because of template deduction issue)
798std::vector<MSChromatogram> extractXICs(
799 const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
800 unsigned int ms_level) const
801{
802 return extractXICs(mz_rt_ranges, ms_level, SumIntensityReduction());
803}
804
813 std::vector<std::vector<MSExperiment::CoordinateType>> aggregateFromMatrix(
814 const Matrix<double>& ranges,
815 unsigned int ms_level,
816 const std::string& mz_agg) const
817 {
818 // Check matrix dimensions
819 if (ranges.cols() != 4)
820 {
821 throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
822 "Range matrix must have 4 columns [mz_min, mz_max, rt_min, rt_max]");
823 }
824
825 // Convert matrix rows to vector of pairs
826 std::vector<std::pair<RangeMZ, RangeRT>> mz_rt_ranges;
827 mz_rt_ranges.reserve((Size)ranges.rows());
828
829 for (Size i = 0; i < (Size)ranges.rows(); ++i)
830 {
831 mz_rt_ranges.emplace_back(
832 RangeMZ(ranges(i, 0), ranges(i, 1)), // min max mz
833 RangeRT(ranges(i, 2), ranges(i, 3)) // min max rt
834 );
835 // std::cout << "mz: " << ranges(i, 0) << " - " << ranges(i, 1) << " rt: " << ranges(i, 2) << " - " << ranges(i, 3) << std::endl;
836 }
837
838 // Call appropriate aggregation function based on mz_agg parameter
839 if (mz_agg == "sum")
840 {
841 return aggregate(mz_rt_ranges, ms_level,
842 [](auto begin_it, auto end_it)
843 {
844 return std::accumulate(begin_it, end_it, 0.0,
845 [](double a, const Peak1D& b) { return a + b.getIntensity(); });
846 });
847 }
848 else if (mz_agg == "max")
849 {
850 return aggregate(mz_rt_ranges, ms_level,
851 [](auto begin_it, auto end_it)->double
852 {
853 if (begin_it == end_it) return 0.0;
854 return std::max_element(begin_it, end_it,
855 [](const Peak1D& a, const Peak1D& b) { return a.getIntensity() < b.getIntensity(); }
856 )->getIntensity();
857 });
858 }
859 else if (mz_agg == "min")
860 {
861 return aggregate(mz_rt_ranges, ms_level,
862 [](auto begin_it, auto end_it)->double
863 {
864 if (begin_it == end_it) return 0.0;
865 return std::min_element(begin_it, end_it,
866 [](const Peak1D& a, const Peak1D& b) { return a.getIntensity() < b.getIntensity(); }
867 )->getIntensity();
868 });
869 }
870 else if (mz_agg == "mean")
871 {
872 return aggregate(mz_rt_ranges, ms_level,
873 [](auto begin_it, auto end_it)
874 {
875 if (begin_it == end_it) return 0.0;
876 double sum = std::accumulate(begin_it, end_it, 0.0,
877 [](double a, const Peak1D& b) { return a + b.getIntensity(); });
878 return sum / static_cast<double>(std::distance(begin_it, end_it));
879 });
880 }
881 else
882 {
883 throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
884 "Invalid aggregation function", mz_agg);
885 }
886 }
887
896 std::vector<MSChromatogram> extractXICsFromMatrix(
897 const Matrix<double>& ranges,
898 unsigned int ms_level,
899 const std::string& mz_agg) const
900 {
901 // Check matrix dimensions
902 if (ranges.cols() != 4)
903 {
904 throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
905 "Range matrix must have 4 columns [mz_min, mz_max, rt_min, rt_max]");
906 }
907
908 // Convert matrix rows to vector of pairs
909 std::vector<std::pair<RangeMZ, RangeRT>> mz_rt_ranges;
910 mz_rt_ranges.reserve((Size)ranges.rows());
911
912 for (Size i = 0; i < (Size)ranges.rows(); ++i)
913 {
914 mz_rt_ranges.emplace_back(
915 RangeMZ(ranges(i, 0), ranges(i, 1)),
916 RangeRT(ranges(i, 2), ranges(i, 3))
917 );
918 }
919
920 // Call appropriate extractXICs function based on mz_agg parameter
921 if (mz_agg == "sum")
922 {
923 return extractXICs(mz_rt_ranges, ms_level,
924 [](auto begin_it, auto end_it)
925 {
926 return std::accumulate(begin_it, end_it, 0.0,
927 [](double a, const Peak1D& b) { return a + b.getIntensity(); });
928 });
929 }
930 else if (mz_agg == "max")
931 {
932 return extractXICs(mz_rt_ranges, ms_level,
933 [](auto begin_it, auto end_it)->double
934 {
935 if (begin_it == end_it) return 0.0;
936 return std::max_element(begin_it, end_it,
937 [](const Peak1D& a, const Peak1D& b) { return a.getIntensity() < b.getIntensity(); }
938 )->getIntensity();
939 });
940 }
941 else if (mz_agg == "min")
942 {
943 return extractXICs(mz_rt_ranges, ms_level,
944 [](auto begin_it, auto end_it)->double
945 {
946 if (begin_it == end_it) return 0.0;
947 return std::min_element(begin_it, end_it,
948 [](const Peak1D& a, const Peak1D& b) { return a.getIntensity() < b.getIntensity(); }
949 )->getIntensity();
950 });
951 }
952 else if (mz_agg == "mean")
953 {
954 return extractXICs(mz_rt_ranges, ms_level,
955 [](auto begin_it, auto end_it)
956 {
957 if (begin_it == end_it) return 0.0;
958 double sum = std::accumulate(begin_it, end_it, 0.0,
959 [](double a, const Peak1D& b) { return a + b.getIntensity(); });
960 return sum / static_cast<double>(std::distance(begin_it, end_it));
961 });
962 }
963 else
964 {
965 throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
966 "Invalid aggregation function", mz_agg);
967 }
968 }
969
978
987
994
1001
1002
1011
1021
1029
1037 {
1038 combined_ranges_.clearRanges();
1039 spectrum_ranges_.clearRanges();
1040 chromatogram_ranges_.clearRanges();
1041 }
1042
1044 double getMinRT() const { return combined_ranges_.getMinRT(); }
1045
1047 double getMaxRT() const { return combined_ranges_.getMaxRT(); }
1048
1050 double getMinMZ() const { return combined_ranges_.getMinMZ(); }
1051
1053 double getMaxMZ() const { return combined_ranges_.getMaxMZ(); }
1054
1056 double getMinIntensity() const { return combined_ranges_.getMinIntensity(); }
1057
1059 double getMaxIntensity() const { return combined_ranges_.getMaxIntensity(); }
1060
1062 double getMinMobility() const { return combined_ranges_.getMinMobility(); }
1063
1065 double getMaxMobility() const { return combined_ranges_.getMaxMobility(); }
1066
1078
1081
1083 std::vector<UInt> getMSLevels() const;
1084
1086
1090
1093
1096
1101 void sortSpectra(bool sort_mz = true);
1102
1108 void sortChromatograms(bool sort_rt = true);
1109
1115 bool isSorted(bool check_mz = true) const;
1116
1118
1120 void reset();
1121
1128
1131
1134
1136 void getPrimaryMSRunPath(StringList& toFill) const;
1137
1154
1160 int getPrecursorSpectrum(int zero_based_index) const;
1161
1189
1197 int getFirstProductSpectrum(int zero_based_index) const;
1198
1200 void swap(MSExperiment& from);
1201
1203 void setSpectra(const std::vector<MSSpectrum>& spectra);
1204 void setSpectra(std::vector<MSSpectrum>&& spectra);
1205
1207 void addSpectrum(const MSSpectrum& spectrum);
1208 void addSpectrum(MSSpectrum&& spectrum);
1209
1211 const std::vector<MSSpectrum>& getSpectra() const;
1212
1214 std::vector<MSSpectrum>& getSpectra();
1215
1219
1221 ConstIterator getClosestSpectrumInRT(const double RT, UInt ms_level) const;
1222 Iterator getClosestSpectrumInRT(const double RT, UInt ms_level);
1223
1225 void setChromatograms(const std::vector<MSChromatogram>& chromatograms);
1226 void setChromatograms(std::vector<MSChromatogram>&& chromatograms);
1227
1229 void addChromatogram(const MSChromatogram& chromatogram);
1231
1233 const std::vector<MSChromatogram>& getChromatograms() const;
1234
1236 std::vector<MSChromatogram>& getChromatograms();
1237
1239
1240
1242
1245
1248
1252
1263 const MSChromatogram calculateTIC(float rt_bin_size = 0, UInt ms_level = 1) const;
1264
1270 void clear(bool clear_meta_data);
1271
1273 bool containsScanOfLevel(size_t ms_level) const;
1274
1276 bool hasZeroIntensities(size_t ms_level) const;
1277
1279 bool isIMFrame() const;
1280
1281 protected:
1283 std::vector<MSChromatogram > chromatograms_;
1285 std::vector<SpectrumType> spectra_;
1288
1291
1294
1295 public:
1305 const SpectrumRangeManagerType& spectrumRanges() const { return spectrum_ranges_; }
1306
1316 const ChromatogramRangeManagerType& chromatogramRanges() const { return chromatogram_ranges_; }
1317
1326 const RangeManagerType& combinedRanges() const { return combined_ranges_; }
1327
1328 private:
1329
1331 template<typename ContainerValueType, bool addMassTraces>
1333 {
1334 static void addData_(SpectrumType* spectrum, const ContainerValueType* item);
1335 static void addData_(SpectrumType* spectrum, const ContainerValueType* item, const StringList& store_metadata_names);
1336 };
1337
1338 template<typename ContainerValueType>
1339 struct ContainerAdd_<ContainerValueType, false>
1340 {
1342 static void addData_(SpectrumType* spectrum, const ContainerValueType* item)
1343 {
1344 // create temporary peak and insert it into spectrum
1345 spectrum->insert(spectrum->end(), PeakType());
1346 spectrum->back().setIntensity(item->getIntensity());
1347 spectrum->back().setPosition(item->getMZ());
1348 }
1350 static void addData_(SpectrumType* spectrum, const ContainerValueType* item, const StringList& store_metadata_names)
1351 {
1352 addData_(spectrum, item);
1353 for (StringList::const_iterator itm = store_metadata_names.begin(); itm != store_metadata_names.end(); ++itm)
1354 {
1355 float val = std::numeric_limits<float>::quiet_NaN();
1356 if (item->metaValueExists(*itm)) val = item->getMetaValue(*itm);
1357 spectrum->getFloatDataArrays()[itm - store_metadata_names.begin()].push_back(val);
1358 }
1359 }
1360 };
1361
1362 template<typename ContainerValueType>
1363 struct ContainerAdd_<ContainerValueType, true>
1364 {
1366 static void addData_(SpectrumType* spectrum, const ContainerValueType* item)
1367 {
1368 if (item->metaValueExists("num_of_masstraces"))
1369 {
1370 Size mts = item->getMetaValue("num_of_masstraces");
1371 int charge = (item->getCharge()==0 ? 1 : item->getCharge()); // set to 1 if charge is 0, otherwise div/0 below
1372 for (Size i = 0; i < mts; ++i)
1373 {
1374 String meta_name = String("masstrace_intensity_") + i;
1375 if (!item->metaValueExists(meta_name))
1376 {
1377 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, String("Meta value '") + meta_name + "' expected but not found in container.");
1378 }
1379 ContainerValueType p;
1380 p.setIntensity(item->getMetaValue(meta_name));
1381 p.setPosition(item->getMZ() + Constants::C13C12_MASSDIFF_U / charge * i);
1383 }
1384 }
1386 }
1387 };
1388
1389
1390 /*
1391 @brief Append a spectrum to current MSExperiment
1392
1393 @param[in] rt RT of new spectrum
1394 @return Pointer to newly created spectrum
1395 */
1397
1398 /*
1399 @brief Append a spectrum including floatdata arrays to current MSExperiment
1400
1401 @param[in] rt RT of new spectrum
1402 @param[in] metadata_names Names of floatdata arrays attached to this spectrum
1403 @return Pointer to newly created spectrum
1404 */
1406
1407 };
1408
1410 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const MSExperiment& exp);
1411
1412} // namespace OpenMS
1413
1415
1416
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