From 97e01aecb469c206efe5aba6aa5da3657ad77a0e Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Sat, 6 May 2017 21:44:48 +0200
Subject: [PATCH] log10 evalue on protein

---
 src/core/proteinmatch.cpp              | 8 ++++++--
 src/core/proteinmatch.h                | 4 ++++
 src/gui/protein_view/proteinwindow.cpp | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp
index 233d8b06..ec243cca 100644
--- a/src/core/proteinmatch.cpp
+++ b/src/core/proteinmatch.cpp
@@ -266,6 +266,10 @@ unsigned int ProteinMatch::countPeptideMassCharge(ValidationState state, const M
 }
 
 pappso::pappso_double ProteinMatch::getEvalue(const MsRun * sp_msrun_id) const {
+    return (std::pow ((double) 10.0,getLogEvalue(sp_msrun_id)));
+}
+
+pappso::pappso_double ProteinMatch::getLogEvalue(const MsRun * sp_msrun_id) const {
     std::map<QString, pappso::pappso_double> map_sequence_evalue;
     for (auto & p_peptide_match : _peptide_match_list) {
         if (p_peptide_match->isValidAndChecked()) {
@@ -296,8 +300,8 @@ pappso::pappso_double ProteinMatch::getEvalue(const MsRun * sp_msrun_id) const {
 
     pappso::pappso_double evalue_prot = 1;
     for (auto && peptide_pair: map_sequence_evalue) {
-        //evalue_prot += std::log10(peptide_pair.second);
-        evalue_prot *= peptide_pair.second;
+        evalue_prot += std::log10(peptide_pair.second);
+        //evalue_prot *= peptide_pair.second;
     }
 
     //return (std::pow ((double) 10.0,evalue_prot));
diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h
index f239bf50..687ff075 100644
--- a/src/core/proteinmatch.h
+++ b/src/core/proteinmatch.h
@@ -44,6 +44,10 @@ public:
     ~ProteinMatch();
 
     const ProteinXtpSp & getProteinXtpSp() const;
+    
+    /** @brief compute protein log10(Evalue) within samples
+      * */
+    pappso::pappso_double getLogEvalue(const MsRun * sp_msrun_id = nullptr) const;
 
     /** @brief compute protein Evalue within samples
       * */
diff --git a/src/gui/protein_view/proteinwindow.cpp b/src/gui/protein_view/proteinwindow.cpp
index 2788a4ab..faafebfb 100644
--- a/src/gui/protein_view/proteinwindow.cpp
+++ b/src/gui/protein_view/proteinwindow.cpp
@@ -80,7 +80,7 @@ void ProteinWindow::updateDisplay() {
         ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence());
         ui->coverage_label->setText(QString("%1 %").arg(_p_protein_match->getCoverage()*100));
         ui->mw_label->setText(QString("%1 kDa").arg(_p_protein_match->getProteinXtpSp().get()->getMass()/1000));
-        ui->evalue_label->setText(QString("%1 (log10: %2)").arg(_p_protein_match->getEvalue()).arg(std::log10(_p_protein_match->getEvalue())));
+        ui->evalue_label->setText(QString("%1 (log10: %2)").arg(_p_protein_match->getEvalue()).arg(_p_protein_match->getLogEvalue()));
     }
     catch (pappso::PappsoException exception_pappso) {
         QMessageBox::warning(this,
-- 
GitLab