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
43namespace pappso
44{
45
46//! Type of binning when performing integrations to a mass spectrum
47enum class BinningType
48{
49 //! < no binning
50 NONE = 0,
51
52 //! binning based on mass spectral data
54
55 //! binning based on arbitrary bin size value
57
58 LAST,
59};
60
61extern std::map<BinningType, QString> binningTypeMap;
62BinningType getBinningTypeFromString(const QString &text);
63
64
65//! The MzIntegrationParams class provides the parameters definining how m/z !
66// integrations must be performed.
67/*!
68 * Depending on the various mass spectrometer vendors, the mass spectrometry
69 * data files are structured in different ways and the software for mass data
70 * format conversion from raw files to mzML or mzXML produce mass data
71 * characterized by different behaviours.
72 *
73 * The different characteristics of mass spectrometry data set are:
74 *
75 * The size of the various mass spectra in the file is constant or variable;
76 *
77 * The first m/z value of the various spectra is identical or not (that is,
78 * the spectra are root in a constant or variable root m/z value);
79 *
80 * The m/z delta between two consecutive m/z values of a given spectrum are
81 * constant or variable;
82 *
83 * The spectra contain or not 0-value m/z data points;
84
85*/
87{
88 public:
89
91 {
92 // The order is important.
93 DEFAULT = 0,
94 FROM_SETTINGS_BIN_SIZE_MODEL_PARTIAL = 1,
95 FROM_SETTINGS_BIN_SIZE_MODEL_FULL = 2,
96 FROM_SETTINGS_FULL = 3
97 };
98
99 Q_INVOKABLE MzIntegrationParams();
100 Q_INVOKABLE MzIntegrationParams(const QString &text);
103 BinningType binningType,
104 int decimalPlaces,
105 pappso::PrecisionPtr precisionPtr,
106 int binSizeDivisor,
107 bool removeZeroValDataPoints);
108
109 Q_INVOKABLE MzIntegrationParams(const MzIntegrationParams &other);
110
111 virtual ~MzIntegrationParams();
112
113 InitializationResult initialize(const QString &text);
114
115 MzIntegrationParams &operator=(const MzIntegrationParams &other);
116
117 Q_INVOKABLE void setSmallestMz(pappso::pappso_double value);
118 Q_INVOKABLE void updateSmallestMz(pappso::pappso_double value);
119 pappso::pappso_double getSmallestMz() const;
120
121 Q_INVOKABLE void setGreatestMz(pappso::pappso_double value);
122 Q_INVOKABLE void updateGreatestMz(pappso::pappso_double value);
123 Q_INVOKABLE pappso::pappso_double getGreatestMz() const;
124
125 Q_INVOKABLE void setBinningType(BinningType binningType);
126 Q_INVOKABLE BinningType getBinningType() const;
127
128 Q_INVOKABLE void setDecimalPlaces(int decimal_places);
129 Q_INVOKABLE int getDecimalPlaces() const;
130
131 Q_INVOKABLE void setBinSizeModel(pappso::PrecisionPtr bin_size_model);
132 Q_INVOKABLE pappso::PrecisionPtr getBinSizeModel() const;
133
134 void setBinSizeDivisor(int divisor);
135 int getBinSizeDivisor() const;
136
137 Q_INVOKABLE void setRemoveZeroValDataPoints(bool removeOrNot = true);
138 Q_INVOKABLE bool isRemoveZeroValDataPoints() const;
139
140 Q_INVOKABLE void reset();
141
142 Q_INVOKABLE bool isValid() const;
143
144 Q_INVOKABLE bool hasValidMzRange() const;
145
146 Q_INVOKABLE std::vector<pappso::pappso_double> createBins();
147 Q_INVOKABLE std::vector<pappso::pappso_double>
148 createBins(pappso::MassSpectrumCstSPtr mass_spectrum_csp);
149
150 Q_INVOKABLE QString toString(int offset, const QString &spacer = " ") const;
151 // The string below is used to recreate the MzIntegrationParams from string
152 Q_INVOKABLE QString toString() const;
153
154 private:
155 // That smallest value needs to be set to max, because it will be necessary
156 // compare any new m/z valut to it.
157 pappso::pappso_double m_smallestMz = std::numeric_limits<double>::max();
158
159 // That greatest value needs to be set to min, because it will be necessary
160 // compare any new m/z valut to it.
161 pappso::pappso_double m_greatestMz = std::numeric_limits<double>::min();
162
164
165 // -1 means that there is no restriction on the number of digits after the
166 // decimal point.
167 int m_decimalPlaces = -1;
168
169 // This should actually be called "bin size model" as it describes the width of
170 // the bins on the basis of a unit (ppm, res, dalton) and of a nominal value (nominal).
171 pappso::PrecisionPtr mp_binSizeModel =
173
174 int m_binSizeDivisor = 1;
175
176 bool m_removeZeroValDataPoints = true;
177
178 std::vector<double> createArbitraryBins();
179 std::vector<double>
180 createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum);
181};
182
183
184} // namespace pappso
185
188
The MzIntegrationParams class provides the parameters definining how m/z !
static PrecisionPtr getResInstance(pappso_double value)
get a resolution precision pointer
Definition: precision.cpp:180
#define PMSPP_LIB_DECL
int mzIntegrationParamsMetaTypeId
Q_DECLARE_METATYPE(pappso::MzIntegrationParams)
int mzIntegrationParamsPtrMetaTypeId
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
BinningType getBinningTypeFromString(const QString &text)
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:52
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition: massspectrum.h:57
std::map< BinningType, QString > binningTypeMap
Map relating the BinningType to a textual representation.