OpenMS
IsoSpecWrapper.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: Hannes Rost $
6 // $Authors: Hannes Rost, Michał Startek, Mateusz Łącki $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <vector>
12 #include <memory>
13 
14 #include <OpenMS/CONCEPT/Types.h>
17 
18 #include <OpenMS/KERNEL/Peak1D.h>
19 
22 
23 
24 // forward declarations
25 namespace IsoSpec
26 {
27 class IsoLayeredGenerator;
28 class IsoThresholdGenerator;
29 class IsoOrderedGenerator;
30 }
31 
32 namespace OpenMS
33 {
62  class OPENMS_DLLAPI IsoSpecGeneratorWrapper
63  {
64 
65 public:
66 
77  virtual bool nextConf() = 0;
78 
86  virtual Peak1D getConf() = 0;
87 
95  virtual double getMass() = 0;
96 
104  virtual double getIntensity() = 0;
105 
116  virtual double getLogIntensity() = 0;
117 
121  virtual ~IsoSpecGeneratorWrapper() = default;
122  };
123 
129  class OPENMS_DLLAPI IsoSpecWrapper
130  {
131 public:
153  virtual IsotopeDistribution run() = 0;
154 
155  virtual inline ~IsoSpecWrapper() = default;
156  };
157 
158  //--------------------------------------------------------------------------
159  // IsoSpecGeneratorWrapper classes
160  //--------------------------------------------------------------------------
161 
189  {
190 public:
204  IsoSpecTotalProbGeneratorWrapper(const std::vector<int>& isotopeNumbers,
205  const std::vector<int>& atomCounts,
206  const std::vector<std::vector<double> >& isotopeMasses,
207  const std::vector<std::vector<double> >& isotopeProbabilities,
208  double p);
209 
217 
219 
220  bool nextConf() final;
221  Peak1D getConf() final;
222  double getMass() final;
223  double getIntensity() final;
224  double getLogIntensity() final;
225 
226 protected:
227  std::unique_ptr<IsoSpec::IsoLayeredGenerator> ILG;
228  };
229 
252  {
253 
254 public:
269  IsoSpecThresholdGeneratorWrapper(const std::vector<int>& isotopeNumbers,
270  const std::vector<int>& atomCounts,
271  const std::vector<std::vector<double> >& isotopeMasses,
272  const std::vector<std::vector<double> >& isotopeProbabilities,
273  double threshold,
274  bool absolute);
275 
276  // delete copy constructor
278 
283  IsoSpecThresholdGeneratorWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
284 
286 
287  bool nextConf() final;
288  Peak1D getConf() final;
289  double getMass() final;
290  double getIntensity() final;
291  double getLogIntensity() final;
292 
293 
294 protected:
295  std::unique_ptr<IsoSpec::IsoThresholdGenerator> ITG;
296  };
297 
316  {
317 public:
327  IsoSpecOrderedGeneratorWrapper(const std::vector<int>& isotopeNumbers,
328  const std::vector<int>& atomCounts,
329  const std::vector<std::vector<double> >& isotopeMasses,
330  const std::vector<std::vector<double> >& isotopeProbabilities);
331 
332  // delete copy constructor
339 
341 
342  inline bool nextConf() final;
343  inline Peak1D getConf() final;
344  inline double getMass() final;
345  inline double getIntensity() final;
346  inline double getLogIntensity() final;
347 
348 protected:
349  std::unique_ptr<IsoSpec::IsoOrderedGenerator> IOG;
350  };
351 
352  //--------------------------------------------------------------------------
353  // IsoSpecWrapper classes
354  //--------------------------------------------------------------------------
355 
377  class OPENMS_DLLAPI IsoSpecTotalProbWrapper : public IsoSpecWrapper
378  {
379 public:
394  IsoSpecTotalProbWrapper(const std::vector<int>& isotopeNumbers,
395  const std::vector<int>& atomCounts,
396  const std::vector<std::vector<double> >& isotopeMasses,
397  const std::vector<std::vector<double> >& isotopeProbabilities,
398  double p,
399  bool do_p_trim = false);
400 
401  // delete copy constructor
403 
408  IsoSpecTotalProbWrapper(const EmpiricalFormula& formula, double p, bool do_p_trim = false);
409 
411 
413 
414 protected:
415  std::unique_ptr<IsoSpec::IsoLayeredGenerator> ILG;
416  const double target_prob;
417  const bool do_p_trim;
418  };
419 
440  class OPENMS_DLLAPI IsoSpecThresholdWrapper : public IsoSpecWrapper
441  {
442 
443 public:
458  IsoSpecThresholdWrapper(const std::vector<int>& isotopeNumbers,
459  const std::vector<int>& atomCounts,
460  const std::vector<std::vector<double> >& isotopeMasses,
461  const std::vector<std::vector<double> >& isotopeProbabilities,
462  double threshold,
463  bool absolute);
464 
465  // delelte copy constructor
471  IsoSpecThresholdWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
472 
474 
476 
477 protected:
478  std::unique_ptr<IsoSpec::IsoThresholdGenerator> ITG;
479 
480  };
481 
482 }
483 
Representation of an empirical formula.
Definition: EmpiricalFormula.h:59
Interface for the IsoSpec algorithm - a generator of infinitely-resolved theoretical spectra.
Definition: IsoSpecWrapper.h:63
virtual Peak1D getConf()=0
Obtain the current isotopologue.
virtual bool nextConf()=0
Move the generator to a next isotopologue.
virtual ~IsoSpecGeneratorWrapper()=default
Destructor.
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:316
bool nextConf() final
Move the generator to a next isotopologue.
IsoSpecOrderedGeneratorWrapper(const EmpiricalFormula &formula)
Setup the algorithm to run on an EmpiricalFormula.
IsoSpecOrderedGeneratorWrapper(const IsoSpecOrderedGeneratorWrapper &)=delete
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.
Provides a threshold-based generator of isotopologues: generates all isotopologues more probable than...
Definition: IsoSpecWrapper.h:252
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.
IsoSpecThresholdGeneratorWrapper(const IsoSpecThresholdGeneratorWrapper &)=delete
bool nextConf() final
Move the generator to a next isotopologue.
IsoSpecThresholdGeneratorWrapper(const EmpiricalFormula &formula, double threshold, bool absolute)
Setup the algorithm to run on an EmpiricalFormula.
A non-generator version of IsoSpecThresholdGeneratorWrapper.
Definition: IsoSpecWrapper.h:441
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.
IsotopeDistribution run() final
Run the algorithm.
IsoSpecThresholdWrapper(const EmpiricalFormula &formula, double threshold, bool absolute)
Setup the algorithm to run on an EmpiricalFormula.
IsoSpecThresholdWrapper(const IsoSpecThresholdWrapper &)=delete
Generate a p-set of configurations for a given p (that is, a set of configurations such that their pr...
Definition: IsoSpecWrapper.h:189
IsoSpecTotalProbGeneratorWrapper(const IsoSpecTotalProbGeneratorWrapper &)=delete
delete copy constructor
IsoSpecTotalProbGeneratorWrapper(const EmpiricalFormula &formula, double p)
Setup the algorithm to run on an EmpiricalFormula.
bool nextConf() final
Move the generator to a next isotopologue.
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.
Create a p-set of configurations for a given p (that is, a set of configurations such that their prob...
Definition: IsoSpecWrapper.h:378
IsoSpecTotalProbWrapper(const IsoSpecTotalProbWrapper &)=delete
IsotopeDistribution run() 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:130
virtual IsotopeDistribution run()=0
Run the algorithm.
virtual ~IsoSpecWrapper()=default
Definition: IsotopeDistribution.h:39
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:28
Definition: IsoSpecWrapper.h:26
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22