OpenMS
MSExperiment.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- 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 
17 
18 #include <vector>
19 
20 
21 namespace OpenMS
22 {
23  class Peak1D;
24  class ChromatogramPeak;
25 
44  class OPENMS_DLLAPI MSExperiment final : public RangeManagerContainer<RangeRT, RangeMZ, RangeIntensity, RangeMobility>,
46  {
47 
48 public:
49  typedef Peak1D PeakT;
51 
53 
54  typedef PeakT PeakType;
71  typedef std::vector<SpectrumType> Base;
73 
75 
76  typedef std::vector<SpectrumType>::iterator Iterator;
79  typedef std::vector<SpectrumType>::const_iterator ConstIterator;
85 
87  // Attention: these refer to the spectra vector only!
89  typedef Base::value_type value_type;
90  typedef Base::iterator iterator;
91  typedef Base::const_iterator const_iterator;
92 
95 
97  MSExperiment(const MSExperiment & source);
98 
101 
104 
107 
110 
112  ~MSExperiment() override;
113 
115  bool operator==(const MSExperiment & rhs) const;
116 
118  bool operator!=(const MSExperiment & rhs) const;
119 
121  inline Size size() const noexcept
122  {
123  return spectra_.size();
124  }
125 
127  inline void resize(Size n)
128  {
129  spectra_.resize(n);
130  }
131 
133  inline bool empty() const noexcept
134  {
135  return spectra_.empty();
136  }
137 
139  inline void reserve(Size n)
140  {
141  spectra_.reserve(n);
142  }
143 
146  {
147  return spectra_[n];
148  }
149 
151  inline const SpectrumType& operator[](Size n) const
152  {
153  return spectra_[n];
154  }
155 
156  inline Iterator begin() noexcept
157  {
158  return spectra_.begin();
159  }
160 
161  inline ConstIterator begin() const noexcept
162  {
163  return spectra_.cbegin();
164  }
165 
166  inline ConstIterator cbegin() const noexcept
167  {
168  return spectra_.cbegin();
169  }
170 
171  inline Iterator end()
172  {
173  return spectra_.end();
174  }
175 
176  inline ConstIterator end() const noexcept
177  {
178  return spectra_.cend();
179  }
180 
181  inline ConstIterator cend() const noexcept
182  {
183  return spectra_.cend();
184  }
186 
187  // Aliases / chromatograms
190 
192 
193 
199  template <class Container>
200  void get2DData(Container& cont) const
201  {
202  for (typename Base::const_iterator spec = spectra_.begin(); spec != spectra_.end(); ++spec)
203  {
204  if (spec->getMSLevel() != 1)
205  {
206  continue;
207  }
208  typename Container::value_type s; // explicit object here, since instantiation within push_back() fails on VS<12
209  for (typename SpectrumType::const_iterator it = spec->begin(); it != spec->end(); ++it)
210  {
211  cont.push_back(s);
212  cont.back().setRT(spec->getRT());
213  cont.back().setMZ(it->getMZ());
214  cont.back().setIntensity(it->getIntensity());
215  }
216  }
217  }
218 
230  template <class Container>
231  void set2DData(const Container& container)
232  {
233  set2DData<false, Container>(container);
234  }
235 
250  template <class Container>
251  void set2DData(const Container& container, const StringList& store_metadata_names)
252  {
253  // clean up the container first
254  clear(true);
255  SpectrumType* spectrum = nullptr;
256  typename PeakType::CoordinateType current_rt = -std::numeric_limits<typename PeakType::CoordinateType>::max();
257  for (typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
258  {
259  // check if the retention time has changed
260  if (current_rt != iter->getRT() || spectrum == nullptr)
261  {
262  // append new spectrum
263  if (current_rt > iter->getRT())
264  {
265  throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Input container is not sorted!");
266  }
267  current_rt = iter->getRT();
268  spectrum = createSpec_(current_rt, store_metadata_names);
269  }
270 
271  // add either data point or mass traces (depending on template argument value)
272  ContainerAdd_<typename Container::value_type, false>::addData_(spectrum, &(*iter), store_metadata_names);
273  }
274  }
275 
294  template <bool add_mass_traces, class Container>
295  void set2DData(const Container& container)
296  {
297  // clean up the container first
298  clear(true);
299  SpectrumType* spectrum = nullptr;
300  typename PeakType::CoordinateType current_rt = -std::numeric_limits<typename PeakType::CoordinateType>::max();
301  for (typename Container::const_iterator iter = container.begin(); iter != container.end(); ++iter)
302  {
303  // check if the retention time has changed
304  if (current_rt != iter->getRT() || spectrum == nullptr)
305  {
306  // append new spectrum
307  if (current_rt > iter->getRT())
308  {
309  throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Input container is not sorted!");
310  }
311  current_rt = iter->getRT();
312  spectrum = createSpec_(current_rt);
313  }
314 
315  // add either data point or mass traces (depending on template argument value)
317  }
318  }
319 
321 
322 
324 
325  AreaIterator areaBegin(CoordinateType min_rt, CoordinateType max_rt,
327  CoordinateType min_mz, CoordinateType max_mz, UInt ms_level = 1);
328 
330  AreaIterator areaBegin(const RangeManagerType& range, UInt ms_level = 1);
331 
334 
337 
339  ConstAreaIterator areaBeginConst(const RangeManagerType& range, UInt ms_level = 1) const;
340 
343 
344  /* @brief Retrieves the peak data in the given mz-rt range and store data spectrum-wise in separate arrays.
345  *
346  * For fast pyOpenMS access to peak data in format: [rt, [mz, intensity]]
347  *
348  * @param min_rt The minimum retention time.
349  * @param max_rt The maximum retention time.
350  * @param min_mz The minimum m/z value.
351  * @param max_mz The maximum m/z value.
352  * @param ms_level The MS level of the spectra to consider.
353  * @param rt The vector to store the retention times in.
354  * @param mz The vector to store the m/z values in.
355  * @param intensity The vector to store the intensities in.
356  */
358  CoordinateType min_rt,
359  CoordinateType max_rt,
360  CoordinateType min_mz,
361  CoordinateType max_mz,
362  Size ms_level,
363  std::vector<float>& rt,
364  std::vector<std::vector<float>>& mz,
365  std::vector<std::vector<float>>& intensity) const
366  {
367  float t = -1.0;
368  for (auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz, ms_level); it != areaEndConst(); ++it)
369  {
370  if (it.getRT() != t)
371  {
372  t = (float)it.getRT();
373  rt.push_back(t);
374  mz.push_back(std::vector<float>());
375  intensity.push_back(std::vector<float>());
376  }
377  mz.back().push_back((float)it->getMZ());
378  intensity.back().push_back(it->getIntensity());
379  }
380  }
381 
382  /* @brief Retrieves the peak data in the given mz-rt range and store data spectrum-wise in separate arrays.
383  *
384  * For fast pyOpenMS access to MS1 peak data in format: [rt, [mz, intensity, ion mobility]]
385  *
386  * @param min_rt The minimum retention time.
387  * @param max_rt The maximum retention time.
388  * @param min_mz The minimum m/z value.
389  * @param max_mz The maximum m/z value.
390  * @param ms_level The MS level of the spectra to consider.
391  * @param rt The vector to store the retention times in.
392  * @param mz The vector to store the m/z values in.
393  * @param intensity The vector to store the intensities in.
394  * @param ion_mobility The vector to store the ion mobility values in.
395  */
397  CoordinateType min_rt,
398  CoordinateType max_rt,
399  CoordinateType min_mz,
400  CoordinateType max_mz,
401  Size ms_level,
402  std::vector<float>& rt,
403  std::vector<std::vector<float>>& mz,
404  std::vector<std::vector<float>>& intensity,
405  std::vector<std::vector<float>>& ion_mobility) const
406  {
407  DriftTimeUnit unit;
408  std::vector<float> im;
409  float t = -1.0;
410  for (auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz, ms_level); it != areaEndConst(); ++it)
411  {
412  if (it.getRT() != t)
413  {
414  t = (float)it.getRT();
415  rt.push_back(t);
416  std::tie(unit, im) = it.getSpectrum().maybeGetIMData();
417  mz.push_back(std::vector<float>());
418  intensity.push_back(std::vector<float>());
419  ion_mobility.push_back(std::vector<float>());
420  }
421 
422  if (unit != DriftTimeUnit::NONE)
423  {
424  const Size peak_index = it.getPeakIndex().peak;
425  ion_mobility.back().push_back(im[peak_index]);
426  }
427  else
428  {
429  ion_mobility.back().push_back(-1.0);
430  }
431  mz.back().push_back((float)it->getMZ());
432  intensity.back().push_back(it->getIntensity());
433  }
434  }
435 
436  /* @brief Retrieves the peak data in the given mz-rt range and store in separate arrays.
437  *
438  * For fast pyOpenMS access to MS1 peak data in format: [rt, mz, intensity]
439  *
440  * @param min_rt The minimum retention time.
441  * @param max_rt The maximum retention time.
442  * @param min_mz The minimum m/z value.
443  * @param max_mz The maximum m/z value.
444  * @param ms_level The MS level of the spectra to consider.
445  * @param rt The vector to store the retention times in.
446  * @param mz The vector to store the m/z values in.
447  * @param intensity The vector to store the intensities in.
448  */
450  CoordinateType min_rt,
451  CoordinateType max_rt,
452  CoordinateType min_mz,
453  CoordinateType max_mz,
454  Size ms_level,
455  std::vector<float>& rt,
456  std::vector<float>& mz,
457  std::vector<float>& intensity)
458  const
459  {
460  for (auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz, ms_level); it != areaEndConst(); ++it)
461  {
462  rt.push_back((float)it.getRT());
463  mz.push_back((float)it->getMZ());
464  intensity.push_back(it->getIntensity());
465  }
466  }
467 
468 
469  /* @brief Retrieves the peak data in the given mz-rt range and store in separate arrays.
470  *
471  * For fast pyOpenMS access to MS1 peak data in format: [rt, mz, intensity, ion mobility]
472  *
473  * @param min_rt The minimum retention time.
474  * @param max_rt The maximum retention time.
475  * @param min_mz The minimum m/z value.
476  * @param max_mz The maximum m/z value.
477  * @param ms_level The MS level of the spectra to consider.
478  * @param rt The vector to store the retention times in.
479  * @param mz The vector to store the m/z values in.
480  * @param intensity The vector to store the intensities in.
481  */
483  CoordinateType min_rt,
484  CoordinateType max_rt,
485  CoordinateType min_mz,
486  CoordinateType max_mz,
487  Size ms_level,
488  std::vector<float>& rt,
489  std::vector<float>& mz,
490  std::vector<float>& intensity,
491  std::vector<float>& ion_mobility) const
492  {
493  for (auto it = areaBeginConst(min_rt, max_rt, min_mz, max_mz, ms_level); it != areaEndConst(); ++it)
494  {
495  DriftTimeUnit unit;
496  std::vector<float> im;
497  float t = -1.0;
498  if (it.getRT() != t)
499  {
500  t = (float)it.getRT();
501  std::tie(unit, im) = it.getSpectrum().maybeGetIMData();
502  }
503  rt.push_back((float)it.getRT());
504  mz.push_back((float)it->getMZ());
505  intensity.push_back(it->getIntensity());
506  if (unit != DriftTimeUnit::NONE)
507  {
508  const Size peak_index = it.getPeakIndex().peak;
509  ion_mobility.push_back(im[peak_index]);
510  }
511  else
512  {
513  ion_mobility.push_back(-1.0);
514  }
515  }
516  }
517 
529 
530  template <typename Iterator>
531  auto operator()(Iterator begin, Iterator end) const {
532  // Static assert to verify iterator type has intensity accessor
533  using ValueType = typename std::iterator_traits<Iterator>::value_type;
534  using IntensityType = decltype(std::declval<ValueType>().getIntensity());
535  static_assert(std::is_member_function_pointer_v<decltype(&ValueType::getIntensity)>,
536  "Iterator value type must have getIntensity() member function");
537 
538  IntensityType sum{};
539  for (auto it = begin; it != end; ++it) {
540  sum += it->getIntensity();
541  }
542  return sum;
543  }
544 };
545 
595 template<class MzReductionFunctionType>
596 std::vector<std::vector<MSExperiment::CoordinateType>> aggregate(
597  const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
598  unsigned int ms_level,
599  MzReductionFunctionType func_mz_reduction) const
600 {
601  // Early exit if there are no ranges
602  if (mz_rt_ranges.empty())
603  {
604  // likely an error, but we return an empty vector instead of throwing an exception for now
605  return {};
606  }
607 
608  // Create a view of the spectra with given MS level
609  std::vector<std::reference_wrapper<const MSSpectrum>> spectra_view;
610  spectra_view.reserve(spectra_.size());
611  std::copy_if(spectra_.begin(), spectra_.end(),
612  std::back_inserter(spectra_view),
613  [ms_level](const auto& spec) {
614  return spec.getMSLevel() == ms_level;
615  });
616 
617  // Early exit if there are no spectra with the given MS level
618  if (spectra_view.empty()) { // could be valid use or an error -> we return an empty vector
619  return {};
620  }
621 
622  // Get the indices of the spectra covered by the RT ranges by considering the MS level
623  // If start and stop are the same, the range is empty
624  auto getCoveredSpectra = [](
625  const std::vector<std::reference_wrapper<const MSSpectrum>>& spectra_view,
626  const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges)
627  -> std::vector<std::pair<size_t, size_t>>
628  {
629  std::vector<std::pair<size_t, size_t>> res;
630  res.reserve(mz_rt_ranges.size());
631 
632  for (const auto & mz_rt : mz_rt_ranges)
633  {
634  // std::cout << "rt range: " << mz_rt.second.getMin() << " - " << mz_rt.second.getMax() << std::endl;
635  // std::cout << "specs start:" << spectra_view[0].get().getRT() << " specs end:" << spectra_view[spectra_view.size() - 1].get().getRT() << std::endl;
636  auto start_it = std::lower_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMin(),
637  [](const auto& spec, double rt)
638  { return spec.get().getRT() < rt; });
639 
640  auto stop_it = std::upper_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMax(),
641  [](double rt, const auto& spec)
642  { return rt < spec.get().getRT(); });
643 
644  res.emplace_back(
645  std::distance(spectra_view.begin(), start_it),
646  std::distance(spectra_view.begin(), stop_it)
647  );
648  // std::cout << "start: " << std::distance(spectra_view.begin(), start_it) << " stop: " << std::distance(spectra_view.begin(), stop_it) << std::endl;
649  }
650  return res;
651  };
652 
653  // For each range, gets (spectrum start index, spectrum stop index). The spectra covered by each RT range.
654  const std::vector<std::pair<size_t, size_t>> rt_ranges_idcs = getCoveredSpectra(spectra_view, mz_rt_ranges);
655 
656  // Initialize result vector
657  std::vector<std::vector<MSExperiment::CoordinateType>> result(mz_rt_ranges.size());
658 
659  // Initialize counts per spectrum index and total mappings
660  std::vector<std::vector<size_t>> spec_idx_to_range_idx(spectra_view.size());
661 
662  // Build spectrum to range index mapping
663  for (size_t i = 0; i < rt_ranges_idcs.size(); ++i)
664  {
665  const auto& [start, stop] = rt_ranges_idcs[i];
666  result[i].resize(stop - start);
667  // std::cout << "start: " << start << " stop: " << stop << std::endl;
668  for (size_t j = start; j < stop; ++j)
669  {
670  spec_idx_to_range_idx[j].push_back(i);
671  }
672  }
673 
674  #pragma omp parallel for schedule(dynamic)
675  for (Int64 i = 0; i < (Int64)spec_idx_to_range_idx.size(); ++i) // OpenMP on windows still requires signed loop variable
676  {
677  if (spec_idx_to_range_idx[i].empty()) continue; // no ranges for this spectrum? skip it
678 
679  const auto& spec = spectra_view[i].get();
680  auto spec_begin = spec.cbegin();
681  auto spec_end = spec.cend();
682 
683  for (size_t range_idx : spec_idx_to_range_idx[i])
684  {
685  const auto& mz_range = mz_rt_ranges[range_idx].first;
686 
687  // Find data points within MZ range
688  auto start_it = spec.PosBegin(spec_begin, mz_range.getMinMZ(), spec_end);
689  auto end_it = start_it;
690 
691  while (end_it != spec_end && end_it->getPosition() <= mz_range.getMaxMZ())
692  {
693  ++end_it;
694  }
695 
696  // 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;
697 
698  // Calculate result using provided reduction function
699  result[range_idx][i - rt_ranges_idcs[range_idx].first] =
700  func_mz_reduction(start_it, end_it);
701  }
702  }
703  return result;
704  }
705 
706 // Overload without func_mz_reduction parameter (default to SumIntensityReduction). Needed because of template deduction issues
707 std::vector<std::vector<MSExperiment::CoordinateType>> aggregate(
708  const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
709  unsigned int ms_level) const
710 {
711  return aggregate(mz_rt_ranges, ms_level, SumIntensityReduction());
712 }
713 
726 template<class MzReductionFunctionType>
727 std::vector<MSChromatogram> extractXICs(
728  const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
729  unsigned int ms_level,
730  MzReductionFunctionType func_mz_reduction) const
731 {
732  // Early exit if there are no ranges
733  if (mz_rt_ranges.empty())
734  {
735  // likely an error, but we return an empty vector instead of throwing an exception for now
736  return {};
737  }
738 
739  // Create a view of the spectra with given MS level
740  std::vector<std::reference_wrapper<const MSSpectrum>> spectra_view;
741  spectra_view.reserve(spectra_.size());
742  std::copy_if(spectra_.begin(), spectra_.end(),
743  std::back_inserter(spectra_view),
744  [ms_level](const auto& spec) {
745  return spec.getMSLevel() == ms_level;
746  });
747 
748  // Early exit if there are no spectra with the given MS level
749  if (spectra_view.empty()) { // could be valid use or an error -> we return an empty vector
750  return {};
751  }
752 
753  // Get the indices of the spectra covered by the RT ranges by considering the MS level
754  // If start and stop are the same, the range is empty
755  auto getCoveredSpectra = [](
756  const std::vector<std::reference_wrapper<const MSSpectrum>>& spectra_view,
757  const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges)
758  -> std::vector<std::pair<size_t, size_t>>
759  {
760  std::vector<std::pair<size_t, size_t>> res;
761  res.reserve(mz_rt_ranges.size());
762 
763  for (const auto & mz_rt : mz_rt_ranges)
764  {
765  auto start_it = std::lower_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMin(),
766  [](const auto& spec, double rt)
767  { return spec.get().getRT() < rt; });
768 
769  auto stop_it = std::upper_bound(spectra_view.begin(), spectra_view.end(), mz_rt.second.getMax(),
770  [](double rt, const auto& spec)
771  { return rt < spec.get().getRT(); });
772 
773  res.emplace_back(
774  std::distance(spectra_view.begin(), start_it),
775  std::distance(spectra_view.begin(), stop_it)
776  );
777  }
778  return res;
779  };
780 
781  // For each range, gets (spectrum start index, spectrum stop index). The spectra covered by each RT range.
782  const std::vector<std::pair<size_t, size_t>> rt_ranges_idcs = getCoveredSpectra(spectra_view, mz_rt_ranges);
783 
784  // Initialize result vector
785  std::vector<MSChromatogram> result(mz_rt_ranges.size());
786 
787  // Initialize counts per spectrum index and total mappings
788  std::vector<std::vector<size_t>> spec_idx_to_range_idx(spectra_view.size());
789 
790  // Build spectrum to range index mapping
791  for (size_t i = 0; i < rt_ranges_idcs.size(); ++i)
792  {
793  const auto& [start, stop] = rt_ranges_idcs[i];
794  result[i].resize(stop - start);
795  result[i].getProduct().setMZ(
796  (mz_rt_ranges[i].first.getMinMZ() + mz_rt_ranges[i].first.getMaxMZ()) / 2.0);
797  for (size_t j = start; j < stop; ++j)
798  {
799  spec_idx_to_range_idx[j].push_back(i);
800  }
801  }
802 
803  #pragma omp parallel for schedule(dynamic)
804  for (Int64 i = 0; i < (Int64)spec_idx_to_range_idx.size(); ++i) // OpenMP on windows still requires signed loop variable
805  {
806  if (spec_idx_to_range_idx[i].empty()) continue; // no ranges for this spectrum? skip
807 
808  const auto& spec = spectra_view[i].get();
809  const double rt = spec.getRT();
810  auto spec_begin = spec.cbegin();
811  auto spec_end = spec.cend();
812 
813  for (size_t range_idx : spec_idx_to_range_idx[i])
814  {
815  const auto& mz_range = mz_rt_ranges[range_idx].first;
816 
817  // Find data points within MZ range
818  auto start_it = spec.PosBegin(spec_begin, mz_range.getMinMZ(), spec_end);
819  auto end_it = start_it;
820 
821  while (end_it != spec_end && end_it->getPosition() <= mz_range.getMaxMZ())
822  {
823  ++end_it;
824  }
825 
826  // Calculate result using provided reduction function
827  result[range_idx][i - rt_ranges_idcs[range_idx].first] =
828  ChromatogramPeak(rt, func_mz_reduction(start_it, end_it));
829  }
830  }
831 
832  for (auto& r : result) r.updateRanges(); // TODO: prob.. faster to look at first and last peaks as range is sorted
833 
834  return result;
835  }
836 
837 // Overload without func_mz_reduction parameter (needed because of template deduction issue)
838 std::vector<MSChromatogram> extractXICs(
839  const std::vector<std::pair<RangeMZ, RangeRT>>& mz_rt_ranges,
840  unsigned int ms_level) const
841 {
842  return extractXICs(mz_rt_ranges, ms_level, SumIntensityReduction());
843 }
844 
853  std::vector<std::vector<MSExperiment::CoordinateType>> aggregateFromMatrix(
854  const Matrix<double>& ranges,
855  unsigned int ms_level,
856  const std::string& mz_agg) const
857  {
858  // Check matrix dimensions
859  if (ranges.cols() != 4)
860  {
861  throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
862  "Range matrix must have 4 columns [mz_min, mz_max, rt_min, rt_max]");
863  }
864 
865  // Convert matrix rows to vector of pairs
866  std::vector<std::pair<RangeMZ, RangeRT>> mz_rt_ranges;
867  mz_rt_ranges.reserve((Size)ranges.rows());
868 
869  for (Size i = 0; i < (Size)ranges.rows(); ++i)
870  {
871  mz_rt_ranges.emplace_back(
872  RangeMZ(ranges(i, 0), ranges(i, 1)), // min max mz
873  RangeRT(ranges(i, 2), ranges(i, 3)) // min max rt
874  );
875  // std::cout << "mz: " << ranges(i, 0) << " - " << ranges(i, 1) << " rt: " << ranges(i, 2) << " - " << ranges(i, 3) << std::endl;
876  }
877 
878  // Call appropriate aggregation function based on mz_agg parameter
879  if (mz_agg == "sum")
880  {
881  return aggregate(mz_rt_ranges, ms_level,
882  [](auto begin_it, auto end_it)
883  {
884  return std::accumulate(begin_it, end_it, 0.0,
885  [](double a, const Peak1D& b) { return a + b.getIntensity(); });
886  });
887  }
888  else if (mz_agg == "max")
889  {
890  return aggregate(mz_rt_ranges, ms_level,
891  [](auto begin_it, auto end_it)->double
892  {
893  if (begin_it == end_it) return 0.0;
894  return std::max_element(begin_it, end_it,
895  [](const Peak1D& a, const Peak1D& b) { return a.getIntensity() < b.getIntensity(); }
896  )->getIntensity();
897  });
898  }
899  else if (mz_agg == "min")
900  {
901  return aggregate(mz_rt_ranges, ms_level,
902  [](auto begin_it, auto end_it)->double
903  {
904  if (begin_it == end_it) return 0.0;
905  return std::min_element(begin_it, end_it,
906  [](const Peak1D& a, const Peak1D& b) { return a.getIntensity() < b.getIntensity(); }
907  )->getIntensity();
908  });
909  }
910  else if (mz_agg == "mean")
911  {
912  return aggregate(mz_rt_ranges, ms_level,
913  [](auto begin_it, auto end_it)
914  {
915  if (begin_it == end_it) return 0.0;
916  double sum = std::accumulate(begin_it, end_it, 0.0,
917  [](double a, const Peak1D& b) { return a + b.getIntensity(); });
918  return sum / static_cast<double>(std::distance(begin_it, end_it));
919  });
920  }
921  else
922  {
923  throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
924  "Invalid aggregation function", mz_agg);
925  }
926  }
927 
936  std::vector<MSChromatogram> extractXICsFromMatrix(
937  const Matrix<double>& ranges,
938  unsigned int ms_level,
939  const std::string& mz_agg) const
940  {
941  // Check matrix dimensions
942  if (ranges.cols() != 4)
943  {
944  throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
945  "Range matrix must have 4 columns [mz_min, mz_max, rt_min, rt_max]");
946  }
947 
948  // Convert matrix rows to vector of pairs
949  std::vector<std::pair<RangeMZ, RangeRT>> mz_rt_ranges;
950  mz_rt_ranges.reserve((Size)ranges.rows());
951 
952  for (Size i = 0; i < (Size)ranges.rows(); ++i)
953  {
954  mz_rt_ranges.emplace_back(
955  RangeMZ(ranges(i, 0), ranges(i, 1)),
956  RangeRT(ranges(i, 2), ranges(i, 3))
957  );
958  }
959 
960  // Call appropriate extractXICs function based on mz_agg parameter
961  if (mz_agg == "sum")
962  {
963  return extractXICs(mz_rt_ranges, ms_level,
964  [](auto begin_it, auto end_it)
965  {
966  return std::accumulate(begin_it, end_it, 0.0,
967  [](double a, const Peak1D& b) { return a + b.getIntensity(); });
968  });
969  }
970  else if (mz_agg == "max")
971  {
972  return extractXICs(mz_rt_ranges, ms_level,
973  [](auto begin_it, auto end_it)->double
974  {
975  if (begin_it == end_it) return 0.0;
976  return std::max_element(begin_it, end_it,
977  [](const Peak1D& a, const Peak1D& b) { return a.getIntensity() < b.getIntensity(); }
978  )->getIntensity();
979  });
980  }
981  else if (mz_agg == "min")
982  {
983  return extractXICs(mz_rt_ranges, ms_level,
984  [](auto begin_it, auto end_it)->double
985  {
986  if (begin_it == end_it) return 0.0;
987  return std::min_element(begin_it, end_it,
988  [](const Peak1D& a, const Peak1D& b) { return a.getIntensity() < b.getIntensity(); }
989  )->getIntensity();
990  });
991  }
992  else if (mz_agg == "mean")
993  {
994  return extractXICs(mz_rt_ranges, ms_level,
995  [](auto begin_it, auto end_it)
996  {
997  if (begin_it == end_it) return 0.0;
998  double sum = std::accumulate(begin_it, end_it, 0.0,
999  [](double a, const Peak1D& b) { return a + b.getIntensity(); });
1000  return sum / static_cast<double>(std::distance(begin_it, end_it));
1001  });
1002  }
1003  else
1004  {
1005  throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
1006  "Invalid aggregation function", mz_agg);
1007  }
1008  }
1009 
1018 
1027 
1034 
1041 
1042 
1051 
1061 
1068  // Docu in base class
1069  void updateRanges() override;
1070 
1076  void updateRanges(Int ms_level);
1077 
1079  UInt64 getSize() const;
1080 
1082  const std::vector<UInt>& getMSLevels() const;
1083 
1085 
1089 
1092 
1095 
1100  void sortSpectra(bool sort_mz = true);
1101 
1107  void sortChromatograms(bool sort_rt = true);
1108 
1114  bool isSorted(bool check_mz = true) const;
1115 
1117 
1119  void reset();
1120 
1127 
1130 
1133 
1135  void getPrimaryMSRunPath(StringList& toFill) const;
1136 
1153 
1159  int getPrecursorSpectrum(int zero_based_index) const;
1160 
1186 
1194  int getFirstProductSpectrum(int zero_based_index) const;
1195 
1197  void swap(MSExperiment& from);
1198 
1200  void setSpectra(const std::vector<MSSpectrum>& spectra);
1201  void setSpectra(std::vector<MSSpectrum>&& spectra);
1202 
1204  void addSpectrum(const MSSpectrum& spectrum);
1205  void addSpectrum(MSSpectrum&& spectrum);
1206 
1208  const std::vector<MSSpectrum>& getSpectra() const;
1209 
1211  std::vector<MSSpectrum>& getSpectra();
1212 
1214  ConstIterator getClosestSpectrumInRT(const double RT) const;
1216 
1218  ConstIterator getClosestSpectrumInRT(const double RT, UInt ms_level) const;
1219  Iterator getClosestSpectrumInRT(const double RT, UInt ms_level);
1220 
1222  void setChromatograms(const std::vector<MSChromatogram>& chromatograms);
1223  void setChromatograms(std::vector<MSChromatogram>&& chromatograms);
1224 
1226  void addChromatogram(const MSChromatogram& chromatogram);
1228 
1230  const std::vector<MSChromatogram>& getChromatograms() const;
1231 
1233  std::vector<MSChromatogram>& getChromatograms();
1234 
1236 
1237  MSChromatogram& getChromatogram(Size id);
1239 
1242 
1245 
1249 
1260  const MSChromatogram calculateTIC(float rt_bin_size = 0, UInt ms_level = 1) const;
1261 
1267  void clear(bool clear_meta_data);
1268 
1270  bool containsScanOfLevel(size_t ms_level) const;
1271 
1273  bool hasZeroIntensities(size_t ms_level) const;
1274 
1277 
1279  bool isIMFrame() const;
1280 
1281  protected:
1283  std::vector<UInt> ms_levels_;
1287  std::vector<MSChromatogram > chromatograms_;
1289  std::vector<SpectrumType> spectra_;
1290 
1291 private:
1292 
1294  template<typename ContainerValueType, bool addMassTraces>
1296  {
1297  static void addData_(SpectrumType* spectrum, const ContainerValueType* item);
1298  static void addData_(SpectrumType* spectrum, const ContainerValueType* item, const StringList& store_metadata_names);
1299  };
1300 
1301  template<typename ContainerValueType>
1302  struct ContainerAdd_<ContainerValueType, false>
1303  {
1305  static void addData_(SpectrumType* spectrum, const ContainerValueType* item)
1306  {
1307  // create temporary peak and insert it into spectrum
1308  spectrum->insert(spectrum->end(), PeakType());
1309  spectrum->back().setIntensity(item->getIntensity());
1310  spectrum->back().setPosition(item->getMZ());
1311  }
1313  static void addData_(SpectrumType* spectrum, const ContainerValueType* item, const StringList& store_metadata_names)
1314  {
1315  addData_(spectrum, item);
1316  for (StringList::const_iterator itm = store_metadata_names.begin(); itm != store_metadata_names.end(); ++itm)
1317  {
1318  float val = std::numeric_limits<float>::quiet_NaN();
1319  if (item->metaValueExists(*itm)) val = item->getMetaValue(*itm);
1320  spectrum->getFloatDataArrays()[itm - store_metadata_names.begin()].push_back(val);
1321  }
1322  }
1323  };
1324 
1325  template<typename ContainerValueType>
1326  struct ContainerAdd_<ContainerValueType, true>
1327  {
1329  static void addData_(SpectrumType* spectrum, const ContainerValueType* item)
1330  {
1331  if (item->metaValueExists("num_of_masstraces"))
1332  {
1333  Size mts = item->getMetaValue("num_of_masstraces");
1334  int charge = (item->getCharge()==0 ? 1 : item->getCharge()); // set to 1 if charge is 0, otherwise div/0 below
1335  for (Size i = 0; i < mts; ++i)
1336  {
1337  String meta_name = String("masstrace_intensity_") + i;
1338  if (!item->metaValueExists(meta_name))
1339  {
1340  throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, String("Meta value '") + meta_name + "' expected but not found in container.");
1341  }
1342  ContainerValueType p;
1343  p.setIntensity(item->getMetaValue(meta_name));
1344  p.setPosition(item->getMZ() + Constants::C13C12_MASSDIFF_U / charge * i);
1346  }
1347  }
1349  }
1350  };
1351 
1352  /*
1353  @brief Append a spectrum to current MSExperiment
1354 
1355  @param rt RT of new spectrum
1356  @return Pointer to newly created spectrum
1357  */
1359 
1360  /*
1361  @brief Append a spectrum including floatdata arrays to current MSExperiment
1362 
1363  @param rt RT of new spectrum
1364  @param metadata_names Names of floatdata arrays attached to this spectrum
1365  @return Pointer to newly created spectrum
1366  */
1368 
1369  };
1370 
1372  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const MSExperiment& exp);
1373 
1374 } // namespace OpenMS
1375 
1377 
1378 
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:28
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:316
Invalid value exception.
Definition: Exception.h:305
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: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.
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:1289
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:200
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
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:251
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
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:727
bool empty() const noexcept
Are there any spectra (does not consider chromatograms)
Definition: MSExperiment.h:133
UInt64 getSize() const
returns the total number of peaks
std::vector< MSChromatogram > extractXICs(const std::vector< std::pair< RangeMZ, RangeRT >> &mz_rt_ranges, unsigned int ms_level) const
Definition: MSExperiment.h:838
ConstIterator begin() const noexcept
Definition: MSExperiment.h:161
MSExperiment & operator=(MSExperiment &&) &=default
Move assignment operator.
ConstIterator cbegin() const noexcept
Definition: MSExperiment.h:166
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)
Iterator getClosestSpectrumInRT(const double RT, UInt ms_level)
Iterator begin() noexcept
Definition: MSExperiment.h:156
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
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)
MSExperiment & operator=(const MSExperiment &source)
Assignment operator.
MSSpectrum SpectrumType
Spectrum Type.
Definition: MSExperiment.h:67
Size getNrChromatograms() const
get the total number of chromatograms available
Iterator getClosestSpectrumInRT(const double RT)
Base::value_type value_type
Definition: MSExperiment.h:89
Size size() const noexcept
The number of spectra.
Definition: MSExperiment.h:121
MSExperiment()
Constructor.
bool operator!=(const MSExperiment &rhs) const
Equality operator.
Peak1D PeakT
Definition: MSExperiment.h:49
ConstAreaIterator areaEndConst() const
Returns a non-mutable invalid area iterator marking the end of an area.
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
Definition: MSExperiment.h:396
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:231
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:1283
void resize(Size n)
Resize to n spectra.
Definition: MSExperiment.h:127
ConstIterator cend() const noexcept
Definition: MSExperiment.h:181
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
Definition: MSExperiment.h:449
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 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
Definition: MSExperiment.h:482
void sortChromatograms(bool sort_rt=true)
Sorts the data points of the chromatograms by m/z.
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.
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:853
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
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
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:936
Iterator end()
Definition: MSExperiment.h:171
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:707
UInt64 total_size_
Number of all data points.
Definition: MSExperiment.h:1285
bool isSorted(bool check_mz=true) const
Checks if all spectra are sorted with respect to ascending RT.
MSExperiment(const MSExperiment &source)
Copy constructor.
ConstIterator end() const noexcept
Definition: MSExperiment.h:176
RangeManager< RangeRT, RangeMZ, RangeIntensity, RangeMobility > RangeManagerType
RangeManager type.
Definition: MSExperiment.h:63
std::vector< MSSpectrum > & getSpectra()
returns the spectrum list (mutable)
ConstIterator getClosestSpectrumInRT(const double RT) const
Returns the closest(=nearest) spectrum in retention time to the given RT.
void set2DData(const Container &container)
Assignment of a data container with RT and MZ to an MSExperiment.
Definition: MSExperiment.h:295
ChromatogramPeak ChromatogramPeakT
Definition: MSExperiment.h:50
void sortSpectra(bool sort_mz=true)
Sorts the data points by retention time.
void reset()
Clear all internal data (spectra, ranges, metadata)
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)
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
Definition: MSExperiment.h:357
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
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:596
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.
ConstIterator getFirstProductSpectrum(ConstIterator iterator) const
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:1287
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.
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:28
double CoordinateType
Coordinate type.
Definition: Peak1D.h:40
IntensityType getIntensity() const
Definition: Peak1D.h:82
float IntensityType
Intensity type.
Definition: Peak1D.h:36
Definition: RangeManager.h:871
A more convenient string class.
Definition: String.h:34
int64_t Int64
Signed integer type (64bit)
Definition: Types.h:40
int Int
Signed integer type.
Definition: Types.h:72
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
static double sum(IteratorType begin, IteratorType end)
Calculates the sum of a range of values.
Definition: StatisticFunctions.h:81
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)
DriftTimeUnit
Drift time unit for ion mobility.
Definition: IMTypes.h:23
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
general method for adding data points
Definition: MSExperiment.h:1305
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:1313
static void addData_(SpectrumType *spectrum, const ContainerValueType *item)
specialization for adding feature mass traces (does not support metadata_names currently)
Definition: MSExperiment.h:1329
Helper class to add either general data points in set2DData or use mass traces from meta values.
Definition: MSExperiment.h:1296
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:528
auto operator()(Iterator begin, Iterator end) const
Definition: MSExperiment.h:531
Definition: RangeManager.h:346
Definition: RangeManager.h:285