libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
qcborspectrumprecursor.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/core/processing/cbor/mzcbor/copyreplace/qcborspectrumprecursor.cpp
3
* \date 2/10/2026
4
* \author Olivier Langella
5
* \brief Low level CBOR map to store an mzCBOR Spectrum object
6
* */
7
8
/*******************************************************************************
9
* Copyright (c) 2026 Olivier Langella <Olivier.Langella@cnrs.fr>.
10
*
11
* This file is part of PAPPSOms-tools.
12
*
13
* PAPPSOms-tools is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation, either version 3 of the License, or
16
* (at your option) any later version.
17
*
18
* PAPPSOms-tools is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License
24
* along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
25
*
26
******************************************************************************/
27
28
29
#include "
qcborspectrumprecursor.h
"
30
#include "
pappsomspp/core/exception/exceptionnotfound.h
"
31
#include "
pappsomspp/core/processing/cbor/mzcbor/precursor.h
"
32
#include <QCborArray>
33
#include <qcborarray.h>
34
#include <qcbormap.h>
35
#include <qcborvalue.h>
36
#include <qlogging.h>
37
38
namespace
pappso
39
{
40
namespace
cbor
41
{
42
namespace
mzcbor
43
{
44
QcborSpectrumPrecursor::QcborSpectrumPrecursor
(
const
QCborMap &cbor_map) : QCborMap(cbor_map)
45
{
46
}
47
QcborSpectrumPrecursor::QcborSpectrumPrecursor
(
const
QcborSpectrumPrecursor
&other)
48
: QCborMap(other)
49
{
50
}
51
QString
52
QcborSpectrumPrecursor::getSpectrumRef
()
const
53
{
54
//"spectrumRef":"controllerType=0 controllerNumber=1 scan=2711",
55
//
56
auto
it = constFind(QCborValue(
"spectrumRef"
));
57
if
(it != end())
58
{
59
return
it.value().toString();
60
}
61
else
62
{
63
throw
pappso::ExceptionNotFound
(
64
QObject::tr(
"ERROR: no spectrumRef in QcborSpectrumPrecursor"
));
65
}
66
}
67
68
void
69
QcborSpectrumPrecursor::setSpectrumRef
(
const
QString &spectrum_ref)
70
{
71
auto
it = find(QCborValue(
"spectrumRef"
));
72
if
(it != end())
73
{
74
insert(QCborValue(
"spectrumRef"
), spectrum_ref);
75
}
76
else
77
{
78
throw
pappso::ExceptionNotFound
(
79
QObject::tr(
"ERROR: no spectrumRef in QcborSpectrumPrecursor"
));
80
}
81
}
82
83
84
IsolationWindow
85
QcborSpectrumPrecursor::getIsolationWindow
()
const
86
{
87
auto
it = constFind(QCborValue(
"isolationWindow"
));
88
if
(it != end())
89
{
90
IsolationWindow
isolation_window;
91
isolation_window.
fromQCborMap
(it->toMap());
92
return
isolation_window;
93
}
94
else
95
{
96
throw
pappso::PappsoException
(
97
QObject::tr(
"ERROR: no isolationWindow in QcborSpectrumPrecursor"
));
98
}
99
}
100
101
void
102
QcborSpectrumPrecursor::setSelectedIon
(
double
mz,
double
intensity,
int
charge)
103
{
104
auto
it = find(QCborValue(
"selectedIonList"
));
105
if
(it != end())
106
{
107
QCborMap new_selected_ion_list;
108
new_selected_ion_list.insert(QString(
"count"
), 1);
109
110
QCborMap new_selected_ion;
111
// <cvParam cvRef="MS" accession="MS:1000041" value="3" name="charge state"/>
112
QCborArray cv_param_list;
113
QCborMap cv_param;
114
cv_param.insert(QString(
"cvRef"
), QCborValue(
"MS"
));
115
cv_param.insert(QString(
"accession"
), QCborValue(
"MS:1000041"
));
116
cv_param.insert(QString(
"value"
), QCborValue(charge));
117
cv_param.insert(QString(
"name"
), QCborValue(
"charge state"
));
118
cv_param_list.push_back(cv_param);
119
// <cvParam cvRef="MS" accession="MS:1000042" value="248032.25" name="peak intensity"
120
// unitAccession="MS:1000131" unitName="number of detector counts" unitCvRef="MS"/>
121
//
122
QCborMap cv_param_intensity;
123
cv_param_intensity.insert(QString(
"cvRef"
), QCborValue(
"MS"
));
124
cv_param_intensity.insert(QString(
"accession"
), QCborValue(
"MS:1000042"
));
125
cv_param_intensity.insert(QString(
"value"
), QCborValue(intensity));
126
cv_param_intensity.insert(QString(
"name"
), QCborValue(
"peak intensity"
));
127
cv_param_list.push_back(cv_param_intensity);
128
// <cvParam
129
// cvRef="MS" accession="MS:1000744" value="506.2513" name="selected ion m/z"
130
// unitAccession="MS:1000040" unitName="m/z" unitCvRef="MS"/>
131
QCborMap cv_param_mz;
132
cv_param_mz.insert(QString(
"cvRef"
), QCborValue(
"MS"
));
133
cv_param_mz.insert(QString(
"accession"
), QCborValue(
"MS:1000744"
));
134
cv_param_mz.insert(QString(
"value"
), QCborValue(mz));
135
cv_param_mz.insert(QString(
"name"
), QCborValue(
"selected ion m/z"
));
136
cv_param_list.push_back(cv_param_mz);
137
138
new_selected_ion.insert(QString(
"cvParam"
), cv_param_list);
139
140
141
QCborArray new_selected_ion_arr;
142
new_selected_ion_arr.push_back(new_selected_ion);
143
144
145
new_selected_ion_list.insert(QString(
"selectedIon"
), new_selected_ion_arr);
146
qDebug();
147
// it.value() = new_selected_ion_list;
148
insert(QCborValue(
"selectedIonList"
), new_selected_ion_list);
149
qDebug();
150
}
151
152
else
153
{
154
throw
pappso::PappsoException
(
155
QObject::tr(
"ERROR: no selectedIonList in QcborSpectrumPrecursor"
));
156
}
157
}
158
std::vector<SelectedIon>
159
QcborSpectrumPrecursor::getSelectedIonList
()
const
160
{
161
std::vector<SelectedIon> selected_ion_list;
162
auto
itout = constFind(QCborValue(
"selectedIonList"
));
163
if
(itout != end())
164
{
165
auto
it = itout.value().toMap().constFind(QCborValue(
"selectedIon"
));
166
if
(it != end())
167
{
168
for
(
auto
it_cv = it->toArray().cbegin(); it_cv != it->toArray().cend(); it_cv++)
169
{
170
SelectedIon
precursor;
171
precursor.
fromQCborMap
(it_cv->toMap());
172
selected_ion_list.push_back(precursor);
173
}
174
return
selected_ion_list;
175
}
176
else
177
{
178
throw
pappso::PappsoException
(
179
QObject::tr(
"ERROR: no selectedIon array in QcborSpectrumPrecursor"
));
180
}
181
}
182
else
183
{
184
throw
pappso::PappsoException
(
185
QObject::tr(
"ERROR: no selectedIonList in QcborSpectrumPrecursor"
));
186
}
187
}
188
}
// namespace mzcbor
189
}
// namespace cbor
190
}
// namespace pappso
pappso::ExceptionNotFound
Definition
exceptionnotfound.h:32
pappso::PappsoException
Definition
pappsoexception.h:41
pappso::cbor::mzcbor::QcborSpectrumPrecursor::getSelectedIonList
std::vector< SelectedIon > getSelectedIonList() const
Definition
qcborspectrumprecursor.cpp:159
pappso::cbor::mzcbor::QcborSpectrumPrecursor::getIsolationWindow
IsolationWindow getIsolationWindow() const
Definition
qcborspectrumprecursor.cpp:85
pappso::cbor::mzcbor::QcborSpectrumPrecursor::QcborSpectrumPrecursor
QcborSpectrumPrecursor(const QCborMap &cbor_map)
Definition
qcborspectrumprecursor.cpp:44
pappso::cbor::mzcbor::QcborSpectrumPrecursor::setSelectedIon
void setSelectedIon(double mz, double intensity, int charge)
Definition
qcborspectrumprecursor.cpp:102
pappso::cbor::mzcbor::QcborSpectrumPrecursor::getSpectrumRef
QString getSpectrumRef() const
Definition
qcborspectrumprecursor.cpp:52
pappso::cbor::mzcbor::QcborSpectrumPrecursor::setSpectrumRef
void setSpectrumRef(const QString &spectrum_ref)
Definition
qcborspectrumprecursor.cpp:69
exceptionnotfound.h
pappso::cbor::mzcbor
Definition
binarydataarray.h:41
pappso::cbor
Definition
cborstreamreader.cpp:35
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
precursor.h
PSI precursor object for mzML/mzCBOR.
qcborspectrumprecursor.h
Low level CBOR map to store an mzCBOR Spectrum object.
pappso::cbor::mzcbor::IsolationWindow
Definition
precursor.h:43
pappso::cbor::mzcbor::IsolationWindow::fromQCborMap
void fromQCborMap(const QCborMap &reader)
Definition
precursor.cpp:35
pappso::cbor::mzcbor::SelectedIon
Definition
precursor.h:72
pappso::cbor::mzcbor::SelectedIon::fromQCborMap
void fromQCborMap(const QCborMap &reader)
Definition
precursor.cpp:162
pappsomspp
core
processing
cbor
mzcbor
copyreplace
qcborspectrumprecursor.cpp
Generated on
for libpappsomspp by
1.17.0