libpappsomspp
Library for mass spectrometry
mzintegrationparams.h
Go to the documentation of this file.
1 /* BEGIN software license
2  *
3  * msXpertSuite - mass spectrometry software suite
4  * -----------------------------------------------
5  * Copyright(C) 2009,...,2018 Filippo Rusconi
6  *
7  * http://www.msxpertsuite.org
8  *
9  * This file is part of the msXpertSuite project.
10  *
11  * The msXpertSuite project is the successor of the massXpert project. This
12  * project now includes various independent modules:
13  *
14  * - massXpert, model polymer chemistries and simulate mass spectrometric data;
15  * - mineXpert, a powerful TIC chromatogram/mass spectrum viewer/miner;
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program. If not, see <http://www.gnu.org/licenses/>.
29  *
30  * END software license
31  */
32 
33 
34 #pragma once
35 
36 
37 #include <map>
38 
39 #include "../../precision.h"
40 #include "../../massspectrum/massspectrum.h"
41 
42 namespace pappso
43 {
44 
45 //! Type of binning when performing integrations to a mass spectrum
46 enum class BinningType
47 {
48  //! < no binning
49  NONE = 0,
50 
51  //! binning based on mass spectral data
52  DATA_BASED,
53 
54  //! binning based on arbitrary bin size value
55  ARBITRARY,
56 
57  LAST,
58 };
59 
60 extern std::map<BinningType, QString> binningTypeMap;
61 
62 
63 //! The MzIntegrationParams class provides the parameters definining how m/z !
64 // integrations must be performed.
65 /*!
66  * Depending on the various mass spectrometer vendors, the mass spectrometry
67  * data files are structured in different ways and the software for mass data
68  * format conversion from raw files to mzML or mzXML produce mass data
69  * characterized by different behaviours.
70  *
71  * The different characteristics of mass spectrometry data set are:
72  *
73  * The size of the various mass spectra in the file is constant or variable;
74  *
75  * The first m/z value of the various spectra is identical or not (that is,
76  * the spectra are root in a constant or variable root m/z value);
77  *
78  * The m/z delta between two consecutive m/z values of a given spectrum are
79  * constant or variable;
80  *
81  * The spectra contain or not 0-value m/z data points;
82 
83 */
85 {
86 
87  public:
91  BinningType binningType,
92  int decimalPlaces,
93  pappso::PrecisionPtr precisionPtr,
94  bool applyMzShift,
95  pappso::pappso_double mzShift,
96  bool removeZeroValDataPoints);
97 
99 
100  virtual ~MzIntegrationParams();
101 
102  MzIntegrationParams &operator=(const MzIntegrationParams &other);
103 
104  void setSmallestMz(pappso::pappso_double value);
105  void updateSmallestMz(pappso::pappso_double value);
106  pappso::pappso_double getSmallestMz() const;
107 
108  void setGreatestMz(pappso::pappso_double value);
109  void updateGreatestMz(pappso::pappso_double value);
110  pappso::pappso_double getGreatestMz() const;
111 
112  void setBinningType(BinningType binningType);
113  BinningType getBinningType() const;
114 
115  void setDecimalPlaces(int decimal_places);
116  int getDecimalPlaces() const;
117 
118  void setPrecision(pappso::PrecisionPtr precisionPtr);
119  pappso::PrecisionPtr getPrecision() const;
120 
121  void setApplyMzShift(bool applyMzShift);
122  bool isApplyMzShift() const;
123 
124  void setMzShift(double value);
125  double getMzShift() const;
126 
127  void setRemoveZeroValDataPoints(bool removeOrNot = true);
128  bool isRemoveZeroValDataPoints() const;
129 
130  void reset();
131 
132  bool isValid() const;
133 
134  bool hasValidMzRange() const;
135 
136  std::vector<pappso::pappso_double> createBins();
137  std::vector<pappso::pappso_double>
138  createBins(pappso::MassSpectrumCstSPtr mass_spectrum_csp);
139 
140  QString toString(int offset = 0, const QString &spacer = QString()) const;
141 
142  private:
143  // That smallest value needs to be set to max, because it will be necessary
144  // compare any new m/z valut to it.
145  pappso::pappso_double m_smallestMz = std::numeric_limits<double>::max();
146 
147  // That greatest value needs to be set to min, because it will be necessary
148  // compare any new m/z valut to it.
149  pappso::pappso_double m_greatestMz = std::numeric_limits<double>::min();
150 
152 
153  int m_decimalPlaces = -1;
154 
155  // This should actually be called "bin size" as it describes the width of
156  // the bins.
157  pappso::PrecisionPtr mp_precision =
159  bool m_applyMzShift = false;
160  pappso::pappso_double m_mzShift = 0;
161  bool m_removeZeroValDataPoints = true;
162 
163  std::vector<double> createArbitraryBins();
164  std::vector<double>
165  createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum);
166 };
167 
168 
169 } // namespace pappso
The MzIntegrationParams class provides the parameters definining how m/z !
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition: precision.cpp:129
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
BinningType
Type of binning when performing integrations to a mass spectrum.
@ DATA_BASED
binning based on mass spectral data
@ ARBITRARY
binning based on arbitrary bin size value
@ NONE
< no binning
double pappso_double
A type definition for doubles.
Definition: types.h:48
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition: massspectrum.h:55
std::map< BinningType, QString > binningTypeMap
Map relating the BinningType to a textual representation.