OpenMS
DimMapper.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: Chris Bielow $
6 // $Authors: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 
21 #include <OpenMS/KERNEL/Peak1D.h>
22 #include <OpenMS/KERNEL/Peak2D.h>
24 
25 #include <array>
26 #include <memory>
27 
28 
29 namespace OpenMS
30 {
40  class OPENMS_DLLAPI DimBase
41  {
42  public:
43  using ValueType = double;
44  using ValueTypes = std::vector<ValueType>;
45 
47  DimBase() = delete;
48 
50  DimBase(DIM_UNIT unit) :
51  unit_(unit)
52  {}
53 
55  DimBase& operator=(const DimBase& rhs) = default;
56 
58  virtual ~DimBase() noexcept = default;
59 
61  bool operator==(const DimBase& rhs) const
62  {
63  return unit_ == rhs.unit_;
64  }
65 
67  virtual std::unique_ptr<DimBase> clone() const = 0;
68 
69  virtual ValueType map(const Peak1D& p) const = 0;
70  virtual ValueType map(const Peak2D& p) const = 0;
71  virtual ValueType map(const ChromatogramPeak& p) const = 0;
72  virtual ValueType map(const MSExperiment::ConstAreaIterator& it) const = 0;
73  virtual ValueType map(const MobilityPeak1D& p) const = 0;
74  virtual ValueType map(const MobilityPeak2D& p) const = 0;
75 
77  virtual ValueType map(const MSSpectrum& spec, const Size index) const = 0;
79  virtual ValueType map(const MSChromatogram& chrom, const Size index) const = 0;
81  virtual ValueType map(const Mobilogram& mb, const Size index) const = 0;
82 
85  virtual ValueTypes map(const MSSpectrum& spec) const = 0;
86 
89  virtual ValueTypes map(const MSChromatogram& chrom) const = 0;
90 
91  virtual ValueType map(const BaseFeature& bf) const = 0;
92 
93  virtual ValueType map(const PeptideIdentification& pi) const = 0;
94 
96  virtual RangeBase map(const RangeAllType& rm) const = 0;
97 
99  virtual RangeBase& map(RangeAllType& rm) const = 0;
100 
102  virtual void setRange(const RangeBase& in, RangeAllType& out) const = 0;
103 
104 
105  // from XY to a type
106 
108  virtual void fromXY(const ValueType in, Peak1D& p) const = 0;
110  virtual void fromXY(const ValueType in, ChromatogramPeak& p) const = 0;
112  virtual void fromXY(const ValueType in, MobilityPeak1D& p) const = 0;
114  virtual void fromXY(const ValueType in, MobilityPeak2D& p) const = 0;
115 
117  std::string_view getDimName() const
118  {
119  return DIM_NAMES[(int)unit_];
120  }
121 
123  std::string_view getDimNameShort() const
124  {
125  return DIM_NAMES_SHORT[(int)unit_];
126  }
127 
130  {
131  return unit_;
132  }
133 
139  String formattedValue(const ValueType value) const;
140 
143 
145  int valuePrecision() const;
146 
147  protected:
149  };
150 
151 
152 
163  class OPENMS_DLLAPI DimRT final : public DimBase
164  {
165  public:
167 
168  std::unique_ptr<DimBase> clone() const override
169  {
170  return std::make_unique<DimRT>();
171  }
172 
173  ValueType map(const Peak1D&) const override
174  {
175  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
176  }
177  ValueType map(const Peak2D& p) const override
178  {
179  return p.getRT();
180  }
181  ValueType map(const ChromatogramPeak& p) const override
182  {
183  return p.getRT();
184  }
185  ValueType map(const MSSpectrum& spec, const Size /*index*/) const override
186  {
187  return spec.getRT();
188  }
189  ValueType map(const MSChromatogram& chrom, const Size index) const override
190  {
191  return chrom[index].getRT();
192  }
193  ValueType map(const Mobilogram& mb, const Size /*index*/) const override
194  {
195  return mb.getRT();
196  }
197 
198  ValueTypes map(const MSSpectrum&) const override
199  {
200  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
201  }
202  ValueTypes map(const MSChromatogram& chrom) const override
203  {
204  ValueTypes res;
205  res.reserve(chrom.size());
206  for (const auto& p : chrom)
207  {
208  res.push_back(p.getRT());
209  }
210  return res;
211  }
212 
214  {
215  return it.getRT();
216  }
217  ValueType map(const MobilityPeak1D&) const override
218  {
219  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
220  }
221  ValueType map(const MobilityPeak2D&) const override
222  {
223  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
224  }
225 
226  ValueType map(const BaseFeature& bf) const override
227  {
228  return bf.getRT();
229  }
230 
231  ValueType map(const PeptideIdentification& pi) const override
232  {
233  return pi.getRT();
234  }
235 
236  RangeBase map(const RangeAllType& rm) const override
237  {
238  return rm.getRangeForDim(MSDim::RT);
239  }
240  RangeBase& map(RangeAllType& rm) const override
241  {
242  return rm.getRangeForDim(MSDim::RT);
243  }
244 
245  void setRange(const RangeBase& in, RangeAllType& out) const override
246  {
247  out.RangeRT::operator=(in);
248  }
249 
251  void fromXY(const ValueType, Peak1D&) const override
252  {
253  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
254  }
255 
257  void fromXY(const ValueType in, ChromatogramPeak& p) const override
258  {
259  p.setRT(in);
260  }
262  void fromXY(const ValueType, MobilityPeak1D&) const override
263  {
264  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
265  }
267  void fromXY(const ValueType, MobilityPeak2D&) const override
268  {
269  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
270  }
271  };
272 
283  class OPENMS_DLLAPI DimMZ final : public DimBase
284  {
285  public:
287 
288  std::unique_ptr<DimBase> clone() const override
289  {
290  return std::make_unique<DimMZ>();
291  }
292 
293  ValueType map(const Peak1D& p) const override
294  {
295  return p.getMZ();
296  }
297  ValueType map(const Peak2D& p) const override
298  {
299  return p.getMZ();
300  }
301  ValueType map(const ChromatogramPeak&) const override
302  {
303  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
304  }
306  {
307  return it->getMZ();
308  }
309  ValueType map(const MobilityPeak1D&) const override
310  {
311  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
312  }
313  ValueType map(const MobilityPeak2D& p) const override
314  {
315  return p.getMZ();
316  }
317 
318  ValueType map(const MSSpectrum& spec, const Size index) const override
319  {
320  return spec[index].getMZ();
321  }
322  ValueType map(const MSChromatogram& chrom, const Size /*index*/) const override
323  {
324  return chrom.getPrecursor().getMZ();
325  }
326  ValueType map(const Mobilogram& /*mb*/, const Size /*index*/) const override
327  {
328  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
329  }
330 
331  ValueTypes map(const MSSpectrum& spec) const override
332  {
333  ValueTypes res;
334  res.reserve(spec.size());
335  for (const auto& p : spec)
336  {
337  res.push_back(p.getMZ());
338  }
339  return res;
340  }
341  ValueTypes map(const MSChromatogram&) const override
342  {
343  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
344  }
345 
346  ValueType map(const BaseFeature& bf) const override
347  {
348  return bf.getMZ();
349  }
350 
351  ValueType map(const PeptideIdentification& pi) const override
352  {
353  return pi.getMZ();
354  }
355 
356  RangeBase map(const RangeAllType& rm) const override
357  {
358  return rm.getRangeForDim(MSDim::MZ);
359  }
360  RangeBase& map(RangeAllType& rm) const override
361  {
362  return rm.getRangeForDim(MSDim::MZ);
363  }
364 
365  void setRange(const RangeBase& in, RangeAllType& out) const override
366  {
367  out.RangeMZ::operator=(in);
368  }
369 
371  void fromXY(const ValueType in, Peak1D& p) const override
372  {
373  p.setMZ(in);
374  }
375 
377  void fromXY(const ValueType, ChromatogramPeak&) const override
378  {
379  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
380  }
381 
383  void fromXY(const ValueType, MobilityPeak1D&) const override
384  {
385  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
386  }
388  void fromXY(const ValueType in, MobilityPeak2D& p) const override
389  {
390  p.setMZ(in);
391  }
392  };
393 
404  class OPENMS_DLLAPI DimINT final : public DimBase
405  {
406  public:
408 
409  std::unique_ptr<DimBase> clone() const override
410  {
411  return std::make_unique<DimINT>();
412  }
413 
414  ValueType map(const Peak1D& p) const override
415  {
416  return p.getIntensity();
417  }
418  ValueType map(const Peak2D& p) const override
419  {
420  return p.getIntensity();
421  }
422  ValueType map(const ChromatogramPeak& p) const override
423  {
424  return p.getIntensity();
425  }
427  {
428  return it->getIntensity();
429  }
430  ValueType map(const MobilityPeak1D& p) const override
431  {
432  return p.getIntensity();
433  }
434  ValueType map(const MobilityPeak2D& p) const override
435  {
436  return p.getIntensity();
437  }
438 
439  ValueType map(const MSSpectrum& spec, const Size index) const override
440  {
441  return spec[index].getIntensity();
442  }
443  ValueType map(const MSChromatogram& chrom, const Size index) const override
444  {
445  return chrom[index].getIntensity();
446  }
447  ValueType map(const Mobilogram& mb, const Size index) const override
448  {
449  return mb[index].getIntensity();
450  }
451 
452  ValueTypes map(const MSSpectrum& spec) const override
453  {
454  ValueTypes res;
455  res.reserve(spec.size());
456  for (const auto& p : spec)
457  {
458  res.push_back(p.getIntensity());
459  }
460  return res;
461  }
462 
463  ValueTypes map(const MSChromatogram& chrom) const override
464  {
465  ValueTypes res;
466  res.reserve(chrom.size());
467  for (const auto& p : chrom)
468  {
469  res.push_back(p.getIntensity());
470  }
471  return res;
472  }
473 
474  ValueType map(const BaseFeature& bf) const override
475  {
476  return bf.getIntensity();
477  }
478 
479  ValueType map(const PeptideIdentification&) const override
480  {
481  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
482  }
483 
484  RangeBase map(const RangeAllType& rm) const override
485  {
486  return rm.getRangeForDim(MSDim::INT);
487  }
488  RangeBase& map(RangeAllType& rm) const override
489  {
490  return rm.getRangeForDim(MSDim::INT);
491  }
492 
493  void setRange(const RangeBase& in, RangeAllType& out) const override
494  {
495  out.RangeIntensity::operator=(in);
496  }
497 
499  void fromXY(const ValueType in, Peak1D& p) const override
500  {
502  }
503 
505  void fromXY(const ValueType in, ChromatogramPeak& p) const override
506  {
508  }
510  void fromXY(const ValueType in, MobilityPeak1D& p) const override
511  {
513  }
515  void fromXY(const ValueType in, MobilityPeak2D& p) const override
516  {
518  }
519  };
520 
534  class OPENMS_DLLAPI DimIM final : public DimBase
535  {
536  public:
537  DimIM(const DIM_UNIT im_unit) : DimBase(im_unit) {}
538 
539  std::unique_ptr<DimBase> clone() const override
540  {
541  return std::make_unique<DimIM>(*this);
542  }
543 
544  ValueType map(const Peak1D&) const override
545  {
546  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
547  }
548  ValueType map(const Peak2D&) const override
549  {
550  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
551  }
552  ValueType map(const ChromatogramPeak&) const override
553  {
554  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
555  }
556  ValueTypes map(const MSSpectrum&) const override
557  {
558  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
559  }
560  ValueTypes map(const MSChromatogram&) const override
561  {
562  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
563  }
564 
566  {
567  return it.getDriftTime();
568  }
569 
570  ValueType map(const MobilityPeak1D& p) const override
571  {
572  return p.getMobility();
573  }
574  ValueType map(const MobilityPeak2D& p) const override
575  {
576  return p.getMobility();
577  }
578 
579  ValueType map(const MSSpectrum& spec, const Size /*index*/) const override
580  {
581  return spec.getDriftTime();
582  }
583  ValueType map(const MSChromatogram&, const Size) const override
584  {
585  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
586  }
587  ValueType map(const Mobilogram& mb, const Size index) const override
588  {
589  return mb[index].getMobility();
590  }
591 
592  ValueType map(const BaseFeature&) const override
593  {
594  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
595  }
596 
597  ValueType map(const PeptideIdentification&) const override
598  {
599  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
600  }
601 
602  RangeBase map(const RangeAllType& rm) const override
603  {
604  return rm.getRangeForDim(MSDim::IM);
605  }
606  RangeBase& map(RangeAllType& rm) const override
607  {
608  return rm.getRangeForDim(MSDim::IM);
609  }
610 
611  void setRange(const RangeBase& in, RangeAllType& out) const override
612  {
613  out.RangeMobility::operator=(in);
614  }
615 
617  void fromXY(const ValueType, Peak1D&) const override
618  {
619  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
620  }
621 
623  void fromXY(const ValueType, ChromatogramPeak&) const override
624  {
625  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
626  }
627 
629  void fromXY(const ValueType in, MobilityPeak1D& p) const override
630  {
631  p.setMobility(in);
632  }
634  void fromXY(const ValueType in, MobilityPeak2D& p) const override
635  {
636  p.setMobility(in);
637  }
638  };
639 
643  enum class DIM
644  {
645  X = 0,
646  Y = 1,
647  Z = 2
648  };
649 
660  template<int N_DIM>
661  class DimMapper
662  {
663  public:
665 
667  DimMapper() = delete;
668 
670  DimMapper(const DIM_UNIT (&units)[N_DIM])
671  :dims_([&]() {
672  std::array<std::unique_ptr<const DimBase>, N_DIM> dims_tmp;
673  for (int i = 0; i < N_DIM; ++i)
674  {
675  dims_tmp[i] = create_(units[i]);
676  }
677  return dims_tmp;
678  }()) // immediately evaluated lambda to enable 'dims_' to be const
679  {
680  static_assert(N_DIM >= 1); // at least one dimension (X)
681  static_assert(N_DIM <= 3); // at most three (X, Y, Z)
682  }
683 
685  DimMapper(const DimMapper& rhs) // cannot be defaulted due to unique_ptr
686  {
687  *this = rhs;
688  };
689 
691  DimMapper& operator=(const DimMapper& rhs) // cannot be defaulted due to unique_ptr
692  {
693  for (int i = 0; i < N_DIM; ++i) dims_[i] = rhs.dims_[i]->clone();
694  return *this;
695  };
696 
698  bool operator==(const DimMapper& rhs) const
699  {
700  bool res {true};
701  for (int i = 0; i < N_DIM; ++i)
702  {
703  res &= (*dims_[i] == *rhs.dims_[i]);
704  }
705  return res;
706  }
707 
709  bool operator!=(const DimMapper& rhs) const
710  {
711  return !operator==(rhs);
712  }
713 
715  template <typename T>
716  Point map(const T& data) const
717  {
718  Point pr;
719  for (int i = 0; i < N_DIM; ++i) pr[i] = dims_[i]->map(data);
720  return pr;
721  }
723  template<typename Container>
724  Point map(const Container& data, const Size index) const
725  {
726  Point pr;
727  for (int i = 0; i < N_DIM; ++i)
728  pr[i] = dims_[i]->map(data, index);
729  return pr;
730  }
731 
733  template<typename ...Ranges>
735  {
736  DRange<N_DIM> res;
737  RangeAllType all;
738  all.assign(ranges);
739  for (int i = 0; i < N_DIM; ++i)
740  {
741  RangeBase mm = dims_[i]->map(all);
742  if (mm.isEmpty()) continue;
743  res.setDimMinMax(i, {mm.getMin(), mm.getMax()});
744  }
745  return res;
746  }
747 
751  template<typename... Ranges>
752  void fromXY(const DRange<N_DIM>& in, RangeManager<Ranges...>& output) const
753  {
754  for (int i = 0; i < N_DIM; ++i)
755  {
756  if (in.isEmpty(i))
757  dims_[i]->setRange(RangeBase(), output);
758  else
759  dims_[i]->setRange({in.minPosition()[i], in.maxPosition()[i]}, output);
760  }
761  }
762 
766  template<typename... Ranges>
767  void fromXY(const Point& in, RangeManager<Ranges...>& output) const
768  {
769  for (int i = 0; i < N_DIM; ++i)
770  {
771  dims_[i]->setRange({in[i], in[i]}, output);
772  }
773  }
774 
778  template<typename T>
779  void fromXY(const Point& in, T& out) const
780  {
781  for (int i = 0; i < N_DIM; ++i)
782  {
783  dims_[i]->fromXY(in[i], out);
784  }
785  }
786 
790  RangeAllType fromXY(const Point& in) const
791  {
792  RangeAllType output;
793  for (int i = 0; i < N_DIM; ++i)
794  {
795  dims_[i]->setRange({in[i], in[i]}, output);
796  }
797  return output;
798  }
799 
801  const DimBase& getDim(DIM d) const
802  {
803  assert((int)d <= N_DIM);
804  return *dims_[(int)d];
805  }
806 
807  bool hasUnit(DIM_UNIT unit) const
808  {
809  for (int i = 0; i < N_DIM; ++i)
810  {
811  if (dims_[i]->getUnit() == unit) return true;
812  }
813  return false;
814  }
815 
816  protected:
818  static std::unique_ptr<const DimBase> create_(DIM_UNIT u)
819  {
820  switch (u)
821  {
822  case DIM_UNIT::RT:
823  return std::make_unique<DimRT>();
824  case DIM_UNIT::MZ:
825  return std::make_unique<DimMZ>();
826  case DIM_UNIT::INT:
827  return std::make_unique<DimINT>();
828  case DIM_UNIT::FAIMS_CV:
829  case DIM_UNIT::IM_MS:
830  case DIM_UNIT::IM_VSSC:
831  return std::make_unique<DimIM>(u);
832  default:
833  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
834  }
835  }
836 
837  std::array<std::unique_ptr<const DimBase>, N_DIM> dims_;
838  };
839 
840 
843  template <int N_DIM>
844  class Area
845  {
846  public:
849 
851  Area() = delete;
852 
854  Area(const DimMapper<N_DIM>* const dims)
855  : mapper_(dims)
856  {
857  }
858 
860  Area(const Area& range) = default;
861 
863  Area& operator=(const Area& rhs)
864  {
865  // check that Dims are identical, otherwise this is very dangerous (the user probably only wanted to update the area, not change its mapping).
866  if (mapper_ != rhs.mapper_ && *mapper_ != *rhs.mapper_)
867  {
868  throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Assignment of Areas using different mappers!");
869  }
870  data_range_ = rhs.data_range_;
872  return *this;
873  }
874 
875  bool operator==(const Area& rhs) const
876  {
877  return data_range_ == rhs.data_range_
878  && visible_area_ == rhs.visible_area_
879  && (*mapper_ == *rhs.mapper_);
880  }
881  bool operator!=(const Area& rhs) const
882  {
883  return !operator==(rhs);
884  }
885 
891  const Area& setArea(const RangeAllType& data)
892  {
893  data_range_ = data;
894  // update axis view using dims
895  visible_area_ = mapper_->mapRange(data);
896  return *this;
897  }
898 
904  const Area& setArea(const AreaXYType& data)
905  {
906  visible_area_ = data;
907  // update range view from XY area using dims
909  return *this;
910  }
911 
912  const AreaXYType& getAreaXY() const
913  {
914  return visible_area_;
915  }
916 
917  const RangeAllType& getAreaUnit() const
918  {
919  return data_range_;
920  }
921 
927  Area cloneWith(const AreaXYType& data) const
928  {
929  Area clone(*this);
930  clone.setArea(data);
931  return clone;
932  }
933 
939  Area cloneWith(const RangeAllType& data) const
940  {
941  Area clone(*this);
942  clone.setArea(data);
943  return clone;
944  }
945 
950  void pushInto(const RangeAllType& sandbox)
951  {
952  auto a = data_range_;
953  a.pushInto(sandbox);
954  setArea(a);
955  }
956 
958  void clear()
959  {
961  }
962 
963  private:
964  /* two sides of the same coin... */
969  };
970 
971 } // namespace OpenMS
Definition: DimMapper.h:845
bool operator!=(const Area &rhs) const
Definition: DimMapper.h:881
const Area & setArea(const RangeAllType &data)
Set the area using unit data (RT, m/z, ...)
Definition: DimMapper.h:891
Area()=delete
No default C'tor.
bool operator==(const Area &rhs) const
Definition: DimMapper.h:875
RangeAllType data_range_
range in units
Definition: DimMapper.h:965
const Area & setArea(const AreaXYType &data)
Set the area using axis data (X and Y)
Definition: DimMapper.h:904
void pushInto(const RangeAllType &sandbox)
Push the area into a sandbox (if its outside the sandbox). See UnitRange::pushInto()
Definition: DimMapper.h:950
AreaXYType visible_area_
Definition: DimMapper.h:966
Area cloneWith(const RangeAllType &data) const
Clone the current object, set the area of the clone using unit data (RT, m/z, ...) and return the clo...
Definition: DimMapper.h:939
const DimMapper< N_DIM > * mapper_
and a mapper (non-owning pointer) to translate between the two
Definition: DimMapper.h:968
Area & operator=(const Area &rhs)
Assignment operator - which checks for identical DimMappers and throws otherwise.
Definition: DimMapper.h:863
Area cloneWith(const AreaXYType &data) const
Clone the current object, set the area of the clone using axis data (X and Y) and return the clone.
Definition: DimMapper.h:927
Area(const DimMapper< N_DIM > *const dims)
Custom C'tor with a mapper (non owning pointer)
Definition: DimMapper.h:854
const RangeAllType & getAreaUnit() const
Definition: DimMapper.h:917
Area(const Area &range)=default
Copy C'tor.
void clear()
empty all dimensions
Definition: DimMapper.h:958
const AreaXYType & getAreaXY() const
Definition: DimMapper.h:912
A basic LC-MS feature.
Definition: BaseFeature.h:34
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:28
IntensityType getIntensity() const
Non-mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:84
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:95
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:86
double IntensityType
Intensity type.
Definition: ChromatogramPeak.h:37
CoordinateType getRT() const
Non-mutable access to RT.
Definition: ChromatogramPeak.h:89
const Precursor & getPrecursor() const
returns a const reference to the precursors
Representation of a coordinate in D-dimensional space.
Definition: DPosition.h:30
A base class for a dimension which represents a certain unit (e.g. RT or m/z). Derived classes implem...
Definition: DimMapper.h:41
virtual ValueType map(const MSChromatogram &chrom, const Size index) const =0
obtain value from a certain point in a chromatogram
virtual ValueType map(const Peak1D &p) const =0
virtual ~DimBase() noexcept=default
D'tor (needs to be virtual; we are holding pointers to base in DimMapper)
virtual void fromXY(const ValueType in, Peak1D &p) const =0
set the dimension of a Peak1D
virtual RangeBase & map(RangeAllType &rm) const =0
Return the min/max (range) for a certain dimension (i.e. a reference to the base class of rm)
virtual ValueType map(const PeptideIdentification &pi) const =0
double ValueType
Definition: DimMapper.h:43
std::string_view getDimNameShort() const
Name of the dimension, e.g. 'RT'.
Definition: DimMapper.h:123
virtual ValueType map(const MobilityPeak2D &p) const =0
virtual ValueType map(const MSExperiment::ConstAreaIterator &it) const =0
virtual ValueType map(const ChromatogramPeak &p) const =0
int valuePrecision() const
return the recommended precision for the current unit (2 digits for RT, 8 for m/z,...
DimBase(DIM_UNIT unit)
Custom c'tor with unit.
Definition: DimMapper.h:50
virtual ValueType map(const Mobilogram &mb, const Size index) const =0
obtain value from a certain point in a mobilogram
virtual void fromXY(const ValueType in, ChromatogramPeak &p) const =0
set the dimension of a ChromatogramPeak
DIM_UNIT unit_
the unit of this dimension
Definition: DimMapper.h:148
String formattedValue(const ValueType value) const
Creates a short string representation with "UNIT: value", where value has a predefined precision (see...
DimBase & operator=(const DimBase &rhs)=default
Assignment operator.
virtual ValueTypes map(const MSChromatogram &chrom) const =0
virtual ValueType map(const BaseFeature &bf) const =0
virtual void setRange(const RangeBase &in, RangeAllType &out) const =0
Set the min/max (range) in out for a certain dimension.
virtual ValueType map(const MSSpectrum &spec, const Size index) const =0
obtain value from a certain point in a spectrum
std::vector< ValueType > ValueTypes
Definition: DimMapper.h:44
String formattedValue(ValueType value, const String &prefix) const
like formattedValue() but with a custom unit prefix instead of the default one for the dim,...
std::string_view getDimName() const
Name of the dimension, e.g. 'RT [s]'.
Definition: DimMapper.h:117
virtual void fromXY(const ValueType in, MobilityPeak2D &p) const =0
set the dimension of a MobilityPeak2D
virtual RangeBase map(const RangeAllType &rm) const =0
Return the min/max (range) for a certain dimension.
virtual ValueType map(const MobilityPeak1D &p) const =0
virtual ValueTypes map(const MSSpectrum &spec) const =0
virtual void fromXY(const ValueType in, MobilityPeak1D &p) const =0
set the dimension of a MobilityPeak1D
virtual ValueType map(const Peak2D &p) const =0
DIM_UNIT getUnit() const
The unit of the dimension.
Definition: DimMapper.h:129
DimBase()=delete
No default c'tor.
virtual std::unique_ptr< DimBase > clone() const =0
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Dimension implementation for ion mobility values.
Definition: DimMapper.h:535
ValueType map(const MSChromatogram &, const Size) const override
obtain value from a certain point in a chromatogram
Definition: DimMapper.h:583
ValueType map(const Peak2D &) const override
Definition: DimMapper.h:548
ValueType map(const BaseFeature &) const override
Definition: DimMapper.h:592
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:611
ValueType map(const PeptideIdentification &) const override
Definition: DimMapper.h:597
void fromXY(const ValueType, Peak1D &) const override
set the IM of a Peak1D (throws)
Definition: DimMapper.h:617
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:539
ValueTypes map(const MSSpectrum &) const override
Definition: DimMapper.h:556
ValueType map(const MSSpectrum &spec, const Size) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:579
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:565
ValueType map(const ChromatogramPeak &) const override
Definition: DimMapper.h:552
void fromXY(const ValueType, ChromatogramPeak &) const override
set the IM of a ChromatogramPeak (throws)
Definition: DimMapper.h:623
RangeBase & map(RangeAllType &rm) const override
Return the min/max (range) for a certain dimension (i.e. a reference to the base class of rm)
Definition: DimMapper.h:606
ValueType map(const Mobilogram &mb, const Size index) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:587
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:602
void fromXY(const ValueType in, MobilityPeak2D &p) const override
set the IM of a MobilityPeak2D
Definition: DimMapper.h:634
ValueType map(const MobilityPeak2D &p) const override
Definition: DimMapper.h:574
ValueType map(const MobilityPeak1D &p) const override
Definition: DimMapper.h:570
DimIM(const DIM_UNIT im_unit)
Definition: DimMapper.h:537
ValueTypes map(const MSChromatogram &) const override
Definition: DimMapper.h:560
ValueType map(const Peak1D &) const override
Definition: DimMapper.h:544
void fromXY(const ValueType in, MobilityPeak1D &p) const override
set the IM of a MobilityPeak1D
Definition: DimMapper.h:629
Dimension implementation for intensity values.
Definition: DimMapper.h:405
ValueType map(const Peak1D &p) const override
Definition: DimMapper.h:414
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:493
ValueType map(const Peak2D &p) const override
Definition: DimMapper.h:418
ValueType map(const PeptideIdentification &) const override
Definition: DimMapper.h:479
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:409
ValueTypes map(const MSChromatogram &chrom) const override
Definition: DimMapper.h:463
ValueType map(const MSSpectrum &spec, const Size index) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:439
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:426
ValueType map(const ChromatogramPeak &p) const override
Definition: DimMapper.h:422
DimINT()
Definition: DimMapper.h:407
ValueTypes map(const MSSpectrum &spec) const override
Definition: DimMapper.h:452
RangeBase & map(RangeAllType &rm) const override
Return the min/max (range) for a certain dimension (i.e. a reference to the base class of rm)
Definition: DimMapper.h:488
ValueType map(const BaseFeature &bf) const override
Definition: DimMapper.h:474
ValueType map(const Mobilogram &mb, const Size index) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:447
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:484
void fromXY(const ValueType in, MobilityPeak2D &p) const override
set the intensity of a MobilityPeak2D
Definition: DimMapper.h:515
ValueType map(const MobilityPeak2D &p) const override
Definition: DimMapper.h:434
ValueType map(const MobilityPeak1D &p) const override
Definition: DimMapper.h:430
void fromXY(const ValueType in, Peak1D &p) const override
set the intensity of a Peak1D
Definition: DimMapper.h:499
void fromXY(const ValueType in, ChromatogramPeak &p) const override
set the intensity of a ChromatogramPeak
Definition: DimMapper.h:505
ValueType map(const MSChromatogram &chrom, const Size index) const override
obtain value from a certain point in a chromatogram
Definition: DimMapper.h:443
void fromXY(const ValueType in, MobilityPeak1D &p) const override
set the intensity of a MobilityPeak1D
Definition: DimMapper.h:510
Dimension implementation for m/z values.
Definition: DimMapper.h:284
ValueType map(const Peak1D &p) const override
Definition: DimMapper.h:293
ValueType map(const Mobilogram &, const Size) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:326
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:365
DimMZ()
Definition: DimMapper.h:286
ValueType map(const MSChromatogram &chrom, const Size) const override
obtain value from a certain point in a chromatogram
Definition: DimMapper.h:322
ValueType map(const Peak2D &p) const override
Definition: DimMapper.h:297
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:288
ValueType map(const MSSpectrum &spec, const Size index) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:318
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:305
ValueTypes map(const MSSpectrum &spec) const override
Definition: DimMapper.h:331
ValueType map(const ChromatogramPeak &) const override
Definition: DimMapper.h:301
void fromXY(const ValueType, ChromatogramPeak &) const override
set the MZ of a ChromatogramPeak (throws)
Definition: DimMapper.h:377
RangeBase & map(RangeAllType &rm) const override
Return the min/max (range) for a certain dimension (i.e. a reference to the base class of rm)
Definition: DimMapper.h:360
ValueType map(const BaseFeature &bf) const override
Definition: DimMapper.h:346
ValueType map(const PeptideIdentification &pi) const override
Definition: DimMapper.h:351
void fromXY(const ValueType, MobilityPeak1D &) const override
set the MZ of a MobilityPeak1D (throws)
Definition: DimMapper.h:383
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:356
void fromXY(const ValueType in, MobilityPeak2D &p) const override
set the MZ of a MobilityPeak2D (throws)
Definition: DimMapper.h:388
ValueType map(const MobilityPeak2D &p) const override
Definition: DimMapper.h:313
ValueTypes map(const MSChromatogram &) const override
Definition: DimMapper.h:341
void fromXY(const ValueType in, Peak1D &p) const override
set the MZ of a Peak1D
Definition: DimMapper.h:371
ValueType map(const MobilityPeak1D &) const override
Definition: DimMapper.h:309
Allows dynamical switching (at runtime) between a dimension (RT, m/z, int, IM, etc) and X,...
Definition: DimMapper.h:662
static std::unique_ptr< const DimBase > create_(DIM_UNIT u)
a minimal factory
Definition: DimMapper.h:818
bool operator!=(const DimMapper &rhs) const
Inequality.
Definition: DimMapper.h:709
std::array< std::unique_ptr< const DimBase >, N_DIM > dims_
mappers for the X,Y,Z... dimension
Definition: DimMapper.h:837
bool operator==(const DimMapper &rhs) const
Equality.
Definition: DimMapper.h:698
void fromXY(const DRange< N_DIM > &in, RangeManager< Ranges... > &output) const
Definition: DimMapper.h:752
DimMapper & operator=(const DimMapper &rhs)
Assignment operator.
Definition: DimMapper.h:691
void fromXY(const Point &in, RangeManager< Ranges... > &output) const
Definition: DimMapper.h:767
bool hasUnit(DIM_UNIT unit) const
Definition: DimMapper.h:807
DimMapper(const DimMapper &rhs)
Copy C'tor.
Definition: DimMapper.h:685
DRange< N_DIM > mapRange(const RangeManager< Ranges... > &ranges) const
Convert Range to an N_DIM-dimensional area (min and max for each dimension)
Definition: DimMapper.h:734
Point map(const T &data) const
convert an OpenMS datatype (such as Feature) to an N_DIM-dimensional point
Definition: DimMapper.h:716
const DimBase & getDim(DIM d) const
obtain unit/name for X/Y/Z dimension.
Definition: DimMapper.h:801
RangeAllType fromXY(const Point &in) const
Definition: DimMapper.h:790
DimMapper(const DIM_UNIT(&units)[N_DIM])
Custom C'tor with given dimensions to map to (the order is assumed to be X, Y, Z, ....
Definition: DimMapper.h:670
DimMapper()=delete
No default c'tor (we need dimensions)
Point map(const Container &data, const Size index) const
convert an OpenMS datapoint in a container (such as MSSpectrum) to an N_DIM-dimensional point
Definition: DimMapper.h:724
void fromXY(const Point &in, T &out) const
Definition: DimMapper.h:779
Dimension implementation for retention time values.
Definition: DimMapper.h:164
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:245
ValueType map(const MobilityPeak2D &) const override
Definition: DimMapper.h:221
ValueType map(const Peak2D &p) const override
Definition: DimMapper.h:177
void fromXY(const ValueType, MobilityPeak2D &) const override
set the RT of a MobilityPeak2D (throws)
Definition: DimMapper.h:267
void fromXY(const ValueType, Peak1D &) const override
set the RT of a Peak1D (throws)
Definition: DimMapper.h:251
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:168
ValueTypes map(const MSChromatogram &chrom) const override
Definition: DimMapper.h:202
ValueTypes map(const MSSpectrum &) const override
Definition: DimMapper.h:198
ValueType map(const MSSpectrum &spec, const Size) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:185
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:213
ValueType map(const ChromatogramPeak &p) const override
Definition: DimMapper.h:181
RangeBase & map(RangeAllType &rm) const override
Return the min/max (range) for a certain dimension (i.e. a reference to the base class of rm)
Definition: DimMapper.h:240
ValueType map(const BaseFeature &bf) const override
Definition: DimMapper.h:226
ValueType map(const PeptideIdentification &pi) const override
Definition: DimMapper.h:231
void fromXY(const ValueType, MobilityPeak1D &) const override
set the RT of a MobilityPeak1D (throws)
Definition: DimMapper.h:262
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:236
DimRT()
Definition: DimMapper.h:166
ValueType map(const Mobilogram &mb, const Size) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:193
ValueType map(const Peak1D &) const override
Definition: DimMapper.h:173
void fromXY(const ValueType in, ChromatogramPeak &p) const override
set the RT of a ChromatogramPeak
Definition: DimMapper.h:257
ValueType map(const MobilityPeak1D &) const override
Definition: DimMapper.h:217
ValueType map(const MSChromatogram &chrom, const Size index) const override
obtain value from a certain point in a chromatogram
Definition: DimMapper.h:189
Invalid range exception.
Definition: Exception.h:257
Not implemented exception.
Definition: Exception.h:399
Precondition failed exception.
Definition: Exception.h:128
Forward iterator for an area of peaks in an experiment.
Definition: AreaIterator.h:36
CoordinateType getDriftTime() const
returns the ion mobility time of the current scan
Definition: AreaIterator.h:248
CoordinateType getRT() const
returns the retention time of the current scan
Definition: AreaIterator.h:242
void setDimMinMax(UInt dim, const DIntervalBase< 1 > &min_max)
only set interval for a single dimension
Definition: DIntervalBase.h:228
PositionType const & maxPosition() const
Accessor to maximum position.
Definition: DIntervalBase.h:104
bool isEmpty() const
Definition: DIntervalBase.h:216
static DIntervalBase const empty
empty instance
Definition: DIntervalBase.h:258
PositionType const & minPosition() const
Accessor to minimum position.
Definition: DIntervalBase.h:98
The representation of a chromatogram.
Definition: MSChromatogram.h:30
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
double getRT() const
double getDriftTime() const
Returns the ion mobility drift time (IMTypes::DRIFTTIME_NOT_SET means it is not set)
A 1-dimensional raw data mobility point or peak. The unit (ms, 1/K_0, etc) is implicit.
Definition: MobilityPeak1D.h:25
IntensityType getIntensity() const
Definition: MobilityPeak1D.h:79
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: MobilityPeak1D.h:84
void setMobility(CoordinateType mobility)
Mutable access to mobility.
Definition: MobilityPeak1D.h:96
CoordinateType getMobility() const
Non-mutable access to m/z.
Definition: MobilityPeak1D.h:90
float IntensityType
Intensity type.
Definition: MobilityPeak1D.h:32
A 2-dimensional raw data point or peak.
Definition: MobilityPeak2D.h:29
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: MobilityPeak2D.h:168
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: MobilityPeak2D.h:174
void setMobility(CoordinateType coordinate)
Mutable access to the IM coordinate (index 0)
Definition: MobilityPeak2D.h:186
float IntensityType
Intensity type.
Definition: MobilityPeak2D.h:35
IntensityType getIntensity() const
Definition: MobilityPeak2D.h:138
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition: MobilityPeak2D.h:144
CoordinateType getMobility() const
Returns the IM coordinate (index 0)
Definition: MobilityPeak2D.h:180
The representation of a 1D ion mobilogram.
Definition: Mobilogram.h:32
double getRT() const noexcept
Returns the retention time (in seconds)
Definition: Mobilogram.h:246
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:28
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:87
IntensityType getIntensity() const
Definition: Peak1D.h:82
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:84
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:93
float IntensityType
Intensity type.
Definition: Peak1D.h:36
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:29
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: Peak2D.h:172
IntensityType getIntensity() const
Definition: Peak2D.h:142
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:184
Represents the set of candidates (SpectrumMatches) identified for a single precursor spectrum.
Definition: PeptideIdentification.h:63
double getRT() const
returns the RT of the MS2 spectrum where the identification occurred
double getMZ() const
returns the MZ of the MS2 spectrum
void pushInto(const RangeManager< RangeBasesOther... > &sandbox)
Definition: RangeManager.h:703
const RangeBase & getRangeForDim(MSDim dim) const
obtain a range dimension at runtime using dim
Definition: RangeManager.h:747
auto & assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:615
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
static String prefix(const String &this_s, size_t length)
Definition: StringUtilsSimple.h:122
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
DIM
Definition: DimMapper.h:644
RangeManager< RangeRT, RangeMZ, RangeIntensity, RangeMobility > RangeAllType
Range which contains all known dimensions.
Definition: RangeManager.h:914
DIM_UNIT
Definition: CommonEnums.h:20
@ IM_VSSC
volt-second per square centimeter (i.e. 1/K_0)
@ INT
intensity
@ FAIMS_CV
FAIMS compensation voltage.
@ RT
RT in seconds.
@ IM_MS
ion mobility milliseconds
std::string_view DIM_NAMES[(int) DIM_UNIT::SIZE_OF_DIM_UNITS]
Definition: CommonEnums.h:29
std::string_view DIM_NAMES_SHORT[(int) DIM_UNIT::SIZE_OF_DIM_UNITS]
Definition: CommonEnums.h:30
Base class for a simple range with minimum and maximum.
Definition: RangeManager.h:37
double getMin() const
Definition: RangeManager.h:128
bool isEmpty() const
is the range empty (i.e. min > max)?
Definition: RangeManager.h:88
double getMax() const
Definition: RangeManager.h:139