OpenMS
Scaler.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Mathias Walzer $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 //
9 #pragma once
10 
15 
16 #include <map>
17 
18 namespace OpenMS
19 {
25  class OPENMS_DLLAPI Scaler :
26  public DefaultParamHandler
27  {
28 public:
29 
30  // @name Constructors and Destructors
31  // @{
33  Scaler();
35  ~Scaler() override;
36 
38  Scaler(const Scaler & source);
40  Scaler & operator=(const Scaler & source);
41 
42  // @}
43 
44  // @name Accessors
45  // @{
46 
47  template <typename SpectrumType>
48  void filterSpectrum(SpectrumType & spectrum)
49  {
50  if (spectrum.empty()) return;
51 
52  spectrum.sortByIntensity();
53  typename SpectrumType::size_type count = spectrum.size();
54  ++count;
55  typename SpectrumType::PeakType::IntensityType last_int = 0.0;
56  typename SpectrumType::Iterator it = spectrum.end();
57  do
58  {
59  --it;
60  if (it->getIntensity() != last_int)
61  {
62  --count;
63  }
64  last_int = it->getIntensity();
65  it->setIntensity(count);
66  }
67  while (it != spectrum.begin());
68  }
69 
70  void filterPeakSpectrum(PeakSpectrum & spectrum);
71 
72  void filterPeakMap(PeakMap & exp);
73 
74  //TODO reimplement DefaultParamHandler::updateMembers_() when introducing member variables
75 
76  // @}
77 
78  };
79 
80 }
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
ContainerType::iterator Iterator
Mutable iterator.
Definition: MSSpectrum.h:108
void sortByIntensity(bool reverse=false)
Lexicographically sorts the peaks by their intensity.
float IntensityType
Intensity type.
Definition: Peak1D.h:36
Scaler scales the peak by ranking the peaks and assigning intensity according to rank.
Definition: Scaler.h:27
void filterPeakSpectrum(PeakSpectrum &spectrum)
void filterPeakMap(PeakMap &exp)
Scaler()
default constructor
~Scaler() override
destructor
Scaler & operator=(const Scaler &source)
assignment operator
void filterSpectrum(SpectrumType &spectrum)
Definition: Scaler.h:48
Scaler(const Scaler &source)
copy constructor
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22