OpenMS  3.0.0
DimMapper.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 
47 #include <OpenMS/KERNEL/Peak1D.h>
48 #include <OpenMS/KERNEL/Peak2D.h>
50 
51 #include <array>
52 #include <memory>
53 
54 
55 namespace OpenMS
56 {
66  class OPENMS_DLLAPI DimBase
67  {
68  public:
69  using ValueType = double;
70  using ValueTypes = std::vector<ValueType>;
71 
73  DimBase() = delete;
74 
76  DimBase(DIM_UNIT unit) :
77  unit_(unit)
78  {}
79 
81  DimBase& operator=(const DimBase& rhs) = default;
82 
84  virtual ~DimBase() noexcept = default;
85 
87  bool operator==(const DimBase& rhs) const
88  {
89  return unit_ == rhs.unit_;
90  }
91 
93  virtual std::unique_ptr<DimBase> clone() const = 0;
94 
95  virtual ValueType map(const Peak1D& p) const = 0;
96  virtual ValueType map(const Peak2D& p) const = 0;
97  virtual ValueType map(const ChromatogramPeak& p) const = 0;
98  virtual ValueType map(const MSExperiment::ConstAreaIterator& it) const = 0;
99  virtual ValueType map(const MobilityPeak1D& p) const = 0;
100  virtual ValueType map(const MobilityPeak2D& p) const = 0;
101 
103  virtual ValueType map(const MSSpectrum& spec, const Size index) const = 0;
105  virtual ValueType map(const MSChromatogram& chrom, const Size index) const = 0;
107  virtual ValueType map(const Mobilogram& mb, const Size index) const = 0;
108 
111  virtual ValueTypes map(const MSSpectrum& spec) const = 0;
112 
115  virtual ValueTypes map(const MSChromatogram& chrom) const = 0;
116 
117  virtual ValueType map(const BaseFeature& bf) const = 0;
118 
119  virtual ValueType map(const PeptideIdentification& pi) const = 0;
120 
122  virtual RangeBase map(const RangeAllType& rm) const = 0;
123 
125  virtual void setRange(const RangeBase& in, RangeAllType& out) const = 0;
126 
127 
128  // from XY to a type
129 
131  virtual void fromXY(const ValueType in, Peak1D& p) const = 0;
133  virtual void fromXY(const ValueType in, ChromatogramPeak& p) const = 0;
135  virtual void fromXY(const ValueType in, MobilityPeak1D& p) const = 0;
137  virtual void fromXY(const ValueType in, MobilityPeak2D& p) const = 0;
138 
140  std::string_view getDimName() const
141  {
142  return DIM_NAMES[(int)unit_];
143  }
144 
146  std::string_view getDimNameShort() const
147  {
148  return DIM_NAMES_SHORT[(int)unit_];
149  }
150 
153  {
154  return unit_;
155  }
156 
162  String formattedValue(const ValueType value) const;
163 
165  String formattedValue(ValueType value, const String& prefix) const;
166 
168  int valuePrecision() const;
169 
170  protected:
172  };
173 
174 
175 
176  class OPENMS_DLLAPI DimRT final : public DimBase
177  {
178  public:
180 
181  std::unique_ptr<DimBase> clone() const override
182  {
183  return std::make_unique<DimRT>();
184  }
185 
186  ValueType map(const Peak1D&) const override
187  {
188  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
189  }
190  ValueType map(const Peak2D& p) const override
191  {
192  return p.getRT();
193  }
194  ValueType map(const ChromatogramPeak& p) const override
195  {
196  return p.getRT();
197  }
198  ValueType map(const MSSpectrum& spec, const Size /*index*/) const override
199  {
200  return spec.getRT();
201  }
202  ValueType map(const MSChromatogram& chrom, const Size index) const override
203  {
204  return chrom[index].getRT();
205  }
206  ValueType map(const Mobilogram& mb, const Size /*index*/) const override
207  {
208  return mb.getRT();
209  }
210 
211  ValueTypes map(const MSSpectrum&) const override
212  {
213  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
214  }
215  ValueTypes map(const MSChromatogram& chrom) const override
216  {
217  ValueTypes res;
218  res.reserve(chrom.size());
219  for (const auto& p : chrom)
220  {
221  res.push_back(p.getRT());
222  }
223  return res;
224  }
225 
227  {
228  return it.getRT();
229  }
230  ValueType map(const MobilityPeak1D&) const override
231  {
232  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
233  }
234  ValueType map(const MobilityPeak2D&) const override
235  {
236  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
237  }
238 
239  ValueType map(const BaseFeature& bf) const override
240  {
241  return bf.getRT();
242  }
243 
244  ValueType map(const PeptideIdentification& pi) const override
245  {
246  return pi.getRT();
247  }
248 
249  RangeBase map(const RangeAllType& rm) const override
250  {
251  return rm.getRangeForDim(MSDim::RT);
252  }
253 
254  void setRange(const RangeBase& in, RangeAllType& out) const override
255  {
256  out.RangeRT::operator=(in);
257  }
258 
260  void fromXY(const ValueType, Peak1D&) const override
261  {
262  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
263  }
264 
266  void fromXY(const ValueType in, ChromatogramPeak& p) const override
267  {
268  p.setRT(in);
269  }
271  void fromXY(const ValueType, MobilityPeak1D&) const override
272  {
273  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
274  }
276  void fromXY(const ValueType, MobilityPeak2D&) const override
277  {
278  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
279  }
280  };
281 
282  class OPENMS_DLLAPI DimMZ final : public DimBase
283  {
284  public:
286 
287  std::unique_ptr<DimBase> clone() const override
288  {
289  return std::make_unique<DimMZ>();
290  }
291 
292  ValueType map(const Peak1D& p) const override
293  {
294  return p.getMZ();
295  }
296  ValueType map(const Peak2D& p) const override
297  {
298  return p.getMZ();
299  }
300  ValueType map(const ChromatogramPeak&) const override
301  {
302  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
303  }
305  {
306  return it->getMZ();
307  }
308  ValueType map(const MobilityPeak1D&) const override
309  {
310  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
311  }
312  ValueType map(const MobilityPeak2D& p) const override
313  {
314  return p.getMZ();
315  }
316 
317  ValueType map(const MSSpectrum& spec, const Size index) const override
318  {
319  return spec[index].getMZ();
320  }
321  ValueType map(const MSChromatogram& chrom, const Size /*index*/) const override
322  {
323  return chrom.getPrecursor().getMZ();
324  }
325  ValueType map(const Mobilogram& /*mb*/, const Size /*index*/) const override
326  {
327  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
328  }
329 
330  ValueTypes map(const MSSpectrum& spec) const override
331  {
332  ValueTypes res;
333  res.reserve(spec.size());
334  for (const auto& p : spec)
335  {
336  res.push_back(p.getMZ());
337  }
338  return res;
339  }
340  ValueTypes map(const MSChromatogram&) const override
341  {
342  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
343  }
344 
345  ValueType map(const BaseFeature& bf) const override
346  {
347  return bf.getMZ();
348  }
349 
350  ValueType map(const PeptideIdentification& pi) const override
351  {
352  return pi.getMZ();
353  }
354 
355  RangeBase map(const RangeAllType& rm) const override
356  {
357  return rm.getRangeForDim(MSDim::MZ);
358  }
359 
360  void setRange(const RangeBase& in, RangeAllType& out) const override
361  {
362  out.RangeMZ::operator=(in);
363  }
364 
366  void fromXY(const ValueType in, Peak1D& p) const override
367  {
368  p.setMZ(in);
369  }
370 
372  void fromXY(const ValueType, ChromatogramPeak&) const override
373  {
374  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
375  }
376 
378  void fromXY(const ValueType, MobilityPeak1D&) const override
379  {
380  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
381  }
383  void fromXY(const ValueType in, MobilityPeak2D& p) const override
384  {
385  p.setMZ(in);
386  }
387  };
388 
389  class OPENMS_DLLAPI DimINT final : public DimBase
390  {
391  public:
393 
394  std::unique_ptr<DimBase> clone() const override
395  {
396  return std::make_unique<DimINT>();
397  }
398 
399  ValueType map(const Peak1D& p) const override
400  {
401  return p.getIntensity();
402  }
403  ValueType map(const Peak2D& p) const override
404  {
405  return p.getIntensity();
406  }
407  ValueType map(const ChromatogramPeak& p) const override
408  {
409  return p.getIntensity();
410  }
412  {
413  return it->getIntensity();
414  }
415  ValueType map(const MobilityPeak1D& p) const override
416  {
417  return p.getIntensity();
418  }
419  ValueType map(const MobilityPeak2D& p) const override
420  {
421  return p.getIntensity();
422  }
423 
424  ValueType map(const MSSpectrum& spec, const Size index) const override
425  {
426  return spec[index].getIntensity();
427  }
428  ValueType map(const MSChromatogram& chrom, const Size index) const override
429  {
430  return chrom[index].getIntensity();
431  }
432  ValueType map(const Mobilogram& mb, const Size index) const override
433  {
434  return mb[index].getIntensity();
435  }
436 
437  ValueTypes map(const MSSpectrum& spec) const override
438  {
439  ValueTypes res;
440  res.reserve(spec.size());
441  for (const auto& p : spec)
442  {
443  res.push_back(p.getIntensity());
444  }
445  return res;
446  }
447 
448  ValueTypes map(const MSChromatogram& chrom) const override
449  {
450  ValueTypes res;
451  res.reserve(chrom.size());
452  for (const auto& p : chrom)
453  {
454  res.push_back(p.getIntensity());
455  }
456  return res;
457  }
458 
459  ValueType map(const BaseFeature& bf) const override
460  {
461  return bf.getIntensity();
462  }
463 
464  ValueType map(const PeptideIdentification&) const override
465  {
466  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
467  }
468 
469  RangeBase map(const RangeAllType& rm) const override
470  {
471  return rm.getRangeForDim(MSDim::INT);
472  }
473 
474  void setRange(const RangeBase& in, RangeAllType& out) const override
475  {
476  out.RangeIntensity::operator=(in);
477  }
478 
480  void fromXY(const ValueType in, Peak1D& p) const override
481  {
482  p.setIntensity(in);
483  }
484 
486  void fromXY(const ValueType in, ChromatogramPeak& p) const override
487  {
488  p.setIntensity(in);
489  }
491  void fromXY(const ValueType in, MobilityPeak1D& p) const override
492  {
493  p.setIntensity(in);
494  }
496  void fromXY(const ValueType in, MobilityPeak2D& p) const override
497  {
498  p.setIntensity(in);
499  }
500  };
501 
502  class OPENMS_DLLAPI DimIM final : public DimBase
503  {
504  public:
505  DimIM(const DIM_UNIT im_unit) : DimBase(im_unit) {}
506 
507  std::unique_ptr<DimBase> clone() const override
508  {
509  return std::make_unique<DimIM>(*this);
510  }
511 
512  ValueType map(const Peak1D&) const override
513  {
514  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
515  }
516  ValueType map(const Peak2D&) const override
517  {
518  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
519  }
520  ValueType map(const ChromatogramPeak&) const override
521  {
522  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
523  }
524  ValueTypes map(const MSSpectrum&) const override
525  {
526  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
527  }
528  ValueTypes map(const MSChromatogram&) const override
529  {
530  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
531  }
532 
534  {
535  return it.getDriftTime();
536  }
537 
538  ValueType map(const MobilityPeak1D& p) const override
539  {
540  return p.getMobility();
541  }
542  ValueType map(const MobilityPeak2D& p) const override
543  {
544  return p.getMobility();
545  }
546 
547  ValueType map(const MSSpectrum& spec, const Size /*index*/) const override
548  {
549  return spec.getDriftTime();
550  }
551  ValueType map(const MSChromatogram&, const Size) const override
552  {
553  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
554  }
555  ValueType map(const Mobilogram& mb, const Size index) const override
556  {
557  return mb[index].getMobility();
558  }
559 
560  ValueType map(const BaseFeature&) const override
561  {
562  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
563  }
564 
565  ValueType map(const PeptideIdentification&) const override
566  {
567  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
568  }
569 
570  RangeBase map(const RangeAllType& rm) const override
571  {
572  return rm.getRangeForDim(MSDim::IM);
573  }
574 
575  void setRange(const RangeBase& in, RangeAllType& out) const override
576  {
577  out.RangeMobility::operator=(in);
578  }
579 
581  void fromXY(const ValueType, Peak1D&) const override
582  {
583  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
584  }
585 
587  void fromXY(const ValueType, ChromatogramPeak&) const override
588  {
589  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
590  }
591 
593  void fromXY(const ValueType in, MobilityPeak1D& p) const override
594  {
595  p.setMobility(in);
596  }
598  void fromXY(const ValueType in, MobilityPeak2D& p) const override
599  {
600  p.setMobility(in);
601  }
602  };
603 
607  enum class DIM
608  {
609  X = 0,
610  Y = 1,
611  Z = 2
612  };
613 
624  template<int N_DIM>
625  class DimMapper
626  {
627  public:
629 
631  DimMapper() = delete;
632 
634  DimMapper(const DIM_UNIT (&units)[N_DIM])
635  :dims_([&]() {
636  std::array<std::unique_ptr<const DimBase>, N_DIM> dims_tmp;
637  for (int i = 0; i < N_DIM; ++i)
638  {
639  dims_tmp[i] = create_(units[i]);
640  }
641  return dims_tmp;
642  }()) // immediately evaluated lambda to enable 'dims_' to be const
643  {
644  static_assert(N_DIM >= 1); // at least one dimension (X)
645  static_assert(N_DIM <= 3); // at most three (X, Y, Z)
646  }
647 
649  DimMapper(const DimMapper& rhs) // cannot be defaulted due to unique_ptr
650  {
651  *this = rhs;
652  };
653 
655  DimMapper& operator=(const DimMapper& rhs) // cannot be defaulted due to unique_ptr
656  {
657  for (int i = 0; i < N_DIM; ++i) dims_[i] = rhs.dims_[i]->clone();
658  return *this;
659  };
660 
662  bool operator==(const DimMapper& rhs) const
663  {
664  bool res {true};
665  for (int i = 0; i < N_DIM; ++i)
666  {
667  res &= (*dims_[i] == *rhs.dims_[i]);
668  }
669  return res;
670  }
671 
673  bool operator!=(const DimMapper& rhs) const
674  {
675  return !operator==(rhs);
676  }
677 
679  template <typename T>
680  Point map(const T& data) const
681  {
682  Point pr;
683  for (int i = 0; i < N_DIM; ++i) pr[i] = dims_[i]->map(data);
684  return pr;
685  }
687  template<typename Container>
688  Point map(const Container& data, const Size index) const
689  {
690  Point pr;
691  for (int i = 0; i < N_DIM; ++i)
692  pr[i] = dims_[i]->map(data, index);
693  return pr;
694  }
695 
697  template<typename ...Ranges>
699  {
700  DRange<N_DIM> res;
701  RangeAllType all;
702  all.assign(ranges);
703  for (int i = 0; i < N_DIM; ++i)
704  {
705  RangeBase mm = dims_[i]->map(all);
706  if (mm.isEmpty()) continue;
707  res.setDimMinMax(i, {mm.getMin(), mm.getMax()});
708  }
709  return res;
710  }
711 
715  template<typename... Ranges>
716  void fromXY(const DRange<N_DIM>& in, RangeManager<Ranges...>& output) const
717  {
718  for (int i = 0; i < N_DIM; ++i)
719  {
720  if (in.isEmpty(i))
721  dims_[i]->setRange(RangeBase(), output);
722  else
723  dims_[i]->setRange({in.minPosition()[i], in.maxPosition()[i]}, output);
724  }
725  }
726 
730  template<typename... Ranges>
731  void fromXY(const Point& in, RangeManager<Ranges...>& output) const
732  {
733  for (int i = 0; i < N_DIM; ++i)
734  {
735  dims_[i]->setRange({in[i], in[i]}, output);
736  }
737  }
738 
742  template<typename T>
743  void fromXY(const Point& in, T& out) const
744  {
745  for (int i = 0; i < N_DIM; ++i)
746  {
747  dims_[i]->fromXY(in[i], out);
748  }
749  }
750 
754  RangeAllType fromXY(const Point& in) const
755  {
756  RangeAllType output;
757  for (int i = 0; i < N_DIM; ++i)
758  {
759  dims_[i]->setRange({in[i], in[i]}, output);
760  }
761  return output;
762  }
763 
765  const DimBase& getDim(DIM d) const
766  {
767  assert((int)d <= N_DIM);
768  return *dims_[(int)d];
769  }
770 
771  protected:
773  static std::unique_ptr<const DimBase> create_(DIM_UNIT u)
774  {
775  switch (u)
776  {
777  case DIM_UNIT::RT:
778  return std::make_unique<DimRT>();
779  case DIM_UNIT::MZ:
780  return std::make_unique<DimMZ>();
781  case DIM_UNIT::INT:
782  return std::make_unique<DimINT>();
783  case DIM_UNIT::FAIMS_CV:
784  case DIM_UNIT::IM_MS:
785  case DIM_UNIT::IM_VSSC:
786  return std::make_unique<DimIM>(u);
787  default:
788  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
789  }
790  }
791 
792  std::array<std::unique_ptr<const DimBase>, N_DIM> dims_;
793  };
794 
795 
798  template <int N_DIM>
799  class Area
800  {
801  public:
804 
806  Area() = delete;
807 
809  Area(const DimMapper<N_DIM>* const dims)
810  : mapper_(dims)
811  {
812  }
813 
815  Area(const Area& range) = default;
816 
818  Area& operator=(const Area& rhs)
819  {
820  // check that Dims are identical, otherwise this is very dangerous (the user probably only wanted to update the area, not change its mapping).
821  if (mapper_ != rhs.mapper_ && *mapper_ != *rhs.mapper_)
822  {
823  throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Assignment of Areas using different mappers!");
824  }
825  data_range_ = rhs.data_range_;
827  return *this;
828  }
829 
830  bool operator==(const Area& rhs) const
831  {
832  return data_range_ == rhs.data_range_
833  && visible_area_ == rhs.visible_area_
834  && (*mapper_ == *rhs.mapper_);
835  }
836  bool operator!=(const Area& rhs) const
837  {
838  return !operator==(rhs);
839  }
840 
846  const Area& setArea(const RangeAllType& data)
847  {
848  data_range_ = data;
849  // update axis view using dims
850  visible_area_ = mapper_->mapRange(data);
851  return *this;
852  }
853 
859  const Area& setArea(const AreaXYType& data)
860  {
861  visible_area_ = data;
862  // update range view from XY area using dims
864  return *this;
865  }
866 
867  const AreaXYType& getAreaXY() const
868  {
869  return visible_area_;
870  }
871 
872  const RangeAllType& getAreaUnit() const
873  {
874  return data_range_;
875  }
876 
882  Area cloneWith(const AreaXYType& data) const
883  {
884  Area clone(*this);
885  clone.setArea(data);
886  return clone;
887  }
888 
894  Area cloneWith(const RangeAllType& data) const
895  {
896  Area clone(*this);
897  clone.setArea(data);
898  return clone;
899  }
900 
905  void pushInto(const RangeAllType& sandbox)
906  {
907  auto a = data_range_;
908  a.pushInto(sandbox);
909  setArea(a);
910  }
911 
913  void clear()
914  {
916  }
917 
918  private:
919  /* two sides of the same coin... */
922  const DimMapper<N_DIM>* mapper_;
924  };
925 
926 } // namespace OpenMS
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:121
double getRT() const noexcept
Definition: Mobilogram.h:262
void pushInto(const RangeManager< RangeBasesOther... > &sandbox)
Definition: RangeManager.h:704
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:533
CoordinateType getDriftTime() const
returns the ion mobility time of the current scan
Definition: AreaIterator.h:259
void fromXY(const ValueType, Peak1D &) const override
set the IM of a Peak1D (throws)
Definition: DimMapper.h:581
std::string_view DIM_NAMES_SHORT[(int) DIM_UNIT::SIZE_OF_DIM_UNITS]
Definition: CommonEnums.h:56
RangeManager< RangeRT, RangeMZ, RangeIntensity, RangeMobility > RangeAllType
Range which contains all known dimensions.
Definition: RangeManager.h:920
ValueType map(const MobilityPeak2D &p) const override
Definition: DimMapper.h:312
ValueType map(const Peak2D &p) const override
Definition: DimMapper.h:296
A more convenient string class.
Definition: String.h:58
DimINT()
Definition: DimMapper.h:392
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:360
AreaXYType visible_area_
Definition: DimMapper.h:921
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:54
void fromXY(const ValueType, ChromatogramPeak &) const override
set the MZ of a ChromatogramPeak (throws)
Definition: DimMapper.h:372
ValueType map(const ChromatogramPeak &p) const override
Definition: DimMapper.h:407
const Area & setArea(const AreaXYType &data)
Set the area using axis data (X and Y)
Definition: DimMapper.h:859
ValueType map(const BaseFeature &) const override
Definition: DimMapper.h:560
std::string_view getDimName() const
Name of the dimension, e.g. &#39;RT [s]&#39;.
Definition: DimMapper.h:140
ValueType map(const Mobilogram &mb, const Size index) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:555
void fromXY(const ValueType, Peak1D &) const override
set the RT of a Peak1D (throws)
Definition: DimMapper.h:260
The representation of a chromatogram.
Definition: MSChromatogram.h:53
void fromXY(const ValueType in, MobilityPeak2D &p) const override
set the IM of a MobilityPeak2D
Definition: DimMapper.h:598
ValueType map(const Peak1D &p) const override
Definition: DimMapper.h:292
DIM_UNIT unit_
the unit of this dimension
Definition: DimMapper.h:171
ValueType map(const Mobilogram &, const Size) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:325
IntensityType getIntensity() const
Definition: MobilityPeak1D.h:105
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:113
ValueType map(const Peak1D &p) const override
Definition: DimMapper.h:399
ValueTypes map(const MSSpectrum &) const override
Definition: DimMapper.h:524
ValueType map(const MSChromatogram &chrom, const Size index) const override
obtain value from a certain point in a chromatogram
Definition: DimMapper.h:428
const Area & setArea(const RangeAllType &data)
Set the area using unit data (RT, m/z, ...)
Definition: DimMapper.h:846
ValueType map(const MSChromatogram &chrom, const Size index) const override
obtain value from a certain point in a chromatogram
Definition: DimMapper.h:202
Allows dynamical switching (at runtime) between a dimension (RT, m/z, int, IM, etc) and X...
Definition: DimMapper.h:625
DimRT()
Definition: DimMapper.h:179
void pushInto(const RangeAllType &sandbox)
Push the area into a sandbox (if its outside the sandbox). See UnitRange::pushInto() ...
Definition: DimMapper.h:905
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:394
Forward iterator for an area of peaks in an experiment.
Definition: AreaIterator.h:61
A 2-dimensional raw data point or peak.
Definition: MobilityPeak2D.h:54
bool isEmpty() const
is the range empty (i.e. min > max)?
Definition: RangeManager.h:108
ValueType map(const ChromatogramPeak &p) const override
Definition: DimMapper.h:194
Area()=delete
No default C&#39;tor.
ValueType map(const Peak2D &p) const override
Definition: DimMapper.h:190
const RangeAllType & getAreaUnit() const
Definition: DimMapper.h:872
DimMapper(const DIM_UNIT(&units)[N_DIM])
Custom C&#39;tor with given dimensions to map to (the order is assumed to be X, Y, Z, ...
Definition: DimMapper.h:634
double getDriftTime() const
Returns the ion mobility drift time (MSSpectrum::DRIFTTIME_NOT_SET means it is not set) ...
void setMobility(CoordinateType mobility)
Mutable access to mobility.
Definition: MobilityPeak1D.h:122
void fromXY(const ValueType, ChromatogramPeak &) const override
set the IM of a ChromatogramPeak (throws)
Definition: DimMapper.h:587
void fromXY(const ValueType in, ChromatogramPeak &p) const override
set the intensity of a ChromatogramPeak
Definition: DimMapper.h:486
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:411
void fromXY(const ValueType in, MobilityPeak2D &p) const override
set the intensity of a MobilityPeak2D
Definition: DimMapper.h:496
DimMZ()
Definition: DimMapper.h:285
ValueType map(const PeptideIdentification &) const override
Definition: DimMapper.h:565
ValueType map(const PeptideIdentification &pi) const override
Definition: DimMapper.h:244
ValueType map(const MSSpectrum &spec, const Size index) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:424
ValueType map(const Peak2D &) const override
Definition: DimMapper.h:516
const Precursor & getPrecursor() const
returns a const reference to the precursors
DimMapper & operator=(const DimMapper &rhs)
Assignment operator.
Definition: DimMapper.h:655
bool isEmpty() const
Definition: DIntervalBase.h:242
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:119
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:110
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:181
ValueType map(const MobilityPeak2D &) const override
Definition: DimMapper.h:234
DIM_UNIT
Definition: CommonEnums.h:45
Precondition failed exception.
Definition: Exception.h:157
IntensityType getIntensity() const
Definition: Peak2D.h:168
ValueType map(const Peak1D &) const override
Definition: DimMapper.h:512
Area & operator=(const Area &rhs)
Assignment operator - which checks for identical DimMappers and throws otherwise. ...
Definition: DimMapper.h:818
std::string_view DIM_NAMES[(int) DIM_UNIT::SIZE_OF_DIM_UNITS]
Definition: CommonEnums.h:55
ValueType map(const ChromatogramPeak &) const override
Definition: DimMapper.h:520
double getMax() const
only useful if isEmpty() returns false
Definition: RangeManager.h:154
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:287
A basic LC-MS feature.
Definition: BaseFeature.h:58
ValueType map(const BaseFeature &bf) const override
Definition: DimMapper.h:239
PositionType const & maxPosition() const
Accessor to maximum position.
Definition: DIntervalBase.h:130
double getMZ() const
returns the MZ of the MS2 spectrum
void fromXY(const ValueType in, MobilityPeak1D &p) const override
set the IM of a MobilityPeak1D
Definition: DimMapper.h:593
void fromXY(const Point &in, T &out) const
Definition: DimMapper.h:743
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:570
RangeAllType fromXY(const Point &in) const
Definition: DimMapper.h:754
Definition: DimMapper.h:389
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:355
DimMapper(const DimMapper &rhs)
Copy C&#39;tor.
Definition: DimMapper.h:649
static std::unique_ptr< const DimBase > create_(DIM_UNIT u)
a minimal factory
Definition: DimMapper.h:773
void fromXY(const Point &in, RangeManager< Ranges... > &output) const
Definition: DimMapper.h:731
void setMobility(CoordinateType coordinate)
Mutable access to the IM coordinate (index 0)
Definition: MobilityPeak2D.h:212
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
void fromXY(const ValueType in, ChromatogramPeak &p) const override
set the RT of a ChromatogramPeak
Definition: DimMapper.h:266
void setDimMinMax(UInt dim, const DIntervalBase< 1 > &min_max)
only set interval for a single dimension
Definition: DIntervalBase.h:254
ValueType map(const MobilityPeak2D &p) const override
Definition: DimMapper.h:419
auto & assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:612
Point map(const T &data) const
convert an OpenMS datatype (such as Feature) to an N_DIM-dimensional point
Definition: DimMapper.h:680
static String prefix(const String &this_s, size_t length)
Definition: StringUtilsSimple.h:147
ValueType map(const MobilityPeak1D &) const override
Definition: DimMapper.h:230
bool operator!=(const Area &rhs) const
Definition: DimMapper.h:836
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: Peak2D.h:198
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
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:432
double getRT() const
returns the RT of the MS2 spectrum where the identification occurred
void fromXY(const ValueType, MobilityPeak2D &) const override
set the RT of a MobilityPeak2D (throws)
Definition: DimMapper.h:276
Representation of a coordinate in D-dimensional space.
Definition: DPosition.h:53
ValueType map(const BaseFeature &bf) const override
Definition: DimMapper.h:345
ValueTypes map(const MSChromatogram &) const override
Definition: DimMapper.h:528
void clear()
empty all dimensions
Definition: DimMapper.h:913
bool operator==(const DimMapper &rhs) const
Equality.
Definition: DimMapper.h:662
Base class for a simple range with minimum and maximum.
Definition: RangeManager.h:63
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:575
CoordinateType getRT() const
Non-mutable access to RT.
Definition: ChromatogramPeak.h:115
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:53
const DimBase & getDim(DIM d) const
obtain unit/name for X/Y/Z dimension.
Definition: DimMapper.h:765
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:894
A base class for a dimension which represents a certain unit (e.g. RT or m/z). Derived classes implem...
Definition: DimMapper.h:66
void fromXY(const ValueType in, MobilityPeak2D &p) const override
set the MZ of a MobilityPeak2D (throws)
Definition: DimMapper.h:383
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:688
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:304
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition: MobilityPeak2D.h:170
ValueType map(const PeptideIdentification &pi) const override
Definition: DimMapper.h:350
std::vector< ValueType > ValueTypes
Definition: DimMapper.h:70
ValueTypes map(const MSChromatogram &chrom) const override
Definition: DimMapper.h:215
ValueType map(const PeptideIdentification &) const override
Definition: DimMapper.h:464
bool operator!=(const DimMapper &rhs) const
Inequality.
Definition: DimMapper.h:673
ValueType map(const MSChromatogram &, const Size) const override
obtain value from a certain point in a chromatogram
Definition: DimMapper.h:551
std::array< std::unique_ptr< const DimBase >, N_DIM > dims_
mappers for the X,Y,Z... dimension
Definition: DimMapper.h:792
ValueType map(const MSSpectrum &spec, const Size) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:547
FAIMS compensation voltage.
DIM
Definition: DimMapper.h:607
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:254
ion mobility milliseconds
Definition: DimMapper.h:176
ValueTypes map(const MSChromatogram &) const override
Definition: DimMapper.h:340
ValueType map(const MobilityPeak2D &p) const override
Definition: DimMapper.h:542
ValueTypes map(const MSSpectrum &spec) const override
Definition: DimMapper.h:330
ValueType map(const MSSpectrum &spec, const Size index) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:317
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:210
ValueType map(const MobilityPeak1D &p) const override
Definition: DimMapper.h:415
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: MobilityPeak2D.h:200
ValueTypes map(const MSSpectrum &spec) const override
Definition: DimMapper.h:437
CoordinateType getMobility() const
Returns the IM coordinate (index 0)
Definition: MobilityPeak2D.h:206
std::string_view getDimNameShort() const
Name of the dimension, e.g. &#39;RT&#39;.
Definition: DimMapper.h:146
ValueType map(const Peak2D &p) const override
Definition: DimMapper.h:403
void fromXY(const ValueType, MobilityPeak1D &) const override
set the MZ of a MobilityPeak1D (throws)
Definition: DimMapper.h:378
DIM_UNIT getUnit() const
The unit of the dimension.
Definition: DimMapper.h:152
ValueType map(const BaseFeature &bf) const override
Definition: DimMapper.h:459
ValueType map(const MobilityPeak1D &p) const override
Definition: DimMapper.h:538
const DimMapper< N_DIM > * mapper_
and a mapper (non-owning pointer) to translate between the two
Definition: DimMapper.h:923
Definition: DimMapper.h:282
ValueType map(const MSChromatogram &chrom, const Size) const override
obtain value from a certain point in a chromatogram
Definition: DimMapper.h:321
Invalid range exception.
Definition: Exception.h:276
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:112
CoordinateType getRT() const
returns the retention time of the current scan
Definition: AreaIterator.h:253
ValueType map(const MSSpectrum &spec, const Size) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:198
double getMin() const
only useful if isEmpty() returns false
Definition: RangeManager.h:148
Definition: DimMapper.h:799
DimMapper()=delete
No default c&#39;tor (we need dimensions)
ValueType map(const ChromatogramPeak &) const override
Definition: DimMapper.h:300
void fromXY(const ValueType in, Peak1D &p) const override
set the intensity of a Peak1D
Definition: DimMapper.h:480
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
const AreaXYType & getAreaXY() const
Definition: DimMapper.h:867
A 1-dimensional raw data mobility point or peak. The unit (ms, 1/K_0, etc) is implicit.
Definition: MobilityPeak1D.h:50
ValueTypes map(const MSSpectrum &) const override
Definition: DimMapper.h:211
ValueType map(const Mobilogram &mb, const Size) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:206
void fromXY(const ValueType in, Peak1D &p) const override
set the MZ of a Peak1D
Definition: DimMapper.h:366
Area(const DimMapper< N_DIM > *const dims)
Custom C&#39;tor with a mapper (non owning pointer)
Definition: DimMapper.h:809
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:469
IntensityType getIntensity() const
Definition: MobilityPeak2D.h:164
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: MobilityPeak2D.h:194
const RangeBase & getRangeForDim(MSDim dim) const
obtain a range dimension at runtime using dim
Definition: RangeManager.h:748
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:249
ValueTypes map(const MSChromatogram &chrom) const override
Definition: DimMapper.h:448
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:53
bool operator==(const Area &rhs) const
Definition: DimMapper.h:830
IntensityType getIntensity() const
Non-mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:110
DimIM(const DIM_UNIT im_unit)
Definition: DimMapper.h:505
ValueType map(const MobilityPeak1D &) const override
Definition: DimMapper.h:308
void fromXY(const DRange< N_DIM > &in, RangeManager< Ranges... > &output) const
Definition: DimMapper.h:716
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:698
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:226
static DIntervalBase const empty
empty instance
Definition: DIntervalBase.h:284
double getRT() const
volt-second per square centimeter (i.e. 1/K_0)
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:507
RangeAllType data_range_
range in units
Definition: DimMapper.h:920
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: MobilityPeak1D.h:110
The representation of a 1D ion mobilogram.
Definition: Mobilogram.h:54
void fromXY(const ValueType in, MobilityPeak1D &p) const override
set the intensity of a MobilityPeak1D
Definition: DimMapper.h:491
DimBase(DIM_UNIT unit)
Custom c&#39;tor with unit.
Definition: DimMapper.h:76
void fromXY(const ValueType, MobilityPeak1D &) const override
set the RT of a MobilityPeak1D (throws)
Definition: DimMapper.h:271
Not implemented exception.
Definition: Exception.h:428
RT in seconds.
CoordinateType getMobility() const
Non-mutable access to m/z.
Definition: MobilityPeak1D.h:116
ValueType map(const Peak1D &) const override
Definition: DimMapper.h:186
Definition: DimMapper.h:502
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:63
IntensityType getIntensity() const
Definition: Peak1D.h:108
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:882
PositionType const & minPosition() const
Accessor to minimum position.
Definition: DIntervalBase.h:124