From fd4a185b30d9c2a235312b122d7fbdd3fd188f03 Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Thu, 8 Jun 2017 22:51:16 +0200
Subject: [PATCH] accession label

---
 src/core/proteinxtp.cpp                     |  5 ++++-
 src/gui/protein_view/protein_detail_view.ui | 17 +----------------
 src/gui/protein_view/proteinwindow.cpp      |  5 +++++
 3 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/src/core/proteinxtp.cpp b/src/core/proteinxtp.cpp
index c5551184..947eb414 100644
--- a/src/core/proteinxtp.cpp
+++ b/src/core/proteinxtp.cpp
@@ -125,7 +125,7 @@ unsigned int ProteinXtp::countTrypticPeptidesForPAI() const {
 
 void ProteinXtp::parseAccession2dbxref() {
     qDebug() << "ProteinXtp::parseAccession2dbxref begin" ;
-    QStringList access_list = getAccession().split("\\|");
+    QStringList access_list = getAccession().split("|");
     // if (access.length == 1)
     QRegExp atg("^[Aa][Tt][MmCc1-5][Gg]\\d{5}\\.?\\d?$");
     QRegExp ncbi_gi("^[0-9]{5,8}$");
@@ -134,6 +134,7 @@ void ProteinXtp::parseAccession2dbxref() {
     QRegExp ref ("^[NZ]P\\_[0-9]{5,8}$");
 
     for (QString & accession :access_list) {
+        qDebug() << "ProteinXtp::parseAccession2dbxref accession " << accession;
         if (atg.indexIn(accession, 0) != -1) {
             QStringList temp = accession.split("\\.");
             _dbxref_list.push_back(std::make_pair(ExternalDatabase::AGI_LocusCode, temp.at(0)));
@@ -143,10 +144,12 @@ void ProteinXtp::parseAccession2dbxref() {
         }
 
         if (swiss_prot.indexIn(accession, 0) != -1) {
+            qDebug() << "ProteinXtp::parseAccession2dbxref accession SwissProt " << accession;
             _dbxref_list.push_back(std::make_pair(ExternalDatabase::SwissProt, accession));
         }
 
         if (trembl.indexIn(accession, 0) != -1) {
+            qDebug() << "ProteinXtp::parseAccession2dbxref accession TrEMBL " << accession;
             _dbxref_list.push_back(std::make_pair(ExternalDatabase::TrEMBL, accession));
         }
         if (ref.indexIn(accession, 0) != -1) {
diff --git a/src/gui/protein_view/protein_detail_view.ui b/src/gui/protein_view/protein_detail_view.ui
index 4233a77c..9281f5c0 100644
--- a/src/gui/protein_view/protein_detail_view.ui
+++ b/src/gui/protein_view/protein_detail_view.ui
@@ -39,27 +39,12 @@
           </item>
           <item>
            <widget class="QLabel" name="accession_label">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="maximumSize">
-             <size>
-              <width>16777215</width>
-              <height>167</height>
-             </size>
-            </property>
             <property name="text">
              <string>TextLabel</string>
             </property>
             <property name="wordWrap">
              <bool>true</bool>
             </property>
-            <property name="textInteractionFlags">
-             <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
-            </property>
            </widget>
           </item>
           <item>
@@ -172,7 +157,7 @@
      <x>0</x>
      <y>0</y>
      <width>609</width>
-     <height>46</height>
+     <height>25</height>
     </rect>
    </property>
   </widget>
diff --git a/src/gui/protein_view/proteinwindow.cpp b/src/gui/protein_view/proteinwindow.cpp
index faafebfb..cb8698c2 100644
--- a/src/gui/protein_view/proteinwindow.cpp
+++ b/src/gui/protein_view/proteinwindow.cpp
@@ -76,6 +76,11 @@ void ProteinWindow::updateDisplay() {
         ui->decoy_checkbox->setCheckState(Qt::Unchecked);
         if (_p_protein_match->getProteinXtpSp().get()->isDecoy()) ui->decoy_checkbox->setCheckState(Qt::Checked);
         ui->accession_label->setText(_p_protein_match->getProteinXtpSp().get()->getAccession());
+        for (std::pair<ExternalDatabase, QString> dbxref:_p_protein_match->getProteinXtpSp().get()->getDbxrefList()) {
+            QString accession = ui->accession_label->text().replace(dbxref.second, QString("<a href=\"\" style=\"color:%2;\">%1</a>").arg(dbxref.second).arg("blue"));
+            ui->accession_label->setText(accession);
+            qDebug() << "ProteinWindow::updateDisplay " << accession;
+        }
         ui->description_label->setText(_p_protein_match->getProteinXtpSp().get()->getDescription());
         ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence());
         ui->coverage_label->setText(QString("%1 %").arg(_p_protein_match->getCoverage()*100));
-- 
GitLab