libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
msrunreadconfig.cpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright (c) 2023 Filippo Rusconi
3
*<filippo.rusconi@universite-paris-saclay.fr>.
4
*
5
* This file is part of the PAPPSOms++ library.
6
*
7
* PAPPSOms++ is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* PAPPSOms++ is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
19
*
20
******************************************************************************/
21
22
#include "
msrunreadconfig.h
"
23
#include <QDebug>
24
25
namespace
pappso
26
{
27
28
MsRunReadConfig::MsRunReadConfig
()
29
{
30
// Set these two levels to true by default.
31
m_msLevels
[1] =
true
;
32
m_msLevels
[2] =
true
;
33
}
34
35
MsRunReadConfig::MsRunReadConfig
(
const
MsRunReadConfig
&other)
36
:
m_retentionTimeStartSeconds
(other.
m_retentionTimeStartSeconds
),
37
m_retentionTimeEndSeconds
(other.
m_retentionTimeEndSeconds
),
38
m_paramsMap
(other.
m_paramsMap
)
39
{
40
for
(std::size_t index = 0; index <
MAX_MS_LEVELS
; ++index)
41
m_msLevels
[index] = other.
m_msLevels
[index];
42
}
43
44
MsRunReadConfig::~MsRunReadConfig
()
45
{
46
}
47
48
MsRunReadConfig
&
49
MsRunReadConfig::operator=
(
const
MsRunReadConfig
&other)
50
{
51
if
(&other ==
this
)
52
return
*
this
;
53
54
m_retentionTimeStartSeconds
= other.
m_retentionTimeStartSeconds
;
55
m_retentionTimeEndSeconds
= other.
m_retentionTimeEndSeconds
;
56
m_paramsMap
= other.
m_paramsMap
;
57
58
for
(std::size_t index = 0; index <
MAX_MS_LEVELS
; ++index)
59
m_msLevels
[index] = other.
m_msLevels
[index];
60
61
return
*
this
;
62
}
63
64
void
65
MsRunReadConfig::setRetentionTimeStartInSeconds
(
double
retention_time_start_in_seconds)
66
{
67
m_retentionTimeStartSeconds
= retention_time_start_in_seconds;
68
}
69
70
double
71
MsRunReadConfig::getRetentionTimeStartInSeconds
()
const
72
{
73
return
m_retentionTimeStartSeconds
;
74
}
75
76
void
77
MsRunReadConfig::setRetentionTimeEndInSeconds
(
double
retention_time_end_in_seconds)
78
{
79
m_retentionTimeEndSeconds
= retention_time_end_in_seconds;
80
}
81
82
double
83
MsRunReadConfig::getRetentionTimeEndInSeconds
()
const
84
{
85
return
m_retentionTimeEndSeconds
;
86
}
87
88
void
89
MsRunReadConfig::setMsLevels
(std::vector<std::size_t> ms_levels)
90
{
91
// First reset all the levels to false, this time, since we'll fill the array
92
// with explicit values.
93
for
(std::size_t index = 0; index <
MAX_MS_LEVELS
; ++index)
94
m_msLevels
[index] =
false
;
95
96
// And now actually fill with true values the proper array cells.
97
for
(
auto
ms_level : ms_levels)
98
{
99
if
(ms_level >=
MAX_MS_LEVELS
)
100
{
101
qDebug() <<
"The passed vector of MS levels holds a value that is "
102
"not correct:"
103
<< ms_level <<
": skipping it."
;
104
105
continue
;
106
}
107
m_msLevels
[ms_level] =
true
;
108
}
109
}
110
111
const
bool
*
112
MsRunReadConfig::getMsLevels
(
void
)
const
113
{
114
return
m_msLevels
;
115
}
116
117
QString
118
MsRunReadConfig::getMsLevelsAsString
()
const
119
{
120
QString text =
""
;
121
122
for
(std::size_t index = 0; index <
MAX_MS_LEVELS
; ++index)
123
{
124
if
(
m_msLevels
[index] ==
true
)
125
text += QString(
"%1 "
).arg(index);
126
}
127
128
return
text;
129
}
130
131
132
bool
133
MsRunReadConfig::acceptMsLevel
(std::size_t ms_level)
const
134
{
135
if
(ms_level >=
MAX_MS_LEVELS
)
136
return
false
;
137
138
return
m_msLevels
[ms_level];
139
}
140
141
bool
142
MsRunReadConfig::acceptRetentionTimeInSeconds
(
double
retention_time_in_seconds)
const
143
{
144
// qDebug() << "Requested retention_time_in_seconds:"
145
// << retention_time_in_seconds;
146
147
// Whatever the member datum below, if it is equal to -1
148
// then that means that RT is not a selection criterion.
149
if
(
m_retentionTimeStartSeconds
== -1 ||
m_retentionTimeEndSeconds
== -1)
150
{
151
return
true
;
152
}
153
154
// We use inclusive RT ranges.
155
if
(retention_time_in_seconds >=
m_retentionTimeStartSeconds
)
156
{
157
if
(retention_time_in_seconds <=
m_retentionTimeEndSeconds
)
158
{
159
return
true
;
160
}
161
}
162
163
return
false
;
164
}
165
166
bool
167
MsRunReadConfig::needPeakList
()
const
168
{
169
return
m_isPeakListNeeded
;
170
}
171
172
void
173
MsRunReadConfig::setNeedPeakList
(
bool
need_peak_list)
174
{
175
m_isPeakListNeeded
= need_peak_list;
176
}
177
178
void
179
MsRunReadConfig::setParameterValue
(
pappso::MsRunReadConfigParameter
parameter,
180
const
QVariant &value)
181
{
182
183
auto
ret =
m_paramsMap
.insert(std::pair<MsRunReadConfigParameter, QVariant>(parameter, value));
184
185
if
(ret.second ==
false
)
186
{
187
ret.first->second = value;
188
}
189
}
190
191
const
QVariant
192
MsRunReadConfig::getParameterValue
(
pappso::MsRunReadConfigParameter
parameter)
const
193
{
194
auto
it =
m_paramsMap
.find(parameter);
195
if
(it ==
m_paramsMap
.end())
196
{
197
return
QVariant();
198
}
199
else
200
{
201
return
it->second;
202
}
203
}
204
205
206
void
207
MsRunReadConfig::reset
()
208
{
209
m_retentionTimeStartSeconds
= -1;
210
m_retentionTimeEndSeconds
= -1;
211
m_isPeakListNeeded
=
true
;
212
213
for
(std::size_t index = 0; index <
MAX_MS_LEVELS
; ++index)
214
{
215
m_msLevels
[index] =
false
;
216
}
217
// Set these two levels to true by default.
218
m_msLevels
[1] =
true
;
219
m_msLevels
[2] =
true
;
220
221
m_paramsMap
.clear();
222
}
223
224
QString
225
MsRunReadConfig::toString
()
const
226
{
227
QString text = QString(
"MsRunReadConfig\n: RT start: %1, RT end: %2\n"
)
228
.arg(
m_retentionTimeStartSeconds
)
229
.arg(
m_retentionTimeEndSeconds
);
230
231
text +=
"MS level(s): "
;
232
233
for
(std::size_t index = 0; index <
MAX_MS_LEVELS
; ++index)
234
{
235
if
(
m_msLevels
[index] ==
true
)
236
text += QString(
"%1 "
).arg(index);
237
}
238
239
text +=
" \n"
;
240
241
if
(!
getParameterValue
(
MsRunReadConfigParameter::TimsFrameIonMobScanIndexBegin
).isNull())
242
{
243
text +=
244
QString(
"Mobility index range: [%1-%2]\n"
)
245
.arg(
getParameterValue
(
MsRunReadConfigParameter::TimsFrameIonMobScanIndexBegin
).toUInt())
246
.arg(
getParameterValue
(
MsRunReadConfigParameter::TimsFrameIonMobScanIndexEnd
).toUInt());
247
}
248
249
if
(!
getParameterValue
(
MsRunReadConfigParameter::TimsFrameIonMobOneOverK0Begin
).isNull())
250
{
251
text +=
252
QString(
"Mobility 1/K0 range: [%1-%2]\n"
)
253
.arg(
254
getParameterValue
(
MsRunReadConfigParameter::TimsFrameIonMobOneOverK0Begin
).toDouble())
255
.arg(
getParameterValue
(
MsRunReadConfigParameter::TimsFrameIonMobOneOverK0End
).toDouble());
256
}
257
258
if
(!
getParameterValue
(
MsRunReadConfigParameter::MzRangeBegin
).isNull())
259
{
260
text += QString(
"m/z range: [%1-%2]\n"
)
261
.arg(
getParameterValue
(
MsRunReadConfigParameter::MzRangeBegin
).toDouble())
262
.arg(
getParameterValue
(
MsRunReadConfigParameter::MzRangeEnd
).toDouble());
263
}
264
265
if
(!
getParameterValue
(
MsRunReadConfigParameter::TimsFrameMzIndexMergeWindow
).isNull())
266
{
267
text +=
268
QString(
"m/z merge window %1\n"
)
269
.arg(
getParameterValue
(
MsRunReadConfigParameter::TimsFrameMzIndexMergeWindow
).toUInt());
270
}
271
272
return
text;
273
}
274
}
// namespace pappso
pappso::MsRunReadConfig
Definition
msrunreadconfig.h:62
pappso::MsRunReadConfig::needPeakList
bool needPeakList() const
Definition
msrunreadconfig.cpp:167
pappso::MsRunReadConfig::getRetentionTimeEndInSeconds
double getRetentionTimeEndInSeconds() const
Definition
msrunreadconfig.cpp:83
pappso::MsRunReadConfig::m_retentionTimeStartSeconds
double m_retentionTimeStartSeconds
Definition
msrunreadconfig.h:97
pappso::MsRunReadConfig::m_msLevels
bool m_msLevels[MAX_MS_LEVELS]
Definition
msrunreadconfig.h:105
pappso::MsRunReadConfig::operator=
MsRunReadConfig & operator=(const MsRunReadConfig &other)
Definition
msrunreadconfig.cpp:49
pappso::MsRunReadConfig::toString
QString toString() const
Definition
msrunreadconfig.cpp:225
pappso::MsRunReadConfig::m_retentionTimeEndSeconds
double m_retentionTimeEndSeconds
Definition
msrunreadconfig.h:98
pappso::MsRunReadConfig::~MsRunReadConfig
~MsRunReadConfig()
Definition
msrunreadconfig.cpp:44
pappso::MsRunReadConfig::setNeedPeakList
void setNeedPeakList(bool need_peak_list)
Definition
msrunreadconfig.cpp:173
pappso::MsRunReadConfig::setRetentionTimeStartInSeconds
void setRetentionTimeStartInSeconds(double retention_time_start_in_seconds)
Definition
msrunreadconfig.cpp:65
pappso::MsRunReadConfig::getParameterValue
const QVariant getParameterValue(MsRunReadConfigParameter parameter) const
Definition
msrunreadconfig.cpp:192
pappso::MsRunReadConfig::acceptMsLevel
bool acceptMsLevel(std::size_t ms_level) const
Definition
msrunreadconfig.cpp:133
pappso::MsRunReadConfig::acceptRetentionTimeInSeconds
bool acceptRetentionTimeInSeconds(double retention_time_in_seconds) const
Definition
msrunreadconfig.cpp:142
pappso::MsRunReadConfig::m_isPeakListNeeded
bool m_isPeakListNeeded
Definition
msrunreadconfig.h:100
pappso::MsRunReadConfig::m_paramsMap
std::map< MsRunReadConfigParameter, QVariant > m_paramsMap
map containing any parameter value
Definition
msrunreadconfig.h:110
pappso::MsRunReadConfig::reset
void reset()
Definition
msrunreadconfig.cpp:207
pappso::MsRunReadConfig::getRetentionTimeStartInSeconds
double getRetentionTimeStartInSeconds() const
Definition
msrunreadconfig.cpp:71
pappso::MsRunReadConfig::MsRunReadConfig
MsRunReadConfig()
Definition
msrunreadconfig.cpp:28
pappso::MsRunReadConfig::setMsLevels
void setMsLevels(std::vector< std::size_t > ms_levels)
Definition
msrunreadconfig.cpp:89
pappso::MsRunReadConfig::setRetentionTimeEndInSeconds
void setRetentionTimeEndInSeconds(double retention_time_end_in_seconds)
Definition
msrunreadconfig.cpp:77
pappso::MsRunReadConfig::getMsLevelsAsString
QString getMsLevelsAsString() const
Definition
msrunreadconfig.cpp:118
pappso::MsRunReadConfig::getMsLevels
const bool * getMsLevels() const
Definition
msrunreadconfig.cpp:112
pappso::MsRunReadConfig::setParameterValue
void setParameterValue(MsRunReadConfigParameter parameter, const QVariant &value)
Definition
msrunreadconfig.cpp:179
msrunreadconfig.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::MAX_MS_LEVELS
constexpr std::size_t MAX_MS_LEVELS
Definition
msrunreadconfig.h:59
pappso::MsRunReadConfigParameter
MsRunReadConfigParameter
Definition
msrunreadconfig.h:36
pappso::MsRunReadConfigParameter::MzRangeBegin
@ MzRangeBegin
Definition
msrunreadconfig.h:49
pappso::MsRunReadConfigParameter::TimsFrameIonMobOneOverK0Begin
@ TimsFrameIonMobOneOverK0Begin
Definition
msrunreadconfig.h:44
pappso::MsRunReadConfigParameter::TimsFrameIonMobOneOverK0End
@ TimsFrameIonMobOneOverK0End
Definition
msrunreadconfig.h:45
pappso::MsRunReadConfigParameter::TimsFrameIonMobScanIndexBegin
@ TimsFrameIonMobScanIndexBegin
Definition
msrunreadconfig.h:39
pappso::MsRunReadConfigParameter::TimsFrameMzIndexMergeWindow
@ TimsFrameMzIndexMergeWindow
Definition
msrunreadconfig.h:54
pappso::MsRunReadConfigParameter::TimsFrameIonMobScanIndexEnd
@ TimsFrameIonMobScanIndexEnd
Definition
msrunreadconfig.h:40
pappso::MsRunReadConfigParameter::MzRangeEnd
@ MzRangeEnd
Definition
msrunreadconfig.h:50
pappsomspp
core
msrun
msrunreadconfig.cpp
Generated on
for libpappsomspp by
1.17.0