libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
obotermform.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/widget/obo/obotermform/obotermform.cpp
3 * \date 20/04/2021
4 * \author Olivier Langella
5 * \brief display an obo term form
6 */
7
8
9/*******************************************************************************
10 * Copyright (c) 2021 Olivier Langella
11 *<Olivier.Langella@universite-paris-saclay.fr>.
12 *
13 * This file is part of the PAPPSOms++ library.
14 *
15 * PAPPSOms++ is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * PAPPSOms++ is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
27 *
28 ******************************************************************************/
29
30#include "obotermform.h"
31
32#include "ui_uiobotermform.h"
33#include <QDebug>
35
36using namespace pappso;
37
38//"Oxidation of methionine to methionine sulfoxide with neutral loss of CH3SOH."
39//[PubMed:18688235, PubMed:9004526]
40QRegularExpression OboTermForm::m_findExternalLinks("^(.*)\\s\\[(.*)\\]$");
41
42
43OboTermForm::OboTermForm(QWidget *parent) : QWidget(parent), ui(new Ui::OboTermForm)
44{
45 qDebug();
46 ui->setupUi(this);
47
48 OboPsiModTerm empty;
49 displayOboTerm(empty);
50}
51
56
57void
59{
60 qDebug() << oboTerm.getAccession();
61 ui->accessionHttpButton->setText(oboTerm.getAccession());
62 ui->nameLabel->setText(oboTerm.m_name);
63 ui->definitionLabel->setText(oboTerm.m_definition);
64 ui->diffFormulaLabel->setText(oboTerm.m_diffFormula);
65 if(oboTerm.isValid())
66 {
67 ui->diffMonoLabel->setText(QString::number(oboTerm.m_diffMono, 'f', 4));
69 }
70 else
71 {
72 ui->diffMonoLabel->setText("");
73 }
74 ui->originLabel->setText(oboTerm.m_origin);
75 ui->psiModLabel->setText(oboTerm.m_psiModLabel);
76
77
78 m_oboPsiModTerm = oboTerm;
79}
80
83{
84 if(isOboTerm())
85 {
86 }
87 else
88 {
89 throw pappso::ExceptionNotFound(tr("OBO term not available"));
90 }
91 return m_oboPsiModTerm;
92}
93
94bool
96{
97 return m_oboPsiModTerm.isValid();
98}
99
100void
102{
103 QString label = ui->definitionLabel->text();
104 //"Oxidation of methionine to methionine sulfoxide with neutral loss of
105 // CH3SOH." [PubMed:18688235, PubMed:9004526]
106
107 QLayoutItem *child;
108 while((child = ui->xrefScrollAreaLayout->takeAt(0)) != 0)
109 {
110 if(child->widget() != NULL)
111 {
112 delete(child->widget());
113 }
114 delete child;
115 }
116
117 ui->xrefScrollArea->hide();
118 QRegularExpressionMatch match = m_findExternalLinks.match(label);
119 if(match.hasMatch())
120 {
121 QStringList pline = match.capturedTexts();
122 ui->definitionLabel->setText(pline[1]);
123
124 QStringList list_xref = pline[2].split(",");
125
126 ui->xrefScrollArea->show();
127 for(auto xref : list_xref)
128 {
129 HttpButton *newButton = new HttpButton;
130 newButton->setText(xref.trimmed());
131 newButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
132 ui->xrefScrollAreaLayout->addWidget(newButton);
133 }
134 }
135}
void setText(const QString &text)
const QString & getAccession() const
const OboPsiModTerm & getOboPsiModTerm() const
get the obo term or an exception
OboPsiModTerm m_oboPsiModTerm
Definition obotermform.h:80
void parseDefinitionLabel()
parse the definition label to extract external links
bool isOboTerm() const
tells if an OBO term is displayed
OboTermForm(QWidget *parent=nullptr)
void displayOboTerm(OboPsiModTerm oboTerm)
Ui::OboTermForm * ui
Definition obotermform.h:78
static QRegularExpression m_findExternalLinks
Definition obotermform.h:83
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39