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
33double
35{
36 // <cvParam cvRef="MS" accession="MS:1000016" value="0.0048758833" name="scan start
37 // time" unitAccession="UO:0000031" unitName="minute" unitCvRef="UO" />
38
39 auto it = cvParamMap.find("MS:1000016");
40 if(it == cvParamMap.end())
41 {
42 throw pappso::ExceptionNotFound(QObject::tr("retention time not found in cvParam map"));
43 }
44 double rt_seconds = it->second.valueDouble;
45 if(it->second.unitAccession == "UO:0000031")
46 {
47 // // minutes
48 rt_seconds = rt_seconds * 60;
49 }
50
51 // <cvParam cvRef="MS" accession="MS:1000016" value="0" name="scan start time"
52 // unitAccession="UO:0000031" unitName="minute" unitCvRef="UO" />
53 return rt_seconds;
54}
55
56void
58{
59
60 QString txt_value;
61 reader.enterContainer();
62 qDebug() << txt_value;
63 while(reader.hasNext() && (!reader.isInvalid()))
64 {
65 if(reader.isString())
66 {
67 if(reader.decodeString(txt_value))
68 {
69 qDebug() << txt_value;
70 if(txt_value == "cvParam")
71 {
72 // precursorListCvParamMap = CvParam::getCvParamsMapFromCbor(reader);
73 cvParamMap.fromCbor(reader);
74 }
75 else
76 {
77 reader.next();
78 }
79 }
80 else
81 {
82 reader.next();
83 }
84 }
85 else
86 {
87 reader.next();
88 }
89 }
90 reader.leaveContainer();
91}
92
93
94QJsonObject
96{
97 QJsonObject scan;
98 scan.insert("cvParam", cvParamMap.toJsonArray());
99 return scan;
100}
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:95
void fromCbor(CborStreamReader &reader)
Definition scan.cpp:57
CvParamMap cvParamMap
Definition scan.h:55
double getRtInSeconds() const
Definition scan.cpp:34