libpappsomspp
Library for mass spectrometry
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>
34 #include "../../../exception/exceptionnotfound.h"
35 
36 using namespace pappso;
37 
38 //"Oxidation of methionine to methionine sulfoxide with neutral loss of CH3SOH."
39 //[PubMed:18688235, PubMed:9004526]
40 QRegularExpression OboTermForm::m_findExternalLinks("^(.*)\\s\\[(.*)\\]$");
41 
42 
43 OboTermForm::OboTermForm(QWidget *parent)
44  : QWidget(parent), ui(new Ui::OboTermForm)
45 {
46  qDebug();
47  ui->setupUi(this);
48 
49  OboPsiModTerm empty;
50  displayOboTerm(empty);
51 }
52 
54 {
55  delete ui;
56 }
57 
58 void
60 {
61  qDebug() << oboTerm.m_accession;
62  ui->accessionHttpButton->setText(oboTerm.m_accession);
63  ui->nameLabel->setText(oboTerm.m_name);
64  ui->definitionLabel->setText(oboTerm.m_definition);
65  ui->diffFormulaLabel->setText(oboTerm.m_diffFormula);
66  if(oboTerm.isValid())
67  {
68  ui->diffMonoLabel->setText(QString::number(oboTerm.m_diffMono, 'f', 4));
69  parseDefinitionLabel();
70  }
71  else
72  {
73  ui->diffMonoLabel->setText("");
74  }
75  ui->originLabel->setText(oboTerm.m_origin);
76  ui->psiModLabel->setText(oboTerm.m_psiModLabel);
77 
78 
79  m_oboPsiModTerm = oboTerm;
80 }
81 
84 {
85  if(isOboTerm())
86  {
87  }
88  else
89  {
90  throw pappso::ExceptionNotFound(tr("OBO term not available"));
91  }
92  return m_oboPsiModTerm;
93 }
94 
95 bool
97 {
98  return m_oboPsiModTerm.isValid();
99 }
100 
101 void
103 {
104  QString label = ui->definitionLabel->text();
105  //"Oxidation of methionine to methionine sulfoxide with neutral loss of
106  // CH3SOH." [PubMed:18688235, PubMed:9004526]
107 
108  QLayoutItem *child;
109  while((child = ui->xrefScrollAreaLayout->takeAt(0)) != 0)
110  {
111  if(child->widget() != NULL)
112  {
113  delete(child->widget());
114  }
115  delete child;
116  }
117 
118  ui->xrefScrollArea->hide();
119  QRegularExpressionMatch match = m_findExternalLinks.match(label);
120  if(match.hasMatch())
121  {
122  QStringList pline = match.capturedTexts();
123  ui->definitionLabel->setText(pline[1]);
124 
125  QStringList list_xref = pline[2].split(",");
126 
127  ui->xrefScrollArea->show();
128  for(auto xref : list_xref)
129  {
130  HttpButton *newButton = new HttpButton;
131  newButton->setText(xref.trimmed());
132  newButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
133  ui->xrefScrollAreaLayout->addWidget(newButton);
134  }
135  }
136 }
void setText(const QString &text)
Definition: httpbutton.cpp:86
const OboPsiModTerm & getOboPsiModTerm() const
get the obo term or an exception
Definition: obotermform.cpp:83
void parseDefinitionLabel()
parse the definition label to extract external links
bool isOboTerm() const
tells if an OBO term is displayed
Definition: obotermform.cpp:96
OboTermForm(QWidget *parent=nullptr)
Definition: obotermform.cpp:43
void displayOboTerm(OboPsiModTerm oboTerm)
Definition: obotermform.cpp:59
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
display an obo term form