From 675f375f1fe533289fafbc2473bbdb35ada60190 Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Tue, 13 Nov 2018 14:50:01 +0100
Subject: [PATCH] look for sequence LI in protein list

---
 src/gui/protein_list_view/protein_view.ui     |  7 ++-
 .../protein_list_view/proteinlistwindow.cpp   | 45 ++++++++++++++-----
 .../proteintableproxymodel.cpp                | 15 ++++++-
 3 files changed, 53 insertions(+), 14 deletions(-)

diff --git a/src/gui/protein_list_view/protein_view.ui b/src/gui/protein_list_view/protein_view.ui
index c1986229f..ada3765aa 100644
--- a/src/gui/protein_list_view/protein_view.ui
+++ b/src/gui/protein_list_view/protein_view.ui
@@ -96,7 +96,12 @@
         </item>
         <item>
          <property name="text">
-          <string>sequence</string>
+          <string extracomment="look for protein sequence containing this amino acid sequence.">sequence</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string extracomment="look for protein sequence containing these amino acids, but considering that L and I is the same.">sequence LI</string>
          </property>
         </item>
        </widget>
diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp
index 736483554..4a05e8cfc 100644
--- a/src/gui/protein_list_view/proteinlistwindow.cpp
+++ b/src/gui/protein_list_view/proteinlistwindow.cpp
@@ -47,7 +47,9 @@ ProteinListQactionColumn::ProteinListQactionColumn(ProteinListWindow *parent,
 
 #if QT_VERSION >= 0x050000
   // Qt5 code
-  connect(this, &ProteinListQactionColumn::toggled, this,
+  connect(this,
+          &ProteinListQactionColumn::toggled,
+          this,
           &ProteinListQactionColumn::doToggled);
 #else
   // Qt4 code
@@ -116,26 +118,41 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent)
 
 #if QT_VERSION >= 0x050000
   // Qt5 code
-  connect(_project_window, &ProjectWindow::identificationGroupGrouped, this,
+  connect(_project_window,
+          &ProjectWindow::identificationGroupGrouped,
+          this,
           &ProteinListWindow::doIdentificationGroupGrouped);
 
-  connect(this, &ProteinListWindow::proteinDataChanged, _protein_table_model_p,
+  connect(this,
+          &ProteinListWindow::proteinDataChanged,
+          _protein_table_model_p,
           &ProteinTableModel::onProteinDataChanged);
-  connect(ui->tableView, &QTableView::clicked, _p_proxy_model,
+  connect(ui->tableView,
+          &QTableView::clicked,
+          _p_proxy_model,
           &ProteinTableProxyModel::onTableClicked);
-  connect(ui->centralwidget, &QWidget::customContextMenuRequested, this,
+  connect(ui->centralwidget,
+          &QWidget::customContextMenuRequested,
+          this,
           &ProteinListWindow::showContextMenu);
-  connect(_protein_table_model_p, &ProteinTableModel::layoutChanged, this,
+  connect(_protein_table_model_p,
+          &ProteinTableModel::layoutChanged,
+          this,
           &ProteinListWindow::updateStatusBar);
 #else
   // Qt4 code
   connect(_project_window,
-          SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,
+          SIGNAL(identificationGroupGrouped(IdentificationGroup *)),
+          this,
           SLOT(doIdentificationGroupGrouped(IdentificationGroup *)));
 
-  connect(this, SIGNAL(proteinDataChanged()), _protein_table_model_p,
+  connect(this,
+          SIGNAL(proteinDataChanged()),
+          _protein_table_model_p,
           SLOT(onProteinDataChanged()));
-  connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model,
+  connect(ui->tableView,
+          SIGNAL(clicked(const QModelIndex &)),
+          _p_proxy_model,
           SLOT(onTableClicked(const QModelIndex &)));
   // connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)),
   // _p_proxy_model, SLOT(onTableDoubleClicked(const QModelIndex &)));
@@ -145,11 +162,15 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent)
 
   // connect( this, SIGNAL( focusReceived(bool) ),this,
   // SLOT(doFocusReceived(bool)) );
-  connect(ui->centralwidget, SIGNAL(customContextMenuRequested(const QPoint &)),
-          this, SLOT(showContextMenu(const QPoint &)));
+  connect(ui->centralwidget,
+          SIGNAL(customContextMenuRequested(const QPoint &)),
+          this,
+          SLOT(showContextMenu(const QPoint &)));
   // connect(_p_proxy_model, SIGNAL(layoutChanged()),
   //        this, SLOT(doProxyLayoutChanged()));
-  connect(_protein_table_model_p, SIGNAL(layoutChanged()), this,
+  connect(_protein_table_model_p,
+          SIGNAL(layoutChanged()),
+          this,
           SLOT(updateStatusBar()));
 #endif
 }
diff --git a/src/gui/protein_list_view/proteintableproxymodel.cpp b/src/gui/protein_list_view/proteintableproxymodel.cpp
index 7aa1d8ec3..336061c75 100644
--- a/src/gui/protein_list_view/proteintableproxymodel.cpp
+++ b/src/gui/protein_list_view/proteintableproxymodel.cpp
@@ -197,6 +197,18 @@ ProteinTableProxyModel::filterAcceptsRow(int source_row,
                   return false;
                 }
             }
+          else if(_search_on == "sequence LI")
+            {
+              QString peptide_search_string =
+                QString(_protein_search_string).replace("L", "I");
+              QString protein_sequence_li =
+                QString(protein_match->getProteinXtpSp().get()->getSequence())
+                  .replace("L", "I");
+              if(!protein_sequence_li.contains(peptide_search_string))
+                {
+                  return false;
+                }
+            }
           else if(_search_on == "peptide")
             {
               QString peptide_search_string =
@@ -366,7 +378,8 @@ ProteinTableProxyModel::data(const QModelIndex &index, int role) const
 }
 
 QVariant
-ProteinTableProxyModel::headerData(int section, Qt::Orientation orientation,
+ProteinTableProxyModel::headerData(int section,
+                                   Qt::Orientation orientation,
                                    int role) const
 {
   int col = mapToSource(index(0, section)).column();
-- 
GitLab