OpenMS
IsotopeDiffFilter.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: Timo Sachsenberg $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 //
9 #pragma once
10 
12 #include <cmath>
13 
14 namespace OpenMS
15 {
23  class OPENMS_DLLAPI IsotopeDiffFilter :
24  public FilterFunctor
25  {
26 
27 public:
28 
29  // @name Constructors and Destructors
30  // @{
33 
36 
38  ~IsotopeDiffFilter() override;
39  // @}
40 
41  // @name Operators
42  // @{
45  // @}
46 
47  // @name Accessors
48  // @{
50  static FilterFunctor * create() { return new IsotopeDiffFilter(); }
51 
53  template <typename SpectrumType>
54  double apply(SpectrumType & spectrum)
55  {
56  double tolerance = (double)param_.getValue("tolerance");
57  double isodiff = 0;
58 
59  //iterate over all peaks
60  for (Size i = 0; i < spectrum.size(); ++i)
61  {
62  for (Size j = 1; i + j < spectrum.size(); ++j)
63  {
64  double pos_ij = spectrum[i + j].getPosition()[0];
65  double pos_i = spectrum[i].getPosition()[0];
66  if (std::fabs(pos_ij - pos_i + 1) < tolerance)
67  {
68  isodiff += spectrum[i].getIntensity() + spectrum[i + j].getIntensity();
69  }
70  else
71  {
72  if (std::fabs(spectrum[i + j].getPosition()[0] - spectrum[i].getPosition()[0]) > 1 + tolerance)
73  {
74  break;
75  }
76  }
77  }
78  }
79  return isodiff;
80  }
81 
83  static const String getProductName()
84  {
85  return "IsotopeDiffFilter";
86  }
87 
88  // @}
89 
90 private:
91  };
92 }
A FilterFunctor extracts some spectrum characteristics for quality assessment.
Definition: FilterFunctor.h:20
IsotopeDiffFilter returns total intensity of peak pairs that could result from isotope peaks.
Definition: IsotopeDiffFilter.h:25
~IsotopeDiffFilter() override
destructor
IsotopeDiffFilter()
default constructor
IsotopeDiffFilter & operator=(const IsotopeDiffFilter &source)
assignment operator
static FilterFunctor * create()
Definition: IsotopeDiffFilter.h:50
IsotopeDiffFilter(const IsotopeDiffFilter &source)
copy constructor
double apply(SpectrumType &spectrum)
Definition: IsotopeDiffFilter.h:54
static const String getProductName()
Definition: IsotopeDiffFilter.h:83
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22