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"
27#include "../pappsoexception.h"
28
30 qRegisterMetaType<pappso::OboPsiModTerm>("pappso::OboPsiModTerm");
31
32inline void
34{
35 Q_INIT_RESOURCE(libpappsomsppresources);
36}
37
38
39namespace pappso
40{
41
42QRegularExpression OboPsiModTerm::m_firstParse("^([a-z,A-Z,_]+):\\s(.*)$");
44 "^(.*)\\sEXACT\\sPSI-MOD-label\\s\\[\\]$");
45
46// synonym: "Carbamidomethyl" RELATED PSI-MS-label []
48 "^(.*)\\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}
73
76{
78 m_name = other.m_name;
83 m_origin = other.m_origin;
84
85 m_diffMono = other.m_diffMono;
86 m_massMono = other.m_massMono;
87 m_isA = other.m_isA;
88 return *this;
89}
90
91
92bool
94{
95 return (!m_accession.isEmpty());
96}
97
98bool
99OboPsiModTerm::isA(const QString &accession) const
100{
101 return m_isA.contains(accession);
102}
103
104void
106{
107 // qDebug() << "OboPsiModTerm::parseLine begin " << line;
108 // id: MOD:00007
109 // is_a: MOD:01441 ! natural, standard, encoded residue
110 QRegularExpressionMatch match_line = m_firstParse.match(line);
111 if(match_line.hasMatch())
112 {
113 QStringList pline = match_line.capturedTexts();
114 // qDebug() << "OboPsiModTerm::parseLine match " << pline[0] << pline[1];
115 if(pline[1] == "id")
116 {
117 m_accession = pline[2].trimmed();
118 // qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
119 }
120 else if(pline[1] == "name")
121 {
122 m_name = pline[2].trimmed();
123 // qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
124 }
125 else if(pline[1] == "is_a")
126 {
127 m_isA << pline[2].section(" ", 0, 0);
128 // qDebug() << "OboPsiModTerm::parseLine is_a = " << m_isA.join(" ");
129 }
130 else if(pline[1] == "xref")
131 {
132 // xref: DiffMono: "1.007276"
133 QRegularExpressionMatch match_subline = m_firstParse.match(pline[2]);
134 if(match_subline.hasMatch())
135 {
136 QStringList psecond = match_subline.capturedTexts();
137 if(psecond[1] == "DiffMono")
138 {
139 m_diffMono = psecond[2].replace("\"", "").toDouble();
140 // qDebug() << "OboPsiModTerm::parseLine m_diffMono = " <<
141 // m_diffMono;
142 }
143 else if(psecond[1] == "DiffFormula")
144 {
145 m_diffFormula = psecond[2].trimmed().replace("\"", "");
146 // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
147 // m_diffFormula<<"|";
148 }
149 else if(psecond[1] == "Formula")
150 {
151 m_formula = psecond[2].trimmed().replace("\"", "");
152 // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
153 // m_diffFormula<<"|";
154 }
155 else if(psecond[1] == "Origin")
156 {
157 m_origin =
158 psecond[2].trimmed().replace("\"", "").replace(",", "");
159 // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
160 // m_diffFormula<<"|";
161 }
162 // xref: MassMono: "71.037114"
163
164 else if(psecond[1] == "MassMono")
165 {
166 bool is_ok = false;
167 double mass_mono =
168 psecond[2].replace("\"", "").toDouble(&is_ok);
169 if(is_ok)
170 m_massMono = mass_mono;
171 else
172 m_massMono = 0;
173 // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
174 // m_diffFormula<<"|";
175 }
176 }
177 }
178 else if(pline[1] == "synonym")
179 {
180 // synonym: "Se(S)Res" EXACT PSI-MOD-label []
181 QRegularExpressionMatch match_exact_psimod =
182 m_findExactPsiModLabel.match(pline[2]);
183 if(match_exact_psimod.hasMatch())
184 {
186 match_exact_psimod.captured(1).trimmed().replace("\"", "");
187 // qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
188 // m_psiModLabel<<"|";
189 }
190 else
191 {
192 QRegularExpressionMatch match_related_psims =
193 m_findRelatedPsiMsLabel.match(pline[2]);
194 if(match_related_psims.hasMatch())
195 {
197 match_related_psims.captured(1).trimmed().replace("\"", "");
198 // qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
199 // m_psiModLabel<<"|";
200 }
201 }
202 }
203 else if(pline[1] == "def")
204 {
205 // def: "A protein modification that modifies an L-asparagine
206 // residue." [PubMed:18688235]
207 m_definition = pline[2];
208 }
209 }
210}
211void
213{
214 m_accession = "";
215 m_name = "";
216 m_definition = "";
217 m_psiModLabel = "";
218 m_diffFormula = "";
219 m_diffMono = 0;
220 m_origin = "";
221 m_massMono = 0;
222 m_isA.clear();
223}
224
225} // namespace pappso
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)
static QRegularExpression m_findRelatedPsiMsLabel
static QRegularExpression m_findExactPsiModLabel
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
void initMyResource()
int oboPsiModTermMetaTypeId