| OpenMS 2.5.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>
40 #include <OpenMS/CONCEPT/Constants.h>
41 #include <OpenMS/CONCEPT/Exception.h>
42
43 #include <OpenMS/KERNEL/Peak1D.h>
44
45 #include <OpenMS/CHEMISTRY/EmpiricalFormula.h>
46 #include <OpenMS/CHEMISTRY/ISOTOPEDISTRIBUTION/IsotopeDistribution.h>
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
53 #include <OpenMS/../../thirdparty/IsoSpec/IsoSpec/isoSpec++.h>
54
55 namespace OpenMS
56 {
57
86 class OPENMS_DLLAPI IsoSpecGeneratorWrapper
87 {
88
89 public:
90
101 virtual bool nextConf() = 0;
102
110 virtual Peak1D getConf() = 0;
111
119 virtual double getMass() = 0;
120
128 virtual double getIntensity() = 0;
129
140 virtual double getLogIntensity() = 0;
141
145 virtual inline ~IsoSpecGeneratorWrapper() {};
146 };
147
151 class OPENMS_DLLAPI IsoSpecWrapper
152 {
153 public:
175 virtual IsotopeDistribution run() = 0;
176
177 virtual inline ~IsoSpecWrapper() {};
178 };
179
180 //--------------------------------------------------------------------------
181 // IsoSpecGeneratorWrapper classes
182 //--------------------------------------------------------------------------
183
205 class OPENMS_DLLAPI IsoSpecTotalProbGeneratorWrapper : public IsoSpecGeneratorWrapper
206 {
207 public:
222 IsoSpecTotalProbGeneratorWrapper(const std::vector<int>& isotopeNumbers,
223 const std::vector<int>& atomCounts,
224 const std::vector<std::vector<double> >& isotopeMasses,
225 const std::vector<std::vector<double> >& isotopeProbabilities,
226 double p,
227 bool do_p_trim = false);
228
233 IsoSpecTotalProbGeneratorWrapper(const EmpiricalFormula& formula, double p, bool do_p_trim = false);
234
235 virtual inline bool nextConf() override final { return ILG.advanceToNextConfiguration(); };
236 virtual inline Peak1D getConf() override final { return Peak1D(ILG.mass(), ILG.prob()); };
237 virtual inline double getMass() override final { return ILG.mass(); };
238 virtual inline double getIntensity() override final { return ILG.prob(); };
239 virtual inline double getLogIntensity() override final { return ILG.lprob(); };
240
241 protected:
242 IsoSpec::IsoLayeredGenerator ILG;
243 };
244
266 class OPENMS_DLLAPI IsoSpecThresholdGeneratorWrapper : public IsoSpecGeneratorWrapper
267 {
268
269 public:
284 IsoSpecThresholdGeneratorWrapper(const std::vector<int>& isotopeNumbers,
285 const std::vector<int>& atomCounts,
286 const std::vector<std::vector<double> >& isotopeMasses,
287 const std::vector<std::vector<double> >& isotopeProbabilities,
288 double threshold,
289 bool absolute);
290
295 IsoSpecThresholdGeneratorWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
296
297 virtual inline bool nextConf() override final { return ITG.advanceToNextConfiguration(); };
298 virtual inline Peak1D getConf() override final { return Peak1D(ITG.mass(), ITG.prob()); };
299 virtual inline double getMass() override final { return ITG.mass(); };
300 virtual inline double getIntensity() override final { return ITG.prob(); };
301 virtual inline double getLogIntensity() override final { return ITG.lprob(); };
302
303
304 protected:
305 IsoSpec::IsoThresholdGenerator ITG;
306 };
307
324 class OPENMS_DLLAPI IsoSpecOrderedGeneratorWrapper : public IsoSpecGeneratorWrapper
325 {
326 public:
336 IsoSpecOrderedGeneratorWrapper(const std::vector<int>& isotopeNumbers,
337 const std::vector<int>& atomCounts,
338 const std::vector<std::vector<double> >& isotopeMasses,
339 const std::vector<std::vector<double> >& isotopeProbabilities);
340
345 IsoSpecOrderedGeneratorWrapper(const EmpiricalFormula& formula);
346
347 virtual inline bool nextConf() override final { return IOG.advanceToNextConfiguration(); };
348 virtual inline Peak1D getConf() override final { return Peak1D(IOG.mass(), IOG.prob()); };
349 virtual inline double getMass() override final { return IOG.mass(); };
350 virtual inline double getIntensity() override final { return IOG.prob(); };
351 virtual inline double getLogIntensity() override final { return IOG.lprob(); };
352
353 protected:
354 IsoSpec::IsoOrderedGenerator IOG;
355 };
356
357 //--------------------------------------------------------------------------
358 // IsoSpecWrapper classes
359 //--------------------------------------------------------------------------
360
382 class OPENMS_DLLAPI IsoSpecTotalProbWrapper : public IsoSpecWrapper
383 {
384 public:
399 IsoSpecTotalProbWrapper(const std::vector<int>& isotopeNumbers,
400 const std::vector<int>& atomCounts,
401 const std::vector<std::vector<double> >& isotopeMasses,
402 const std::vector<std::vector<double> >& isotopeProbabilities,
403 double p,
404 bool do_p_trim = false);
405
410 IsoSpecTotalProbWrapper(const EmpiricalFormula& formula, double p, bool do_p_trim = false);
411
412 virtual IsotopeDistribution run() override final;
413
414 protected:
415 IsoSpec::IsoLayeredGenerator ILG;
416
417 };
418
439 class OPENMS_DLLAPI IsoSpecThresholdWrapper : public IsoSpecWrapper
440 {
441
442 public:
457 IsoSpecThresholdWrapper(const std::vector<int>& isotopeNumbers,
458 const std::vector<int>& atomCounts,
459 const std::vector<std::vector<double> >& isotopeMasses,
460 const std::vector<std::vector<double> >& isotopeProbabilities,
461 double threshold,
462 bool absolute);
463
468 IsoSpecThresholdWrapper(const EmpiricalFormula& formula, double threshold, bool absolute);
469
470 virtual IsotopeDistribution run() override final;
471
472 protected:
473 IsoSpec::IsoThresholdGenerator ITG;
474
475 };
476
477 }
478
OpenMS::IsoSpecTotalProbGeneratorWrapper::getMass
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:237
Constants.h
OpenMS::IsoSpecOrderedGeneratorWrapper::getMass
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:349
OpenMS::IsoSpecOrderedGeneratorWrapper::nextConf
virtual bool nextConf() override final
Move the generator to a next isotopologue.
Definition: IsoSpecWrapper.h:347
OpenMS::IsotopeDistribution
Definition: IsotopeDistribution.h:64
OpenMS::IsoSpecTotalProbWrapper::ILG
IsoSpec::IsoLayeredGenerator ILG
Definition: IsoSpecWrapper.h:415
OpenMS::IsoSpecThresholdGeneratorWrapper::getIntensity
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:300
Exception.h
OpenMS::IsoSpecThresholdGeneratorWrapper::getConf
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:298
OpenMS::IsoSpecGeneratorWrapper
Interface for the IsoSpec algorithm - a generator of infinitely-resolved theoretical spectra...
Definition: IsoSpecWrapper.h:86
Peak1D.h
Types.h
OpenMS::IsoSpecThresholdWrapper
A non-generator version of IsoSpecThresholdGeneratorWrapper.
Definition: IsoSpecWrapper.h:439
IsotopeDistribution.h
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
OpenMS::IsoSpecThresholdGeneratorWrapper::nextConf
virtual bool nextConf() override final
Move the generator to a next isotopologue.
Definition: IsoSpecWrapper.h:297
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::IsoSpecGeneratorWrapper::~IsoSpecGeneratorWrapper
virtual ~IsoSpecGeneratorWrapper()
Destructor.
Definition: IsoSpecWrapper.h:145
OpenMS::IsoSpecOrderedGeneratorWrapper::getIntensity
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:350
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:205
OpenMS::IsoSpecThresholdWrapper::ITG
IsoSpec::IsoThresholdGenerator ITG
Definition: IsoSpecWrapper.h:473
OpenMS::IsoSpecWrapper::~IsoSpecWrapper
virtual ~IsoSpecWrapper()
Definition: IsoSpecWrapper.h:177
OpenMS::EmpiricalFormula
Representation of an empirical formula.
Definition: EmpiricalFormula.h:82
OpenMS::IsoSpecOrderedGeneratorWrapper::getConf
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:348
OpenMS::IsoSpecTotalProbGeneratorWrapper::nextConf
virtual bool nextConf() override final
Move the generator to a next isotopologue.
Definition: IsoSpecWrapper.h:235
OpenMS::IsoSpecOrderedGeneratorWrapper
Generate the stream of configurations, ordered from most likely to least likely.
Definition: IsoSpecWrapper.h:324
EmpiricalFormula.h
OpenMS::IsoSpecWrapper
A convenience class for the IsoSpec algorithm - easier to use than the IsoSpecGeneratorWrapper classe...
Definition: IsoSpecWrapper.h:151
OpenMS::IsoSpecThresholdGeneratorWrapper::getMass
virtual double getMass() override final
Obtain the mass of the current isotopologue.
Definition: IsoSpecWrapper.h:299
OpenMS::IsoSpecTotalProbGeneratorWrapper::getConf
virtual Peak1D getConf() override final
Obtain the current isotopologue.
Definition: IsoSpecWrapper.h:236
OpenMS::IsoSpecTotalProbGeneratorWrapper::getIntensity
virtual double getIntensity() override final
Obtain the intensity (probability, relative peak height) of the current configuration.
Definition: IsoSpecWrapper.h:238
OpenMS::IsoSpecThresholdGeneratorWrapper
Provides a threshold-based generator of isotopologues: generates all isotopologues more probable than...
Definition: IsoSpecWrapper.h:266
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:382