libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
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
"
30
#include "
pappsomspp/core/exception/exceptionnotfound.h
"
31
32
33
void
34
pappso::cbor::mzcbor::Scan::fromQCborMap
(
const
QCborMap &cbor_map)
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
}
48
double
49
pappso::cbor::mzcbor::Scan::getRtInSeconds
()
const
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
71
void
72
pappso::cbor::mzcbor::Scan::fromCbor
(
CborStreamReader
&reader)
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
109
QJsonObject
110
pappso::cbor::mzcbor::Scan::toJsonObject
()
const
111
{
112
QJsonObject scan;
113
scan.insert(
"cvParam"
,
cvParamMap
.toJsonArray());
114
return
scan;
115
}
pappso::ExceptionNotFound
Definition
exceptionnotfound.h:32
pappso::cbor::CborStreamReader
simple override of the raw QCborStreamReader This adds convenient functions to put CBOR data into C++...
Definition
cborstreamreader.h:47
pappso::cbor::CborStreamReader::decodeString
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...
Definition
cborstreamreader.cpp:48
exceptionnotfound.h
scan.h
PSI scan object for mzML/mzCBOR.
pappso::cbor::mzcbor::Scan::toJsonObject
QJsonObject toJsonObject() const
write the structure to a JSON object
Definition
scan.cpp:110
pappso::cbor::mzcbor::Scan::fromCbor
void fromCbor(CborStreamReader &reader)
Definition
scan.cpp:72
pappso::cbor::mzcbor::Scan::cvParamMap
CvParamMap cvParamMap
Definition
scan.h:56
pappso::cbor::mzcbor::Scan::fromQCborMap
void fromQCborMap(const QCborMap &reader)
Definition
scan.cpp:34
pappso::cbor::mzcbor::Scan::getRtInSeconds
double getRtInSeconds() const
Definition
scan.cpp:49
pappsomspp
core
processing
cbor
mzcbor
scan.cpp
Generated on
for libpappsomspp by
1.17.0