From 5b4ebea8a64a55653cf8a3b7d1afa611b846c008 Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Tue, 9 May 2017 10:27:13 +0200
Subject: [PATCH] new ODS grouping sheet

---
 src/CMakeLists.txt               |  1 +
 src/core/identificationgroup.cpp | 21 +++++++++++++++++++++
 src/core/identificationgroup.h   |  8 ++++++++
 src/output/ods/odsexport.cpp     |  4 ++++
 4 files changed, 34 insertions(+)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f3044829a..87fc13db8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -73,6 +73,7 @@ SET(CPP_FILES
   output/ods/comparbasesheet.cpp
   output/ods/comparspecificspectrasheet.cpp
   output/ods/comparspectrasheet.cpp
+  output/ods/groupingsheet.cpp
   output/ods/infosheet.cpp
   output/ods/odsexport.cpp
   output/ods/peptidepossheet.cpp
diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp
index 3e98431bd..feef57812 100644
--- a/src/core/identificationgroup.cpp
+++ b/src/core/identificationgroup.cpp
@@ -47,6 +47,7 @@ const GroupStore & IdentificationGroup::getGroupStore() const {
 }
 
 unsigned int IdentificationGroup::countPeptideMassSample(ValidationState state) const {
+
     std::vector<std::size_t> count_peptide_mass_sample;
     for (auto & p_protein_match : _protein_match_list) {
         p_protein_match->countPeptideMassSample(count_peptide_mass_sample, state);
@@ -200,3 +201,23 @@ void IdentificationGroup::startGrouping (const GroupingType & grouping_type) {
 const QString IdentificationGroup::getTabName() const {
     return _ms_run_list[0]->getFilename();
 }
+
+
+
+pappso::pappso_double IdentificationGroup::getPeptideMassFdr(ValidationState state) const {
+    //ValidationState state = ValidationState::valid;
+    pappso::pappso_double total_peptide=countPeptideMassSample(state);
+    pappso::pappso_double false_peptide=countDecoyPeptideMassSample(state);
+
+    return (false_peptide/total_peptide);
+}
+
+pappso::pappso_double IdentificationGroup::getProteinFdr(ValidationState state) const {
+    //ValidationState state = ValidationState::valid;
+    pappso::pappso_double total_prot=countProteinMatch(state);
+    pappso::pappso_double false_prot=countDecoyProteinMatch(state);
+
+
+    return (false_prot/total_prot);
+}
+
diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h
index e8393d41d..53c1f6949 100644
--- a/src/core/identificationgroup.h
+++ b/src/core/identificationgroup.h
@@ -76,6 +76,14 @@ public:
     /** @brief count peptide (peptide+mass+sample) included by decoy proteins
      * */
     unsigned int countDecoyPeptideMassSample(ValidationState state) const;
+    
+    /** @brief get False Discovery Rate of proteins 
+     */
+    pappso::pappso_double getProteinFdr(ValidationState state = ValidationState::valid) const;
+    
+    /** @brief get False Discovery Rate of peptide/mass (unique sequence+modifications) 
+     */
+    pappso::pappso_double getPeptideMassFdr(ValidationState state = ValidationState::valid) const;
 
 
     /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks
diff --git a/src/output/ods/odsexport.cpp b/src/output/ods/odsexport.cpp
index ddfc5c365..0aef7f9fb 100644
--- a/src/output/ods/odsexport.cpp
+++ b/src/output/ods/odsexport.cpp
@@ -37,6 +37,7 @@
 #include "comparspecificspectrasheet.h"
 #include "infosheet.h"
 #include "samplesheet.h"
+#include "groupingsheet.h"
 #include <QSettings>
 
 OdsExport::OdsExport(const Project * project):_p_project(project) {
@@ -62,6 +63,9 @@ void OdsExport::write(CalcWriterInterface * p_writer) {
     _even_style = p_writer->getTableCellStyleRef(style);
 
     InfoSheet(this, p_writer, _p_project);
+    if (settings.value("export_ods/groups", "true").toBool()) {
+        GroupingSheet(this, p_writer, _p_project);
+    }
     if (settings.value("export_ods/simple", "false").toBool()) {
         SimpleSheet(p_writer, _p_project);
     }
-- 
GitLab