libpappsomspp
Library for mass spectrometry
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 
32 inline void
34 {
35  Q_INIT_RESOURCE(libpappsomsppresources);
36 }
37 
38 
39 namespace pappso
40 {
41 
42 QRegularExpression OboPsiModTerm::m_firstParse("^([a-z,A-Z]+):\\s(.*)$");
43 QRegularExpression OboPsiModTerm::m_findExactPsiModLabel(
44  "^(.*)\\sEXACT\\sPSI-MOD-label\\s\\[\\]$");
45 
46 // synonym: "Carbamidomethyl" RELATED PSI-MS-label []
48  "^(.*)\\sRELATED\\sPSI-MS-label\\s\\[\\]$");
49 
50 
52 {
53 }
54 
56 {
57 }
59 {
60  m_accession = other.m_accession;
61  m_name = other.m_name;
62  m_definition = other.m_definition;
64  m_psiMsLabel = other.m_psiMsLabel;
66  m_origin = other.m_origin;
67 
68  m_diffMono = other.m_diffMono;
69 }
70 
73 {
74  m_accession = other.m_accession;
75  m_name = other.m_name;
76  m_definition = other.m_definition;
78  m_psiMsLabel = other.m_psiMsLabel;
80  m_origin = other.m_origin;
81 
82  m_diffMono = other.m_diffMono;
83  return *this;
84 }
85 
86 
87 bool
89 {
90  return (!m_accession.isEmpty());
91 }
92 
93 void
94 OboPsiModTerm::parseLine(const QString &line)
95 {
96  // qDebug() << "OboPsiModTerm::parseLine begin " << line;
97  // id: MOD:00007
98  QRegularExpressionMatch match_line = m_firstParse.match(line);
99  if(match_line.hasMatch())
100  {
101  QStringList pline = match_line.capturedTexts();
102  // qDebug() << "OboPsiModTerm::parseLine match " << pline[0] << pline[1];
103  if(pline[1] == "id")
104  {
105  m_accession = pline[2].trimmed();
106  // qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
107  }
108  else if(pline[1] == "name")
109  {
110  m_name = pline[2].trimmed();
111  // qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
112  }
113  else if(pline[1] == "xref")
114  {
115  // xref: DiffMono: "1.007276"
116  QRegularExpressionMatch match_subline = m_firstParse.match(pline[2]);
117  if(match_subline.hasMatch())
118  {
119  QStringList psecond = match_subline.capturedTexts();
120  if(psecond[1] == "DiffMono")
121  {
122  m_diffMono = psecond[2].replace("\"", "").toDouble();
123  // qDebug() << "OboPsiModTerm::parseLine m_diffMono = " <<
124  // m_diffMono;
125  }
126  else if(psecond[1] == "DiffFormula")
127  {
128  m_diffFormula = psecond[2].trimmed().replace("\"", "");
129  // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
130  // m_diffFormula<<"|";
131  }
132  else if(psecond[1] == "Origin")
133  {
134  m_origin =
135  psecond[2].trimmed().replace("\"", "").replace(",", "");
136  // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
137  // m_diffFormula<<"|";
138  }
139  }
140  }
141  else if(pline[1] == "synonym")
142  {
143  // synonym: "Se(S)Res" EXACT PSI-MOD-label []
144  QRegularExpressionMatch match_exact_psimod =
145  m_findExactPsiModLabel.match(pline[2]);
146  if(match_exact_psimod.hasMatch())
147  {
148  m_psiModLabel =
149  match_exact_psimod.captured(1).trimmed().replace("\"", "");
150  // qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
151  // m_psiModLabel<<"|";
152  }
153  else
154  {
155  QRegularExpressionMatch match_related_psims =
156  m_findRelatedPsiMsLabel.match(pline[2]);
157  if(match_related_psims.hasMatch())
158  {
159  m_psiMsLabel =
160  match_related_psims.captured(1).trimmed().replace("\"", "");
161  // qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
162  // m_psiModLabel<<"|";
163  }
164  }
165  }
166  else if(pline[1] == "def")
167  {
168  // def: "A protein modification that modifies an L-asparagine
169  // residue." [PubMed:18688235]
170  m_definition = pline[2];
171  }
172  }
173 }
174 void
176 {
177  m_accession = "";
178  m_name = "";
179  m_definition = "";
180  m_psiModLabel = "";
181  m_diffFormula = "";
182  m_diffMono = 0;
183  m_origin = "";
184 }
185 
186 } // namespace pappso
OboPsiModTerm & operator=(const OboPsiModTerm &)
static QRegularExpression m_firstParse
Definition: obopsimodterm.h:58
void parseLine(const QString &line)
static QRegularExpression m_findRelatedPsiMsLabel
Definition: obopsimodterm.h:60
static QRegularExpression m_findExactPsiModLabel
Definition: obopsimodterm.h:59
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
void initMyResource()
int oboPsiModTermMetaTypeId