libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
obopsimodterm.cpp
Go to the documentation of this file.
1
2
/*******************************************************************************
3
* Copyright (c) 2015 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
25
#include <QDebug>
26
#include "
obopsimodterm.h
"
27
#include "
pappsomspp/core/pappsoexception.h
"
28
29
int
oboPsiModTermMetaTypeId
= qRegisterMetaType<pappso::OboPsiModTerm>(
"pappso::OboPsiModTerm"
);
30
31
inline
void
32
initMyResource
()
33
{
34
Q_INIT_RESOURCE(libpappsomspp_core_resources);
35
}
36
37
38
namespace
pappso
39
{
40
41
QRegularExpression
OboPsiModTerm::m_firstParse
(
"^([a-z,A-Z,_]+):\\s(.*)$"
);
42
QRegularExpression
OboPsiModTerm::m_firstParseUnimod
(
"^([a-z,A-Z,_]+)\\s(.*)$"
);
43
QRegularExpression
OboPsiModTerm::m_parseDefinition
(
"^\"(.*)\"\\s\\[(.*)\\]$"
);
44
QRegularExpression
OboPsiModTerm::m_findExactPsiModLabel
(
"^(.*)\\sEXACT\\sPSI-MOD-label\\s\\[\\]$"
);
45
46
// synonym: "Carbamidomethyl" RELATED PSI-MS-label []
47
QRegularExpression
48
OboPsiModTerm::m_findRelatedPsiMsLabel
(
"^(.*)\\sRELATED\\sPSI-MS-label\\s\\[\\]$"
);
49
50
51
OboPsiModTerm::OboPsiModTerm
()
52
{
53
}
54
55
OboPsiModTerm::~OboPsiModTerm
()
56
{
57
}
58
OboPsiModTerm::OboPsiModTerm
(
const
OboPsiModTerm
&other)
59
{
60
m_accession
= other.
m_accession
;
61
m_name
= other.
m_name
;
62
m_definition
= other.
m_definition
;
63
m_psiModLabel
= other.
m_psiModLabel
;
64
m_psiMsLabel
= other.
m_psiMsLabel
;
65
m_diffFormula
= other.
m_diffFormula
;
66
m_formula
= other.
m_formula
;
67
m_origin
= other.
m_origin
;
68
69
m_diffMono
= other.
m_diffMono
;
70
m_massMono
= other.
m_massMono
;
71
m_isA
= other.
m_isA
;
72
m_isUnimod
= other.
m_isUnimod
;
73
}
74
75
OboPsiModTerm
&
76
OboPsiModTerm::operator=
(
const
OboPsiModTerm
&other)
77
{
78
m_accession
= other.
m_accession
;
79
m_name
= other.
m_name
;
80
m_definition
= other.
m_definition
;
81
m_psiModLabel
= other.
m_psiModLabel
;
82
m_psiMsLabel
= other.
m_psiMsLabel
;
83
m_diffFormula
= other.
m_diffFormula
;
84
m_formula
= other.
m_formula
;
85
m_origin
= other.
m_origin
;
86
87
m_diffMono
= other.
m_diffMono
;
88
m_massMono
= other.
m_massMono
;
89
m_isA
= other.
m_isA
;
90
m_isUnimod
= other.
m_isUnimod
;
91
return
*
this
;
92
}
93
94
95
bool
96
OboPsiModTerm::isValid
()
const
97
{
98
return
(!
m_accession
.isEmpty());
99
}
100
101
bool
102
OboPsiModTerm::isA
(
const
QString &accession)
const
103
{
104
return
m_isA
.contains(accession);
105
}
106
107
void
108
OboPsiModTerm::parseLine
(
const
QString &
line
)
109
{
110
// qDebug() << "OboPsiModTerm::parseLine begin " << line;
111
// id: MOD:00007
112
// is_a: MOD:01441 ! natural, standard, encoded residue
113
QRegularExpressionMatch match_line =
m_firstParse
.match(
line
);
114
if
(match_line.hasMatch())
115
{
116
QStringList pline = match_line.capturedTexts();
117
// qDebug() << "OboPsiModTerm::parseLine match " << pline[0] << pline[1];
118
if
(pline[1] ==
"id"
)
119
{
120
setAccession
(pline[2].trimmed());
121
// qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
122
}
123
else
if
(pline[1] ==
"name"
)
124
{
125
m_name
= pline[2].trimmed();
126
// qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
127
}
128
else
if
(pline[1] ==
"is_a"
)
129
{
130
m_isA
<< pline[2].section(
" "
, 0, 0);
131
// qDebug() << "OboPsiModTerm::parseLine is_a = " << m_isA.join(" ");
132
}
133
else
if
(pline[1] ==
"xref"
)
134
{
135
136
// xref: DiffMono: "1.007276"
137
QRegularExpressionMatch match_subline =
m_firstParse
.match(pline[2]);
138
if
(
m_isUnimod
)
139
{
140
match_subline =
m_firstParseUnimod
.match(pline[2]);
141
}
142
if
(match_subline.hasMatch())
143
{
144
QStringList psecond = match_subline.capturedTexts();
145
if
(psecond[1] ==
"DiffMono"
)
146
{
147
m_diffMono
= psecond[2].replace(
"\""
,
""
).toDouble();
148
// qDebug() << "OboPsiModTerm::parseLine m_diffMono = " <<
149
// m_diffMono;
150
}
151
else
if
(psecond[1] ==
"delta_mono_mass"
)
152
{
// UNIMOD
153
// xref: delta_mono_mass "42.010565"
154
m_diffMono
= psecond[2].replace(
"\""
,
""
).toDouble();
155
// qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
156
// m_diffFormula<<"|";
157
}
158
else
if
(psecond[1] ==
"DiffFormula"
)
159
{
160
m_diffFormula
= psecond[2].trimmed().replace(
"\""
,
""
);
161
// qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
162
// m_diffFormula<<"|";
163
}
164
165
else
if
(psecond[1] ==
"delta_composition"
)
166
{
167
// UNIMOD
168
// xref: delta_composition "H(2) C(2) O"
169
m_diffFormula
= psecond[2].trimmed().replace(
"\""
,
""
);
170
// qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
171
// m_diffFormula<<"|";
172
}
173
174
else
if
(psecond[1] ==
"Formula"
)
175
{
176
// xref: Formula: "C 5 H 9 N 1 O 1 S 1"
177
m_formula
= psecond[2].trimmed().replace(
"\""
,
""
);
178
// qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
179
// m_diffFormula<<"|";
180
}
181
else
if
(psecond[1] ==
"Origin"
)
182
{
183
m_origin
= psecond[2].trimmed().replace(
"\""
,
""
).replace(
","
,
""
);
184
// qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
185
// m_diffFormula<<"|";
186
}
187
// xref: MassMono: "71.037114"
188
189
else
if
(psecond[1] ==
"MassMono"
)
190
{
191
bool
is_ok =
false
;
192
double
mass_mono = psecond[2].replace(
"\""
,
""
).toDouble(&is_ok);
193
if
(is_ok)
194
m_massMono
= mass_mono;
195
else
196
m_massMono
= 0;
197
// qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
198
// m_diffFormula<<"|";
199
}
200
}
201
}
202
else
if
(pline[1] ==
"synonym"
)
203
{
204
// synonym: "Se(S)Res" EXACT PSI-MOD-label []
205
QRegularExpressionMatch match_exact_psimod =
m_findExactPsiModLabel
.match(pline[2]);
206
if
(match_exact_psimod.hasMatch())
207
{
208
m_psiModLabel
= match_exact_psimod.captured(1).trimmed().replace(
"\""
,
""
);
209
// qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
210
// m_psiModLabel<<"|";
211
}
212
else
213
{
214
QRegularExpressionMatch match_related_psims =
m_findRelatedPsiMsLabel
.match(pline[2]);
215
if
(match_related_psims.hasMatch())
216
{
217
m_psiMsLabel
= match_related_psims.captured(1).trimmed().replace(
"\""
,
""
);
218
// qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
219
// m_psiModLabel<<"|";
220
}
221
}
222
}
223
else
if
(pline[1] ==
"def"
)
224
{
225
// def: "A protein modification that modifies an L-asparagine
226
// residue." [PubMed:18688235]
227
228
QRegularExpressionMatch match_subline =
m_parseDefinition
.match(pline[2]);
229
230
if
(match_subline.hasMatch())
231
{
232
QStringList psecond = match_subline.capturedTexts();
233
m_definition
= psecond[1];
234
}
235
else
236
{
237
m_definition
= pline[2];
238
}
239
}
240
}
241
}
242
void
243
OboPsiModTerm::clearTerm
()
244
{
245
m_accession
=
""
;
246
m_name
=
""
;
247
m_definition
=
""
;
248
m_psiModLabel
=
""
;
249
m_diffFormula
=
""
;
250
m_formula
=
""
;
251
m_diffMono
= 0;
252
m_origin
=
""
;
253
m_massMono
= 0;
254
m_isA
.clear();
255
m_isUnimod
=
false
;
256
}
257
258
}
// namespace pappso
259
260
const
QString &
261
pappso::OboPsiModTerm::getAccession
()
const
262
{
263
return
m_accession
;
264
}
265
266
void
267
pappso::OboPsiModTerm::setAccession
(
const
QString &accession)
268
{
269
//qDebug() << accession;
270
m_isUnimod
=
false
;
271
m_accession
= accession;
272
if
(
m_accession
.startsWith(
"UNIMOD:"
))
273
m_isUnimod
=
true
;
274
}
275
276
bool
277
pappso::OboPsiModTerm::isUnimod
()
const
278
{
279
return
m_isUnimod
;
280
}
CardanoResultCase::line
@ line
Definition
cardano.h:42
pappso::OboPsiModTerm
Definition
obopsimodterm.h:34
pappso::OboPsiModTerm::m_firstParseUnimod
static QRegularExpression m_firstParseUnimod
Definition
obopsimodterm.h:78
pappso::OboPsiModTerm::clearTerm
void clearTerm()
Definition
obopsimodterm.cpp:243
pappso::OboPsiModTerm::m_psiModLabel
QString m_psiModLabel
Definition
obopsimodterm.h:60
pappso::OboPsiModTerm::m_isA
QStringList m_isA
Definition
obopsimodterm.h:69
pappso::OboPsiModTerm::setAccession
void setAccession(const QString &accession)
Definition
obopsimodterm.cpp:267
pappso::OboPsiModTerm::OboPsiModTerm
OboPsiModTerm()
Definition
obopsimodterm.cpp:51
pappso::OboPsiModTerm::m_psiMsLabel
QString m_psiMsLabel
Definition
obopsimodterm.h:61
pappso::OboPsiModTerm::operator=
OboPsiModTerm & operator=(const OboPsiModTerm &)
Definition
obopsimodterm.cpp:76
pappso::OboPsiModTerm::m_diffFormula
QString m_diffFormula
Definition
obopsimodterm.h:62
pappso::OboPsiModTerm::m_origin
QString m_origin
Definition
obopsimodterm.h:64
pappso::OboPsiModTerm::m_definition
QString m_definition
Definition
obopsimodterm.h:59
pappso::OboPsiModTerm::isValid
bool isValid() const
Definition
obopsimodterm.cpp:96
pappso::OboPsiModTerm::isA
bool isA(const QString &accession) const
tells if this term "is_a" another accession
Definition
obopsimodterm.cpp:102
pappso::OboPsiModTerm::m_formula
QString m_formula
Definition
obopsimodterm.h:63
pappso::OboPsiModTerm::m_firstParse
static QRegularExpression m_firstParse
Definition
obopsimodterm.h:75
pappso::OboPsiModTerm::parseLine
void parseLine(const QString &line)
Definition
obopsimodterm.cpp:108
pappso::OboPsiModTerm::getAccession
const QString & getAccession() const
Definition
obopsimodterm.cpp:261
pappso::OboPsiModTerm::m_findRelatedPsiMsLabel
static QRegularExpression m_findRelatedPsiMsLabel
Definition
obopsimodterm.h:77
pappso::OboPsiModTerm::isUnimod
bool isUnimod() const
Definition
obopsimodterm.cpp:277
pappso::OboPsiModTerm::m_findExactPsiModLabel
static QRegularExpression m_findExactPsiModLabel
Definition
obopsimodterm.h:76
pappso::OboPsiModTerm::m_massMono
double m_massMono
Definition
obopsimodterm.h:67
pappso::OboPsiModTerm::m_parseDefinition
static QRegularExpression m_parseDefinition
Definition
obopsimodterm.h:79
pappso::OboPsiModTerm::m_diffMono
double m_diffMono
Definition
obopsimodterm.h:66
pappso::OboPsiModTerm::m_isUnimod
bool m_isUnimod
Definition
obopsimodterm.h:83
pappso::OboPsiModTerm::m_accession
QString m_accession
Definition
obopsimodterm.h:82
pappso::OboPsiModTerm::~OboPsiModTerm
~OboPsiModTerm()
Definition
obopsimodterm.cpp:55
pappso::OboPsiModTerm::m_name
QString m_name
Definition
obopsimodterm.h:58
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
initMyResource
void initMyResource()
Definition
obopsimodterm.cpp:32
oboPsiModTermMetaTypeId
int oboPsiModTermMetaTypeId
Definition
obopsimodterm.cpp:29
obopsimodterm.h
pappsoexception.h
pappsomspp
core
obo
obopsimodterm.cpp
Generated on
for libpappsomspp by
1.17.0