libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
psmcborutils.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/cbor/psm/psmcborutils.cpp
3 * \date 16/09/2025
4 * \author Olivier Langella
5 * \brief PSM CBOR utilities
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#include "psmcborutils.h"
29
30namespace pappso
31{
32namespace cbor
33{
34namespace psm
35{
36void
38 QCborMap &cbor_scan, const pappso::QualifiedMassSpectrum &ms2_qualified_mass_spectrum)
39{
40 // id
41 QCborMap cbor_scan_id;
42 cbor_scan_id.insert(QString("index"),
43 (qint64)ms2_qualified_mass_spectrum.getMassSpectrumId().getSpectrumIndex());
44 cbor_scan_id.insert(QString("native_id"),
45 ms2_qualified_mass_spectrum.getMassSpectrumId().getNativeId());
46 cbor_scan.insert(QString("id"), cbor_scan_id.toCborValue());
47
48
49 // precursor
50 QCborMap cbor_scan_precursor;
51 cbor_scan_id.insert(QString("z"), ms2_qualified_mass_spectrum.getPrecursorCharge());
52 cbor_scan_id.insert(QString("mz"), ms2_qualified_mass_spectrum.getPrecursorMz());
53 cbor_scan_id.insert(QString("mh"), ms2_qualified_mass_spectrum.getPrecursorMass());
54 cbor_scan_id.insert(QString("intensity"), ms2_qualified_mass_spectrum.getPrecursorIntensity());
55 cbor_scan.insert(QString("precursor"), cbor_scan_precursor.toCborValue());
56
57
58 // ms2
59 QCborMap cbor_scan_ms2;
60 cbor_scan_ms2.insert(QString("rt"), ms2_qualified_mass_spectrum.getRtInSeconds());
61 cbor_scan.insert(QString("ms2"), cbor_scan_ms2.toCborValue());
62}
63} // namespace psm
64} // namespace cbor
65} // namespace pappso
std::size_t getSpectrumIndex() const
const QString & getNativeId() const
Class representing a fully specified mass spectrum.
uint getPrecursorCharge(bool *ok=nullptr) const
get precursor charge
pappso_double getPrecursorIntensity(bool *ok=nullptr) const
get precursor intensity
double getPrecursorMass(bool *ok_p=nullptr) const
get precursor mass given the charge stats and precursor mz
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
pappso_double getPrecursorMz(bool *ok=nullptr) const
get precursor mz
pappso_double getRtInSeconds() const
Get the retention time in seconds.
static void prepareCborScanWithSpectrum(QCborMap &cbor_scan, const pappso::QualifiedMassSpectrum &ms2_qualified_mass_spectrum)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39