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