OpenMS
RankScaler.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: Mathias Walzer $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 //
9 #pragma once
10 
15 
16 #include <map>
17 
18 namespace OpenMS
19 {
25  class OPENMS_DLLAPI RankScaler :
26  public DefaultParamHandler
27  {
28 public:
29 
30  // @name Constructors and Destructors
31  // @{
35  ~RankScaler() override;
36 
38  RankScaler(const RankScaler & source);
40  RankScaler & operator=(const RankScaler & 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
Scales each peak by ranking the peaks per spectrum and assigning intensity according to rank.
Definition: RankScaler.h:27
RankScaler(const RankScaler &source)
copy constructor
void filterPeakSpectrum(PeakSpectrum &spectrum)
~RankScaler() override
destructor
void filterPeakMap(PeakMap &exp)
RankScaler()
default constructor
void filterSpectrum(SpectrumType &spectrum)
Definition: RankScaler.h:48
RankScaler & operator=(const RankScaler &source)
assignment operator
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19