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
29#include <QStringList>
30using namespace pappso;
31
32
33// QRegularExpression
34// PeptideModificatorPipeline::_rx_modmass("[-+]?[0-9]*\\.?[0-9]*");
35
39
41{
42 throw PappsoException(QObject::tr("unable to copy PeptideModificatorPipeline object"));
43 if(other.mp_peptideModificatorTee != nullptr)
44 {
45 // mp_peptideModificatorTee = new
46 // PeptideModificatorTee(other.mp_peptideModificatorTee);
47 }
48
50 mp_firstModificator = nullptr;
51 for(auto p_mod : other.m_pepModificatorPtrList)
52 {
53 delete(p_mod);
54 }
55
56
57 m_sink = other.m_sink;
58
60
62
64}
65
67{
68
69 for(auto p_mod : m_pepModificatorPtrList)
70 {
71 delete(p_mod);
72 }
73 if(mp_peptideModificatorTee == nullptr)
74 {
76 }
77}
78
79void
81{
82 if(mp_peptideModificatorTee != nullptr)
83 {
84 throw PappsoException(
85 QObject::tr("Please use setSink before addLabeledModificationString function"));
86 }
87
88 m_sink = sink;
89 if(mp_firstModificator != nullptr)
90 {
92 }
93};
94
95void
97{
98 privAddFixedModificationString(mod_str, true, true, true);
99}
100void
102{
103 privAddFixedModificationString(mod_str, true, false, false);
104}
105void
107{
108 privAddFixedModificationString(mod_str, false, true, false);
109}
110
111void
113 bool Nter,
114 bool Cter,
115 bool else_prot)
116{
117 //"MOD:00397@C, MOD:00398@R"
118 if(mp_peptideModificatorTee != nullptr)
119 {
120 throw PappsoException(
121 QObject::tr("Unable to add fixed modification string after "
122 "addLabeledModificationString function"));
123 }
124 QStringList mod_list_str = mod_str.simplified().replace(" ", "").split(",", Qt::SkipEmptyParts);
125 for(auto i = 0; i < mod_list_str.size(); ++i)
126 {
127 parseFixedModification(mod_list_str[i], Nter, Cter, else_prot);
128 }
129}
130
131
132void
134 bool Nter,
135 bool Cter,
136 bool else_prot)
137{
138
139 QStringList str_split = mod_str.split("@", Qt::SkipEmptyParts);
140
142
144 mod->setModificationPattern(str_split[1]);
145 mod->setSink(m_sink);
146 mod->setProtNter(Nter);
147 mod->setProtCter(Cter);
148 mod->setProtElse(else_prot);
149
150 m_pepModificatorPtrList.push_back(mod);
151
152 if(mp_firstModificator == nullptr)
153 {
155 }
156 else
157 {
158 mp_lastPeptideSinkInterface->setSink(mod);
159 }
161}
162
163void
165{
166 privAddPotentialModificationString(mod_str, true, true, true);
167}
168// protein Nter modification
169void
171{
172 privAddPotentialModificationString(mod_str, true, false, false);
173}
174// protein Cter modification
175void
177{
178 privAddPotentialModificationString(mod_str, false, true, false);
179}
180
181void
183 bool Nter,
184 bool Cter,
185 bool else_prot)
186{
187 //"MOD:00397@C, MOD:00398@R"
188 if(mp_peptideModificatorTee != nullptr)
189 {
190 throw PappsoException(
191 QObject::tr("Unable to add potential modification string after "
192 "addLabeledModificationString function"));
193 }
194
195 QStringList mod_list_str = mod_str.simplified().replace(" ", "").split(",", Qt::SkipEmptyParts);
196 for(auto i = 0; i < mod_list_str.size(); ++i)
197 {
198 parsePotentialModification(mod_list_str[i], Nter, Cter, else_prot);
199 }
200}
201
202
203void
205 bool Nter,
206 bool Cter,
207 bool else_prot)
208{
209
210 QStringList str_split = mod_str.split("@", Qt::SkipEmptyParts);
211
212 QString mod_acc_str = str_split[0];
213 QStringList str_acc_split = mod_acc_str.split("(", Qt::SkipEmptyParts);
214 pappso::AaModificationP aa_mod = AaModification::getInstance(str_acc_split[0]);
215
217
218 // qDebug() << "PeptideModificatorPipeline::parsePotentialModification " << ;
219 if(str_acc_split.length() == 2)
220 {
221 QStringList max_num_str_list =
222 str_acc_split[1].replace(")", "").split("-", Qt::SkipEmptyParts);
223 if(max_num_str_list.length() == 1)
224 {
225 mod->setModificationCounter(max_num_str_list[0].toUInt());
226 }
227 else if(max_num_str_list.length() == 2)
228 {
229 mod->setMinNumberMod(max_num_str_list[0].toUInt());
230 mod->setMaxNumberMod(max_num_str_list[1].toUInt());
231 }
232 }
233 mod->setModificationPattern(str_split[1]);
234 mod->setSink(m_sink);
235 mod->setProtNter(Nter);
236 mod->setProtCter(Cter);
237 mod->setProtElse(else_prot);
238
239 m_pepModificatorPtrList.push_back(mod);
240
241 if(mp_firstModificator == nullptr)
242 {
244 }
245 else
246 {
247 mp_lastPeptideSinkInterface->setSink(mod);
248 }
250}
251
252
253void
255{
256
257 if(m_sink == nullptr)
258 {
259 throw PappsoException(
260 QObject::tr("Please use setSink before addLabeledModificationString function"));
261 }
262 if(mp_peptideModificatorTee == nullptr)
263 {
265 }
266 if(mp_firstModificator == nullptr)
267 {
269 }
270
271 // backup pointers
272 PeptideModificatorInterface *backup_sink = m_sink;
273
274 PeptideSpSinkInterface *backup_p_last_peptide_sink_interface = mp_lastPeptideSinkInterface;
275
276 PeptideModificatorInterface *backup_p_first_modificator = mp_firstModificator;
277
278
279 QStringList mod_list_str = mod_str.simplified().replace(" ", "").split(",", Qt::SkipEmptyParts);
280 for(auto i = 0; i < mod_list_str.size(); ++i)
281 {
282 parseLabeledModification(mod_list_str[i], true, true, true);
283
284 if(i == 0)
285 {
287 }
288 }
289
290 m_sink = backup_sink;
291 mp_lastPeptideSinkInterface = backup_p_last_peptide_sink_interface;
292 mp_firstModificator = backup_p_first_modificator;
293
295}
296
297
298void
300 bool Nter,
301 bool Cter,
302 bool else_prot)
303{
304
305 QStringList str_split = mod_str.split("@", Qt::SkipEmptyParts);
307
309 mod->setModificationPattern(str_split[1]);
310 mod->setSink(m_sink);
311 mod->setProtNter(Nter);
312 mod->setProtCter(Cter);
313 mod->setProtCter(else_prot);
314
315 m_pepModificatorPtrList.push_back(mod);
316
317 mp_lastPeptideSinkInterface->setSink(mod);
320}
321
322
323void
324PeptideModificatorPipeline::setPeptideSp(std::int8_t sequence_database_id,
325 const ProteinSp &protein_sp,
326 bool is_decoy,
327 const PeptideSp &peptide_sp_original,
328 unsigned int start,
329 bool is_nter,
330 unsigned int missed_cleavage_number,
331 bool semi_enzyme)
332{
333 if(mp_firstModificator == nullptr)
334 {
335 m_sink->setPeptideSp(sequence_database_id,
336 protein_sp,
337 is_decoy,
338 peptide_sp_original,
339 start,
340 is_nter,
341 missed_cleavage_number,
342 semi_enzyme);
343 }
344 else
345 {
346 mp_firstModificator->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}
356
357
358void
359PeptideModificatorPipeline::setPeptide(std::int8_t sequence_database_id,
360 const ProteinSp &protein_sp,
361 bool is_decoy,
362 const QString &peptide_str,
363 unsigned int start,
364 bool is_nter,
365 unsigned int missed_cleavage_number,
366 bool semi_enzyme)
367{
368
369 qDebug() << "PeptideModificatorPipeline::setPeptide begin";
370
371 Peptide peptide(peptide_str);
372
373 PeptideSp peptide_sp = peptide.makePeptideSp();
374
375 qDebug() << "PeptideModificatorPipeline::setPeptide m_sink->setPeptideSp";
376 setPeptideSp(sequence_database_id,
377 protein_sp,
378 is_decoy,
379 peptide_sp,
380 start,
381 is_nter,
382 missed_cleavage_number,
383 semi_enzyme);
384 qDebug() << "PeptideModificatorPipeline::setPeptide end";
385}
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)
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)
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:160
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
const AaModification * AaModificationP
std::shared_ptr< const Protein > ProteinSp
shared pointer on a Protein object
Definition protein.h:47