libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
peptidemodificatorpipeline.cpp
Go to the documentation of this file.
1
2/*******************************************************************************
3 * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
4 *
5 * This file is part of the PAPPSOms++ library.
6 *
7 * PAPPSOms++ is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * PAPPSOms++ is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Contributors:
21 * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
22 *implementation
23 ******************************************************************************/
24
28#include "../pappsoexception.h"
29#include <QStringList>
30using namespace pappso;
31
32
33// QRegularExpression
34// PeptideModificatorPipeline::_rx_modmass("[-+]?[0-9]*\\.?[0-9]*");
35
39
41 const PeptideModificatorPipeline &other)
42{
43 throw PappsoException(
44 QObject::tr("unable to copy PeptideModificatorPipeline object"));
45 if(other.mp_peptideModificatorTee != nullptr)
46 {
47 // mp_peptideModificatorTee = new
48 // PeptideModificatorTee(other.mp_peptideModificatorTee);
49 }
50
52 mp_firstModificator = nullptr;
53 for(auto p_mod : other.m_pepModificatorPtrList)
54 {
55 delete(p_mod);
56 }
57
58
59 m_sink = other.m_sink;
60
62
64
66}
67
69{
70
71 for(auto p_mod : m_pepModificatorPtrList)
72 {
73 delete(p_mod);
74 }
75 if(mp_peptideModificatorTee == nullptr)
76 {
78 }
79}
80
81void
83{
84 if(mp_peptideModificatorTee != nullptr)
85 {
86 throw PappsoException(QObject::tr(
87 "Please use setSink before addLabeledModificationString function"));
88 }
89
90 m_sink = sink;
91 if(mp_firstModificator != nullptr)
92 {
94 }
95};
96
97void
99{
100 privAddFixedModificationString(mod_str, true, true, true);
101}
102void
104 const QString &mod_str)
105{
106 privAddFixedModificationString(mod_str, true, false, false);
107}
108void
110 const QString &mod_str)
111{
112 privAddFixedModificationString(mod_str, false, true, false);
113}
114
115void
117 const QString &mod_str, bool Nter, bool Cter, bool else_prot)
118{
119 //"MOD:00397@C, MOD:00398@R"
120 if(mp_peptideModificatorTee != nullptr)
121 {
122 throw PappsoException(
123 QObject::tr("Unable to add fixed modification string after "
124 "addLabeledModificationString function"));
125 }
126 QStringList mod_list_str =
127 mod_str.simplified().replace(" ", "").split(",", Qt::SkipEmptyParts);
128 for(auto i = 0; i < mod_list_str.size(); ++i)
129 {
130 parseFixedModification(mod_list_str[i], Nter, Cter, else_prot);
131 }
132}
133
134
135void
137 bool Nter,
138 bool Cter,
139 bool else_prot)
140{
141
142 QStringList str_split = mod_str.split("@", Qt::SkipEmptyParts);
143
145
148 mod->setModificationPattern(str_split[1]);
149 mod->setSink(m_sink);
150 mod->setProtNter(Nter);
151 mod->setProtCter(Cter);
152 mod->setProtElse(else_prot);
153
154 m_pepModificatorPtrList.push_back(mod);
155
156 if(mp_firstModificator == nullptr)
157 {
159 }
160 else
161 {
163 }
165}
166
167void
169 const QString &mod_str)
170{
171 privAddPotentialModificationString(mod_str, true, true, true);
172}
173// protein Nter modification
174void
176 const QString &mod_str)
177{
178 privAddPotentialModificationString(mod_str, true, false, false);
179}
180// protein Cter modification
181void
183 const QString &mod_str)
184{
185 privAddPotentialModificationString(mod_str, false, true, false);
186}
187
188void
190 const QString &mod_str, bool Nter, bool Cter, bool else_prot)
191{
192 //"MOD:00397@C, MOD:00398@R"
193 if(mp_peptideModificatorTee != nullptr)
194 {
195 throw PappsoException(
196 QObject::tr("Unable to add potential modification string after "
197 "addLabeledModificationString function"));
198 }
199
200 QStringList mod_list_str =
201 mod_str.simplified().replace(" ", "").split(",", Qt::SkipEmptyParts);
202 for(auto i = 0; i < mod_list_str.size(); ++i)
203 {
204 parsePotentialModification(mod_list_str[i], Nter, Cter, else_prot);
205 }
206}
207
208
209void
211 bool Nter,
212 bool Cter,
213 bool else_prot)
214{
215
216 QStringList str_split = mod_str.split("@", Qt::SkipEmptyParts);
217
218 QString mod_acc_str = str_split[0];
219 QStringList str_acc_split = mod_acc_str.split("(", Qt::SkipEmptyParts);
221 AaModification::getInstance(str_acc_split[0]);
222
225
226 // qDebug() << "PeptideModificatorPipeline::parsePotentialModification " << ;
227 if(str_acc_split.length() == 2)
228 {
229 QStringList max_num_str_list =
230 str_acc_split[1].replace(")", "").split("-", Qt::SkipEmptyParts);
231 if(max_num_str_list.length() == 1)
232 {
233 mod->setModificationCounter(max_num_str_list[0].toUInt());
234 }
235 else if(max_num_str_list.length() == 2)
236 {
237 mod->setMinNumberMod(max_num_str_list[0].toUInt());
238 mod->setMaxNumberMod(max_num_str_list[1].toUInt());
239 }
240 }
241 mod->setModificationPattern(str_split[1]);
242 mod->setSink(m_sink);
243 mod->setProtNter(Nter);
244 mod->setProtCter(Cter);
245 mod->setProtElse(else_prot);
246
247 m_pepModificatorPtrList.push_back(mod);
248
249 if(mp_firstModificator == nullptr)
250 {
252 }
253 else
254 {
256 }
258}
259
260
261void
263{
264
265 if(m_sink == nullptr)
266 {
267 throw PappsoException(QObject::tr(
268 "Please use setSink before addLabeledModificationString function"));
269 }
270 if(mp_peptideModificatorTee == nullptr)
271 {
273 }
274 if(mp_firstModificator == nullptr)
275 {
277 }
278
279 // backup pointers
280 PeptideModificatorInterface *backup_sink = m_sink;
281
282 PeptideSpSinkInterface *backup_p_last_peptide_sink_interface =
284
285 PeptideModificatorInterface *backup_p_first_modificator = mp_firstModificator;
286
287
288 QStringList mod_list_str =
289 mod_str.simplified().replace(" ", "").split(",", Qt::SkipEmptyParts);
290 for(auto i = 0; i < mod_list_str.size(); ++i)
291 {
292 parseLabeledModification(mod_list_str[i], true, true, true);
293
294 if(i == 0)
295 {
297 }
298 }
299
300 m_sink = backup_sink;
301 mp_lastPeptideSinkInterface = backup_p_last_peptide_sink_interface;
302 mp_firstModificator = backup_p_first_modificator;
303
305}
306
307
308void
310 bool Nter,
311 bool Cter,
312 bool else_prot)
313{
314
315 QStringList str_split = mod_str.split("@", Qt::SkipEmptyParts);
317
320 mod->setModificationPattern(str_split[1]);
321 mod->setSink(m_sink);
322 mod->setProtNter(Nter);
323 mod->setProtCter(Cter);
324 mod->setProtCter(else_prot);
325
326 m_pepModificatorPtrList.push_back(mod);
327
331}
332
333
334void
335PeptideModificatorPipeline::setPeptideSp(std::int8_t sequence_database_id,
336 const ProteinSp &protein_sp,
337 bool is_decoy,
338 const PeptideSp &peptide_sp_original,
339 unsigned int start,
340 bool is_nter,
341 unsigned int missed_cleavage_number,
342 bool semi_enzyme)
343{
344 if(mp_firstModificator == nullptr)
345 {
346 m_sink->setPeptideSp(sequence_database_id,
347 protein_sp,
348 is_decoy,
349 peptide_sp_original,
350 start,
351 is_nter,
352 missed_cleavage_number,
353 semi_enzyme);
354 }
355 else
356 {
357 mp_firstModificator->setPeptideSp(sequence_database_id,
358 protein_sp,
359 is_decoy,
360 peptide_sp_original,
361 start,
362 is_nter,
363 missed_cleavage_number,
364 semi_enzyme);
365 }
366}
367
368
369void
370PeptideModificatorPipeline::setPeptide(std::int8_t sequence_database_id,
371 const ProteinSp &protein_sp,
372 bool is_decoy,
373 const QString &peptide_str,
374 unsigned int start,
375 bool is_nter,
376 unsigned int missed_cleavage_number,
377 bool semi_enzyme)
378{
379
380 qDebug() << "PeptideModificatorPipeline::setPeptide begin";
381
382 Peptide peptide(peptide_str);
383
384 PeptideSp peptide_sp = peptide.makePeptideSp();
385
386 qDebug() << "PeptideModificatorPipeline::setPeptide m_sink->setPeptideSp";
387 setPeptideSp(sequence_database_id,
388 protein_sp,
389 is_decoy,
390 peptide_sp,
391 start,
392 is_nter,
393 missed_cleavage_number,
394 semi_enzyme);
395 qDebug() << "PeptideModificatorPipeline::setPeptide end";
396}
static AaModificationP getInstance(const QString &accession)
void setProtElse(bool arg1)
this modification concerns all peptides between Nter and Cter
void setProtCter(bool arg1)
this modification concerns the Cter peptide
void setSink(PeptideModificatorInterface *sink) override
void setProtNter(bool arg1)
this modification concerns the Nter peptide
virtual void setModificationPattern(QString &pattern) final
set the pattern on which the modification will be applied (usually the list of concerned AA)
virtual void setPeptideSp(std::int8_t sequence_database_id, const ProteinSp &protein_sp, bool is_decoy, const PeptideSp &peptide_sp, unsigned int start, bool is_nter, unsigned int missed_cleavage_number, bool semi_enzyme)=0
function to give the products of modifications for a digested peptide
void addFixedNterModificationString(const QString &mod_str)
void addPotentialCterModificationString(const QString &mod_str)
void parsePotentialModification(const QString &mod_str, bool Nter, bool Cter, bool else_prot)
void addLabeledModificationString(const QString &mod_str)
void setSink(PeptideModificatorInterface *sink) override
void parseLabeledModification(const QString &mod_str, bool Nter, bool Cter, bool else_prot)
void privAddFixedModificationString(const QString &mod_str, bool Nter, bool Cter, bool else_prot)
void privAddPotentialModificationString(const QString &mod_str, bool Nter, bool Cter, bool else_prot)
void setPeptideSp(std::int8_t sequence_database_id, const ProteinSp &protein_sp, bool is_decoy, const PeptideSp &peptide_sp_original, unsigned int start, bool is_nter, unsigned int missed_cleavage_number, bool semi_enzyme) override
function to give the products of modifications for a digested peptide
void addFixedModificationString(const QString &mod_str)
std::vector< PeptideModificatorInterface * > m_pepModificatorPtrList
PeptideModificatorInterface * mp_firstModificator
void setPeptide(std::int8_t sequence_database_id, const ProteinSp &protein_sp, bool is_decoy, const QString &peptide_str, unsigned int start, bool is_nter, unsigned int missed_cleavage_number, bool semi_enzyme) override
function to give the products of a protein digestion by an enzyme
PeptideSpSinkInterface * mp_lastPeptideSinkInterface
void addFixedCterModificationString(const QString &mod_str)
void addPotentialNterModificationString(const QString &mod_str)
void addPotentialModificationString(const QString &mod_str)
void parseFixedModification(const QString &mod_str, bool Nter, bool Cter, bool else_prot)
void addModificator(PeptideModificatorInterface *p_peptide_mod)
virtual void setSink(PeptideModificatorInterface *sink)=0
Modify a peptide shared pointer with a variable modification on one AA.
void setSink(PeptideModificatorInterface *sink) override
void setProtNter(bool arg1)
this modification concerns the Nter peptide
void setProtElse(bool arg1)
this modification concerns all peptides between Nter and Cter
void setProtCter(bool arg1)
this modification concerns the Cter peptide
PeptideSp makePeptideSp() const
Definition peptide.cpp:126
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const Peptide > PeptideSp
std::shared_ptr< const Protein > ProteinSp
shared pointer on a Protein object
Definition protein.h:47