libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
posttreatment.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/specglob/sgposttreatment.cpp
3 * \date 15/11/2023
4 * \author Olivier Langella
5 * \brief SpecGlobTool peptide model post treatment
6 *
7 * C++ implementation of the SpecGlob algorithm described in :
8 * 1. Prunier, G. et al. Fast alignment of mass spectra in large proteomics
9 * datasets, capturing dissimilarities arising from multiple complex
10 * modifications of peptides. BMC Bioinformatics 24, 421 (2023).
11 *
12 * HAL Id : hal-04296170 , version 1
13 * Mot de passe : hxo20cl
14 * DOI : 10.1186/s12859-023-05555-y
15 */
16
17
18/*
19 * SpecGlobTool, Spectra to peptide alignment tool
20 * Copyright (C) 2023 Olivier Langella
21 * <olivier.langella@universite-paris-saclay.fr>
22 *
23 * This program is free software: you can redistribute ipetide to spectrum
24 * alignmentt and/or modify it under the terms of the GNU General Public License
25 * as published by the Free Software Foundation, either version 3 of the
26 * License, or (at your option) any later version.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program. If not, see <http://www.gnu.org/licenses/>.
35 *
36 */
37
38#include "posttreatment.h"
39
40
41namespace pappso
42{
43namespace specglob
44{
46 const PeptideModel &peptide_model)
47 : m_originalPeptideModel(peptide_model), m_betterPeptideModel(peptide_model)
48{
49 m_precision = precision;
51
53}
54
58
59const PeptideModel &
64
65void
67{
70 {
71 // calculate the number of shared peaks with the deltaM on the last aa
76 {
77 }
78 else
79 {
80 // not better, get back to original peptide
82 }
83 }
84 else
85 {
87 }
88
89
90 // Try to remove complementary mass offset
91 // Not done if the number of peaks is increased by more than two peaks
92 // If the number of peaks > +2, it is considered as an information that must
93 // be kept in the alignment Could be modified...the information is in the
94 // preAligned column
95 PeptideModel test_peptide_model_remove_complementary(m_betterPeptideModel);
96 if(test_peptide_model_remove_complementary.eliminateComplementaryDelta(
98 {
99
100 test_peptide_model_remove_complementary.matchExperimentalPeaks(
102
103 qDebug()
104 << "test_peptide_model_remove_complementary.getCountSharedPeaks()="
105 << test_peptide_model_remove_complementary.getCountSharedPeaks()
106 << " m_betterPeptideModel.getCountSharedPeaks()="
108 if(test_peptide_model_remove_complementary.getCountSharedPeaks() <
110 {
111 qDebug() << "replace with "
112 << test_peptide_model_remove_complementary.toString();
114 test_peptide_model_remove_complementary);
115 }
116 }
117
118 // if bestModified contains negative offSet, try to remove amino acids to
119 // explain it
120 PeptideModel test_peptide_model_remove_negative = m_betterPeptideModel;
121 if(test_peptide_model_remove_negative.eliminateNegativeOffset(m_precision))
122 {
123 test_peptide_model_remove_negative.matchExperimentalPeaks(m_precision);
124 if(test_peptide_model_remove_negative.getCountSharedPeaks() >=
126 {
127 qDebug() << "replace with "
128 << test_peptide_model_remove_negative.toString();
129 m_betterPeptideModel.copyDeep(test_peptide_model_remove_negative);
130 }
131 }
132
133 // findBetterMassDifferencePosition
136
137
139 {
141 }
142
144}
145
146void
148{
149
150 PeptideModel better_peptide_model_move_offset = m_betterPeptideModel;
151 std::size_t best_count_shared_peaks =
153 qDebug() << best_count_shared_peaks;
154
155 qDebug() << m_betterPeptideModel.toString();
156 bool move = false;
157 for(std::size_t i = 0; i < m_betterPeptideModel.size(); i++)
158 {
159
160 qDebug() << "i =" << i;
161 if(m_betterPeptideModel.at(i).remove == true)
162 continue;
163 if(m_betterPeptideModel.at(i).mass_difference == 0.0)
164 continue;
165 if(m_betterPeptideModel.at(i).bracket == true)
166 {
167 // try to move if
168 double mass_diff = m_betterPeptideModel.at(i).mass_difference;
169 PeptideModel test_peptide_model_move_offset =
170 better_peptide_model_move_offset;
171 test_peptide_model_move_offset.at(i).mass_difference = 0;
172 qDebug() << test_peptide_model_move_offset.toString();
173
174 std::size_t j = i;
175 while(j > 0)
176 {
177 j -= 1;
178 if(test_peptide_model_move_offset.at(j).bracket == false)
179 break;
180 if(test_peptide_model_move_offset.at(j).mass_difference != 0.0)
181 break;
182
183 test_peptide_model_move_offset.at(j).mass_difference = mass_diff;
184 test_peptide_model_move_offset.matchExperimentalPeaks(
186
187 qDebug() << test_peptide_model_move_offset.toString() << " "
188 << test_peptide_model_move_offset.getCountSharedPeaks()
189 << " " << best_count_shared_peaks;
190 if(test_peptide_model_move_offset.getCountSharedPeaks() >
191 best_count_shared_peaks)
192 {
193 best_count_shared_peaks =
194 test_peptide_model_move_offset.getCountSharedPeaks();
195 better_peptide_model_move_offset.copyDeep(
196 test_peptide_model_move_offset);
197 move = true;
198 }
199 else
200 {
201 test_peptide_model_move_offset =
202 better_peptide_model_move_offset;
203 }
204 }
205 }
206 }
207
208 if(move)
209 {
210 m_betterPeptideModel.copyDeep(better_peptide_model_move_offset);
211 }
212 qDebug() << m_betterPeptideModel.toString();
213}
214
215
216void
218{
219
220 // We'll try to evaluate for each deltaM if it can be a neutral loss or not
221 // For this, we compare the number of shared peaks with and without the shift
222
223 PeptideModel better_peptide_model_for_neutral_loss;
224 std::size_t best_count_shared_peaks =
226 qDebug() << best_count_shared_peaks;
227 for(std::size_t i = 0; i < m_betterPeptideModel.size(); i++)
228 {
229 if(m_betterPeptideModel.at(i).remove == true)
230 continue;
231 if(m_betterPeptideModel.at(i).mass_difference == 0.0)
232 continue;
233
234
235 // try in the case we remove the offset
236 PeptideModel test_peptide_model_for_neutral_loss = m_betterPeptideModel;
237 test_peptide_model_for_neutral_loss.at(i).mass_difference = 0;
238 test_peptide_model_for_neutral_loss.matchExperimentalPeaks(m_precision);
239
240 qDebug() << test_peptide_model_for_neutral_loss.toString() << " "
241 << test_peptide_model_for_neutral_loss.getCountSharedPeaks()
242 << " " << best_count_shared_peaks;
243 if(test_peptide_model_for_neutral_loss.getCountSharedPeaks() >=
244 best_count_shared_peaks)
245 {
246 best_count_shared_peaks =
247 test_peptide_model_for_neutral_loss.getCountSharedPeaks();
248 better_peptide_model_for_neutral_loss.copyDeep(
249 test_peptide_model_for_neutral_loss);
250 }
251 }
252
253 if(better_peptide_model_for_neutral_loss.size() > 0)
254 {
255 m_betterPeptideModel.copyDeep(better_peptide_model_for_neutral_loss);
256 }
257}
258
259void
261{
262 double mass_delta = m_betterPeptideModel.getMassDelta();
263 std::size_t best_count_shared_peaks =
265 PeptideModel better_peptide_model_cumulating_residual_mass_delta;
266 for(std::size_t i = 0; i < m_betterPeptideModel.size(); i++)
267 {
268 if(m_betterPeptideModel.at(i).remove == true)
269 continue;
270 if(m_betterPeptideModel.at(i).mass_difference == 0.0)
271 continue;
272
273 PeptideModel test_peptide_model_cumulating_residual_mass_delta =
275 // try to cumulate the current mass difference with unexplained mass delta
276 // :
277 test_peptide_model_cumulating_residual_mass_delta.at(i).mass_difference +=
278 mass_delta;
279 test_peptide_model_cumulating_residual_mass_delta.matchExperimentalPeaks(
281 if(test_peptide_model_cumulating_residual_mass_delta
282 .getCountSharedPeaks() >= best_count_shared_peaks)
283 {
284 best_count_shared_peaks =
285 test_peptide_model_cumulating_residual_mass_delta
287 better_peptide_model_cumulating_residual_mass_delta.copyDeep(
288 test_peptide_model_cumulating_residual_mass_delta);
289 }
290 }
291
292 if(better_peptide_model_cumulating_residual_mass_delta.size() > 0)
293 {
295 better_peptide_model_cumulating_residual_mass_delta);
296 }
297}
298
299
300const PeptideModel &
305
306bool
308{
309 auto peptide_model = m_betterPeptideModel;
310
311 bool modif = false;
312 std::vector<pappso::AminoAcidChar> aa_list = {
332 if(peptide_model.checkForMutations(aa_list, m_precision))
333 {
334 modif = true;
335 }
336 pappso::Aa cysteine('C');
337 cysteine.addAaModification(
338 pappso::AaModification::getInstance("MOD:00397")); // carbamido
339 if(peptide_model.checkForMutation(cysteine, m_precision))
340 {
341 modif = true;
342 }
344 methionine.addAaModification(
345 pappso::AaModification::getInstance("MOD:00719")); // oxydation
346 if(peptide_model.checkForMutation(methionine, m_precision))
347 {
348 modif = true;
349 }
350 if(modif)
351 {
352 m_betterPeptideModel = peptide_model;
353 }
354 return modif;
355}
356} // namespace specglob
357} // namespace pappso
static AaModificationP getInstance(const QString &accession)
virtual pappso_double getNominal() const final
Definition precision.cpp:65
std::size_t getCountSharedPeaks() const
void matchExperimentalPeaks(pappso::PrecisionPtr precision)
bool eliminateNegativeOffset(pappso::PrecisionPtr precision)
double getMassDelta() const
mass delta between experimental and theoretical mass
bool eliminateComplementaryDelta(pappso::PrecisionPtr precision)
PeptideModel & copyDeep(const PeptideModel &other)
PostTreatment(pappso::PrecisionPtr precision, const PeptideModel &peptide_model)
const PeptideModel & getOriginalPeptideModel() const
pappso::PrecisionPtr m_precision
void findBetterPeptideModel()
whole processus to find a better peptide model
void tryToCumulateOffSets()
try to assign residual mass delta to non aligned elements
const PeptideModel & getBetterPeptideModel() const
void tryToRemoveOffsets()
try to remove offset (mass difference)
void tryBetterPositionOffsets()
try to move offset (mass difference)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39