OpenMS
IsotopeWavelet.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 
14 
15 namespace OpenMS
16 {
24  class OPENMS_DLLAPI IsotopeWavelet
25  {
26 public:
27 
29  static IsotopeWavelet * init(const double max_m, const UInt max_charge);
30 
33  {
34  return me_;
35  }
36 
38  static void destroy();
39 
40 
51  static double getValueByMass(const double t, const double m, const UInt z, const Int mode = +1)
52  {
53  return getValueByLambda(getLambdaL(m * z - z * mode * Constants::IW_PROTON_MASS), t * z + 1);
54  }
55 
65  static double getValueByLambda(const double lambda, const double tz1);
66 
80  static double getValueByLambdaExtrapol(const double lambda, const double tz1);
81 
82  static double getValueByLambdaExact(const double lambda, const double tz1);
83 
84 
86  static UInt getMaxCharge()
87  {
88  return max_charge_;
89  }
90 
92  static void setMaxCharge(const UInt max_charge)
93  {
94  max_charge_ = max_charge;
95  }
96 
102  static double getTableSteps()
103  {
104  return table_steps_;
105  }
106 
112  static double getInvTableSteps()
113  {
114  return inv_table_steps_;
115  }
116 
118  static void setTableSteps(const double table_steps)
119  {
120  inv_table_steps_ = 1. / table_steps;
121  table_steps_ = table_steps;
122  }
123 
125  static double getLambdaL(const double m);
126 
127 
133  static const IsotopeDistribution::ContainerType & getAveragine(const double m, UInt * size = nullptr);
134 
135 
138  {
139  return gamma_table_max_index_;
140  }
141 
144  {
145  return exp_table_max_index_;
146  }
147 
150  static float myPow(float a, float b);
151 
152  static UInt getMzPeakCutOffAtMonoPos(const double mass, const UInt z);
153 
154  static UInt getNumPeakCutOff(const double mass, const UInt z);
155 
156  static UInt getNumPeakCutOff(const double mz);
157 
158 
159 protected:
160 
162  static IsotopeWavelet * me_;
163 
166 
170  IsotopeWavelet(const double max_m, const UInt max_charge);
171 
172 
174  virtual ~IsotopeWavelet();
175 
176 
186  static void preComputeExpensiveFunctions_(const double max_m);
187 
188 
191  static void computeIsotopeDistributionSize_(const double max_m);
192 
193 
198  static float myPow2_(float i);
199 
204  static float myLog2_(float i);
205 
207  union fi_
208  {
210  float f;
211  };
212 
215 
217  static double table_steps_;
218  static double inv_table_steps_;
219 
221  static std::vector<double> gamma_table_;
222  static std::vector<double> gamma_table_new_;
223 
225  static std::vector<double> exp_table_;
226 
228  static std::vector<double> sine_table_;
229 
233 
236 
237  };
238 
239 } //namespace
240 
Isotope pattern generator for coarse isotope distributions.
Definition: CoarseIsotopePatternGenerator.h:79
Definition: IsotopeDistribution.h:39
std::vector< MassAbundance > ContainerType
Definition: IsotopeDistribution.h:46
Implements the isotope wavelet function.
Definition: IsotopeWavelet.h:25
static double table_steps_
Definition: IsotopeWavelet.h:217
static void destroy()
static float myPow2_(float i)
Internally used function; uses register shifts for fast computation of the power function....
Int i
Definition: IsotopeWavelet.h:209
static UInt max_charge_
Definition: IsotopeWavelet.h:214
virtual ~IsotopeWavelet()
Destructor.
static IsotopeDistribution averagine_
Definition: IsotopeWavelet.h:232
static double getValueByLambdaExtrapol(const double lambda, const double tz1)
Returns the value of the isotope wavelet at position t. This function is usually significantly slower...
static UInt getNumPeakCutOff(const double mass, const UInt z)
static double getValueByLambdaExact(const double lambda, const double tz1)
static std::vector< double > gamma_table_
Definition: IsotopeWavelet.h:221
static double inv_table_steps_
Definition: IsotopeWavelet.h:218
static IsotopeWavelet * init(const double max_m, const UInt max_charge)
static double getTableSteps()
Returns the table_steps_ parameter.
Definition: IsotopeWavelet.h:102
static UInt getMaxCharge()
Returns the largest charge state we will consider.
Definition: IsotopeWavelet.h:86
static std::vector< double > exp_table_
Definition: IsotopeWavelet.h:225
static std::vector< double > gamma_table_new_
Definition: IsotopeWavelet.h:222
static Size gamma_table_max_index_
Definition: IsotopeWavelet.h:234
static Size getGammaTableMaxIndex()
Returns the largest possible index for the pre-sampled gamma table.
Definition: IsotopeWavelet.h:137
static double getInvTableSteps()
Returns the inv_table_steps_ parameter.
Definition: IsotopeWavelet.h:112
static Size getExpTableMaxIndex()
Returns the largest possible index for the pre-sampled exp table.
Definition: IsotopeWavelet.h:143
static double getLambdaL(const double m)
Returns the mass-parameter lambda (linear fit).
IsotopeWavelet()
Default Constructor.
static double getValueByMass(const double t, const double m, const UInt z, const Int mode=+1)
Returns the value of the isotope wavelet at position t. Usually, you do not need to call this functio...
Definition: IsotopeWavelet.h:51
static void setMaxCharge(const UInt max_charge)
Sets the max_charge parameter.
Definition: IsotopeWavelet.h:92
static Size exp_table_max_index_
Definition: IsotopeWavelet.h:235
static void computeIsotopeDistributionSize_(const double max_m)
Initializes the internally used averagine model; automatically called by the public constructor.
static float myLog2_(float i)
Internally used function uses register shifts for fast computation of the power function....
static double getValueByLambda(const double lambda, const double tz1)
Returns the value of the isotope wavelet at position t via a fast table lookup. Usually,...
static const IsotopeDistribution::ContainerType & getAveragine(const double m, UInt *size=nullptr)
Computes the averagine isotopic distribution we would expect at the de-convoluted mass.
static UInt getNumPeakCutOff(const double mz)
static void setTableSteps(const double table_steps)
Sets the table_steps parameter.
Definition: IsotopeWavelet.h:118
IsotopeWavelet(const double max_m, const UInt max_charge)
Constructor.
static void preComputeExpensiveFunctions_(const double max_m)
Should be called once before values are drawn from the isotope wavelet function. The function is auto...
static CoarseIsotopePatternGenerator solver_
Definition: IsotopeWavelet.h:231
static UInt getMzPeakCutOffAtMonoPos(const double mass, const UInt z)
static IsotopeWavelet * getInstance()
Definition: IsotopeWavelet.h:32
static std::vector< double > sine_table_
Definition: IsotopeWavelet.h:228
static float myPow(float a, float b)
Internally used function; uses register shifts for fast computation of the power function.
static IsotopeWavelet * me_
Definition: IsotopeWavelet.h:162
float f
Definition: IsotopeWavelet.h:210
Internal union for fast computation of the power function.
Definition: IsotopeWavelet.h:208
int Int
Signed integer type.
Definition: Types.h:76
unsigned int UInt
Unsigned integer type.
Definition: Types.h:68
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
const double IW_PROTON_MASS
Definition: IsotopeWaveletConstants.h:42
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22