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
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
65MsRunReadConfig::setRetentionTimeStartInSeconds(double retention_time_start_in_seconds)
66{
67 m_retentionTimeStartSeconds = retention_time_start_in_seconds;
68}
69
70double
75
76void
77MsRunReadConfig::setRetentionTimeEndInSeconds(double retention_time_end_in_seconds)
78{
79 m_retentionTimeEndSeconds = retention_time_end_in_seconds;
80}
81
82double
87
88void
89MsRunReadConfig::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
111const bool *
113{
114 return m_msLevels;
115}
116
117QString
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
132bool
133MsRunReadConfig::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
141bool
142MsRunReadConfig::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.
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
166bool
171
172void
174{
175 m_isPeakListNeeded = need_peak_list;
176}
177
178void
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
191const QVariant
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
206void
208{
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
224QString
226{
227 QString text = QString("MsRunReadConfig\n: RT start: %1, RT end: %2\n")
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
242 {
243 text +=
244 QString("Mobility index range: [%1-%2]\n")
247 }
248
250 {
251 text +=
252 QString("Mobility 1/K0 range: [%1-%2]\n")
253 .arg(
256 }
257
259 {
260 text += QString("m/z range: [%1-%2]\n")
263 }
264
266 {
267 text +=
268 QString("m/z merge window %1\n")
270 }
271
272 return text;
273}
274} // 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