OpenMS  3.0.0
IsotopeWavelet.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2022.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg$
32 // $Authors: $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 
41 namespace OpenMS
42 {
50  class OPENMS_DLLAPI IsotopeWavelet
51  {
52 public:
53 
55  static IsotopeWavelet * init(const double max_m, const UInt max_charge);
56 
59  {
60  return me_;
61  }
62 
64  static void destroy();
65 
66 
77  static double getValueByMass(const double t, const double m, const UInt z, const Int mode = +1)
78  {
79  return getValueByLambda(getLambdaL(m * z - z * mode * Constants::IW_PROTON_MASS), t * z + 1);
80  }
81 
91  static double getValueByLambda(const double lambda, const double tz1);
92 
106  static double getValueByLambdaExtrapol(const double lambda, const double tz1);
107 
108  static double getValueByLambdaExact(const double lambda, const double tz1);
109 
110 
113  {
114  return max_charge_;
115  }
116 
118  static void setMaxCharge(const UInt max_charge)
119  {
120  max_charge_ = max_charge;
121  }
122 
128  static double getTableSteps()
129  {
130  return table_steps_;
131  }
132 
138  static double getInvTableSteps()
139  {
140  return inv_table_steps_;
141  }
142 
144  static void setTableSteps(const double table_steps)
145  {
146  inv_table_steps_ = 1. / table_steps;
147  table_steps_ = table_steps;
148  }
149 
151  static double getLambdaL(const double m);
152 
153 
159  static const IsotopeDistribution::ContainerType & getAveragine(const double m, UInt * size = nullptr);
160 
161 
164  {
165  return gamma_table_max_index_;
166  }
167 
170  {
171  return exp_table_max_index_;
172  }
173 
176  static float myPow(float a, float b);
177 
178  static UInt getMzPeakCutOffAtMonoPos(const double mass, const UInt z);
179 
180  static UInt getNumPeakCutOff(const double mass, const UInt z);
181 
182  static UInt getNumPeakCutOff(const double mz);
183 
184 
185 protected:
186 
188  static IsotopeWavelet * me_;
189 
191  IsotopeWavelet();
192 
196  IsotopeWavelet(const double max_m, const UInt max_charge);
197 
198 
200  virtual ~IsotopeWavelet();
201 
202 
212  static void preComputeExpensiveFunctions_(const double max_m);
213 
214 
217  static void computeIsotopeDistributionSize_(const double max_m);
218 
219 
224  static float myPow2_(float i);
225 
230  static float myLog2_(float i);
231 
233  union fi_
234  {
236  float f;
237  };
238 
241 
243  static double table_steps_;
244  static double inv_table_steps_;
245 
247  static std::vector<double> gamma_table_;
248  static std::vector<double> gamma_table_new_;
249 
251  static std::vector<double> exp_table_;
252 
254  static std::vector<double> sine_table_;
255 
259 
262 
263  };
264 
265 } //namespace
266 
OpenMS::IsotopeDistribution::ContainerType
std::vector< MassAbundance > ContainerType
Definition: IsotopeDistribution.h:72
OpenMS::IsotopeWavelet::fi_
Internal union for fast computation of the power function.
Definition: IsotopeWavelet.h:233
OpenMS::IsotopeWavelet::getExpTableMaxIndex
static Size getExpTableMaxIndex()
Returns the largest possible index for the pre-sampled exp table.
Definition: IsotopeWavelet.h:169
OpenMS::IsotopeWavelet::table_steps_
static double table_steps_
Definition: IsotopeWavelet.h:243
OpenMS::IsotopeWavelet::getInstance
static IsotopeWavelet * getInstance()
Definition: IsotopeWavelet.h:58
OpenMS::IsotopeWavelet::gamma_table_new_
static std::vector< double > gamma_table_new_
Definition: IsotopeWavelet.h:248
OpenMS::IsotopeWavelet::exp_table_max_index_
static Size exp_table_max_index_
Definition: IsotopeWavelet.h:261
OpenMS::IsotopeWavelet
Implements the isotope wavelet function.
Definition: IsotopeWavelet.h:50
OpenMS::IsotopeWavelet::getValueByMass
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:77
OpenMS::CoarseIsotopePatternGenerator
Isotope pattern generator for coarse isotope distributions.
Definition: CoarseIsotopePatternGenerator.h:103
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::IsotopeWavelet::fi_::f
float f
Definition: IsotopeWavelet.h:236
OpenMS::IsotopeWavelet::getGammaTableMaxIndex
static Size getGammaTableMaxIndex()
Returns the largest possible index for the pre-sampled gamma table.
Definition: IsotopeWavelet.h:163
OpenMS::IsotopeWavelet::max_charge_
static UInt max_charge_
Definition: IsotopeWavelet.h:240
OpenMS::IsotopeWavelet::fi_::i
Int i
Definition: IsotopeWavelet.h:235
OpenMS::Constants::IW_PROTON_MASS
const double IW_PROTON_MASS
Definition: IsotopeWaveletConstants.h:68
OpenMS::IsotopeWavelet::getMaxCharge
static UInt getMaxCharge()
Returns the largest charge state we will consider.
Definition: IsotopeWavelet.h:112
OpenMS::IsotopeWavelet::getTableSteps
static double getTableSteps()
Returns the table_steps_ parameter.
Definition: IsotopeWavelet.h:128
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::IsotopeWavelet::sine_table_
static std::vector< double > sine_table_
Definition: IsotopeWavelet.h:254
CoarseIsotopePatternGenerator.h
OpenMS::IsotopeWavelet::averagine_
static IsotopeDistribution averagine_
Definition: IsotopeWavelet.h:258
IsotopeWaveletConstants.h
OpenMS::IsotopeWavelet::me_
static IsotopeWavelet * me_
Definition: IsotopeWavelet.h:188
OpenMS::IsotopeWavelet::gamma_table_max_index_
static Size gamma_table_max_index_
Definition: IsotopeWavelet.h:260
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::IsotopeWavelet::getInvTableSteps
static double getInvTableSteps()
Returns the inv_table_steps_ parameter.
Definition: IsotopeWavelet.h:138
OpenMS::IsotopeDistribution
Definition: IsotopeDistribution.h:64
OpenMS::IsotopeWavelet::setMaxCharge
static void setMaxCharge(const UInt max_charge)
Sets the max_charge parameter.
Definition: IsotopeWavelet.h:118
OpenMS::IsotopeWavelet::setTableSteps
static void setTableSteps(const double table_steps)
Sets the table_steps parameter.
Definition: IsotopeWavelet.h:144
OpenMS::IsotopeWavelet::inv_table_steps_
static double inv_table_steps_
Definition: IsotopeWavelet.h:244
OpenMS::IsotopeWavelet::gamma_table_
static std::vector< double > gamma_table_
Definition: IsotopeWavelet.h:247
OpenMS::IsotopeWavelet::solver_
static CoarseIsotopePatternGenerator solver_
Definition: IsotopeWavelet.h:257
MSSpectrum.h
OpenMS::IsotopeWavelet::exp_table_
static std::vector< double > exp_table_
Definition: IsotopeWavelet.h:251