OpenMS  2.8.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 #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 
153  class OPENMS_DLLAPI IsoSpecWrapper
154  {
155 public:
177  virtual IsotopeDistribution run() = 0;
178 
179  virtual inline ~IsoSpecWrapper() = default;
180  };
181 
182  //--------------------------------------------------------------------------
183  // IsoSpecGeneratorWrapper classes
184  //--------------------------------------------------------------------------
185 
213  {
214 public:
228  IsoSpecTotalProbGeneratorWrapper(const std::vector<int>& isotopeNumbers,
229  const std::vector<int>& atomCounts,
230  const std::vector<std::vector<double> >& isotopeMasses,
231  const std::vector<std::vector<double> >& isotopeProbabilities,
232  double p);
233 
234  // delete copy constructor
241 
243 
244  bool nextConf() final;
245  Peak1D getConf() final;
246  double getMass() final;
247  double getIntensity() final;
248  double getLogIntensity() final;
249 
250 protected:
251  std::unique_ptr<IsoSpec::IsoLayeredGenerator> ILG;
252  };
253 
276  {
277 
278 public:
293  IsoSpecThresholdGeneratorWrapper(const std::vector<int>& isotopeNumbers,
294  const std::vector<int>& atomCounts,
295  const std::vector<std::vector<double> >& isotopeMasses,
296  const std::vector<std::vector<double> >& isotopeProbabilities,
297  double threshold,
298  bool absolute);
299 
300  // delete copy constructor
302 
307  IsoSpecThresholdGeneratorWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
308 
310 
311  bool nextConf() final;
312  Peak1D getConf() final;
313  double getMass() final;
314  double getIntensity() final;
315  double getLogIntensity() final;
316 
317 
318 protected:
319  std::unique_ptr<IsoSpec::IsoThresholdGenerator> ITG;
320  };
321 
339  {
340 public:
350  IsoSpecOrderedGeneratorWrapper(const std::vector<int>& isotopeNumbers,
351  const std::vector<int>& atomCounts,
352  const std::vector<std::vector<double> >& isotopeMasses,
353  const std::vector<std::vector<double> >& isotopeProbabilities);
354 
355  // delete copy constructor
362 
364 
365  inline bool nextConf() final;
366  inline Peak1D getConf() final;
367  inline double getMass() final;
368  inline double getIntensity() final;
369  inline double getLogIntensity() final;
370 
371 protected:
372  std::unique_ptr<IsoSpec::IsoOrderedGenerator> IOG;
373  };
374 
375  //--------------------------------------------------------------------------
376  // IsoSpecWrapper classes
377  //--------------------------------------------------------------------------
378 
400  class OPENMS_DLLAPI IsoSpecTotalProbWrapper : public IsoSpecWrapper
401  {
402 public:
417  IsoSpecTotalProbWrapper(const std::vector<int>& isotopeNumbers,
418  const std::vector<int>& atomCounts,
419  const std::vector<std::vector<double> >& isotopeMasses,
420  const std::vector<std::vector<double> >& isotopeProbabilities,
421  double p,
422  bool do_p_trim = false);
423 
424  // delete copy constructor
426 
431  IsoSpecTotalProbWrapper(const EmpiricalFormula& formula, double p, bool do_p_trim = false);
432 
434 
436 
437 protected:
438  std::unique_ptr<IsoSpec::IsoLayeredGenerator> ILG;
439  const double target_prob;
440  const bool do_p_trim;
441  };
442 
463  class OPENMS_DLLAPI IsoSpecThresholdWrapper : public IsoSpecWrapper
464  {
465 
466 public:
481  IsoSpecThresholdWrapper(const std::vector<int>& isotopeNumbers,
482  const std::vector<int>& atomCounts,
483  const std::vector<std::vector<double> >& isotopeMasses,
484  const std::vector<std::vector<double> >& isotopeProbabilities,
485  double threshold,
486  bool absolute);
487 
488  // delelte copy constructor
494  IsoSpecThresholdWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
495 
497 
499 
500 protected:
501  std::unique_ptr<IsoSpec::IsoThresholdGenerator> ITG;
502 
503  };
504 
505 }
506 
Representation of an empirical formula.
Definition: EmpiricalFormula.h:82
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:339
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:276
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:464
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:213
IsoSpecTotalProbGeneratorWrapper(const IsoSpecTotalProbGeneratorWrapper &)=delete
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:401
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:154
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:47