libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
scan.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/core/processing/cbor/mzcbor/scan.cpp
3 * \date 03/02/2026
4 * \author Olivier Langella
5 * \brief PSI scan 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 "scan.h"
31
32
33void
35{
36 QString txt_value;
37 for(auto it_binarr = cbor_map.cbegin(); it_binarr != cbor_map.cend(); it_binarr++)
38 {
39 txt_value = it_binarr.key().toString();
40 qDebug() << txt_value;
41 if(txt_value == "cvParam")
42 {
43 cvParamMap.fromQCborArray(it_binarr.value().toArray());
44 // reader.next();
45 }
46 }
47}
48double
50{
51 // <cvParam cvRef="MS" accession="MS:1000016" value="0.0048758833" name="scan start
52 // time" unitAccession="UO:0000031" unitName="minute" unitCvRef="UO" />
53
54 auto it = cvParamMap.find("MS:1000016");
55 if(it == cvParamMap.end())
56 {
57 throw pappso::ExceptionNotFound(QObject::tr("retention time not found in cvParam map"));
58 }
59 double rt_seconds = it->second.valueDouble;
60 if(it->second.unitAccession == "UO:0000031")
61 {
62 // // minutes
63 rt_seconds = rt_seconds * 60;
64 }
65
66 // <cvParam cvRef="MS" accession="MS:1000016" value="0" name="scan start time"
67 // unitAccession="UO:0000031" unitName="minute" unitCvRef="UO" />
68 return rt_seconds;
69}
70
71void
73{
74
75 QString txt_value;
76 reader.enterContainer();
77 qDebug() << txt_value;
78 while(reader.hasNext() && (!reader.isInvalid()))
79 {
80 if(reader.isString())
81 {
82 if(reader.decodeString(txt_value))
83 {
84 qDebug() << txt_value;
85 if(txt_value == "cvParam")
86 {
87 // precursorListCvParamMap = CvParam::getCvParamsMapFromCbor(reader);
88 cvParamMap.fromCbor(reader);
89 }
90 else
91 {
92 reader.next();
93 }
94 }
95 else
96 {
97 reader.next();
98 }
99 }
100 else
101 {
102 reader.next();
103 }
104 }
105 reader.leaveContainer();
106}
107
108
109QJsonObject
111{
112 QJsonObject scan;
113 scan.insert("cvParam", cvParamMap.toJsonArray());
114 return scan;
115}
simple override of the raw QCborStreamReader This adds convenient functions to put CBOR data into C++...
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 scan object for mzML/mzCBOR.
QJsonObject toJsonObject() const
write the structure to a JSON object
Definition scan.cpp:110
void fromCbor(CborStreamReader &reader)
Definition scan.cpp:72
CvParamMap cvParamMap
Definition scan.h:56
void fromQCborMap(const QCborMap &reader)
Definition scan.cpp:34
double getRtInSeconds() const
Definition scan.cpp:49