libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
peptideproformaparser.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/peptide/peptideproformaparser.cpp
3
* \date 27/11/2023
4
* \author Olivier Langella
5
* \brief parse peptide string in ProForma to pappso::Peptide
6
*/
7
8
/*******************************************************************************
9
* Copyright (c) 2023 Olivier Langella
10
*<Olivier.Langella@universite-paris-saclay.fr>.
11
*
12
* This file is part of the PAPPSOms++ library.
13
*
14
* PAPPSOms++ is free software: you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation, either version 3 of the License, or
17
* (at your option) any later version.
18
*
19
* PAPPSOms++ is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26
*
27
******************************************************************************/
28
29
#include "
peptideproformaparser.h
"
30
#include "
../obo/filterobopsimodtermlabel.h
"
31
#include "
../obo/filterobopsimodsink.h
"
32
#include "
pappsomspp/core/exception/exceptionnotpossible.h
"
33
#include "
pappsomspp/core/utils.h
"
34
35
namespace
pappso
36
{
37
38
39
// QRegularExpression PeptideProFormaParser::_mod_parser("\\[[^\\]]*\\]");
40
QRegularExpression
PeptideProFormaParser::_rx_psimod
(
"MOD:[0-9]+"
);
41
QRegularExpression
PeptideProFormaParser::_rx_modmass
(
"[-+]?[0-9]+\\.?[0-9]*"
);
42
43
//[MOD:01090]@C
44
QRegularExpression
45
PeptideProFormaParser::m_firstGlobalMod
(
"^<([\\[,\\],\\,,0-9,A-Z,a-z,:,@,-,^>]*)>(.*)$"
);
46
47
void
48
PeptideProFormaParser::parseStringToPeptide
(
const
QString &pepstr,
Peptide
&peptide)
49
{
50
// Peptide
51
// peptide2("C[MOD:00397][MOD:01160]C[MOD:00397]AADDKEAC[MOD:00397]FAVEGPK");
52
// CCAADDKEACFAVEGPK
53
/*
54
<psimod position="1" accession="MOD:00397"/>
55
<psimod position="2" accession="MOD:00397"/>
56
<psimod position="10" accession="MOD:00397"/>
57
<psimod position="1" accession="MOD:01160"/>
58
*/
59
60
61
QString peptide_str = pepstr;
62
63
QStringList res_split = peptide_str.split(
"?"
);
64
if
(res_split.size() == 2)
65
{
66
peptide_str = res_split.at(1);
67
}
68
QRegularExpressionMatch match_global_mod =
m_firstGlobalMod
.match(peptide_str);
69
70
QStringList global_mod_list;
71
while
(match_global_mod.hasMatch())
72
{
73
QStringList pline = match_global_mod.capturedTexts();
74
qDebug() << pline[1];
75
if
(pline[1] ==
"13C"
)
76
{
77
// Carbon 13: <13C>ATPEILTVNSIGQLK
78
peptide.
setGlobalModification
(
Enums::Isotope::C13
);
79
}
80
else
if
(pline[1] ==
"15N"
)
81
{
82
// Nitrogen 15: <15N>ATPEILTVNSIGQLK
83
peptide.
setGlobalModification
(
Enums::Isotope::N15
);
84
}
85
else
if
(pline[1] ==
"D"
)
86
{
87
// Deuterium: <D>ATPEILTVNSIGQLK
88
peptide.
setGlobalModification
(
Enums::Isotope::H2
);
89
}
90
else
91
{
92
//<[Oxidation]@C,M>
93
global_mod_list << pline[1];
94
}
95
peptide_str = pline[2];
96
match_global_mod =
m_firstGlobalMod
.match(peptide_str);
97
}
98
99
100
std::size_t i = 0;
101
std::size_t end = peptide_str.size();
102
Enums::AminoAcidChar
last_amino_acid =
Enums::AminoAcidChar::alanine
;
103
bool
in_cter =
false
;
104
while
(i < end)
105
{
106
QChar aa_char = peptide_str[i];
107
if
(aa_char ==
'['
)
108
{
109
QString mod;
110
i++;
111
aa_char = peptide_str[i];
112
while
((i < end) && (aa_char !=
']'
))
113
{
114
mod.append(aa_char);
115
i++;
116
if
(i < end)
117
aa_char = peptide_str[i];
118
}
119
120
qDebug() << aa_char;
121
if
(aa_char !=
']'
)
122
{
123
throw
pappso::ExceptionNotPossible
(
124
QObject::tr(
"modification string is malformed %1"
).arg(mod));
125
}
126
// we have a mod
127
// is it a double ?
128
bool
is_double =
false
;
129
double
mass_modif = mod.toDouble(&is_double);
130
AaModificationP
aamod;
131
if
(is_double)
132
{
133
aamod =
134
Utils::guessAaModificationPbyMonoisotopicMassDelta
(last_amino_acid, mass_modif);
135
}
136
else
137
{
138
aamod =
AaModification::getInstance
(mod);
139
}
140
if
(peptide.
m_aaVec
.size() == 0)
141
{
142
if
(is_double)
143
{
144
AaModificationP
better_mod =
Utils::guessAaModificationPbyMonoisotopicMassDelta
(
145
Enums::AminoAcidChar::alanine
, mass_modif);
146
if
(better_mod !=
nullptr
)
147
{
148
aamod = better_mod;
149
}
150
}
151
peptide.
setNterModification
(aamod);
152
}
153
else
154
{
155
if
(in_cter)
156
{
157
if
(is_double)
158
{
159
AaModificationP
better_mod =
160
Utils::guessAaModificationPbyMonoisotopicMassDelta
(
161
Enums::AminoAcidChar::alanine
, mass_modif);
162
if
(better_mod !=
nullptr
)
163
{
164
aamod = better_mod;
165
}
166
}
167
peptide.
setCterModification
(aamod);
168
}
169
else
170
{
171
peptide.
m_aaVec
.back().addAaModification(aamod);
172
}
173
}
174
}
175
else
176
{
177
if
(aa_char.isLetter())
178
{
179
qDebug() << aa_char;
180
Aa
pappso_aa(aa_char.toLatin1());
181
last_amino_acid = pappso_aa.
getAminoAcidChar
();
182
peptide.
m_aaVec
.push_back(pappso_aa);
183
}
184
else
if
(aa_char ==
'-'
)
185
{
186
if
(peptide.
m_aaVec
.size() > 0)
187
in_cter =
true
;
188
}
189
else
190
{
191
throw
pappso::ExceptionNotPossible
(
192
QObject::tr(
"%1 is not an amino acid"
).arg(aa_char));
193
}
194
}
195
i++;
196
}
197
198
199
for
(QString &global_label_str : global_mod_list)
200
{
201
qDebug() << global_label_str;
202
203
QRegularExpression global_label_reg(
"^\\[(.*)\\]@(.*)$"
);
204
205
QRegularExpressionMatch match_global = global_label_reg.match(global_label_str);
206
207
if
(match_global.hasMatch())
208
{
209
QStringList pline = match_global.capturedTexts();
210
qDebug() << pline[1];
211
AaModificationP
aamod =
AaModification::getInstance
(pline[1]);
212
qDebug() << aamod->
getAccession
();
213
qDebug() << pline[2];
214
for
(QString &aa_str : pline[2].split(
","
))
215
{
216
qDebug() << aa_str;
217
peptide.
addAaModificationOnAllAminoAcid
(aamod,
218
(
Enums::AminoAcidChar
)aa_str[0].toLatin1());
219
}
220
}
221
}
222
// qDebug() << peptide.toProForma();
223
peptide.
m_proxyMass
= -1;
224
peptide.
getMass
();
225
}
226
227
PeptideSp
228
PeptideProFormaParser::parseString
(
const
QString &pepstr)
229
{
230
231
// QMutexLocker locker(&_mutex);
232
qDebug();
233
Peptide
peptide(
""
);
234
PeptideProFormaParser::parseStringToPeptide
(pepstr, peptide);
235
// qDebug() << peptide.toProForma();
236
return
(peptide.
makePeptideSp
());
237
}
238
239
NoConstPeptideSp
240
PeptideProFormaParser::parseNoConstString
(
const
QString &pepstr)
241
{
242
243
// QMutexLocker locker(&_mutex);
244
Peptide
peptide(
""
);
245
PeptideProFormaParser::parseStringToPeptide
(pepstr, peptide);
246
247
return
(peptide.
makeNoConstPeptideSp
());
248
}
249
}
// namespace pappso
pappso::AaBase::getAminoAcidChar
const Enums::AminoAcidChar & getAminoAcidChar() const
Definition
aabase.cpp:409
pappso::AaModification::getAccession
const QString & getAccession() const
Definition
aamodification.cpp:94
pappso::AaModification::getInstance
static AaModificationP getInstance(const QString &accession)
Definition
aamodification.cpp:368
pappso::Aa
Definition
aa.h:45
pappso::ExceptionNotPossible
Definition
exceptionnotpossible.h:29
pappso::PeptideProFormaParser::parseNoConstString
static NoConstPeptideSp parseNoConstString(const QString &pepstr)
Definition
peptideproformaparser.cpp:240
pappso::PeptideProFormaParser::_rx_psimod
static QRegularExpression _rx_psimod
Definition
peptideproformaparser.h:51
pappso::PeptideProFormaParser::parseString
static PeptideSp parseString(const QString &pepstr)
Definition
peptideproformaparser.cpp:228
pappso::PeptideProFormaParser::_rx_modmass
static QRegularExpression _rx_modmass
Definition
peptideproformaparser.h:52
pappso::PeptideProFormaParser::parseStringToPeptide
static void parseStringToPeptide(const QString &pepstr, Peptide &peptide)
Definition
peptideproformaparser.cpp:48
pappso::PeptideProFormaParser::m_firstGlobalMod
static QRegularExpression m_firstGlobalMod
Definition
peptideproformaparser.h:53
pappso::Peptide
Definition
peptide.h:102
pappso::Peptide::makePeptideSp
PeptideSp makePeptideSp() const
Definition
peptide.cpp:160
pappso::Peptide::setNterModification
void setNterModification(AaModificationP mod)
Definition
peptide.cpp:649
pappso::Peptide::makeNoConstPeptideSp
NoConstPeptideSp makeNoConstPeptideSp() const
Definition
peptide.cpp:166
pappso::Peptide::setGlobalModification
void setGlobalModification(Enums::Isotope isotope_kind)
apply 100% isotope replacement
Definition
peptide.cpp:826
pappso::Peptide::setCterModification
void setCterModification(AaModificationP mod)
Definition
peptide.cpp:664
pappso::Peptide::addAaModificationOnAllAminoAcid
void addAaModificationOnAllAminoAcid(AaModificationP aaModification, Enums::AminoAcidChar amino_acid)
adds a modification to all amino acid of the sequence
Definition
peptide.cpp:237
pappso::Peptide::getMass
pappso_double getMass()
Definition
peptide.cpp:375
pappso::Peptide::m_proxyMass
double m_proxyMass
Definition
peptide.h:270
pappso::Peptide::m_aaVec
std::vector< Aa > m_aaVec
Definition
peptide.h:266
pappso::Utils::guessAaModificationPbyMonoisotopicMassDelta
static AaModificationP guessAaModificationPbyMonoisotopicMassDelta(Enums::AminoAcidChar aa, pappso_double mass)
Definition
utils.cpp:677
exceptionnotpossible.h
filterobopsimodsink.h
filterobopsimodtermlabel.h
pappso::Enums::Isotope::C13
@ C13
Definition
types.h:121
pappso::Enums::Isotope::N15
@ N15
Definition
types.h:128
pappso::Enums::Isotope::H2
@ H2
Definition
types.h:123
pappso::Enums::AminoAcidChar
AminoAcidChar
Definition
types.h:187
pappso::Enums::AminoAcidChar::alanine
@ alanine
Definition
types.h:188
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::PeptideSp
std::shared_ptr< const Peptide > PeptideSp
Definition
aamodification.h:48
pappso::AaModificationP
const AaModification * AaModificationP
Definition
aamodification.h:52
pappso::NoConstPeptideSp
std::shared_ptr< Peptide > NoConstPeptideSp
Definition
peptide.h:98
peptideproformaparser.h
utils.h
pappsomspp
core
peptide
peptideproformaparser.cpp
Generated on
for libpappsomspp by
1.17.0