libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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/////////////////////// stdlib includes
37#include <map>
38
39
40/////////////////////// Qt includes
41#include <QObject>
42#include <QQmlEngine>
43
44
45/////////////////////// Local includes
47#include "pappsomspp/config.h"
50
51
52namespace pappso
53{
54
55//! The MzIntegrationParams class provides the parameters definining how m/z !
56// integrations must be performed.
57/*!
58 * Depending on the various mass spectrometer vendors, the mass spectrometry
59 * data files are structured in different ways and the software for mass data
60 * format conversion from raw files to mzML or mzXML produce mass data
61 * characterized by different behaviours.
62 *
63 * The different characteristics of mass spectrometry data set are:
64 *
65 * The size of the various mass spectra in the file is constant or variable;
66 *
67 * The first m/z value of the various spectra is identical or not (that is,
68 * the spectra are root in a constant or variable root m/z value);
69 *
70 * The m/z delta between two consecutive m/z values of a given spectrum are
71 * constant or variable;
72 *
73 * The spectra contain or not 0-value m/z data points;
74 */
75
76/* BEGIN CLASS JS REFERENCE
77 * namespace: pappso
78 * class name: MzIntegrationParams
79 *
80 * BEGIN DESCRIPTION
81 * This class configures the way mass spectra are computed,
82 * in particular with respect of the m/z binning.
83 * END DESCRIPTION
84 */
85class PMSPP_LIB_DECL MzIntegrationParams : public QObject
86{
87 Q_OBJECT
88
89 /*$ JS PROP REF Smallest m/z value of the set of mass spectra. This value is used as the
90 * smallest m/z value upon calculation of the bins.*/
91 Q_PROPERTY(double smallestMz READ getSmallestMz WRITE setSmallestMz NOTIFY smallestMzChanged)
92 /*$ JS PROP REF Greatest m/z value of the set of mass spectra. This value is used as the
93 * greatest m/z value upon calculation of the bins.*/
94 Q_PROPERTY(double greatestMz READ getGreatestMz WRITE setGreatestMz NOTIFY greatestMzChanged)
95 Q_PROPERTY(
97 Q_PROPERTY(
101 Q_PROPERTY(
105
106 QML_ELEMENT
107
108 public:
109 enum class BinningType
110 {
111 //! < no binning
112 NONE = 0,
113
114 //! binning based on mass spectral data
116
117 //! binning based on arbitrary bin size value
119
121 };
122 Q_ENUM(BinningType)
123
124 enum class InitializationResult : uint32_t
125 {
126 // The order is important.
127 // See end of class declaration for overload of bitwise operators
128 DEFAULT = 0x000,
129 BINNING_TYPE = 1 << 0,
137 };
138 Q_ENUM(InitializationResult)
139
140 Q_INVOKABLE explicit MzIntegrationParams(QObject *parent = nullptr);
141 Q_INVOKABLE explicit MzIntegrationParams(const QString &text, QObject *parent = nullptr);
142 Q_INVOKABLE explicit MzIntegrationParams(double minMz,
143 double maxMz,
144 BinningType binningType,
145 pappso::PrecisionPtr precisionPtr,
146 int binSizeDivisor,
147 int decimalPlaces,
148 bool removeZeroValDataPoints,
149 QObject *parent = nullptr);
150 virtual ~MzIntegrationParams();
151
152 Q_INVOKABLE MzIntegrationParams *clone(QObject *parent = nullptr) const;
153
154 Q_INVOKABLE InitializationResult initialize(const QString &text);
155
156 Q_INVOKABLE void initialize(double minMz,
157 double maxMz,
158 BinningType binningType,
159 pappso::PrecisionPtr precisionPtr,
160 int binSizeDivisor,
161 int decimalPlaces,
162 bool removeZeroValDataPoints,
163 QObject *parent = nullptr);
164 Q_INVOKABLE void initialize(const MzIntegrationParams &other, QObject *parent = nullptr);
165
166 void initialize(MzIntegrationParams &other, InitializationResult initialization_results);
167
168 void setSmallestMz(double value);
169 Q_INVOKABLE void updateSmallestMz(double value);
170 double getSmallestMz() const;
171
172 void setGreatestMz(double value);
173 Q_INVOKABLE void updateGreatestMz(double value);
174 double getGreatestMz() const;
175
176 Q_INVOKABLE void setMzValues(double smallest, double greatest);
177
178 void setBinningType(BinningType binningType);
179 BinningType getBinningType() const;
180
181 void setBinSizeModel(pappso::PrecisionPtr bin_size_model_p);
182 pappso::PrecisionPtr getBinSizeModel() const;
183
184 void setBinSizeDivisor(int divisor);
185 int getBinSizeDivisor() const;
186
187 void setDecimalPlaces(int decimal_places);
188 int getDecimalPlaces() const;
189
190 void setRemoveZeroValDataPoints(bool removeOrNot = true);
191 bool isRemoveZeroValDataPoints() const;
192
193 Q_INVOKABLE void reset();
194
195 Q_INVOKABLE bool isValid() const;
196
197 Q_INVOKABLE bool hasValidMzRange() const;
198
199 Q_INVOKABLE std::vector<double> createBins();
200 Q_INVOKABLE std::vector<double> createBins(pappso::MassSpectrumCstSPtr mass_spectrum_csp);
201
202 Q_INVOKABLE QString toString(int offset, const QString &spacer = " ") const;
203 // The string below is used to recreate the MzIntegrationParams from string
204 Q_INVOKABLE QString toString() const;
205
206 // # pragma message "This pragma is inside"
207 static void registerJsConstructor(QJSEngine *engine);
208
209 signals:
217 void wasReset();
218
219
220 protected:
221 // That smallest value needs to be set to max, because it will be necessary
222 // compare any new m/z valut to it.
223 double m_smallestMz = std::numeric_limits<double>::max();
224
225 // That greatest value needs to be set to min, because it will be necessary
226 // compare any new m/z valut to it.
227 double m_greatestMz = std::numeric_limits<double>::min();
228
229 ///////////// The binning size logic ///////////////////
230 ///////////// The binning size logic ///////////////////
231
235 // -1 means that there is no restriction on the number of digits after the
236 // decimal point.
238
239 ///////////// The binning size logic ///////////////////
240 ///////////// The binning size logic ///////////////////
241
243
244 std::vector<double> createArbitraryBins();
245 std::vector<double> createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum);
246};
247
248/* END CLASS JS REFERENCE
249 * namespace: pappso
250 * class name: MzIntegrationParams
251 */
252
253
254// Overload bitwise operators
257{
258 return static_cast<MzIntegrationParams::InitializationResult>(static_cast<uint32_t>(a) |
259 static_cast<uint32_t>(b));
260}
261
264{
265 return static_cast<MzIntegrationParams::InitializationResult>(static_cast<uint32_t>(a) &
266 static_cast<uint32_t>(b));
267}
268
276
277
278extern std::map<MzIntegrationParams::BinningType, QString> binningTypeMap;
280
281PAPPSO_REGISTER_JS_CLASS(pappso, MzIntegrationParams)
282
283} // namespace pappso
284
285/*
286Q_DECLARE_METATYPE(pappso::MzIntegrationParams);
287Q_DECLARE_METATYPE(pappso::MzIntegrationParams *);
288
289extern int mzIntegrationParamsMetaTypeId;
290extern int mzIntegrationParamsPtrMetaTypeId;*/
The MzIntegrationParams class provides the parameters definining how m/z !
Q_INVOKABLE MzIntegrationParams(QObject *parent=nullptr)
void setBinSizeModel(pappso::PrecisionPtr bin_size_model_p)
std::vector< double > createArbitraryBins()
pappso::PrecisionPtr binSizeModel
pappso::PrecisionPtr m_binSizeModel
pappso::PrecisionPtr getBinSizeModel() const
@ DATA_BASED
binning based on mass spectral data
@ ARBITRARY
binning based on arbitrary bin size value
void setBinningType(BinningType binningType)
std::vector< double > createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum)
void setDecimalPlaces(int decimal_places)
void setRemoveZeroValDataPoints(bool removeOrNot=true)
static PrecisionPtr getResInstance(pappso_double value)
get a resolution precision pointer
#define PMSPP_LIB_DECL
#define PAPPSO_REGISTER_JS_CLASS(NS_IDENT, CLASS_NAME)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
constexpr MzIntegrationParams::InitializationResult operator|=(MzIntegrationParams::InitializationResult &a, MzIntegrationParams::InitializationResult b)
MzIntegrationParams::BinningType getBinningTypeFromString(const QString &text)
std::map< MzIntegrationParams::BinningType, QString > binningTypeMap
Map relating the BinningType to a textual representation.
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122
constexpr MzIntegrationParams::InitializationResult operator|(MzIntegrationParams::InitializationResult a, MzIntegrationParams::InitializationResult b)
constexpr MzIntegrationParams::InitializationResult operator&(MzIntegrationParams::InitializationResult a, MzIntegrationParams::InitializationResult b)