libpappsomspp
Library for mass spectrometry
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
25namespace pappso
26{
27
29{
30 // Set these two levels to true by default.
31 m_msLevels[1] = true;
32 m_msLevels[2] = true;
33}
34
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
47
50{
51 if(&other == this)
52 return *this;
53
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
64void
66 double retention_time_start_in_seconds)
67{
68 m_retentionTimeStartSeconds = retention_time_start_in_seconds;
69}
70
71double
76
77void
79 double retention_time_end_in_seconds)
80{
81 m_retentionTimeEndSeconds = retention_time_end_in_seconds;
82}
83
84double
89
90void
91MsRunReadConfig::setMsLevels(std::vector<std::size_t> ms_levels)
92{
93 // First reset all the levels to false, this time, since we'll fill the array
94 // with explicit values.
95 for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
96 m_msLevels[index] = false;
97
98 // And now actually fill with true values the proper array cells.
99 for(auto ms_level : ms_levels)
100 {
101 if(ms_level >= MAX_MS_LEVELS)
102 {
103 qDebug() << "The passed vector of MS levels holds a value that is "
104 "not correct:"
105 << ms_level << ": skipping it.";
106
107 continue;
108 }
109 m_msLevels[ms_level] = true;
110 }
111}
112
113const bool *
115{
116 return m_msLevels;
117}
118
119QString
121{
122 QString text = "";
123
124 for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
125 {
126 if(m_msLevels[index] == true)
127 text += QString("%1 ").arg(index);
128 }
129
130 return text;
131}
132
133
134bool
135MsRunReadConfig::acceptMsLevel(std::size_t ms_level) const
136{
137 if(ms_level >= MAX_MS_LEVELS)
138 return false;
139
140 return m_msLevels[ms_level];
141}
142
143bool
145 double retention_time_in_seconds) const
146{
147 qDebug() << "Requested retention_time_in_seconds:"
148 << retention_time_in_seconds;
149
150 // Whatever the member datum below, if it is equal to -1
151 // then that means that RT is not a selection criterion.
153 {
154 return true;
155 }
156
157 // We use inclusive RT ranges.
158 if(retention_time_in_seconds >= m_retentionTimeStartSeconds)
159 {
160 if(retention_time_in_seconds <= m_retentionTimeEndSeconds)
161 {
162 return true;
163 }
164 }
165
166 return false;
167}
168
169bool
174
175void
177{
178 m_isPeakListNeeded = need_peak_list;
179}
180
181void
183 const QVariant &value)
184{
185
186 auto ret = m_paramsMap.insert(
187 std::pair<MsRunReadConfigParameter, QVariant>(parameter, value));
188
189 if(ret.second == false)
190 {
191 ret.first->second = value;
192 }
193}
194
195const QVariant
197 pappso::MsRunReadConfigParameter parameter) const
198{
199 auto it = m_paramsMap.find(parameter);
200 if(it == m_paramsMap.end())
201 {
202 return QVariant();
203 }
204 else
205 {
206 return it->second;
207 }
208}
209
210
211void
213{
216 m_isPeakListNeeded = true;
217
218 for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
219 {
220 m_msLevels[index] = false;
221 }
222 // Set these two levels to true by default.
223 m_msLevels[1] = true;
224 m_msLevels[2] = true;
225
226 m_paramsMap.clear();
227}
228
229QString
231{
232 QString text = QString("MsRunReadConfig\n: RT start: %1, RT end: %2\n")
235
236 text += "MS level(s): ";
237
238 for(std::size_t index = 0; index < MAX_MS_LEVELS; ++index)
239 {
240 if(m_msLevels[index] == true)
241 text += QString("%1 ").arg(index);
242 }
243
244 text += " \n";
245
248 .isNull())
249 {
250 text +=
251 QString("Mobility index range: [%1-%2]\n")
254 .toUInt())
257 .toUInt());
258 }
259
262 .isNull())
263 {
264 text += QString("Mobility 1/K0 range: [%1-%2]\n")
268 .toDouble())
272 .toDouble());
273 }
274
277 .isNull())
278 {
279 text += QString("m/z range: [%1-%2]\n")
282 .toDouble())
285 .toDouble());
286 }
287
290 .isNull())
291 {
292 text +=
293 QString("m/z merge window %1\n")
296 .toUInt());
297 }
298
299 return text;
300}
301} // namespace pappso
double getRetentionTimeEndInSeconds() const
bool m_msLevels[MAX_MS_LEVELS]
MsRunReadConfig & operator=(const MsRunReadConfig &other)
void setNeedPeakList(bool need_peak_list)
void setRetentionTimeStartInSeconds(double retention_time_start_in_seconds)
const QVariant getParameterValue(MsRunReadConfigParameter parameter) const
bool acceptMsLevel(std::size_t ms_level) const
bool acceptRetentionTimeInSeconds(double retention_time_in_seconds) const
std::map< MsRunReadConfigParameter, QVariant > m_paramsMap
map containing any parameter value
double getRetentionTimeStartInSeconds() const
void setMsLevels(std::vector< std::size_t > ms_levels)
void setRetentionTimeEndInSeconds(double retention_time_end_in_seconds)
QString getMsLevelsAsString() const
const bool * getMsLevels() const
void setParameterValue(MsRunReadConfigParameter parameter, const QVariant &value)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
constexpr std::size_t MAX_MS_LEVELS
MsRunReadConfigParameter