OpenMS  2.7.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-2021.
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 
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 
Representation of an empirical formula.
Definition: EmpiricalFormula.h:83
Interface for the IsoSpec algorithm - a generator of infinitely-resolved theoretical spectra.
Definition: IsoSpecWrapper.h:88
virtual Peak1D getConf()=0
Obtain the current isotopologue.
virtual ~IsoSpecGeneratorWrapper()
Destructor.
Definition: IsoSpecWrapper.h:146
virtual bool nextConf()=0
Move the generator to a next isotopologue.
virtual double getIntensity()=0
Obtain the intensity (probability, relative peak height) of the current configuration.
virtual double getLogIntensity()=0
Obtain the natural logarithm of the intensity (probability, relative peak height) of the current conf...
virtual double getMass()=0
Obtain the mass of the current isotopologue.
Generate the stream of configurations, ordered from most likely to least likely.
Definition: IsoSpecWrapper.h:329
IsoSpec::IsoOrderedGenerator IOG
Definition: IsoSpecWrapper.h:355
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:353
IsoSpecOrderedGeneratorWrapper(const EmpiricalFormula &formula)
Setup the algorithm to run on an EmpiricalFormula.
virtual bool nextConf() override final
Move the generator to a next isotopologue.
Definition: IsoSpecWrapper.h:351
IsoSpecOrderedGeneratorWrapper(const std::vector< int > &isotopeNumbers, const std::vector< int > &atomCounts, const std::vector< std::vector< double > > &isotopeMasses, const std::vector< std::vector< double > > &isotopeProbabilities)
Constructor.
virtual double getLogIntensity() override final
Obtain the natural logarithm of the intensity (probability, relative peak height) of the current conf...
Definition: IsoSpecWrapper.h:355
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:352
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:354
Provides a threshold-based generator of isotopologues: generates all isotopologues more probable than...
Definition: IsoSpecWrapper.h:271
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:303
IsoSpecThresholdGeneratorWrapper(const std::vector< int > &isotopeNumbers, const std::vector< int > &atomCounts, const std::vector< std::vector< double > > &isotopeMasses, const std::vector< std::vector< double > > &isotopeProbabilities, double threshold, bool absolute)
Constructor.
IsoSpec::IsoThresholdGenerator ITG
Definition: IsoSpecWrapper.h:305
IsoSpecThresholdGeneratorWrapper(const EmpiricalFormula &formula, double threshold, bool absolute)
Setup the algorithm to run on an EmpiricalFormula.
virtual bool nextConf() override final
Move the generator to a next isotopologue.
Definition: IsoSpecWrapper.h:301
virtual double getLogIntensity() override final
Obtain the natural logarithm of the intensity (probability, relative peak height) of the current conf...
Definition: IsoSpecWrapper.h:305
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:302
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:304
A non-generator version of IsoSpecThresholdGeneratorWrapper.
Definition: IsoSpecWrapper.h:445
IsoSpecThresholdWrapper(const std::vector< int > &isotopeNumbers, const std::vector< int > &atomCounts, const std::vector< std::vector< double > > &isotopeMasses, const std::vector< std::vector< double > > &isotopeProbabilities, double threshold, bool absolute)
Constructor.
virtual IsotopeDistribution run() override final
Run the algorithm.
IsoSpecThresholdWrapper(const EmpiricalFormula &formula, double threshold, bool absolute)
Setup the algorithm to run on an EmpiricalFormula.
Generate a p-set of configurations for a given p (that is, a set of configurations such that their pr...
Definition: IsoSpecWrapper.h:212
IsoSpec::IsoLayeredGenerator ILG
Definition: IsoSpecWrapper.h:243
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:241
IsoSpecTotalProbGeneratorWrapper(const EmpiricalFormula &formula, double p)
Setup the algorithm to run on an EmpiricalFormula.
IsoSpecTotalProbGeneratorWrapper(const std::vector< int > &isotopeNumbers, const std::vector< int > &atomCounts, const std::vector< std::vector< double > > &isotopeMasses, const std::vector< std::vector< double > > &isotopeProbabilities, double p)
Constructor.
virtual bool nextConf() override final
Move the generator to a next isotopologue.
Definition: IsoSpecWrapper.h:239
virtual double getLogIntensity() override final
Obtain the natural logarithm of the intensity (probability, relative peak height) of the current conf...
Definition: IsoSpecWrapper.h:243
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:240
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:242
Create a p-set of configurations for a given p (that is, a set of configurations such that their prob...
Definition: IsoSpecWrapper.h:387
virtual IsotopeDistribution run() override final
Run the algorithm.
IsoSpecTotalProbWrapper(const EmpiricalFormula &formula, double p, bool do_p_trim=false)
Setup the algorithm to run on an EmpiricalFormula.
IsoSpecTotalProbWrapper(const std::vector< int > &isotopeNumbers, const std::vector< int > &atomCounts, const std::vector< std::vector< double > > &isotopeMasses, const std::vector< std::vector< double > > &isotopeProbabilities, double p, bool do_p_trim=false)
Constructor.
A convenience class for the IsoSpec algorithm - easier to use than the IsoSpecGeneratorWrapper classe...
Definition: IsoSpecWrapper.h:153
virtual IsotopeDistribution run()=0
Run the algorithm.
virtual ~IsoSpecWrapper()
Definition: IsoSpecWrapper.h:178
Definition: IsotopeDistribution.h:65
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47