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 bool
52 {
53  return (!m_accession.isEmpty());
54 }
55 
56 void
57 OboPsiModTerm::parseLine(const QString &line)
58 {
59  // qDebug() << "OboPsiModTerm::parseLine begin " << line;
60  // id: MOD:00007
61  QRegularExpressionMatch match_line = m_firstParse.match(line);
62  if(match_line.hasMatch())
63  {
64  QStringList pline = match_line.capturedTexts();
65  // qDebug() << "OboPsiModTerm::parseLine match " << pline[0] << pline[1];
66  if(pline[1] == "id")
67  {
68  m_accession = pline[2].trimmed();
69  // qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
70  }
71  else if(pline[1] == "name")
72  {
73  m_name = pline[2].trimmed();
74  // qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
75  }
76  else if(pline[1] == "xref")
77  {
78  // xref: DiffMono: "1.007276"
79  QRegularExpressionMatch match_subline = m_firstParse.match(pline[2]);
80  if(match_subline.hasMatch())
81  {
82  QStringList psecond = match_subline.capturedTexts();
83  if(psecond[1] == "DiffMono")
84  {
85  m_diffMono = psecond[2].replace("\"", "").toDouble();
86  // qDebug() << "OboPsiModTerm::parseLine m_diffMono = " <<
87  // m_diffMono;
88  }
89  else if(psecond[1] == "DiffFormula")
90  {
91  m_diffFormula = psecond[2].trimmed().replace("\"", "");
92  // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
93  // m_diffFormula<<"|";
94  }
95  else if(psecond[1] == "Origin")
96  {
97  m_origin =
98  psecond[2].trimmed().replace("\"", "").replace(",", "");
99  // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
100  // m_diffFormula<<"|";
101  }
102  }
103  }
104  else if(pline[1] == "synonym")
105  {
106  // synonym: "Se(S)Res" EXACT PSI-MOD-label []
107  QRegularExpressionMatch match_exact_psimod =
108  m_findExactPsiModLabel.match(pline[2]);
109  if(match_exact_psimod.hasMatch())
110  {
111  m_psiModLabel =
112  match_exact_psimod.captured(1).trimmed().replace("\"", "");
113  // qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
114  // m_psiModLabel<<"|";
115  }
116  else
117  {
118  QRegularExpressionMatch match_related_psims =
119  m_findRelatedPsiMsLabel.match(pline[2]);
120  if(match_related_psims.hasMatch())
121  {
122  m_psiMsLabel =
123  match_related_psims.captured(1).trimmed().replace("\"", "");
124  // qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
125  // m_psiModLabel<<"|";
126  }
127  }
128  }
129  else if(pline[1] == "def")
130  {
131  // def: "A protein modification that modifies an L-asparagine
132  // residue." [PubMed:18688235]
133  m_definition = pline[2];
134  }
135  }
136 }
137 void
139 {
140  m_accession = "";
141  m_name = "";
142  m_definition = "";
143  m_psiModLabel = "";
144  m_diffFormula = "";
145  m_diffMono = 0;
146  m_origin = "";
147 }
148 
149 } // namespace pappso
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