OpenMS  2.4.0
IsoSpecWrapper.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-2018.
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: Hannes Rost $
32 // $Authors: Hannes Rost, Michał Startek, Mateusz Łącki $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <vector>
38 
39 #include <OpenMS/CONCEPT/Types.h>
42 
43 #include <OpenMS/KERNEL/Peak1D.h>
44 
47 
48 
49 // Override IsoSpec's use of mmap whenever it is available
50 #define ISOSPEC_GOT_SYSTEM_MMAN false
51 #define ISOSPEC_GOT_MMAN false
52 
53 #include <OpenMS/../../thirdparty/IsoSpec/IsoSpec/isoSpec++.h>
54 
55 
56 namespace OpenMS
57 {
58 
71  class OPENMS_DLLAPI IsoSpecGeneratorWrapper
72  {
77 public:
78 
99  virtual bool nextConf() = 0;
100 
108  virtual Peak1D getConf() = 0;
109 
117  virtual double getMass() = 0;
118 
126  virtual double getIntensity() = 0;
127 
138  virtual double getLogIntensity() = 0;
139 
143  virtual inline ~IsoSpecGeneratorWrapper() {};
144  };
145 
146 
147 
149  {
171 public:
186  IsoSpecTotalProbGeneratorWrapper(const std::vector<int>& isotopeNumbers,
187  const std::vector<int>& atomCounts,
188  const std::vector<std::vector<double> >& isotopeMasses,
189  const std::vector<std::vector<double> >& isotopeProbabilities,
190  double p,
191  bool do_p_trim = false);
192 
197  IsoSpecTotalProbGeneratorWrapper(const EmpiricalFormula& formula, double p, bool do_p_trim = false);
198 
199  virtual inline bool nextConf() override final { return ILG.advanceToNextConfiguration(); };
200  virtual inline Peak1D getConf() override final { return Peak1D(ILG.mass(), ILG.prob()); };
201  virtual inline double getMass() override final { return ILG.mass(); };
202  virtual inline double getIntensity() override final { return ILG.prob(); };
203  virtual inline double getLogIntensity() override final { return ILG.lprob(); };
204 
205 protected:
206  IsoSpec::IsoLayeredGenerator ILG;
207  };
208 
209 
210 
211 
213  {
236 public:
251  IsoSpecThresholdGeneratorWrapper(const std::vector<int>& isotopeNumbers,
252  const std::vector<int>& atomCounts,
253  const std::vector<std::vector<double> >& isotopeMasses,
254  const std::vector<std::vector<double> >& isotopeProbabilities,
255  double threshold,
256  bool absolute);
257 
262  IsoSpecThresholdGeneratorWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
263 
264  virtual inline bool nextConf() override final { return ITG.advanceToNextConfiguration(); };
265  virtual inline Peak1D getConf() override final { return Peak1D(ITG.mass(), ITG.prob()); };
266  virtual inline double getMass() override final { return ITG.mass(); };
267  virtual inline double getIntensity() override final { return ITG.prob(); };
268  virtual inline double getLogIntensity() override final { return ITG.lprob(); };
269 
270 
271 protected:
272  IsoSpec::IsoThresholdGenerator ITG;
273  };
274 
275 
276 
278  {
295 public:
305  IsoSpecOrderedGeneratorWrapper(const std::vector<int>& isotopeNumbers,
306  const std::vector<int>& atomCounts,
307  const std::vector<std::vector<double> >& isotopeMasses,
308  const std::vector<std::vector<double> >& isotopeProbabilities);
309 
315 
316  virtual inline bool nextConf() override final { return IOG.advanceToNextConfiguration(); };
317  virtual inline Peak1D getConf() override final { return Peak1D(IOG.mass(), IOG.prob()); };
318  virtual inline double getMass() override final { return IOG.mass(); };
319  virtual inline double getIntensity() override final { return IOG.prob(); };
320  virtual inline double getLogIntensity() override final { return IOG.lprob(); };
321 
322 protected:
323  IsoSpec::IsoOrderedGenerator IOG;
324  };
325 
326 
327  class OPENMS_DLLAPI IsoSpecWrapper
328  {
331 public:
351  virtual IsotopeDistribution run() = 0;
352 
353  virtual inline ~IsoSpecWrapper() {};
354  };
355 
356 
357  class OPENMS_DLLAPI IsoSpecTotalProbWrapper : public IsoSpecWrapper
358  {
380 public:
395  IsoSpecTotalProbWrapper(const std::vector<int>& isotopeNumbers,
396  const std::vector<int>& atomCounts,
397  const std::vector<std::vector<double> >& isotopeMasses,
398  const std::vector<std::vector<double> >& isotopeProbabilities,
399  double p,
400  bool do_p_trim = false);
401 
406  IsoSpecTotalProbWrapper(const EmpiricalFormula& formula, double p, bool do_p_trim = false);
407 
408  virtual IsotopeDistribution run() override final;
409 
410 protected:
411  IsoSpec::IsoLayeredGenerator ILG;
412 
413  };
414 
415  class OPENMS_DLLAPI IsoSpecThresholdWrapper : public IsoSpecWrapper
416  {
438 public:
453  IsoSpecThresholdWrapper(const std::vector<int>& isotopeNumbers,
454  const std::vector<int>& atomCounts,
455  const std::vector<std::vector<double> >& isotopeMasses,
456  const std::vector<std::vector<double> >& isotopeProbabilities,
457  double threshold,
458  bool absolute);
459 
464  IsoSpecThresholdWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
465 
466  virtual IsotopeDistribution run() override final;
467 
468 protected:
469  IsoSpec::IsoThresholdGenerator ITG;
470 
471  };
472 
473 
474 }
475 
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:318
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:267
Definition: IsoSpecWrapper.h:212
virtual bool nextConf() override final
Interface for the IsoSpec algorithm - a generator of infinitely-resolved theoretical spectra...
Definition: IsoSpecWrapper.h:199
Definition: IsotopeDistribution.h:72
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:265
IsoSpec::IsoThresholdGenerator ITG
Definition: IsoSpecWrapper.h:469
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
virtual bool nextConf() override final
Interface for the IsoSpec algorithm - a generator of infinitely-resolved theoretical spectra...
Definition: IsoSpecWrapper.h:264
Definition: IsoSpecWrapper.h:277
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:317
Definition: IsoSpecWrapper.h:148
Representation of an empirical formula.
Definition: EmpiricalFormula.h:81
virtual ~IsoSpecGeneratorWrapper()
Destructor.
Definition: IsoSpecWrapper.h:143
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:200
virtual bool nextConf() override final
Interface for the IsoSpec algorithm - a generator of infinitely-resolved theoretical spectra...
Definition: IsoSpecWrapper.h:316
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:266
Definition: IsoSpecWrapper.h:357
Definition: IsoSpecWrapper.h:415
virtual ~IsoSpecWrapper()
Definition: IsoSpecWrapper.h:353
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:202
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:201
Interface to the IsoSpec algorithm.
Definition: IsoSpecWrapper.h:71
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:319
IsoSpec::IsoLayeredGenerator ILG
Definition: IsoSpecWrapper.h:411
Definition: IsoSpecWrapper.h:327