Skip to content
Snippets Groups Projects
Commit 2c3478c8 authored by Olivier Langella's avatar Olivier Langella
Browse files

dbxref button works

parent acf0c54c
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,44 @@ ...@@ -25,6 +25,44 @@
#include <pappsomspp/protein/enzyme.h> #include <pappsomspp/protein/enzyme.h>
#include <pappsomspp/pappsoexception.h> #include <pappsomspp/pappsoexception.h>
DbXref::DbXref() {
}
DbXref::DbXref(ExternalDatabase database_in, const QString & accession_in):database(database_in), accession(accession_in) {
}
DbXref::DbXref(const DbXref & other):database(other.database), accession(other.accession) {
}
const QUrl DbXref::getUrl() const {
QUrl url;
qDebug() << "DbXref::getUrl " << accession << " "<< (std::uint8_t)database;
switch (database) {
case ExternalDatabase::AGI_LocusCode :
url.setUrl(QString("http://www.arabidopsis.org/servlets/TairObject?type=locus&name=%1").arg(accession));
break;
case ExternalDatabase::NCBI_gi :
url.setUrl(QString("http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=protein&dopt=GenBank&list_uids=%1").arg(accession));
break;
case ExternalDatabase::SwissProt :
url.setUrl(QString("http://www.uniprot.org/uniprot/%1").arg(accession));
break;
case ExternalDatabase::TrEMBL :
url.setUrl(QString("http://www.uniprot.org/uniprot/%1").arg(accession));
break;
case ExternalDatabase::ref :
break;
case ExternalDatabase::OboPsiMod :
QString iri(QString("http://purl.obolibrary.org/obo/%1").arg(QString(accession).replace(":","_")));
url.setUrl(QString("http://www.ebi.ac.uk/ols/ontologies/mod/terms?iri=%1").arg(iri));
break;
}
qDebug() << "DbXref::getUrl end " << url;
return url;
}
ProteinXtp::ProteinXtp():pappso::Protein() ProteinXtp::ProteinXtp():pappso::Protein()
{ {
...@@ -132,41 +170,59 @@ void ProteinXtp::parseAccession2dbxref() { ...@@ -132,41 +170,59 @@ void ProteinXtp::parseAccession2dbxref() {
QRegExp swiss_prot("^P[A-Z0-9]{5}$"); QRegExp swiss_prot("^P[A-Z0-9]{5}$");
QRegExp trembl("^[QOA][A-Z0-9]{5}$"); QRegExp trembl("^[QOA][A-Z0-9]{5}$");
QRegExp ref ("^[NZ]P\\_[0-9]{5,8}$"); QRegExp ref ("^[NZ]P\\_[0-9]{5,8}$");
QString accession;
for (QString & accession :access_list) { for (unsigned int i=0; i < access_list.size(); i++) {
accession = access_list.at(i);
qDebug() << "ProteinXtp::parseAccession2dbxref accession " << accession; qDebug() << "ProteinXtp::parseAccession2dbxref accession " << accession;
if (atg.indexIn(accession, 0) != -1) { if (atg.indexIn(accession, 0) != -1) {
QStringList temp = accession.split("\\."); QStringList temp = accession.split("\\.");
_dbxref_list.push_back(DbXref(ExternalDatabase::AGI_LocusCode, temp.at(0))); _dbxref_list.push_back(DbXref(ExternalDatabase::AGI_LocusCode, temp.at(0)));
continue;
} }
if (ncbi_gi.indexIn(accession, 0) != -1) { if (ncbi_gi.indexIn(accession, 0) != -1) {
_dbxref_list.push_back(DbXref(ExternalDatabase::NCBI_gi, accession)); _dbxref_list.push_back(DbXref(ExternalDatabase::NCBI_gi, accession));
continue;
} }
if (swiss_prot.indexIn(accession, 0) != -1) { if (swiss_prot.indexIn(accession, 0) != -1) {
qDebug() << "ProteinXtp::parseAccession2dbxref accession SwissProt " << accession; qDebug() << "ProteinXtp::parseAccession2dbxref accession SwissProt " << accession;
_dbxref_list.push_back(DbXref(ExternalDatabase::SwissProt, accession)); _dbxref_list.push_back(DbXref(ExternalDatabase::SwissProt, accession));
continue;
} }
if (trembl.indexIn(accession, 0) != -1) { if (trembl.indexIn(accession, 0) != -1) {
qDebug() << "ProteinXtp::parseAccession2dbxref accession TrEMBL " << accession; qDebug() << "ProteinXtp::parseAccession2dbxref accession TrEMBL " << accession;
_dbxref_list.push_back(DbXref(ExternalDatabase::TrEMBL, accession)); _dbxref_list.push_back(DbXref(ExternalDatabase::TrEMBL, accession));
continue;
} }
if (ref.indexIn(accession, 0) != -1) { if (ref.indexIn(accession, 0) != -1) {
_dbxref_list.push_back(DbXref(ExternalDatabase::ref, accession)); _dbxref_list.push_back(DbXref(ExternalDatabase::ref, accession));
continue;
}
if (i > 0) {
if ((access_list.at(i-1) == "sp")&&(accession.size() == 6)) {
_dbxref_list.push_back(DbXref(ExternalDatabase::SwissProt, accession));
}
if ((access_list.at(i-1) == "tr")&&(accession.size() == 6)) {
_dbxref_list.push_back(DbXref(ExternalDatabase::TrEMBL, accession));
}
}
if (_dbxref_list.size() > 1) {
_dbxref_list.sort([] (const DbXref & first, const DbXref & second)
{
return std::tie(first.database, first.accession) < std::tie(second.database, second.accession);
});
_dbxref_list.unique([] (const DbXref & first, const DbXref & second)
{
return ( first.database == second.database ) && (first.accession == second.accession);
});
} }
} }
if (_dbxref_list.size() > 1) {
_dbxref_list.sort([] (const DbXref & first, const DbXref & second)
{
return std::tie(first.database, first.accession) < std::tie(second.database, second.accession);
});
_dbxref_list.unique([] (const DbXref & first, const DbXref & second)
{
return ( first.database == second.database ) && (first.accession == second.accession);
});
}
qDebug() << "ProteinXtp::parseAccession2dbxref end" ; qDebug() << "ProteinXtp::parseAccession2dbxref end" ;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <pappsomspp/protein/protein.h> #include <pappsomspp/protein/protein.h>
#include <pappsomspp/types.h> #include <pappsomspp/types.h>
#include <list> #include <list>
#include <QUrl>
#include "sequencedatabase.h" #include "sequencedatabase.h"
#include "../utils/types.h" #include "../utils/types.h"
...@@ -31,8 +32,10 @@ ...@@ -31,8 +32,10 @@
#define PROTEIN_XTP_H #define PROTEIN_XTP_H
struct DbXref { struct DbXref {
DbXref(ExternalDatabase database_in, const QString & accession_in):database(database), accession(accession_in) { DbXref();
}; DbXref(const DbXref & other);
DbXref(ExternalDatabase database_in, const QString & accession_in);
const QUrl getUrl() const;
ExternalDatabase database; ExternalDatabase database;
QString accession; QString accession;
}; };
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<item> <item>
<widget class="QLabel" name="accession_label"> <widget class="QLabel" name="accession_label">
<property name="text"> <property name="text">
<string>TextLabel</string> <string>TextLa&amp;bel</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
...@@ -48,24 +48,26 @@ ...@@ -48,24 +48,26 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="button_space_layout"> <widget class="QWidget" name="button_layout" native="true">
<item> <layout class="QHBoxLayout" name="button_space_layout">
<layout class="QHBoxLayout" name="dbxref_list_layout"/> <item>
</item> <layout class="QHBoxLayout" name="dbxref_list_layout"/>
<item> </item>
<spacer name="horizontalSpacer_2"> <item>
<property name="orientation"> <spacer name="button_spacer">
<enum>Qt::Horizontal</enum> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
<property name="sizeHint" stdset="0"> </property>
<size> <property name="sizeHint" stdset="0">
<width>40</width> <size>
<height>20</height> <width>40</width>
</size> <height>20</height>
</property> </size>
</spacer> </property>
</item> </spacer>
</layout> </item>
</layout>
</widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="description_label"> <widget class="QLabel" name="description_label">
...@@ -126,14 +128,14 @@ ...@@ -126,14 +128,14 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>coverage</string> <string>cove&amp;rage</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="coverage_label"> <widget class="QLabel" name="coverage_label">
<property name="text"> <property name="text">
<string>0%</string> <string>&amp;0%</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -147,7 +149,7 @@ ...@@ -147,7 +149,7 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="mw_label"> <widget class="QLabel" name="mw_label">
<property name="text"> <property name="text">
<string>1Da</string> <string>&amp;1Da</string>
</property> </property>
</widget> </widget>
</item> </item>
......
...@@ -26,8 +26,30 @@ ...@@ -26,8 +26,30 @@
#include "ui_protein_detail_view.h" #include "ui_protein_detail_view.h"
#include <pappsomspp/pappsoexception.h> #include <pappsomspp/pappsoexception.h>
#include <QMessageBox> #include <QMessageBox>
#include <QDesktopServices>
#include <cmath> #include <cmath>
#include <QPushButton>
DbXrefButton::DbXrefButton(QWidget * parent, DbXref dbxref): QPushButton(parent) {
_dbxref = dbxref;
#if QT_VERSION >= 0x050000
// Qt5 code
/*
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
connect(this, &PtSpectrumViewer::operateMsDataFile, worker, &PwizLoaderThread::doMsDataFileLoad);
connect(worker, &PwizLoaderThread::msDataReady, this, &PtSpectrumViewer::handleMsDataFile);
*/
#else
// Qt4 code
QObject::connect(this, SIGNAL(clicked()),this, SLOT(clickedSlot()));
#endif
setText(_dbxref.accession);
}
void DbXrefButton::clickedSlot() {
qDebug() << "DbXrefButton::clickedSlot " << _dbxref.getUrl();
QDesktopServices::openUrl (_dbxref.getUrl()) ;
}
ProteinWindow::ProteinWindow(ProjectWindow *parent): ProteinWindow::ProteinWindow(ProjectWindow *parent):
QMainWindow(parent), QMainWindow(parent),
...@@ -66,17 +88,18 @@ void ProteinWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identif ...@@ -66,17 +88,18 @@ void ProteinWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identif
void ProteinWindow::doPeptideMatchSelected(PeptideMatch * peptide_match) { void ProteinWindow::doPeptideMatchSelected(PeptideMatch * peptide_match) {
if (_p_protein_match != nullptr) { if (_p_protein_match != nullptr) {
ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence(peptide_match)); ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence(peptide_match));
} }
} }
void ProteinWindow::clearDbXrefLayout() { void ProteinWindow::clearDbXrefLayout() {
for (int i = 0; i < ui->dbxref_list_layout->count(); ++i) for (int i = 0; i < ui->dbxref_list_layout->count(); ++i)
{ {
delete ui->dbxref_list_layout->itemAt(i)->widget(); delete ui->dbxref_list_layout->itemAt(i)->widget();
}
} }
void ProteinWindow::browseUrl(int i) {
} }
void ProteinWindow::updateDisplay() { void ProteinWindow::updateDisplay() {
try { try {
clearDbXrefLayout(); clearDbXrefLayout();
...@@ -89,15 +112,14 @@ void ProteinWindow::updateDisplay() { ...@@ -89,15 +112,14 @@ void ProteinWindow::updateDisplay() {
QString accession = ui->accession_label->text().replace(dbxref.accession, QString("<span style=\"color:%2;\">%1</span>").arg(dbxref.accession).arg("blue")); QString accession = ui->accession_label->text().replace(dbxref.accession, QString("<span style=\"color:%2;\">%1</span>").arg(dbxref.accession).arg("blue"));
ui->accession_label->setText(accession); ui->accession_label->setText(accession);
qDebug() << "ProteinWindow::updateDisplay " << accession; qDebug() << "ProteinWindow::updateDisplay " << accession;
QPushButton * dbxref_button = new QPushButton(this); DbXrefButton * dbxref_button = new DbXrefButton(this,dbxref);
dbxref_button->setText(dbxref.accession);
ui->dbxref_list_layout->addWidget(dbxref_button); ui->dbxref_list_layout->addWidget(dbxref_button);
} }
ui->button_space_layout->setEnabled(true); ui->button_layout->setVisible(true);
if (ui->dbxref_list_layout->count() == 0) { if (ui->dbxref_list_layout->count() == 0) {
ui->button_space_layout->setEnabled(false); ui->button_layout->setVisible(false);
} }
ui->description_label->setText(_p_protein_match->getProteinXtpSp().get()->getDescription()); ui->description_label->setText(_p_protein_match->getProteinXtpSp().get()->getDescription());
ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence()); ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence());
......
...@@ -26,8 +26,19 @@ ...@@ -26,8 +26,19 @@
#include <QMainWindow> #include <QMainWindow>
#include <QTextDocument> #include <QTextDocument>
#include <QPushButton>
#include "../../core/proteinmatch.h" #include "../../core/proteinmatch.h"
class DbXrefButton: public QPushButton {
Q_OBJECT
public :
DbXrefButton(QWidget * parent, DbXref dbxref);
protected slots:
void clickedSlot();
private:
DbXref _dbxref;
};
class ProjectWindow; class ProjectWindow;
namespace Ui { namespace Ui {
...@@ -46,7 +57,9 @@ public: ...@@ -46,7 +57,9 @@ public:
public slots: public slots:
void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group); void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group);
void doPeptideMatchSelected(PeptideMatch * peptide_match); void doPeptideMatchSelected(PeptideMatch * peptide_match);
protected slots:
void browseUrl(int i);
protected : protected :
void updateDisplay(); void updateDisplay();
void clearDbXrefLayout(); void clearDbXrefLayout();
......
...@@ -32,11 +32,12 @@ ...@@ -32,11 +32,12 @@
* *
*/ */
enum class ExternalDatabase: std::int8_t { enum class ExternalDatabase: std::int8_t {
SwissProt =1, ///< Swiss-Prot OboPsiMod =1, ///< OBO PSI MOD
TrEMBL=2, ///< TrEMBL SwissProt =2, ///< Swiss-Prot
AGI_LocusCode=3, ///< AGI_LocusCode TrEMBL=3, ///< TrEMBL
NCBI_gi=4, ///< NCBI_gi AGI_LocusCode=4, ///< AGI_LocusCode
ref=5 ///< ref NCBI_gi=5, ///< NCBI_gi
ref=6 ///< ref
}; };
/** \def IdentificationEngine identification engine /** \def IdentificationEngine identification engine
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment