libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
psmspecpeptidoms.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/cbor/psm/evalscan/psmspecglob.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
29#include "psmspecpeptidoms.h"
30
31#include "../../../../processing/filters/filterchargedeconvolution.h"
32#include "../../../../processing/filters/filterresample.h"
33#include "../../../../processing/filters/filterpass.h"
34#include "../../../../peptide/peptideproformaparser.h"
35#include "../../../../pappsoexception.h"
36#include "../../../../processing/specpeptidoms/semiglobalalignment.h"
37#include "../../../../processing/specpeptidoms/spomsspectrum.h"
38
40 pappso::cbor::CborStreamWriter *cbor_output_p,
41 const QJsonObject &parameters)
42 : PsmFileScanProcessAndCopy(buffer_scan_size, cbor_output_p, "SpecPeptidOms")
43{
44 m_specpeptidomsParameters = parameters;
45
46 if(parameters.value("fragment_tolerance_unit").toString() == "dalton")
47 {
49 parameters.value("fragment_tolerance").toDouble());
50 }
51 else if(parameters.value("fragment_tolerance_unit").toString() == "ppm")
52 {
54 pappso::PrecisionFactory::getPpmInstance(parameters.value("fragment_tolerance").toDouble());
55 }
56
57 QJsonObject spectrum_param = parameters.value("spectrum").toObject();
58
59 m_minimumMz = spectrum_param.value("minimum_mz").toDouble();
60 m_nMostIntense = spectrum_param.value("n_most_intense").toInt();
61 m_deisotope = spectrum_param.value("deisotope").toBool();
62
64}
65
69
70void
72{
73 if(m_deisotope)
74 pappso::FilterChargeDeconvolution(m_fragmentTolerance).filter(mass_spectrum);
75 pappso::FilterResampleKeepGreater(m_minimumMz).filter(mass_spectrum);
76 pappso::FilterGreatestY(m_nMostIntense).filter(mass_spectrum);
77}
78
79void
83
86{
87 return new PsmSpecPeptidOmsScan(*this, m_fragmentTolerance);
88}
89
90const pappso::AaCode &
92{
93 return m_aaCode;
94}
95
96
98 const pappso::cbor::psm::PsmSpecPeptidOms &psm_specpeptidoms,
99 pappso::PrecisionPtr fragment_tolerance)
100 : CborScanMapBase(psm_specpeptidoms)
101{
102 m_fragmentTolerance = fragment_tolerance;
103 mp_psmSpecPeptidOms = &psm_specpeptidoms;
104}
105
109
110void
112{
113 // qDebug() << keys();
114 if(!keys().contains("id"))
115 {
116 throw pappso::PappsoException(QObject::tr("missing scan id"));
117 }
118 if(keys().contains("psm_list"))
119 {
120 QualifiedMassSpectrumSPtr qualified_mass_spectrum = getCurrentQualifiedMassSpectrumSPtr();
121
122
123 mp_psmSpecPeptidOms->filterMassSpectrum(
124 *(qualified_mass_spectrum.get()->getMassSpectrumSPtr().get()));
125
126 QCborArray new_psm_arr;
127 for(QCborValue cbor_psm : value("psm_list").toArray())
128 {
129 QCborMap cbor_psm_map = cbor_psm.toMap();
130
131 if(!cbor_psm_map.keys().contains("proforma"))
132 {
134 QObject::tr("missing proforma in psm %1").arg(cbor_psm_map.keys().size()));
135 }
136 QCborMap cbor_psm_eval_specglob;
137 pappso::PeptideSp peptide_sp =
138 pappso::PeptideProFormaParser::parseString(cbor_psm_map.value("proforma").toString());
139
140
141 pappso::specpeptidoms::SpOMSSpectrumCsp experimental_spectrum =
142 std::make_shared<pappso::specpeptidoms::SpOMSSpectrum>(
143 *qualified_mass_spectrum.get(),
144 m_fragmentTolerance,
145 mp_psmSpecPeptidOms->getAaCode());
146 /*
147 pappso::specglob::SpectralAlignment
148 spectral_alignment(pappso::specglob::ScoreValues(), m_fragmentTolerance);
149
150 spectral_alignment.align(peptide_spectra, experimental_spectrum);
151
152
153 cbor_psm_eval_specglob.insert(QString("max_score"),
154 spectral_alignment.getMaxScore());
155
156
157 if(spectral_alignment.getMaxScore() > 0)
158 {
159 pappso::specglob::PeptideModel peptide_model =
160 spectral_alignment.buildPeptideModel();
161
162 // peptide_model.eliminateComplementaryDelta(m_fragmentTolerance);
163 // peptide_model.matchExperimentalPeaks(m_fragmentTolerance);
164
165
166 pappso::specglob::PostTreatment post_treatment(m_fragmentTolerance,
167 peptide_model); if(m_checkMutations) post_treatment.findReplaceMutations();
168 peptide_model = post_treatment.getBetterPeptideModel();
169
170 cbor_psm_eval_specglob.insert(QString("count"),
171 (qint64)peptide_model.getCountSharedPeaks());
172
173 cbor_psm_eval_specglob.insert(QString("proforma"),
174 peptide_model.toProForma()); cbor_psm_eval_specglob.insert(QString("bracket"),
175 peptide_model.toString());
176
177 // peptide_model.checkForMutations()
178 }
179
180
181 QCborMap psm_eval = cbor_psm_map.value("eval").toMap();
182 psm_eval.remove(QString("specglob"));
183 psm_eval.insert(QString("specglob"), cbor_psm_eval_specglob);
184 cbor_psm_map.remove(QString("eval"));
185 cbor_psm_map.insert(QString("eval"), psm_eval);
186
187 new_psm_arr.push_back(cbor_psm_map);
188 */
189 }
190
191 // insert(QString("psm_list"), new_psm_arr);
192 remove(QString("psm_list"));
193 insert(QString("psm_list"), new_psm_arr);
194 }
195}
collection of integer code for each amino acid 0 => null 1 to 20 => amino acid sorted by there mass (...
Definition aacode.h:44
void addAaModification(char aa_letter, AaModificationP aaModification)
add a modification on an amino acid for example carbamido on C
Definition aacode.cpp:164
static AaModificationP getInstance(const QString &accession)
Trace & filter(Trace &data_points) const override
get all the datapoints and remove different isotope and add their intensity and change to charge = 1 ...
keep N datapoints form the greatest intensities to the lowest
Definition filterpass.h:96
Trace & filter(Trace &data_points) const override
Trace & filter(Trace &trace) const override
Class to represent a mass spectrum.
static PeptideSp parseString(const QString &pepstr)
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Basic PSM file reader to process scan (parallelized scan processing) and write a new resulting PSM fi...
const PsmSpecPeptidOms * mp_psmSpecPeptidOms
PsmSpecPeptidOmsScan(const PsmSpecPeptidOms &psm_specpeptidoms, pappso::PrecisionPtr fragment_tolerance)
void parameterMapReady(pappso::UiMonitorInterface &monitor) override
PsmSpecPeptidOms(std::size_t buffer_scan_size, CborStreamWriter *cbor_output_p, const QJsonObject &parameters)
const pappso::AaCode & getAaCode() const
void filterMassSpectrum(pappso::MassSpectrum &mass_spectrum) const
CborScanMapBase * newCborScanMap() override
std::shared_ptr< const SpOMSSpectrum > SpOMSSpectrumCsp
std::shared_ptr< QualifiedMassSpectrum > QualifiedMassSpectrumSPtr
std::shared_ptr< const Peptide > PeptideSp