OpenMS  2.6.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-2020.
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 #define ISOSPEC_BUILDING_OPENMS true
53 
54 #include <OpenMS/../../thirdparty/IsoSpec/IsoSpec/isoSpec++.h>
55 
56 namespace OpenMS
57 {
58 
87  class OPENMS_DLLAPI IsoSpecGeneratorWrapper
88  {
89 
90 public:
91 
102  virtual bool nextConf() = 0;
103 
111  virtual Peak1D getConf() = 0;
112 
120  virtual double getMass() = 0;
121 
129  virtual double getIntensity() = 0;
130 
141  virtual double getLogIntensity() = 0;
142 
146  virtual inline ~IsoSpecGeneratorWrapper() {};
147  };
148 
152  class OPENMS_DLLAPI IsoSpecWrapper
153  {
154 public:
176  virtual IsotopeDistribution run() = 0;
177 
178  virtual inline ~IsoSpecWrapper() {};
179  };
180 
181  //--------------------------------------------------------------------------
182  // IsoSpecGeneratorWrapper classes
183  //--------------------------------------------------------------------------
184 
212  {
213 public:
227  IsoSpecTotalProbGeneratorWrapper(const std::vector<int>& isotopeNumbers,
228  const std::vector<int>& atomCounts,
229  const std::vector<std::vector<double> >& isotopeMasses,
230  const std::vector<std::vector<double> >& isotopeProbabilities,
231  double p);
232 
237  IsoSpecTotalProbGeneratorWrapper(const EmpiricalFormula& formula, double p);
238 
239  virtual inline bool nextConf() override final { return ILG.advanceToNextConfiguration(); };
240  virtual inline Peak1D getConf() override final { return Peak1D(ILG.mass(), ILG.prob()); };
241  virtual inline double getMass() override final { return ILG.mass(); };
242  virtual inline double getIntensity() override final { return ILG.prob(); };
243  virtual inline double getLogIntensity() override final { return ILG.lprob(); };
244 
245 protected:
246  IsoSpec::IsoLayeredGenerator ILG;
247  };
248 
271  {
272 
273 public:
288  IsoSpecThresholdGeneratorWrapper(const std::vector<int>& isotopeNumbers,
289  const std::vector<int>& atomCounts,
290  const std::vector<std::vector<double> >& isotopeMasses,
291  const std::vector<std::vector<double> >& isotopeProbabilities,
292  double threshold,
293  bool absolute);
294 
299  IsoSpecThresholdGeneratorWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
300 
301  virtual inline bool nextConf() override final { return ITG.advanceToNextConfiguration(); };
302  virtual inline Peak1D getConf() override final { return Peak1D(ITG.mass(), ITG.prob()); };
303  virtual inline double getMass() override final { return ITG.mass(); };
304  virtual inline double getIntensity() override final { return ITG.prob(); };
305  virtual inline double getLogIntensity() override final { return ITG.lprob(); };
306 
307 
308 protected:
309  IsoSpec::IsoThresholdGenerator ITG;
310  };
311 
329  {
330 public:
340  IsoSpecOrderedGeneratorWrapper(const std::vector<int>& isotopeNumbers,
341  const std::vector<int>& atomCounts,
342  const std::vector<std::vector<double> >& isotopeMasses,
343  const std::vector<std::vector<double> >& isotopeProbabilities);
344 
350 
351  virtual inline bool nextConf() override final { return IOG.advanceToNextConfiguration(); };
352  virtual inline Peak1D getConf() override final { return Peak1D(IOG.mass(), IOG.prob()); };
353  virtual inline double getMass() override final { return IOG.mass(); };
354  virtual inline double getIntensity() override final { return IOG.prob(); };
355  virtual inline double getLogIntensity() override final { return IOG.lprob(); };
356 
357 protected:
358  IsoSpec::IsoOrderedGenerator IOG;
359  };
360 
361  //--------------------------------------------------------------------------
362  // IsoSpecWrapper classes
363  //--------------------------------------------------------------------------
364 
386  class OPENMS_DLLAPI IsoSpecTotalProbWrapper : public IsoSpecWrapper
387  {
388 public:
403  IsoSpecTotalProbWrapper(const std::vector<int>& isotopeNumbers,
404  const std::vector<int>& atomCounts,
405  const std::vector<std::vector<double> >& isotopeMasses,
406  const std::vector<std::vector<double> >& isotopeProbabilities,
407  double p,
408  bool do_p_trim = false);
409 
414  IsoSpecTotalProbWrapper(const EmpiricalFormula& formula, double p, bool do_p_trim = false);
415 
416  virtual IsotopeDistribution run() override final;
417 
418 protected:
419  IsoSpec::IsoLayeredGenerator ILG;
420  const double target_prob;
421  const bool do_p_trim;
422  };
423 
444  class OPENMS_DLLAPI IsoSpecThresholdWrapper : public IsoSpecWrapper
445  {
446 
447 public:
462  IsoSpecThresholdWrapper(const std::vector<int>& isotopeNumbers,
463  const std::vector<int>& atomCounts,
464  const std::vector<std::vector<double> >& isotopeMasses,
465  const std::vector<std::vector<double> >& isotopeProbabilities,
466  double threshold,
467  bool absolute);
468 
473  IsoSpecThresholdWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
474 
475  virtual IsotopeDistribution run() override final;
476 
477 protected:
478  IsoSpec::IsoThresholdGenerator ITG;
479 
480  };
481 
482 }
483 
OpenMS::IsoSpecOrderedGeneratorWrapper::getConf
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:352
OpenMS::IsoSpecTotalProbGeneratorWrapper::getConf
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:240
OpenMS::IsoSpecWrapper::~IsoSpecWrapper
virtual ~IsoSpecWrapper()
Definition: IsoSpecWrapper.h:178
Types.h
OpenMS::IsoSpecTotalProbGeneratorWrapper::nextConf
virtual bool nextConf() override final
Move the generator to a next isotopologue.
Definition: IsoSpecWrapper.h:239
OpenMS::IsoSpecThresholdGeneratorWrapper::getIntensity
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:304
Peak1D.h
OpenMS::IsoSpecOrderedGeneratorWrapper::getIntensity
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:354
OpenMS::IsoSpecTotalProbGeneratorWrapper::getIntensity
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:242
OpenMS::IsoSpecWrapper
A convenience class for the IsoSpec algorithm - easier to use than the IsoSpecGeneratorWrapper classe...
Definition: IsoSpecWrapper.h:152
OpenMS::IsoSpecThresholdWrapper
A non-generator version of IsoSpecThresholdGeneratorWrapper.
Definition: IsoSpecWrapper.h:444
Constants.h
OpenMS::IsoSpecThresholdGeneratorWrapper
Provides a threshold-based generator of isotopologues: generates all isotopologues more probable than...
Definition: IsoSpecWrapper.h:270
OpenMS::IsoSpecThresholdGeneratorWrapper::getConf
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:302
OpenMS::IsoSpecTotalProbGeneratorWrapper
Generate a p-set of configurations for a given p (that is, a set of configurations such that their pr...
Definition: IsoSpecWrapper.h:211
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::IsoSpecTotalProbGeneratorWrapper::getMass
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:241
Exception.h
OpenMS::IsoSpecThresholdGeneratorWrapper::getMass
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:303
IsotopeDistribution.h
OpenMS::IsoSpecOrderedGeneratorWrapper::nextConf
virtual bool nextConf() override final
Move the generator to a next isotopologue.
Definition: IsoSpecWrapper.h:351
OpenMS::IsoSpecTotalProbWrapper::do_p_trim
const bool do_p_trim
Definition: IsoSpecWrapper.h:421
OpenMS::IsoSpecTotalProbWrapper::ILG
IsoSpec::IsoLayeredGenerator ILG
Definition: IsoSpecWrapper.h:419
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
OpenMS::IsoSpecOrderedGeneratorWrapper::getMass
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:353
EmpiricalFormula.h
OpenMS::IsotopeDistribution
Definition: IsotopeDistribution.h:64
OpenMS::EmpiricalFormula
Representation of an empirical formula.
Definition: EmpiricalFormula.h:82
OpenMS::IsoSpecThresholdWrapper::ITG
IsoSpec::IsoThresholdGenerator ITG
Definition: IsoSpecWrapper.h:478
OpenMS::IsoSpecThresholdGeneratorWrapper::nextConf
virtual bool nextConf() override final
Move the generator to a next isotopologue.
Definition: IsoSpecWrapper.h:301
OpenMS::IsoSpecOrderedGeneratorWrapper
Generate the stream of configurations, ordered from most likely to least likely.
Definition: IsoSpecWrapper.h:328
OpenMS::IsoSpecGeneratorWrapper
Interface for the IsoSpec algorithm - a generator of infinitely-resolved theoretical spectra.
Definition: IsoSpecWrapper.h:87
OpenMS::IsoSpecTotalProbWrapper
Create a p-set of configurations for a given p (that is, a set of configurations such that their prob...
Definition: IsoSpecWrapper.h:386
OpenMS::IsoSpecGeneratorWrapper::~IsoSpecGeneratorWrapper
virtual ~IsoSpecGeneratorWrapper()
Destructor.
Definition: IsoSpecWrapper.h:146
OpenMS::IsoSpecTotalProbWrapper::target_prob
const double target_prob
Definition: IsoSpecWrapper.h:420