libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
peptidestrparser.cpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
3
*
4
* This file is part of the PAPPSOms++ library.
5
*
6
* PAPPSOms++ is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* PAPPSOms++ is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
18
*
19
* Contributors:
20
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
21
*implementation
22
******************************************************************************/
23
24
#include <QStringList>
25
#include "
peptidestrparser.h
"
26
#include "
../obo/filterobopsimodtermlabel.h
"
27
#include "
../obo/filterobopsimodsink.h
"
28
29
namespace
pappso
30
{
31
32
33
QRegularExpression
PeptideStrParser::_mod_parser
(
"\\([^)]*\\)"
);
34
QRegularExpression
PeptideStrParser::_rx_psimod
(
"MOD:[0-9]+"
);
35
QRegularExpression
PeptideStrParser::_rx_modmass
(
"[-+]?[0-9]+\\.?[0-9]*"
);
36
37
void
38
PeptideStrParser::parseStringToPeptide
(
const
QString &pepstr,
Peptide
&peptide)
39
{
40
// Peptide
41
// peptide2("C(MOD:00397+MOD:01160)C(MOD:00397)AADDKEAC(MOD:00397)FAVEGPK");
42
// CCAADDKEACFAVEGPK
43
/*
44
<psimod position="1" accession="MOD:00397"/>
45
<psimod position="2" accession="MOD:00397"/>
46
<psimod position="10" accession="MOD:00397"/>
47
<psimod position="1" accession="MOD:01160"/>
48
*/
49
int
matched_length_cumul = 0;
50
int
pos = 0;
51
52
QRegularExpressionMatch match_mod =
_mod_parser
.match(pepstr, pos);
53
54
while
(match_mod.hasMatch())
55
{
56
pos = match_mod.capturedStart(0);
57
QString captured = match_mod.captured(0);
58
qDebug() <<
" captured="
<< captured <<
" pos="
<< pos
59
<<
" match_mod.lastCapturedIndex()="
<< match_mod.lastCapturedIndex();
60
QStringList mod_list =
61
captured.mid(1, captured.size() - 2).split(QRegularExpression(
"[+,\\,]"
));
62
for
(QString &mod : mod_list)
63
{
64
qDebug() <<
"PeptideStrParser::parseString mod "
<< mod;
65
QRegularExpressionMatch match_psimod =
_rx_psimod
.match(mod);
66
if
(match_psimod.hasMatch())
67
{
68
qDebug() <<
"PeptideStrParser::parseString pos-1 "
69
<< (pos - 1 - matched_length_cumul);
70
peptide.
addAaModification
(
AaModification::getInstance
(mod),
71
pos - 1 - matched_length_cumul);
72
}
73
else
if
(mod.startsWith(
"internal:Nter_"
))
74
{
75
peptide.
setCleavageNterModification
(
AaModification::getInstance
(mod));
76
}
77
else
if
(mod.startsWith(
"internal:Cter_"
))
78
{
79
peptide.
setCleavageCterModification
(
AaModification::getInstance
(mod));
80
}
81
else
if
(mod.startsWith(
"C13N15:"
))
82
{
83
qDebug() <<
"PeptideStrParser::parseString pos-1 "
84
<< (pos - 1 - matched_length_cumul);
85
peptide.
addAaModification
(
AaModification::getInstance
(mod),
86
pos - 1 - matched_length_cumul);
87
}
88
else
89
{
90
qDebug() <<
"mod="
<< mod;
91
QRegularExpressionMatch match_modmass =
_rx_modmass
.match(mod);
92
if
(match_modmass.hasMatch())
93
{
94
// number
95
qDebug() <<
"number mod="
<< mod <<
" cap="
<< match_modmass.captured(0);
96
if
(!mod.contains(
"."
))
97
{
98
// integer
99
qDebug() <<
"integer mod="
<< mod;
100
mod =
"MOD:0000"
+ mod;
101
while
(mod.size() > 9)
102
{
103
mod = mod.replace(4, 1,
""
);
104
}
105
peptide.
addAaModification
(
AaModification::getInstance
(mod),
106
pos - 1 - matched_length_cumul);
107
}
108
else
109
{
110
qDebug() <<
"double mod="
<< mod;
111
peptide.
addAaModification
(
112
AaModification::getInstanceCustomizedMod
(mod.toDouble()),
113
pos - 1 - matched_length_cumul);
114
}
115
}
116
else
117
{
118
qDebug() <<
"not a number mod="
<< mod;
119
FilterOboPsiModSink
term_list;
120
FilterOboPsiModTermLabel
filter_label(term_list, mod);
121
122
OboPsiMod
psimod(filter_label);
123
124
peptide.
addAaModification
(
AaModification::getInstance
(term_list.
getFirst
()),
125
pos - 1 - matched_length_cumul);
126
}
127
}
128
}
129
qDebug();
130
matched_length_cumul += captured.size();
131
match_mod =
_mod_parser
.match(pepstr, pos + 1);
132
qDebug();
133
}
134
}
135
136
PeptideSp
137
PeptideStrParser::parseString
(
const
QString &pepstr)
138
{
139
140
qDebug();
141
// QMutexLocker locker(&_mutex);
142
Peptide
peptide(QString(pepstr).replace(
_mod_parser
,
""
));
143
PeptideStrParser::parseStringToPeptide
(pepstr, peptide);
144
145
return
(peptide.
makePeptideSp
());
146
}
147
148
NoConstPeptideSp
149
PeptideStrParser::parseNoConstString
(
const
QString &pepstr)
150
{
151
152
qDebug() << pepstr;
153
QString new_pep = QString(pepstr).replace(
_mod_parser
,
""
);
154
qDebug() << new_pep;
155
// QMutexLocker locker(&_mutex);
156
Peptide
peptide(new_pep);
157
qDebug();
158
PeptideStrParser::parseStringToPeptide
(pepstr, peptide);
159
160
return
(peptide.
makeNoConstPeptideSp
());
161
}
162
}
// namespace pappso
pappso::AaModification::getInstance
static AaModificationP getInstance(const QString &accession)
Definition
aamodification.cpp:368
pappso::AaModification::getInstanceCustomizedMod
static AaModificationP getInstanceCustomizedMod(pappso_double modificationMass)
Definition
aamodification.cpp:349
pappso::FilterOboPsiModSink
Definition
filterobopsimodsink.h:36
pappso::FilterOboPsiModSink::getFirst
const OboPsiModTerm & getFirst()
Definition
filterobopsimodsink.cpp:68
pappso::FilterOboPsiModTermLabel
Definition
filterobopsimodtermlabel.h:33
pappso::OboPsiMod
Definition
obopsimod.h:35
pappso::PeptideStrParser::parseNoConstString
static NoConstPeptideSp parseNoConstString(const QString &pepstr)
Definition
peptidestrparser.cpp:149
pappso::PeptideStrParser::_rx_psimod
static QRegularExpression _rx_psimod
Definition
peptidestrparser.h:43
pappso::PeptideStrParser::parseString
static PeptideSp parseString(const QString &pepstr)
Definition
peptidestrparser.cpp:137
pappso::PeptideStrParser::parseStringToPeptide
static void parseStringToPeptide(const QString &pepstr, Peptide &peptide)
Definition
peptidestrparser.cpp:38
pappso::PeptideStrParser::_rx_modmass
static QRegularExpression _rx_modmass
Definition
peptidestrparser.h:44
pappso::PeptideStrParser::_mod_parser
static QRegularExpression _mod_parser
Definition
peptidestrparser.h:42
pappso::Peptide
Definition
peptide.h:102
pappso::Peptide::makePeptideSp
PeptideSp makePeptideSp() const
Definition
peptide.cpp:160
pappso::Peptide::makeNoConstPeptideSp
NoConstPeptideSp makeNoConstPeptideSp() const
Definition
peptide.cpp:166
pappso::Peptide::setCleavageCterModification
void setCleavageCterModification(AaModificationP mod)
Definition
peptide.cpp:621
pappso::Peptide::setCleavageNterModification
void setCleavageNterModification(AaModificationP mod)
Definition
peptide.cpp:605
pappso::Peptide::addAaModification
void addAaModification(AaModificationP aaModification, unsigned int position)
adds a modification to amino acid sequence
Definition
peptide.cpp:222
filterobopsimodsink.h
filterobopsimodtermlabel.h
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::NoConstPeptideSp
std::shared_ptr< Peptide > NoConstPeptideSp
Definition
peptide.h:98
peptidestrparser.h
pappsomspp
core
peptide
peptidestrparser.cpp
Generated on
for libpappsomspp by
1.17.0