OpenMS
NeutralLossDiffFilter.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 
13 #include <map>
14 #include <cmath>
15 
16 namespace OpenMS
17 {
25  class OPENMS_DLLAPI NeutralLossDiffFilter :
26  public FilterFunctor
27  {
28 public:
29 
30  // @name Constructors and Destructors
31  // @{
34 
37 
40  // @}
41 
42  // @name Operators
43  // @{
46  // @}
47 
48  // @name Accessors
49  // @{
51  static FilterFunctor * create() { return new NeutralLossDiffFilter(); }
52 
54  template <typename SpectrumType>
55  double apply(SpectrumType & spectrum)
56  {
57  double tolerance = (double)param_.getValue("tolerance");
58  double isodiff = 0;
59  //iterate over all peaks
60  for (int i = 0; i < (int)spectrum.size(); ++i)
61  {
62  for (int j = 1; i - j >= 0; ++j)
63  {
64  double pos_diff = std::fabs(spectrum[i - j].getPosition()[0] - spectrum[i].getPosition()[0]);
65  if (std::fabs(pos_diff - 18) < tolerance || std::fabs(pos_diff - 17) < tolerance) // water and ammonium
66  {
67  isodiff += spectrum[i - j].getIntensity() + spectrum[i].getIntensity();
68  }
69  else
70  {
71  if (pos_diff > 18 + tolerance)
72  {
73  break;
74  }
75  }
76  }
77  }
78 
79  return isodiff;
80  }
81 
83  static const String getProductName()
84  {
85  return "NeutralLossDiffFilter";
86  }
87 
88  // @}
89 
90  };
91 }
A FilterFunctor extracts some spectrum characteristics for quality assessment.
Definition: FilterFunctor.h:20
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
NeutralLossDiffFilter returns the total intensity ob peak pairs whose m/z difference can be explained...
Definition: NeutralLossDiffFilter.h:27
NeutralLossDiffFilter(const NeutralLossDiffFilter &source)
copy constructor
static FilterFunctor * create()
Definition: NeutralLossDiffFilter.h:51
~NeutralLossDiffFilter() override
destructor
NeutralLossDiffFilter & operator=(const NeutralLossDiffFilter &source)
assignment operator
double apply(SpectrumType &spectrum)
Definition: NeutralLossDiffFilter.h:55
NeutralLossDiffFilter()
default constructor
static const String getProductName()
Definition: NeutralLossDiffFilter.h:83
A more convenient string class.
Definition: String.h:34
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22