libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
precursor.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/core/processing/cbor/mzcbor/precursor.h
3 * \date 24/11/2025
4 * \author Olivier Langella
5 * \brief PSI precursor object for mzML/mzCBOR
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.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 "precursor.h"
31
32
33void
35{
36 QString txt_value;
37 reader.enterContainer();
38 qDebug() << txt_value;
39 while(reader.hasNext() && (!reader.isInvalid()))
40 {
41 if(reader.isString())
42 {
43 if(reader.decodeString(txt_value))
44 {
45 qDebug() << txt_value;
46 if(txt_value == "cvParam")
47 {
49 // reader.next();
50 }
51 else
52 {
53 reader.next();
54 }
55 }
56 else
57 {
58 reader.next();
59 }
60 }
61 else
62 {
63 reader.next();
64 }
65 }
66 reader.leaveContainer();
67}
68
69
70int
72{
73
74 // <cvParam cvRef="MS" accession="MS:1000041" value="3" name="charge state" />
75
76 auto it = cvParamMap.find("MS:1000041");
77 if(it == cvParamMap.end())
78 {
80 QObject::tr("Charge state not found in SelectedIon cvParam map"));
81 }
82 qDebug() << it->first << " " << it->second.valueInt;
83 return it->second.valueInt;
84}
85
86qint64
88{
89
90 // <cvParam cvRef="MS" accession="MS:1000042" value="248032.25" name="peak intensity"
91 // unitAccession="MS:1000131" unitName="number of detector counts" unitCvRef="MS" />
92
93 auto it = cvParamMap.find("MS:1000042");
94 if(it == cvParamMap.end())
95 {
97 QObject::tr("Intensity not found in SelectedIon cvParam map"));
98 }
99 qDebug() << it->first << " " << it->second.valueInt;
100 return it->second.valueInt;
101}
102
103double
105{
106
107 // <cvParam cvRef="MS" accession="MS:1000744" value="506.2513" name="selected ion m/z"
108 // unitAccession="MS:1000040" unitName="m/z" unitCvRef="MS" />
109
110 auto it = cvParamMap.find("MS:1000744");
111 if(it == cvParamMap.end())
112 {
113 throw pappso::ExceptionNotFound(QObject::tr("m/z not found in SelectedIon cvParam map"));
114 }
115 qDebug() << it->first << " " << it->second.valueDouble;
116 return it->second.valueDouble;
117}
118
119
120void
122{
123
124 QString txt_value;
125 reader.enterContainer();
126 qDebug() << txt_value;
127 while(reader.hasNext() && (!reader.isInvalid()))
128 {
129 if(reader.isString())
130 {
131 if(reader.decodeString(txt_value))
132 {
133 qDebug() << txt_value;
134 if(txt_value == "cvParam")
135 {
136 // precursorListCvParamMap = CvParam::getCvParamsMapFromCbor(reader);
137 reader.next();
138 }
139 else if(txt_value == "isolationWindow")
140 {
141 reader.next();
142 }
143 else if(txt_value == "selectedIonList")
144 {
145
146 reader.enterContainer();
147
148 while(reader.hasNext() && (!reader.isInvalid()))
149 {
150 if(reader.isString())
151 {
152 if(reader.decodeString(txt_value))
153 {
154 qDebug() << txt_value;
155 if(txt_value == "cvParam")
156 {
159 }
160 else if(txt_value == "selectedIon")
161 {
162
163 reader.enterContainer(); // array
164
165 while(reader.hasNext() && (!reader.isInvalid()))
166 {
167 SelectedIon selected_ion;
168 selected_ion.fromCbor(reader);
169 selectedIonList.emplace_back(selected_ion);
170 }
171 reader.leaveContainer(); // array
172 }
173 else
174 {
175 reader.next();
176 }
177 }
178 else
179 {
180 reader.next();
181 }
182 }
183 else
184 {
185 reader.next();
186 }
187 }
188 reader.leaveContainer();
189 }
190 else if(txt_value == "activation")
191 {
192 qDebug();
193 reader.next();
194 }
195
196 else if(txt_value == "spectrumRef")
197 {
198 reader.decodeString(txt_value);
199 qDebug() << txt_value;
200 spectrumRef = txt_value;
201 }
202 else
203 {
204 reader.next();
205 }
206 }
207 else
208 {
209 reader.next();
210 }
211 }
212 else
213 {
214 reader.next();
215 }
216 }
217 reader.leaveContainer();
218}
bool decodeString(QString &the_str)
decode the current cbor value as a string the point to the next value the current value is decoded as...
PSI precursor object for mzML/mzCBOR.
static std::map< QString, pappso::cbor::mzcbor::CvParam > getCvParamsMapFromCbor(CborStreamReader &reader)
Definition cvparam.cpp:182
std::vector< SelectedIon > selectedIonList
Definition precursor.h:62
void fromCbor(CborStreamReader &reader)
std::map< QString, pappso::cbor::mzcbor::CvParam > selectedIonListCvParamMap
Definition precursor.h:60
std::map< QString, pappso::cbor::mzcbor::CvParam > cvParamMap
Definition precursor.h:49
void fromCbor(CborStreamReader &reader)
Definition precursor.cpp:34