From 32646ed54c52bb0194bf9b20f3efa9d887648384 Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Wed, 29 Mar 2017 17:02:42 +0200
Subject: [PATCH] display not valid peptides, warning : bug counting valid
 peptides per msrun

---
 src/CMakeLists.txt                              |  4 ++--
 src/core/proteinmatch.cpp                       | 12 ++++++++----
 src/gui/peptide_list_view/peptidetablemodel.cpp |  9 ++++++++-
 src/gui/protein_list_view/proteinlistwindow.cpp |  5 ++++-
 src/gui/protein_list_view/proteinlistwindow.h   |  2 +-
 5 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2f5d3bbc..46172223 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -29,8 +29,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5
 
 #sudo apt-get install libpappsomspp-dev
 #FIND_PACKAGE( Pappsomspp REQUIRED )
-SET (PAPPSOMSPP_DIR  "/home/olivier/eclipse/git/pappsomspp")
-# SET (PAPPSOMSPP_DIR  "/home/langella/developpement/git/pappsomspp")
+# SET (PAPPSOMSPP_DIR  "/home/olivier/eclipse/git/pappsomspp")
+ SET (PAPPSOMSPP_DIR  "/home/langella/developpement/git/pappsomspp")
  SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src")
  SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt4.so")
 
diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp
index eae99e21..fc62465f 100644
--- a/src/core/proteinmatch.cpp
+++ b/src/core/proteinmatch.cpp
@@ -63,19 +63,23 @@ void ProteinMatch::updateAutomaticFilters(const AutomaticFilterParameters & auto
                 else {
                     std::pair<std::map<const pappso::MsRunId*, unsigned int>::iterator,bool> ret = _count_per_msrun.insert(std::pair<const pappso::MsRunId*, unsigned int>(p_peptide_match->getMsRunIdSp().get(),0));
                     ret.first->second +=1;
-                    if (ret.first->second > _number_of_valid_peptides) {
-                        _number_of_valid_peptides = ret.first->second;
-                    }
                 }
             }
         }
     }
 
 
+    for (auto && pair_msrun_count : _count_per_msrun) {
+        if (pair_msrun_count.second > _number_of_valid_peptides) {
+            _number_of_valid_peptides  = pair_msrun_count.second;
+        }
+    }
     //update protein evalue ?
 
 
-    if (_number_of_valid_peptides >= automatic_filter_parameters.getFilterMinimumPeptidePerMatch()) {
+    if (_number_of_valid_peptides < automatic_filter_parameters.getFilterMinimumPeptidePerMatch()) {
+    }
+    else {
         if (_evalue <= automatic_filter_parameters.getFilterProteinEvalue()) {
             _proxy_valid = true;
         }
diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp
index adb38945..65e5bbc1 100644
--- a/src/gui/peptide_list_view/peptidetablemodel.cpp
+++ b/src/gui/peptide_list_view/peptidetablemodel.cpp
@@ -24,6 +24,7 @@
 #include "peptidetablemodel.h"
 
 #include <QDebug>
+#include <QColor>
 #include <pappsomspp/grouping/grppeptide.h>
 
 
@@ -145,6 +146,12 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
             }
         }
         break;
+        case Qt::BackgroundRole:
+        if (_p_protein_match->getPeptideMatchList().at(row)->isValid() == false)
+        {
+            return QVariant(QColor("grey"));
+        }
+        break;
     case Qt::DisplayRole:
         if (_p_protein_match == nullptr) {
         }
@@ -203,5 +210,5 @@ bool PeptideTableModel::acceptRow(int source_row) {
     if (_p_protein_match->getPeptideMatchList().at(source_row)->isValid()) {
         return true;
     }
-    return false;
+    return true;
 }
diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp
index 00348a5a..6fe75065 100644
--- a/src/gui/protein_list_view/proteinlistwindow.cpp
+++ b/src/gui/protein_list_view/proteinlistwindow.cpp
@@ -188,7 +188,10 @@ void ProteinListWindow::setIdentificationGroup(IdentificationGroup * p_identific
 
 }
 void ProteinListWindow::updateStatusBar() {
+    if (_p_identification_group == nullptr) {
+    }
+    else {
     ui->statusbar->showMessage(tr("proteins %1 valid, %2 checked, %3 displayed").arg(_p_identification_group->countValid()).arg(_p_identification_group->countValidAndChecked()).arg(_p_proxy_model->rowCount()));
-
+    }
 }
 
diff --git a/src/gui/protein_list_view/proteinlistwindow.h b/src/gui/protein_list_view/proteinlistwindow.h
index 268939d4..4ce0985f 100644
--- a/src/gui/protein_list_view/proteinlistwindow.h
+++ b/src/gui/protein_list_view/proteinlistwindow.h
@@ -74,7 +74,7 @@ protected :
         
 
 private:
-    IdentificationGroup * _p_identification_group;
+    IdentificationGroup * _p_identification_group=nullptr;
     Ui::ProteinView *ui;
     ProteinTableModel * _protein_table_model_p = nullptr;
     ProteinTableProxyModel * _p_proxy_model = nullptr;
-- 
GitLab