OpenMS
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-2023.
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 #include <memory>
39 
40 #include <OpenMS/CONCEPT/Types.h>
43 
44 #include <OpenMS/KERNEL/Peak1D.h>
45 
48 
49 
50 // forward declarations
51 namespace IsoSpec
52 {
53 class IsoLayeredGenerator;
54 class IsoThresholdGenerator;
55 class IsoOrderedGenerator;
56 }
57 
58 namespace OpenMS
59 {
88  class OPENMS_DLLAPI IsoSpecGeneratorWrapper
89  {
90 
91 public:
92 
103  virtual bool nextConf() = 0;
104 
112  virtual Peak1D getConf() = 0;
113 
121  virtual double getMass() = 0;
122 
130  virtual double getIntensity() = 0;
131 
142  virtual double getLogIntensity() = 0;
143 
147  virtual ~IsoSpecGeneratorWrapper() = default;
148  };
149 
155  class OPENMS_DLLAPI IsoSpecWrapper
156  {
157 public:
179  virtual IsotopeDistribution run() = 0;
180 
181  virtual inline ~IsoSpecWrapper() = default;
182  };
183 
184  //--------------------------------------------------------------------------
185  // IsoSpecGeneratorWrapper classes
186  //--------------------------------------------------------------------------
187 
215  {
216 public:
230  IsoSpecTotalProbGeneratorWrapper(const std::vector<int>& isotopeNumbers,
231  const std::vector<int>& atomCounts,
232  const std::vector<std::vector<double> >& isotopeMasses,
233  const std::vector<std::vector<double> >& isotopeProbabilities,
234  double p);
235 
243 
245 
246  bool nextConf() final;
247  Peak1D getConf() final;
248  double getMass() final;
249  double getIntensity() final;
250  double getLogIntensity() final;
251 
252 protected:
253  std::unique_ptr<IsoSpec::IsoLayeredGenerator> ILG;
254  };
255 
278  {
279 
280 public:
295  IsoSpecThresholdGeneratorWrapper(const std::vector<int>& isotopeNumbers,
296  const std::vector<int>& atomCounts,
297  const std::vector<std::vector<double> >& isotopeMasses,
298  const std::vector<std::vector<double> >& isotopeProbabilities,
299  double threshold,
300  bool absolute);
301 
302  // delete copy constructor
304 
309  IsoSpecThresholdGeneratorWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
310 
312 
313  bool nextConf() final;
314  Peak1D getConf() final;
315  double getMass() final;
316  double getIntensity() final;
317  double getLogIntensity() final;
318 
319 
320 protected:
321  std::unique_ptr<IsoSpec::IsoThresholdGenerator> ITG;
322  };
323 
342  {
343 public:
353  IsoSpecOrderedGeneratorWrapper(const std::vector<int>& isotopeNumbers,
354  const std::vector<int>& atomCounts,
355  const std::vector<std::vector<double> >& isotopeMasses,
356  const std::vector<std::vector<double> >& isotopeProbabilities);
357 
358  // delete copy constructor
365 
367 
368  inline bool nextConf() final;
369  inline Peak1D getConf() final;
370  inline double getMass() final;
371  inline double getIntensity() final;
372  inline double getLogIntensity() final;
373 
374 protected:
375  std::unique_ptr<IsoSpec::IsoOrderedGenerator> IOG;
376  };
377 
378  //--------------------------------------------------------------------------
379  // IsoSpecWrapper classes
380  //--------------------------------------------------------------------------
381 
403  class OPENMS_DLLAPI IsoSpecTotalProbWrapper : public IsoSpecWrapper
404  {
405 public:
420  IsoSpecTotalProbWrapper(const std::vector<int>& isotopeNumbers,
421  const std::vector<int>& atomCounts,
422  const std::vector<std::vector<double> >& isotopeMasses,
423  const std::vector<std::vector<double> >& isotopeProbabilities,
424  double p,
425  bool do_p_trim = false);
426 
427  // delete copy constructor
429 
434  IsoSpecTotalProbWrapper(const EmpiricalFormula& formula, double p, bool do_p_trim = false);
435 
437 
439 
440 protected:
441  std::unique_ptr<IsoSpec::IsoLayeredGenerator> ILG;
442  const double target_prob;
443  const bool do_p_trim;
444  };
445 
466  class OPENMS_DLLAPI IsoSpecThresholdWrapper : public IsoSpecWrapper
467  {
468 
469 public:
484  IsoSpecThresholdWrapper(const std::vector<int>& isotopeNumbers,
485  const std::vector<int>& atomCounts,
486  const std::vector<std::vector<double> >& isotopeMasses,
487  const std::vector<std::vector<double> >& isotopeProbabilities,
488  double threshold,
489  bool absolute);
490 
491  // delelte copy constructor
497  IsoSpecThresholdWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
498 
500 
502 
503 protected:
504  std::unique_ptr<IsoSpec::IsoThresholdGenerator> ITG;
505 
506  };
507 
508 }
509 
Representation of an empirical formula.
Definition: EmpiricalFormula.h:85
Interface for the IsoSpec algorithm - a generator of infinitely-resolved theoretical spectra.
Definition: IsoSpecWrapper.h:89
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:342
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:278
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:467
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:215
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:404
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:156
virtual IsotopeDistribution run()=0
Run the algorithm.
virtual ~IsoSpecWrapper()=default
Definition: IsotopeDistribution.h:65
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
Definition: IsoSpecWrapper.h:52
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48