From 37ea0a23a6c04141215549f7ce9e85315bb1961f Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Sun, 17 Dec 2017 08:10:09 +0100
Subject: [PATCH] compute FDR also on grouped proteins

---
 src/gui/project_view/project_view.ui   | 78 ++++++++++++++++++++++----
 src/gui/project_view/projectwindow.cpp | 21 ++++++-
 2 files changed, 85 insertions(+), 14 deletions(-)

diff --git a/src/gui/project_view/project_view.ui b/src/gui/project_view/project_view.ui
index e559751f5..72e0934a4 100644
--- a/src/gui/project_view/project_view.ui
+++ b/src/gui/project_view/project_view.ui
@@ -24,7 +24,7 @@
        <string/>
       </property>
       <property name="currentIndex">
-       <number>1</number>
+       <number>2</number>
       </property>
       <widget class="QWidget" name="identifications">
        <attribute name="title">
@@ -82,23 +82,16 @@
           <item>
            <widget class="QGroupBox" name="groupBox_3">
             <property name="toolTip">
-             <string/>
+             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;FDR is computed using proteins tagged as &amp;quot;decoy&amp;quot; on all valid peptides in valid proteins (check filter parameters)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
             </property>
             <property name="title">
              <string>FDR</string>
             </property>
-            <layout class="QFormLayout" name="formLayout">
-             <item row="0" column="0">
-              <widget class="QLabel" name="label">
-               <property name="text">
-                <string>FDR on peptides</string>
-               </property>
-              </widget>
-             </item>
+            <layout class="QGridLayout" name="gridLayout_4">
              <item row="0" column="1">
               <widget class="QLabel" name="peptide_fdr_label">
                <property name="toolTip">
-                <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;FDR is computed using peptides tagged as &amp;quot;decoy&amp;quot; on all valid peptides in valid proteins (check filter parameters)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+                <string/>
                </property>
                <property name="text">
                 <string>0 %</string>
@@ -112,11 +105,72 @@
                </property>
               </widget>
              </item>
+             <item row="0" column="2">
+              <spacer name="horizontalSpacer_3">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>40</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+             <item row="0" column="3">
+              <widget class="QLabel" name="label_6">
+               <property name="text">
+                <string>grouped peptides</string>
+               </property>
+              </widget>
+             </item>
+             <item row="0" column="0">
+              <widget class="QLabel" name="label">
+               <property name="text">
+                <string>FDR on peptides</string>
+               </property>
+              </widget>
+             </item>
              <item row="1" column="1">
               <widget class="QLabel" name="protein_fdr_label">
                <property name="toolTip">
-                <string>FDR is computed using proteins tagged as &quot;decoy&quot; on all valid proteins (check filter parameters)</string>
+                <string/>
+               </property>
+               <property name="text">
+                <string>0 %</string>
+               </property>
+              </widget>
+             </item>
+             <item row="0" column="4">
+              <widget class="QLabel" name="grouped_peptide_fdr_label">
+               <property name="text">
+                <string>0 %</string>
                </property>
+              </widget>
+             </item>
+             <item row="1" column="2">
+              <spacer name="horizontalSpacer_4">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>40</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+             <item row="1" column="3">
+              <widget class="QLabel" name="label_7">
+               <property name="text">
+                <string>grouped proteins</string>
+               </property>
+              </widget>
+             </item>
+             <item row="1" column="4">
+              <widget class="QLabel" name="grouped_protein_fdr_label">
                <property name="text">
                 <string>0 %</string>
                </property>
diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp
index 2ed43bf75..4a1896ef9 100644
--- a/src/gui/project_view/projectwindow.cpp
+++ b/src/gui/project_view/projectwindow.cpp
@@ -221,8 +221,25 @@ void ProjectWindow::computeFdr() {
             total_peptide += identification_group->countPeptideMassSample(state);
             false_peptide += identification_group->countDecoyPeptideMassSample(state);
         }
-        ui->protein_fdr_label->setText(QString("%1 %").arg(QString::number((false_prot/total_prot)*100.0,'f',10)));
-        ui->peptide_fdr_label->setText(QString("%1 %").arg(QString::number((false_peptide/total_peptide)*100.0,'f',10)));
+        ui->protein_fdr_label->setText(QString("%1 %").arg(QString::number((false_prot/total_prot)*100.0,'f',2)));
+        ui->peptide_fdr_label->setText(QString("%1 %").arg(QString::number((false_peptide/total_peptide)*100.0,'f',2)));
+        
+        
+        state = ValidationState::grouped;
+        total_prot=0;
+        false_prot=0;
+        total_peptide=0;
+        false_peptide=0;
+        for (IdentificationGroup * identification_group : _project_sp.get()->getIdentificationGroupList()) {
+            total_prot += identification_group->countProteinMatch(state);
+            false_prot += identification_group->countDecoyProteinMatch(state);
+            //total_peptide += identification_group->countPeptideMatch(state);
+            //false_peptide += identification_group->countDecoyPeptideMatch(state);
+            total_peptide += identification_group->countPeptideMassSample(state);
+            false_peptide += identification_group->countDecoyPeptideMassSample(state);
+        }
+        ui->grouped_protein_fdr_label->setText(QString("%1 %").arg(QString::number((false_prot/total_prot)*100.0,'f',2)));
+        ui->grouped_peptide_fdr_label->setText(QString("%1 %").arg(QString::number((false_peptide/total_peptide)*100.0,'f',2)));
     }
     catch (pappso::PappsoException exception_pappso) {
         QMessageBox::warning(this,
-- 
GitLab