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 QRegExp 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 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  if(m_firstParse.exactMatch(line))
62  {
63  QStringList pline = m_firstParse.capturedTexts();
64  // qDebug() << "OboPsiModTerm::parseLine match " << pline[0] << pline[1];
65  if(pline[1] == "id")
66  {
67  m_accession = pline[2].trimmed();
68  // qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
69  }
70  else if(pline[1] == "name")
71  {
72  m_name = pline[2].trimmed();
73  // qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
74  }
75  else if(pline[1] == "xref")
76  {
77  // xref: DiffMono: "1.007276"
78  if(m_firstParse.exactMatch(pline[2]))
79  {
80  QStringList psecond = m_firstParse.capturedTexts();
81  if(psecond[1] == "DiffMono")
82  {
83  m_diffMono = psecond[2].replace("\"", "").toDouble();
84  // qDebug() << "OboPsiModTerm::parseLine m_diffMono = " <<
85  // m_diffMono;
86  }
87  else if(psecond[1] == "DiffFormula")
88  {
89  m_diffFormula = psecond[2].trimmed().replace("\"", "");
90  // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
91  // m_diffFormula<<"|";
92  }
93  else if(psecond[1] == "Origin")
94  {
95  m_origin =
96  psecond[2].trimmed().replace("\"", "").replace(",", "");
97  // qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
98  // m_diffFormula<<"|";
99  }
100  }
101  }
102  else if(pline[1] == "synonym")
103  {
104  // synonym: "Se(S)Res" EXACT PSI-MOD-label []
105  if(m_findExactPsiModLabel.exactMatch(pline[2]))
106  {
107  m_psiModLabel =
108  m_findExactPsiModLabel.capturedTexts()[1].trimmed().replace(
109  "\"", "");
110  // qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
111  // m_psiModLabel<<"|";
112  }
113  else if(m_findRelatedPsiMsLabel.exactMatch(pline[2]))
114  {
115  m_psiMsLabel =
116  m_findRelatedPsiMsLabel.capturedTexts()[1].trimmed().replace(
117  "\"", "");
118  // qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
119  // m_psiModLabel<<"|";
120  }
121  }
122  else if(pline[1] == "def")
123  {
124  // def: "A protein modification that modifies an L-asparagine
125  // residue." [PubMed:18688235]
126  m_definition = pline[2];
127  }
128  }
129 }
130 void
132 {
133  m_accession = "";
134  m_name = "";
135  m_definition = "";
136  m_psiModLabel = "";
137  m_diffFormula = "";
138  m_diffMono = 0;
139  m_origin = "";
140 }
141 
142 } // namespace pappso
static QRegExp m_findExactPsiModLabel
Definition: obopsimodterm.h:59
static QRegExp m_firstParse
Definition: obopsimodterm.h:58
static QRegExp m_findRelatedPsiMsLabel
Definition: obopsimodterm.h:60
void parseLine(const QString &line)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
void initMyResource()
int oboPsiModTermMetaTypeId