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 "../filters/savgolfilter.h"
41 #include "../../massspectrum/massspectrum.h"
42 
43 namespace pappso
44 {
45 
46 //! Type of binning when performing integrations to a mass spectrum
47 enum class BinningType
48 {
49  //! < no binning
50  NONE = 0,
51 
52  //! binning based on mass spectral data
53  DATA_BASED,
54 
55  //! binning based on arbitrary bin size value
56  ARBITRARY,
57 
58  LAST,
59 };
60 
61 extern std::map<BinningType, QString> binningTypeMap;
62 
63 
64 //! The MzIntegrationParams class provides the parameters definining how m/z !
65 // integrations must be performed.
66 /*!
67  * Depending on the various mass spectrometer vendors, the mass spectrometry
68  * data files are structured in different ways and the software for mass data
69  * format conversion from raw files to mzML or mzXML produce mass data
70  * characterized by different behaviours.
71  *
72  * The different characteristics of mass spectrometry data set are:
73  *
74  * The size of the various mass spectra in the file is constant or variable;
75  *
76  * The first m/z value of the various spectra is identical or not (that is,
77  * the spectra are root in a constant or variable root m/z value);
78  *
79  * The m/z delta between two consecutive m/z values of a given spectrum are
80  * constant or variable;
81  *
82  * The spectra contain or not 0-value m/z data points;
83 
84 */
86 {
87 
88  public:
92  BinningType binningType,
93  int decimalPlaces,
94  pappso::PrecisionPtr precisionPtr,
95  bool applyMzShift,
96  pappso::pappso_double mzShift,
97  bool removeZeroValDataPoints);
98 
100  MzIntegrationParams(const pappso::SavGolParams &savGolParams);
101 
102  virtual ~MzIntegrationParams();
103 
105 
109 
113 
114  void setBinningType(BinningType binningType);
115  BinningType getBinningType() const;
116 
117  void setDecimalPlaces(int decimal_places);
118  int getDecimalPlaces() const;
119 
120  void setPrecision(pappso::PrecisionPtr precisionPtr);
122 
123  void setApplyMzShift(bool applyMzShift);
124  bool isApplyMzShift() const;
125 
126  void setMzShift(double value);
127  double getMzShift() const;
128 
129  void setRemoveZeroValDataPoints(bool removeOrNot = true);
130  bool isRemoveZeroValDataPoints() const;
131 
132  void setApplySavGolFilter(bool applySavGolFilter);
133  bool isApplySavGolFilter() const;
134 
135  void setSavGolParams(int nL = 15,
136  int nR = 15,
137  int m = 4,
138  int lD = 0,
139  bool convolveWithNr = false);
140  void setSavGolParams(const pappso::SavGolParams &params);
142 
143  void reset();
144 
145  bool isValid() const;
146 
147  bool hasValidMzRange() const;
148 
149  std::vector<pappso::pappso_double> createBins();
150  std::vector<pappso::pappso_double>
151  createBins(pappso::MassSpectrumCstSPtr mass_spectrum_csp);
152 
153  QString toString(int offset = 0, const QString &spacer = QString()) const;
154 
155  private:
156  // That smallest value needs to be set to max, because it will be necessary
157  // compare any new m/z valut to it.
158  pappso::pappso_double m_smallestMz = std::numeric_limits<double>::max();
159 
160  // That greatest value needs to be set to min, because it will be necessary
161  // compare any new m/z valut to it.
162  pappso::pappso_double m_greatestMz = std::numeric_limits<double>::min();
163 
164  BinningType m_binningType = BinningType::NONE;
165 
166  int m_decimalPlaces = -1;
167 
168  // This should actually be called "bin size" as it describes the width of
169  // the bins.
172  bool m_applyMzShift = false;
175 
176  bool m_applySavGolFilter = false;
178 
179  std::vector<double> createArbitraryBins();
180  std::vector<double>
182 };
183 
184 
185 } // namespace pappso
pappso::MzIntegrationParams::isRemoveZeroValDataPoints
bool isRemoveZeroValDataPoints() const
Definition: mzintegrationparams.cpp:259
pappso::MzIntegrationParams::setPrecision
void setPrecision(pappso::PrecisionPtr precisionPtr)
Definition: mzintegrationparams.cpp:222
pappso::MzIntegrationParams::createArbitraryBins
std::vector< double > createArbitraryBins()
Definition: mzintegrationparams.cpp:451
pappso::MzIntegrationParams::m_savGolParams
pappso::SavGolParams m_savGolParams
Definition: mzintegrationparams.h:177
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:48
pappso::MassSpectrumCstSPtr
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition: massspectrum.h:55
pappso::MzIntegrationParams::setMzShift
void setMzShift(double value)
Definition: mzintegrationparams.cpp:266
pappso::MzIntegrationParams::m_applyMzShift
bool m_applyMzShift
Definition: mzintegrationparams.h:172
pappso::MzIntegrationParams::isApplyMzShift
bool isApplyMzShift() const
Definition: mzintegrationparams.cpp:245
pappso::MzIntegrationParams::setGreatestMz
void setGreatestMz(pappso::pappso_double value)
Definition: mzintegrationparams.cpp:177
pappso::MzIntegrationParams::setDecimalPlaces
void setDecimalPlaces(int decimal_places)
Definition: mzintegrationparams.cpp:209
pappso::MzIntegrationParams::setApplySavGolFilter
void setApplySavGolFilter(bool applySavGolFilter)
Definition: mzintegrationparams.cpp:280
pappso::MzIntegrationParams::setRemoveZeroValDataPoints
void setRemoveZeroValDataPoints(bool removeOrNot=true)
Definition: mzintegrationparams.cpp:252
pappso::BinningType
BinningType
Type of binning when performing integrations to a mass spectrum.
Definition: mzintegrationparams.h:48
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
pappso::MzIntegrationParams::toString
QString toString(int offset=0, const QString &spacer=QString()) const
Definition: mzintegrationparams.cpp:721
pappso::BinningType::NONE
@ NONE
< no binning
pappso::MzIntegrationParams::setBinningType
void setBinningType(BinningType binningType)
Definition: mzintegrationparams.cpp:197
pappso::MzIntegrationParams::getMzShift
double getMzShift() const
Definition: mzintegrationparams.cpp:273
pappso::MzIntegrationParams::m_binningType
BinningType m_binningType
Definition: mzintegrationparams.h:164
pappso::MzIntegrationParams::setSavGolParams
void setSavGolParams(int nL=15, int nR=15, int m=4, int lD=0, bool convolveWithNr=false)
Definition: mzintegrationparams.cpp:294
pappso::MzIntegrationParams::getBinningType
BinningType getBinningType() const
Definition: mzintegrationparams.cpp:203
pappso::MzIntegrationParams::setSmallestMz
void setSmallestMz(pappso::pappso_double value)
Definition: mzintegrationparams.cpp:156
pappso::binningTypeMap
std::map< BinningType, QString > binningTypeMap
Map relating the BinningType to a textual representation.
Definition: mzintegrationparams.cpp:60
pappso::MzIntegrationParams::getSmallestMz
pappso::pappso_double getSmallestMz() const
Definition: mzintegrationparams.cpp:170
pappso::MzIntegrationParams::MzIntegrationParams
MzIntegrationParams()
Definition: mzintegrationparams.cpp:66
pappso::MzIntegrationParams::hasValidMzRange
bool hasValidMzRange() const
Definition: mzintegrationparams.cpp:383
pappso::MzIntegrationParams::getSavGolParams
pappso::SavGolParams getSavGolParams() const
Definition: mzintegrationparams.cpp:317
pappso::MzIntegrationParams::createBins
std::vector< pappso::pappso_double > createBins()
Definition: mzintegrationparams.cpp:391
pappso::MzIntegrationParams::~MzIntegrationParams
virtual ~MzIntegrationParams()
Definition: mzintegrationparams.cpp:122
pappso::MzIntegrationParams
The MzIntegrationParams class provides the parameters definining how m/z !
Definition: mzintegrationparams.h:86
pappso::PrecisionFactory::getDaltonInstance
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition: precision.cpp:129
pappso::SavGolParams
Parameters for the Savitzky-Golay filter.
Definition: savgolfilter.h:49
pappso::MzIntegrationParams::operator=
MzIntegrationParams & operator=(const MzIntegrationParams &other)
Definition: mzintegrationparams.cpp:128
pappso::MzIntegrationParams::m_smallestMz
pappso::pappso_double m_smallestMz
Definition: mzintegrationparams.h:158
pappso::MzIntegrationParams::getDecimalPlaces
int getDecimalPlaces() const
Definition: mzintegrationparams.cpp:216
pappso::MzIntegrationParams::setApplyMzShift
void setApplyMzShift(bool applyMzShift)
Definition: mzintegrationparams.cpp:238
pappso::MzIntegrationParams::m_mzShift
pappso::pappso_double m_mzShift
Definition: mzintegrationparams.h:173
pappso::MzIntegrationParams::getPrecision
pappso::PrecisionPtr getPrecision() const
Definition: mzintegrationparams.cpp:231
pappso::MzIntegrationParams::mp_precision
pappso::PrecisionPtr mp_precision
Definition: mzintegrationparams.h:170
pappso::PrecisionBase
Definition: precision.h:44
pappso::MzIntegrationParams::reset
void reset()
Reset the instance to default values.
Definition: mzintegrationparams.cpp:325
pappso::MzIntegrationParams::updateGreatestMz
void updateGreatestMz(pappso::pappso_double value)
Definition: mzintegrationparams.cpp:184
pappso::MzIntegrationParams::m_decimalPlaces
int m_decimalPlaces
Definition: mzintegrationparams.h:166
pappso::MzIntegrationParams::m_applySavGolFilter
bool m_applySavGolFilter
Definition: mzintegrationparams.h:176
pappso::MzIntegrationParams::getGreatestMz
pappso::pappso_double getGreatestMz() const
Definition: mzintegrationparams.cpp:191
pappso::MzIntegrationParams::updateSmallestMz
void updateSmallestMz(pappso::pappso_double value)
Definition: mzintegrationparams.cpp:163
pappso::MzIntegrationParams::isValid
bool isValid() const
Definition: mzintegrationparams.cpp:349
pappso::MzIntegrationParams::m_greatestMz
pappso::pappso_double m_greatestMz
Definition: mzintegrationparams.h:162
pappso::MzIntegrationParams::createDataBasedBins
std::vector< double > createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum)
Definition: mzintegrationparams.cpp:606
pappso::MzIntegrationParams::m_removeZeroValDataPoints
bool m_removeZeroValDataPoints
Definition: mzintegrationparams.h:174
pappso::MzIntegrationParams::isApplySavGolFilter
bool isApplySavGolFilter() const
Definition: mzintegrationparams.cpp:287