obopsimodterm.cpp
Go to the documentation of this file.
/*******************************************************************************
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
*implementation
******************************************************************************/
#include <QDebug>
#include "obopsimodterm.h"
#include "../pappsoexception.h"
int oboPsiModTermMetaTypeId =
qRegisterMetaType<pappso::OboPsiModTerm>("pappso::OboPsiModTerm");
inline void
initMyResource()
{
Q_INIT_RESOURCE(libpappsomsppresources);
}
namespace pappso
{
QRegExp OboPsiModTerm::m_firstParse("^([a-z,A-Z]+):\\s(.*)$");
QRegExp OboPsiModTerm::m_findExactPsiModLabel(
"^(.*)\\sEXACT\\sPSI-MOD-label\\s\\[\\]$");
// synonym: "Carbamidomethyl" RELATED PSI-MS-label []
QRegExp OboPsiModTerm::m_findRelatedPsiMsLabel(
"^(.*)\\sRELATED\\sPSI-MS-label\\s\\[\\]$");
bool
OboPsiModTerm::isValid() const
{
return (!m_accession.isEmpty());
}
void
OboPsiModTerm::parseLine(const QString &line)
{
// qDebug() << "OboPsiModTerm::parseLine begin " << line;
// id: MOD:00007
if(m_firstParse.exactMatch(line))
{
QStringList pline = m_firstParse.capturedTexts();
// qDebug() << "OboPsiModTerm::parseLine match " << pline[0] << pline[1];
if(pline[1] == "id")
{
m_accession = pline[2].trimmed();
// qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
}
else if(pline[1] == "name")
{
m_name = pline[2].trimmed();
// qDebug() << "OboPsiModTerm::parseLine accession = " << m_accession;
}
else if(pline[1] == "xref")
{
// xref: DiffMono: "1.007276"
if(m_firstParse.exactMatch(pline[2]))
{
QStringList psecond = m_firstParse.capturedTexts();
if(psecond[1] == "DiffMono")
{
m_diffMono = psecond[2].replace("\"", "").toDouble();
// qDebug() << "OboPsiModTerm::parseLine m_diffMono = " <<
// m_diffMono;
}
else if(psecond[1] == "DiffFormula")
{
m_diffFormula = psecond[2].trimmed().replace("\"", "");
// qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
// m_diffFormula<<"|";
}
else if(psecond[1] == "Origin")
{
m_origin =
psecond[2].trimmed().replace("\"", "").replace(",", "");
// qDebug() << "OboPsiModTerm::parseLine m_diffFormula = |" <<
// m_diffFormula<<"|";
}
}
}
else if(pline[1] == "synonym")
{
// synonym: "Se(S)Res" EXACT PSI-MOD-label []
if(m_findExactPsiModLabel.exactMatch(pline[2]))
{
m_psiModLabel =
m_findExactPsiModLabel.capturedTexts()[1].trimmed().replace(
"\"", "");
// qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
// m_psiModLabel<<"|";
}
else if(m_findRelatedPsiMsLabel.exactMatch(pline[2]))
{
m_psiMsLabel =
m_findRelatedPsiMsLabel.capturedTexts()[1].trimmed().replace(
"\"", "");
// qDebug() << "OboPsiModTerm::parseLine m_psiModLabel = |" <<
// m_psiModLabel<<"|";
}
}
else if(pline[1] == "def")
{
// def: "A protein modification that modifies an L-asparagine
// residue." [PubMed:18688235]
m_definition = pline[2];
}
}
}
void
OboPsiModTerm::clearTerm()
{
m_accession = "";
m_name = "";
m_definition = "";
m_psiModLabel = "";
m_diffFormula = "";
m_diffMono = 0;
m_origin = "";
}
} // namespace pappso
pappso::OboPsiModTerm::m_findExactPsiModLabel
static QRegExp m_findExactPsiModLabel
Definition: obopsimodterm.h:59
pappso::OboPsiModTerm::clearTerm
void clearTerm()
Definition: obopsimodterm.cpp:131
pappso::OboPsiModTerm::m_psiModLabel
QString m_psiModLabel
Definition: obopsimodterm.h:47
pappso::OboPsiModTerm::m_firstParse
static QRegExp m_firstParse
Definition: obopsimodterm.h:58
pappso::OboPsiModTerm::m_psiMsLabel
QString m_psiMsLabel
Definition: obopsimodterm.h:48
pappso::OboPsiModTerm::m_diffFormula
QString m_diffFormula
Definition: obopsimodterm.h:49
pappso::OboPsiModTerm::m_origin
QString m_origin
Definition: obopsimodterm.h:50
pappso::OboPsiModTerm::m_definition
QString m_definition
Definition: obopsimodterm.h:46
pappso::OboPsiModTerm::isValid
bool isValid() const
Definition: obopsimodterm.cpp:51
pappso::OboPsiModTerm::m_findRelatedPsiMsLabel
static QRegExp m_findRelatedPsiMsLabel
Definition: obopsimodterm.h:60
pappso::OboPsiModTerm::parseLine
void parseLine(const QString &line)
Definition: obopsimodterm.cpp:57
pappso::OboPsiModTerm::m_diffMono
double m_diffMono
Definition: obopsimodterm.h:52
pappso::OboPsiModTerm::m_accession
QString m_accession
Definition: obopsimodterm.h:44
pappso::OboPsiModTerm::m_name
QString m_name
Definition: obopsimodterm.h:45
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
initMyResource
void initMyResource()
Definition: obopsimodterm.cpp:33
oboPsiModTermMetaTypeId
int oboPsiModTermMetaTypeId
Definition: obopsimodterm.cpp:29
obopsimodterm.h