libpappsomspp
Library for mass spectrometry
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"
28
29int oboPsiModTermMetaTypeId = qRegisterMetaType<pappso::OboPsiModTerm>("pappso::OboPsiModTerm");
30
31inline void
33{
34 Q_INIT_RESOURCE(libpappsomspp_core_resources);
35}
36
37
38namespace pappso
39{
40
41QRegularExpression OboPsiModTerm::m_firstParse("^([a-z,A-Z,_]+):\\s(.*)$");
42QRegularExpression OboPsiModTerm::m_firstParseUnimod("^([a-z,A-Z,_]+)\\s(.*)$");
43QRegularExpression OboPsiModTerm::m_parseDefinition("^\"(.*)\"\\s\\[(.*)\\]$");
44QRegularExpression OboPsiModTerm::m_findExactPsiModLabel("^(.*)\\sEXACT\\sPSI-MOD-label\\s\\[\\]$");
45
46// synonym: "Carbamidomethyl" RELATED PSI-MS-label []
47QRegularExpression
48 OboPsiModTerm::m_findRelatedPsiMsLabel("^(.*)\\sRELATED\\sPSI-MS-label\\s\\[\\]$");
49
50
54
59{
61 m_name = other.m_name;
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
77{
79 m_name = other.m_name;
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
95bool
97{
98 return (!m_accession.isEmpty());
99}
100
101bool
102OboPsiModTerm::isA(const QString &accession) const
103{
104 return m_isA.contains(accession);
105}
106
107void
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}
242void
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
260const QString &
265
266void
267pappso::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
276bool
278{
279 return m_isUnimod;
280}
static QRegularExpression m_firstParseUnimod
void setAccession(const QString &accession)
OboPsiModTerm & operator=(const OboPsiModTerm &)
bool isA(const QString &accession) const
tells if this term "is_a" another accession
static QRegularExpression m_firstParse
void parseLine(const QString &line)
const QString & getAccession() const
static QRegularExpression m_findRelatedPsiMsLabel
static QRegularExpression m_findExactPsiModLabel
static QRegularExpression m_parseDefinition
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
void initMyResource()
int oboPsiModTermMetaTypeId