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 Mobilogram& mb, const Size index) const = 0;
106 
109  virtual ValueTypes map(const MSSpectrum& spec) const = 0;
110 
113  virtual ValueTypes map(const MSChromatogram& chrom) const = 0;
114 
115  virtual ValueType map(const BaseFeature& bf) const = 0;
116 
117  virtual ValueType map(const PeptideIdentification& pi) const = 0;
118 
120  virtual RangeBase map(const RangeAllType& rm) const = 0;
121 
123  virtual void setRange(const RangeBase& in, RangeAllType& out) const = 0;
124 
125 
126  // from XY to a type
127 
129  virtual void fromXY(const ValueType in, Peak1D& p) const = 0;
131  virtual void fromXY(const ValueType in, ChromatogramPeak& p) const = 0;
133  virtual void fromXY(const ValueType in, MobilityPeak1D& p) const = 0;
135  virtual void fromXY(const ValueType in, MobilityPeak2D& p) const = 0;
136 
138  std::string_view getDimName() const
139  {
140  return DIM_NAMES[(int)unit_];
141  }
142 
144  std::string_view getDimNameShort() const
145  {
146  return DIM_NAMES_SHORT[(int)unit_];
147  }
148 
151  {
152  return unit_;
153  }
154 
160  String formattedValue(const ValueType value) const;
161 
163  String formattedValue(ValueType value, const String& prefix) const;
164 
166  int valuePrecision() const;
167 
168  protected:
170  };
171 
172 
173 
174  class OPENMS_DLLAPI DimRT final : public DimBase
175  {
176  public:
178 
179  std::unique_ptr<DimBase> clone() const override
180  {
181  return std::make_unique<DimRT>();
182  }
183 
184  ValueType map(const Peak1D&) const override
185  {
186  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
187  }
188  ValueType map(const Peak2D& p) const override
189  {
190  return p.getRT();
191  }
192  ValueType map(const ChromatogramPeak& p) const override
193  {
194  return p.getRT();
195  }
196  ValueType map(const MSSpectrum& spec, const Size /*index*/) const override
197  {
198  return spec.getRT();
199  }
200  ValueType map(const Mobilogram& mb, const Size /*index*/) const override
201  {
202  return mb.getRT();
203  }
204 
205  ValueTypes map(const MSSpectrum&) const override
206  {
207  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
208  }
209  ValueTypes map(const MSChromatogram& chrom) const override
210  {
211  ValueTypes res;
212  res.reserve(chrom.size());
213  for (const auto& p : chrom)
214  {
215  res.push_back(p.getRT());
216  }
217  return res;
218  }
219 
221  {
222  return it.getRT();
223  }
224  ValueType map(const MobilityPeak1D&) const override
225  {
226  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
227  }
228  ValueType map(const MobilityPeak2D&) const override
229  {
230  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
231  }
232 
233  ValueType map(const BaseFeature& bf) const override
234  {
235  return bf.getRT();
236  }
237 
238  ValueType map(const PeptideIdentification& pi) const override
239  {
240  return pi.getRT();
241  }
242 
243  RangeBase map(const RangeAllType& rm) const override
244  {
245  return rm.getRangeForDim(MSDim::RT);
246  }
247 
248  void setRange(const RangeBase& in, RangeAllType& out) const override
249  {
250  out.RangeRT::operator=(in);
251  }
252 
254  void fromXY(const ValueType, Peak1D&) const override
255  {
256  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
257  }
258 
260  void fromXY(const ValueType in, ChromatogramPeak& p) const override
261  {
262  p.setRT(in);
263  }
265  void fromXY(const ValueType, MobilityPeak1D&) const override
266  {
267  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
268  }
270  void fromXY(const ValueType, MobilityPeak2D&) const override
271  {
272  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
273  }
274  };
275 
276  class OPENMS_DLLAPI DimMZ final : public DimBase
277  {
278  public:
280 
281  std::unique_ptr<DimBase> clone() const override
282  {
283  return std::make_unique<DimMZ>();
284  }
285 
286  ValueType map(const Peak1D& p) const override
287  {
288  return p.getMZ();
289  }
290  ValueType map(const Peak2D& p) const override
291  {
292  return p.getMZ();
293  }
294  ValueType map(const ChromatogramPeak&) const override
295  {
296  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
297  }
299  {
300  return it->getMZ();
301  }
302  ValueType map(const MobilityPeak1D&) const override
303  {
304  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
305  }
306  ValueType map(const MobilityPeak2D& p) const override
307  {
308  return p.getMZ();
309  }
310 
311  ValueType map(const MSSpectrum& spec, const Size index) const override
312  {
313  return spec[index].getMZ();
314  }
315  ValueType map(const Mobilogram&, const Size /*index*/) const override
316  {
317  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
318  }
319 
320  ValueTypes map(const MSSpectrum& spec) const override
321  {
322  ValueTypes res;
323  res.reserve(spec.size());
324  for (const auto& p : spec)
325  {
326  res.push_back(p.getMZ());
327  }
328  return res;
329  }
330  ValueTypes map(const MSChromatogram&) const override
331  {
332  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
333  }
334 
335  ValueType map(const BaseFeature& bf) const override
336  {
337  return bf.getMZ();
338  }
339 
340  ValueType map(const PeptideIdentification& pi) const override
341  {
342  return pi.getMZ();
343  }
344 
345  RangeBase map(const RangeAllType& rm) const override
346  {
347  return rm.getRangeForDim(MSDim::MZ);
348  }
349 
350  void setRange(const RangeBase& in, RangeAllType& out) const override
351  {
352  out.RangeMZ::operator=(in);
353  }
354 
356  void fromXY(const ValueType in, Peak1D& p) const override
357  {
358  p.setMZ(in);
359  }
360 
362  void fromXY(const ValueType, ChromatogramPeak&) const override
363  {
364  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
365  }
366 
368  void fromXY(const ValueType, MobilityPeak1D&) const override
369  {
370  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
371  }
373  void fromXY(const ValueType in, MobilityPeak2D& p) const override
374  {
375  p.setMZ(in);
376  }
377  };
378 
379  class OPENMS_DLLAPI DimINT final : public DimBase
380  {
381  public:
383 
384  std::unique_ptr<DimBase> clone() const override
385  {
386  return std::make_unique<DimINT>();
387  }
388 
389  ValueType map(const Peak1D& p) const override
390  {
391  return p.getIntensity();
392  }
393  ValueType map(const Peak2D& p) const override
394  {
395  return p.getIntensity();
396  }
397  ValueType map(const ChromatogramPeak& p) const override
398  {
399  return p.getIntensity();
400  }
402  {
403  return it->getIntensity();
404  }
405  ValueType map(const MobilityPeak1D& p) const override
406  {
407  return p.getIntensity();
408  }
409  ValueType map(const MobilityPeak2D& p) const override
410  {
411  return p.getIntensity();
412  }
413 
414  ValueType map(const MSSpectrum& spec, const Size index) const override
415  {
416  return spec[index].getIntensity();
417  }
418  ValueType map(const Mobilogram& mb, const Size index) const override
419  {
420  return mb[index].getIntensity();
421  }
422 
423  ValueTypes map(const MSSpectrum& spec) const override
424  {
425  ValueTypes res;
426  res.reserve(spec.size());
427  for (const auto& p : spec)
428  {
429  res.push_back(p.getIntensity());
430  }
431  return res;
432  }
433 
434  ValueTypes map(const MSChromatogram& chrom) const override
435  {
436  ValueTypes res;
437  res.reserve(chrom.size());
438  for (const auto& p : chrom)
439  {
440  res.push_back(p.getIntensity());
441  }
442  return res;
443  }
444 
445  ValueType map(const BaseFeature& bf) const override
446  {
447  return bf.getIntensity();
448  }
449 
450  ValueType map(const PeptideIdentification&) const override
451  {
452  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
453  }
454 
455  RangeBase map(const RangeAllType& rm) const override
456  {
457  return rm.getRangeForDim(MSDim::INT);
458  }
459 
460  void setRange(const RangeBase& in, RangeAllType& out) const override
461  {
462  out.RangeIntensity::operator=(in);
463  }
464 
466  void fromXY(const ValueType in, Peak1D& p) const override
467  {
468  p.setIntensity(in);
469  }
470 
472  void fromXY(const ValueType in, ChromatogramPeak& p) const override
473  {
474  p.setIntensity(in);
475  }
477  void fromXY(const ValueType in, MobilityPeak1D& p) const override
478  {
479  p.setIntensity(in);
480  }
482  void fromXY(const ValueType in, MobilityPeak2D& p) const override
483  {
484  p.setIntensity(in);
485  }
486  };
487 
488  class OPENMS_DLLAPI DimIM final : public DimBase
489  {
490  public:
491  DimIM(const DIM_UNIT im_unit) : DimBase(im_unit) {}
492 
493  std::unique_ptr<DimBase> clone() const override
494  {
495  return std::make_unique<DimIM>(*this);
496  }
497 
498  ValueType map(const Peak1D&) const override
499  {
500  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
501  }
502  ValueType map(const Peak2D&) const override
503  {
504  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
505  }
506  ValueType map(const ChromatogramPeak&) const override
507  {
508  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
509  }
510  ValueTypes map(const MSSpectrum&) const override
511  {
512  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
513  }
514  ValueTypes map(const MSChromatogram&) const override
515  {
516  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
517  }
518 
520  {
521  return it.getDriftTime();
522  }
523 
524  ValueType map(const MobilityPeak1D& p) const override
525  {
526  return p.getMobility();
527  }
528  ValueType map(const MobilityPeak2D& p) const override
529  {
530  return p.getMobility();
531  }
532 
533  ValueType map(const MSSpectrum& spec, const Size /*index*/) const override
534  {
535  return spec.getDriftTime();
536  }
537  ValueType map(const Mobilogram& mb, const Size index) const override
538  {
539  return mb[index].getMobility();
540  }
541 
542  ValueType map(const BaseFeature&) const override
543  {
544  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
545  }
546 
547  ValueType map(const PeptideIdentification&) const override
548  {
549  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
550  }
551 
552  RangeBase map(const RangeAllType& rm) const override
553  {
554  return rm.getRangeForDim(MSDim::IM);
555  }
556 
557  void setRange(const RangeBase& in, RangeAllType& out) const override
558  {
559  out.RangeMobility::operator=(in);
560  }
561 
563  void fromXY(const ValueType, Peak1D&) const override
564  {
565  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
566  }
567 
569  void fromXY(const ValueType, ChromatogramPeak&) const override
570  {
571  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
572  }
573 
575  void fromXY(const ValueType in, MobilityPeak1D& p) const override
576  {
577  p.setMobility(in);
578  }
580  void fromXY(const ValueType in, MobilityPeak2D& p) const override
581  {
582  p.setMobility(in);
583  }
584  };
585 
589  enum class DIM
590  {
591  X = 0,
592  Y = 1,
593  Z = 2
594  };
595 
606  template<int N_DIM>
607  class DimMapper
608  {
609  public:
611 
613  DimMapper() = delete;
614 
616  DimMapper(const DIM_UNIT (&units)[N_DIM])
617  :dims_([&]() {
618  std::array<std::unique_ptr<const DimBase>, N_DIM> dims_tmp;
619  for (int i = 0; i < N_DIM; ++i)
620  {
621  dims_tmp[i] = create_(units[i]);
622  }
623  return dims_tmp;
624  }()) // immediately evaluated lambda to enable 'dims_' to be const
625  {
626  static_assert(N_DIM >= 1); // at least one dimension (X)
627  static_assert(N_DIM <= 3); // at most three (X, Y, Z)
628  }
629 
631  DimMapper(const DimMapper& rhs) // cannot be defaulted due to unique_ptr
632  {
633  *this = rhs;
634  };
635 
637  DimMapper& operator=(const DimMapper& rhs) // cannot be defaulted due to unique_ptr
638  {
639  for (int i = 0; i < N_DIM; ++i) dims_[i] = rhs.dims_[i]->clone();
640  return *this;
641  };
642 
644  bool operator==(const DimMapper& rhs) const
645  {
646  bool res {true};
647  for (int i = 0; i < N_DIM; ++i)
648  {
649  res &= (*dims_[i] == *rhs.dims_[i]);
650  }
651  return res;
652  }
653 
655  bool operator!=(const DimMapper& rhs) const
656  {
657  return !operator==(rhs);
658  }
659 
661  template <typename T>
662  Point map(const T& data) const
663  {
664  Point pr;
665  for (int i = 0; i < N_DIM; ++i) pr[i] = dims_[i]->map(data);
666  return pr;
667  }
669  template<typename Container>
670  Point map(const Container& data, const Size index) const
671  {
672  Point pr;
673  for (int i = 0; i < N_DIM; ++i)
674  pr[i] = dims_[i]->map(data, index);
675  return pr;
676  }
677 
679  template<typename ...Ranges>
681  {
682  DRange<N_DIM> res;
683  RangeAllType all;
684  all.assign(ranges);
685  for (int i = 0; i < N_DIM; ++i)
686  {
687  RangeBase mm = dims_[i]->map(all);
688  if (mm.isEmpty()) continue;
689  res.setDimMinMax(i, {mm.getMin(), mm.getMax()});
690  }
691  return res;
692  }
693 
697  template<typename... Ranges>
698  void fromXY(const DRange<N_DIM>& in, RangeManager<Ranges...>& output) const
699  {
700  for (int i = 0; i < N_DIM; ++i)
701  {
702  if (in.isEmpty(i))
703  dims_[i]->setRange(RangeBase(), output);
704  else
705  dims_[i]->setRange({in.minPosition()[i], in.maxPosition()[i]}, output);
706  }
707  }
708 
712  template<typename... Ranges>
713  void fromXY(const Point& in, RangeManager<Ranges...>& output) const
714  {
715  for (int i = 0; i < N_DIM; ++i)
716  {
717  dims_[i]->setRange({in[i], in[i]}, output);
718  }
719  }
720 
724  template<typename T>
725  void fromXY(const Point& in, T& out) const
726  {
727  for (int i = 0; i < N_DIM; ++i)
728  {
729  dims_[i]->fromXY(in[i], out);
730  }
731  }
732 
736  RangeAllType fromXY(const Point& in) const
737  {
738  RangeAllType output;
739  for (int i = 0; i < N_DIM; ++i)
740  {
741  dims_[i]->setRange({in[i], in[i]}, output);
742  }
743  return output;
744  }
745 
747  const DimBase& getDim(DIM d) const
748  {
749  assert((int)d <= N_DIM);
750  return *dims_[(int)d];
751  }
752 
753  protected:
755  static std::unique_ptr<const DimBase> create_(DIM_UNIT u)
756  {
757  switch (u)
758  {
759  case DIM_UNIT::RT:
760  return std::make_unique<DimRT>();
761  case DIM_UNIT::MZ:
762  return std::make_unique<DimMZ>();
763  case DIM_UNIT::INT:
764  return std::make_unique<DimINT>();
765  case DIM_UNIT::FAIMS_CV:
766  case DIM_UNIT::IM_MS:
767  case DIM_UNIT::IM_VSSC:
768  return std::make_unique<DimIM>(u);
769  default:
770  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
771  }
772  }
773 
774  std::array<std::unique_ptr<const DimBase>, N_DIM> dims_;
775  };
776 
777 
780  template <int N_DIM>
781  class Area
782  {
783  public:
786 
788  Area() = delete;
789 
791  Area(const DimMapper<N_DIM>* const dims)
792  : mapper_(dims)
793  {
794  }
795 
797  Area(const Area& range) = default;
798 
800  Area& operator=(const Area& rhs)
801  {
802  // check that Dims are identical, otherwise this is very dangerous (the user probably only wanted to update the area, not change its mapping).
803  if (mapper_ != rhs.mapper_ && *mapper_ != *rhs.mapper_)
804  {
805  throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Assignment of Areas using different mappers!");
806  }
807  data_range_ = rhs.data_range_;
809  return *this;
810  }
811 
812  bool operator==(const Area& rhs) const
813  {
814  return data_range_ == rhs.data_range_
815  && visible_area_ == rhs.visible_area_
816  && (*mapper_ == *rhs.mapper_);
817  }
818  bool operator!=(const Area& rhs) const
819  {
820  return !operator==(rhs);
821  }
822 
828  const Area& setArea(const RangeAllType& data)
829  {
830  data_range_ = data;
831  // update axis view using dims
832  visible_area_ = mapper_->mapRange(data);
833  return *this;
834  }
835 
841  const Area& setArea(const AreaXYType& data)
842  {
843  visible_area_ = data;
844  // update range view from XY area using dims
846  return *this;
847  }
848 
849  const AreaXYType& getAreaXY() const
850  {
851  return visible_area_;
852  }
853 
854  const RangeAllType& getAreaUnit() const
855  {
856  return data_range_;
857  }
858 
864  Area cloneWith(const AreaXYType& data) const
865  {
866  Area clone(*this);
867  clone.setArea(data);
868  return clone;
869  }
870 
876  Area cloneWith(const RangeAllType& data) const
877  {
878  Area clone(*this);
879  clone.setArea(data);
880  return clone;
881  }
882 
887  void pushInto(const RangeAllType& sandbox)
888  {
889  auto a = data_range_;
890  a.pushInto(sandbox);
891  setArea(a);
892  }
893 
894  private:
895  /* two sides of the same coin... */
898  const DimMapper<N_DIM>* mapper_;
900  };
901 
902 } // 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:727
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:519
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:563
std::string_view DIM_NAMES_SHORT[(int) DIM_UNIT::SIZE_OF_DIM_UNITS]
Definition: CommonEnums.h:56
ValueType map(const MobilityPeak2D &p) const override
Definition: DimMapper.h:306
ValueType map(const Peak2D &p) const override
Definition: DimMapper.h:290
A more convenient string class.
Definition: String.h:58
DimINT()
Definition: DimMapper.h:382
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:350
AreaXYType visible_area_
Definition: DimMapper.h:897
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:362
ValueType map(const ChromatogramPeak &p) const override
Definition: DimMapper.h:397
const Area & setArea(const AreaXYType &data)
Set the area using axis data (X and Y)
Definition: DimMapper.h:841
ValueType map(const BaseFeature &) const override
Definition: DimMapper.h:542
std::string_view getDimName() const
Name of the dimension, e.g. &#39;RT [s]&#39;.
Definition: DimMapper.h:138
ValueType map(const Mobilogram &mb, const Size index) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:537
void fromXY(const ValueType, Peak1D &) const override
set the RT of a Peak1D (throws)
Definition: DimMapper.h:254
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:580
ValueType map(const Peak1D &p) const override
Definition: DimMapper.h:286
DIM_UNIT unit_
the unit of this dimension
Definition: DimMapper.h:169
ValueType map(const Mobilogram &, const Size) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:315
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:389
ValueTypes map(const MSSpectrum &) const override
Definition: DimMapper.h:510
const Area & setArea(const RangeAllType &data)
Set the area using unit data (RT, m/z, ...)
Definition: DimMapper.h:828
Allows dynamical switching (at runtime) between a dimension (RT, m/z, int, IM, etc) and X...
Definition: DimMapper.h:607
DimRT()
Definition: DimMapper.h:177
void pushInto(const RangeAllType &sandbox)
Push the area into a sandbox (if its outside the sandbox). See UnitRange::pushInto() ...
Definition: DimMapper.h:887
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:384
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:94
ValueType map(const ChromatogramPeak &p) const override
Definition: DimMapper.h:192
Area()=delete
No default C&#39;tor.
ValueType map(const Peak2D &p) const override
Definition: DimMapper.h:188
const RangeAllType & getAreaUnit() const
Definition: DimMapper.h:854
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:616
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:569
void fromXY(const ValueType in, ChromatogramPeak &p) const override
set the intensity of a ChromatogramPeak
Definition: DimMapper.h:472
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:401
void fromXY(const ValueType in, MobilityPeak2D &p) const override
set the intensity of a MobilityPeak2D
Definition: DimMapper.h:482
DimMZ()
Definition: DimMapper.h:279
ValueType map(const PeptideIdentification &) const override
Definition: DimMapper.h:547
ValueType map(const PeptideIdentification &pi) const override
Definition: DimMapper.h:238
ValueType map(const MSSpectrum &spec, const Size index) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:414
ValueType map(const Peak2D &) const override
Definition: DimMapper.h:502
DimMapper & operator=(const DimMapper &rhs)
Assignment operator.
Definition: DimMapper.h:637
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:179
ValueType map(const MobilityPeak2D &) const override
Definition: DimMapper.h:228
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:498
Area & operator=(const Area &rhs)
Assignment operator - which checks for identical DimMappers and throws otherwise. ...
Definition: DimMapper.h:800
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:506
double getMax() const
only useful if isEmpty() returns false
Definition: RangeManager.h:140
std::unique_ptr< DimBase > clone() const override
Copy derived objects to avoid slicing when dealing with pointers to DimBase.
Definition: DimMapper.h:281
A basic LC-MS feature.
Definition: BaseFeature.h:58
ValueType map(const BaseFeature &bf) const override
Definition: DimMapper.h:233
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:575
void fromXY(const Point &in, T &out) const
Definition: DimMapper.h:725
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:552
RangeAllType fromXY(const Point &in) const
Definition: DimMapper.h:736
Definition: DimMapper.h:379
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:345
DimMapper(const DimMapper &rhs)
Copy C&#39;tor.
Definition: DimMapper.h:631
static std::unique_ptr< const DimBase > create_(DIM_UNIT u)
a minimal factory
Definition: DimMapper.h:755
void fromXY(const Point &in, RangeManager< Ranges... > &output) const
Definition: DimMapper.h:713
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:260
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:409
auto & assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:635
Point map(const T &data) const
convert an OpenMS datatype (such as Feature) to an N_DIM-dimensional point
Definition: DimMapper.h:662
static String prefix(const String &this_s, size_t length)
Definition: StringUtilsSimple.h:147
ValueType map(const MobilityPeak1D &) const override
Definition: DimMapper.h:224
bool operator!=(const Area &rhs) const
Definition: DimMapper.h:818
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:460
ValueType map(const Mobilogram &mb, const Size index) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:418
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:270
Representation of a coordinate in D-dimensional space.
Definition: DPosition.h:53
ValueType map(const BaseFeature &bf) const override
Definition: DimMapper.h:335
ValueTypes map(const MSChromatogram &) const override
Definition: DimMapper.h:514
bool operator==(const DimMapper &rhs) const
Equality.
Definition: DimMapper.h:644
Base class for a simple range with minimum and maximum.
Definition: RangeManager.h:58
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:557
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:747
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:876
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:373
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:670
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:298
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition: MobilityPeak2D.h:170
ValueType map(const PeptideIdentification &pi) const override
Definition: DimMapper.h:340
std::vector< ValueType > ValueTypes
Definition: DimMapper.h:70
ValueTypes map(const MSChromatogram &chrom) const override
Definition: DimMapper.h:209
ValueType map(const PeptideIdentification &) const override
Definition: DimMapper.h:450
bool operator!=(const DimMapper &rhs) const
Inequality.
Definition: DimMapper.h:655
std::array< std::unique_ptr< const DimBase >, N_DIM > dims_
mappers for the X,Y,Z... dimension
Definition: DimMapper.h:774
ValueType map(const MSSpectrum &spec, const Size) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:533
FAIMS compensation voltage.
DIM
Definition: DimMapper.h:589
void setRange(const RangeBase &in, RangeAllType &out) const override
Set the min/max (range) in out for a certain dimension.
Definition: DimMapper.h:248
ion mobility milliseconds
Definition: DimMapper.h:174
ValueTypes map(const MSChromatogram &) const override
Definition: DimMapper.h:330
ValueType map(const MobilityPeak2D &p) const override
Definition: DimMapper.h:528
ValueTypes map(const MSSpectrum &spec) const override
Definition: DimMapper.h:320
ValueType map(const MSSpectrum &spec, const Size index) const override
obtain value from a certain point in a spectrum
Definition: DimMapper.h:311
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:210
ValueType map(const MobilityPeak1D &p) const override
Definition: DimMapper.h:405
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:423
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:144
ValueType map(const Peak2D &p) const override
Definition: DimMapper.h:393
void fromXY(const ValueType, MobilityPeak1D &) const override
set the MZ of a MobilityPeak1D (throws)
Definition: DimMapper.h:368
DIM_UNIT getUnit() const
The unit of the dimension.
Definition: DimMapper.h:150
ValueType map(const BaseFeature &bf) const override
Definition: DimMapper.h:445
ValueType map(const MobilityPeak1D &p) const override
Definition: DimMapper.h:524
const DimMapper< N_DIM > * mapper_
and a mapper (non-owning pointer) to translate between the two
Definition: DimMapper.h:899
Definition: DimMapper.h:276
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:196
double getMin() const
only useful if isEmpty() returns false
Definition: RangeManager.h:134
Definition: DimMapper.h:781
DimMapper()=delete
No default c&#39;tor (we need dimensions)
ValueType map(const ChromatogramPeak &) const override
Definition: DimMapper.h:294
void fromXY(const ValueType in, Peak1D &p) const override
set the intensity of a Peak1D
Definition: DimMapper.h:466
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:849
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:205
ValueType map(const Mobilogram &mb, const Size) const override
obtain value from a certain point in a mobilogram
Definition: DimMapper.h:200
void fromXY(const ValueType in, Peak1D &p) const override
set the MZ of a Peak1D
Definition: DimMapper.h:356
Area(const DimMapper< N_DIM > *const dims)
Custom C&#39;tor with a mapper (non owning pointer)
Definition: DimMapper.h:791
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:455
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:771
RangeBase map(const RangeAllType &rm) const override
Return the min/max (range) for a certain dimension.
Definition: DimMapper.h:243
ValueTypes map(const MSChromatogram &chrom) const override
Definition: DimMapper.h:434
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:53
bool operator==(const Area &rhs) const
Definition: DimMapper.h:812
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:491
ValueType map(const MobilityPeak1D &) const override
Definition: DimMapper.h:302
void fromXY(const DRange< N_DIM > &in, RangeManager< Ranges... > &output) const
Definition: DimMapper.h:698
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:680
ValueType map(const MSExperiment::ConstAreaIterator &it) const override
Definition: DimMapper.h:220
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:493
RangeAllType data_range_
range in units
Definition: DimMapper.h:896
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:477
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:265
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:184
Definition: DimMapper.h:488
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:864
PositionType const & minPosition() const
Accessor to minimum position.
Definition: DIntervalBase.h:124