libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
psmspecglobscan.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/cbor/psm/evalscan/psmspecglobscan.cpp
3 * \date 19/07/2025
4 * \author Olivier Langella
5 * \brief compute specglob alignment on scan's PSM
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 "psmspecglobscan.h"
33#include <QCborArray>
34
36 pappso::PrecisionPtr fragment_tolerance)
37 : CborScanMapBase(psm_specgloc)
38{
39 m_fragmentTolerance = fragment_tolerance;
40 mp_psmSpecGlob = &psm_specgloc;
41}
42
46
47void
49{
50 // qDebug() << keys();
51 if(!keys().contains("id"))
52 {
53 throw pappso::PappsoException(QObject::tr("missing scan id"));
54 }
55 if(keys().contains("psm_list"))
56 {
58
59
60 mp_psmSpecGlob->filterMassSpectrum(
61 *(qualified_mass_spectrum.get()->getMassSpectrumSPtr().get()));
62
63 QCborArray new_psm_arr;
64 for(QCborValue cbor_psm : value("psm_list").toArray())
65 {
66 QCborMap cbor_psm_map = cbor_psm.toMap();
67
68 if(!cbor_psm_map.keys().contains("proforma"))
69 {
71 QObject::tr("missing proforma in psm %1").arg(cbor_psm_map.keys().size()));
72 }
73 QCborMap cbor_psm_eval_specglob;
74 pappso::PeptideSp peptide_sp =
75 pappso::PeptideProFormaParser::parseString(cbor_psm_map.value("proforma").toString());
76
78 std::make_shared<pappso::specglob::PeptideSpectrum>(peptide_sp);
79
80
81 pappso::specglob::ExperimentalSpectrumCsp experimental_spectrum =
82 std::make_shared<pappso::specglob::ExperimentalSpectrum>(*qualified_mass_spectrum.get(),
86
87 spectral_alignment.align(peptide_spectra, experimental_spectrum);
88
89
90 cbor_psm_eval_specglob.insert(QString("max_score"), spectral_alignment.getMaxScore());
91
92
93 if(spectral_alignment.getMaxScore() > 0)
94 {
95 pappso::specglob::PeptideModel peptide_model = spectral_alignment.buildPeptideModel();
96
97 // peptide_model.eliminateComplementaryDelta(m_fragmentTolerance);
98 // peptide_model.matchExperimentalPeaks(m_fragmentTolerance);
99
100
101 pappso::specglob::PostTreatment post_treatment(m_fragmentTolerance, peptide_model);
103 post_treatment.findReplaceMutations();
104 peptide_model = post_treatment.getBetterPeptideModel();
105
106 cbor_psm_eval_specglob.insert(QString("count"),
107 (qint64)peptide_model.getCountSharedPeaks());
108
109 cbor_psm_eval_specglob.insert(QString("proforma"), peptide_model.toProForma());
110 cbor_psm_eval_specglob.insert(QString("bracket"), peptide_model.toString());
111
112 // peptide_model.checkForMutations()
113 }
114
115
116 QCborMap psm_eval = cbor_psm_map.value("eval").toMap();
117 psm_eval.remove(QString("specglob"));
118 psm_eval.insert(QString("specglob"), cbor_psm_eval_specglob);
119 cbor_psm_map.remove(QString("eval"));
120 cbor_psm_map.insert(QString("eval"), psm_eval);
121
122 new_psm_arr.push_back(cbor_psm_map);
123 }
124
125 // insert(QString("psm_list"), new_psm_arr);
126 remove(QString("psm_list"));
127 insert(QString("psm_list"), new_psm_arr);
128 }
129}
static PeptideSp parseString(const QString &pepstr)
CborScanMapBase(const PsmFileScanProcess &psm_file_scan_process)
pappso::QualifiedMassSpectrumSPtr getCurrentQualifiedMassSpectrumSPtr() const
pappso::PrecisionPtr m_fragmentTolerance
PsmSpecGlobScan(const PsmSpecGlob &psm_specgloc, pappso::PrecisionPtr fragment_tolerance)
std::size_t getCountSharedPeaks() const
QString toProForma() const
get the peptide model in ProForma notation https://github.com/HUPO-PSI/ProForma/blob/master/README....
const PeptideModel & getBetterPeptideModel() const
void align(PeptideSpectraCsp peptide_spectrum, ExperimentalSpectrumCsp experimental_spectrum)
build the alignment matrix between a peptide sequence and an experimental spectrum
std::shared_ptr< const PeptideSpectrum > PeptideSpectraCsp
std::shared_ptr< const ExperimentalSpectrum > ExperimentalSpectrumCsp
std::shared_ptr< QualifiedMassSpectrum > QualifiedMassSpectrumSPtr
std::shared_ptr< const Peptide > PeptideSp
const PrecisionBase * PrecisionPtr
Definition precision.h:122