OpenMS
MarkerMower.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 
14 
17 
18 #include <vector>
19 #include <map>
20 
21 namespace OpenMS
22 {
28  class OPENMS_DLLAPI MarkerMower :
29  public DefaultParamHandler
30  {
31 public:
32 
33  // @name Constructors and Destructors
34  // @{
38  ~MarkerMower() override;
39 
41  MarkerMower(const MarkerMower & source);
43  MarkerMower & operator=(const MarkerMower & source);
44  // @}
45 
46  // @name Accessors
47  // @{
49  template <typename SpectrumType>
50  void filterSpectrum(SpectrumType & spectrum)
51  {
52  typedef typename SpectrumType::Iterator Iterator;
53 
54  std::map<double, int> marks;
55  for (std::vector<PeakMarker *>::const_iterator cvit = markers_.begin(); cvit != markers_.end(); ++cvit)
56  {
57  std::map<double, bool> marked;
58  (*cvit)->apply(marked, spectrum);
59  for (std::map<double, bool>::const_iterator cmit = marked.begin(); cmit != marked.end(); ++cmit)
60  {
61  if (cmit->second)
62  {
63  marks[cmit->first]++;
64  }
65  }
66  }
67 
68  for (Iterator it = spectrum.begin(); it != spectrum.end(); )
69  {
70  if (marks[it->getMZ()] > 0)
71  {
72  ++it;
73  }
74  else
75  {
76  it = spectrum.erase(it);
77  }
78  }
79  }
80 
81  void filterPeakSpectrum(PeakSpectrum & spectrum);
82 
83  void filterPeakMap(PeakMap & exp);
84 
85  static const String getProductName()
86  {
87  return "MarkerMower";
88  }
89 
91  void insertmarker(PeakMarker * peak_marker);
92 
93  //TODO reimplement DefaultParamHandler::updateMembers_()
94 
95  // @}
96 
97 private:
99  std::vector<PeakMarker *> markers_;
100 
101  };
102 }
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
MarkerMower uses PeakMarker to find peaks, those that are not marked get removed.
Definition: MarkerMower.h:30
void insertmarker(PeakMarker *peak_marker)
insert new Marker (violates the DefaultParamHandler interface)
MarkerMower & operator=(const MarkerMower &source)
assignment operator
void filterPeakSpectrum(PeakSpectrum &spectrum)
MarkerMower()
default constructor
void filterPeakMap(PeakMap &exp)
void filterSpectrum(SpectrumType &spectrum)
Definition: MarkerMower.h:50
~MarkerMower() override
destructor
std::vector< PeakMarker * > markers_
used peak markers
Definition: MarkerMower.h:99
MarkerMower(const MarkerMower &source)
copy constructor
static const String getProductName()
Definition: MarkerMower.h:85
PeakMarker marks peaks that seem to fulfill some criterion.
Definition: PeakMarker.h:23
A more convenient string class.
Definition: String.h:34
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22