From 221efd6ca74e67bf003f44ec4237289b50f9bbac Mon Sep 17 00:00:00 2001
From: Olivier Langella <Olivier.Langella@moulon.inra.fr>
Date: Tue, 2 May 2017 22:23:15 +0200
Subject: [PATCH] compar sequence, specific sequence, PAI and emPAI added

---
 src/core/proteinmatch.cpp                     | 12 +------
 src/core/proteinmatch.h                       |  7 +----
 src/grouping/groupinggroup.cpp                |  2 +-
 .../protein_list_view/proteintablemodel.cpp   |  2 +-
 src/output/ods/comparspecificspectrasheet.cpp | 10 ++++++
 src/output/ods/comparspecificspectrasheet.h   |  9 ++++++
 src/output/ods/comparspectrasheet.cpp         | 31 +++++++++++++++++++
 src/output/ods/comparspectrasheet.h           | 28 +++++++++++++++++
 src/output/ods/odsexport.cpp                  | 12 +++++++
 src/output/ods/proteinsheet.cpp               |  2 +-
 10 files changed, 95 insertions(+), 20 deletions(-)

diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp
index b23140594..233d8b063 100644
--- a/src/core/proteinmatch.cpp
+++ b/src/core/proteinmatch.cpp
@@ -216,17 +216,7 @@ unsigned int ProteinMatch::countPeptideMatch(ValidationState state) const {
     });
 }
 
-size_t ProteinMatch::countUniqueSequenceLi(ValidationState state)const {
-    std::set<QString> sequence_list;
-    for (auto & p_peptide_match : _peptide_match_list) {
-        if (p_peptide_match->getValidationState() >= state) {
-            sequence_list.insert(p_peptide_match->getPeptideXtpSp().get()->getSequenceLi());
-        }
-    }
-    return sequence_list.size();
-}
-
-unsigned int ProteinMatch::countSequenceLi(ValidationState state, const MsRun * p_msrun_id) const {
+size_t ProteinMatch::countSequenceLi(ValidationState state, const MsRun * p_msrun_id) const {
     std::set<QString> sequence_list;
     for (auto & p_peptide_match : _peptide_match_list) {
         if (p_peptide_match->getValidationState() >= state) {
diff --git a/src/core/proteinmatch.h b/src/core/proteinmatch.h
index 990a392c0..67bce97de 100644
--- a/src/core/proteinmatch.h
+++ b/src/core/proteinmatch.h
@@ -91,11 +91,6 @@ public:
      */
     void countPeptideMassSample(std::vector<size_t> & count_peptide_mass_sample, ValidationState state) const;
 
-    /** @brief count unique identified sequences (from valid and cheked spectrums)
-     * */
-    size_t countUniqueSequenceLi(ValidationState state)const;
-
-
     const pappso::GrpProteinSp & getGrpProteinSp() const;
     const GroupingGroupSp & getGroupingGroupSp() const;
 
@@ -113,7 +108,7 @@ public:
      * @param state validation state of peptides to count
      * @param p_msrun_id count within the specified sample
      */
-    unsigned int countSequenceLi(ValidationState state,const MsRun * p_msrun_id) const;
+    size_t countSequenceLi(ValidationState state,const MsRun * p_msrun_id=nullptr) const;
     
     /** @brief count distinct peptide+mass+charge
      * peptide is the peptide sequence LI (Leucine => Isoleucine)
diff --git a/src/grouping/groupinggroup.cpp b/src/grouping/groupinggroup.cpp
index fbc2120d1..806902120 100644
--- a/src/grouping/groupinggroup.cpp
+++ b/src/grouping/groupinggroup.cpp
@@ -128,7 +128,7 @@ std::size_t GroupingGroup::countSpecificSampleScan(const ProteinMatch * p_protei
 
 std::size_t GroupingGroup::countSpecificSequenceLi(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun_id) const {
     if (_number_of_subgroup == 1) {
-        return p_protein_match->countUniqueSequenceLi(state);
+        return p_protein_match->countSequenceLi(state);
     }
     std::set<QString> sequence_list_in;
     for (auto && p_peptide_match :p_protein_match->getPeptideMatchList()) {
diff --git a/src/gui/protein_list_view/proteintablemodel.cpp b/src/gui/protein_list_view/proteintablemodel.cpp
index ed465c589..28f180223 100644
--- a/src/gui/protein_list_view/proteintablemodel.cpp
+++ b/src/gui/protein_list_view/proteintablemodel.cpp
@@ -181,7 +181,7 @@ QVariant ProteinTableModel::data(const QModelIndex &index, int role ) const {
         }
 
         if (_column_assignment[col] == (std::int8_t) ProteinListColumn::sequence ) {
-            return QVariant ((qreal) _p_identification_group->getProteinMatchList().at(row)->countUniqueSequenceLi(ValidationState::validAndChecked));
+            return QVariant ((qreal) _p_identification_group->getProteinMatchList().at(row)->countSequenceLi(ValidationState::validAndChecked));
         }
         if (_column_assignment[col] == (std::int8_t) ProteinListColumn::specific_sequence ) {
             GroupingGroup * p_groupin_group = _p_identification_group->getProteinMatchList().at(row)->getGroupingGroupSp().get();
diff --git a/src/output/ods/comparspecificspectrasheet.cpp b/src/output/ods/comparspecificspectrasheet.cpp
index 23e853414..0e041c3ba 100644
--- a/src/output/ods/comparspecificspectrasheet.cpp
+++ b/src/output/ods/comparspecificspectrasheet.cpp
@@ -41,3 +41,13 @@ void ComparSpecificSpectraSheet::writeComparValue(const ProteinMatch * p_protein
     qDebug() << "ComparSpecificSpectraSheet::writeComparValue end";
 }
 
+
+ComparSpecificSequenceSheet::ComparSpecificSequenceSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) {
+    _title_sheet =  "compar specific unique sequence";
+}
+
+void ComparSpecificSequenceSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) {
+    qDebug() << "ComparSpecificSequenceSheet::writeComparValue begin";
+    _p_writer->writeCell((unsigned int) p_protein_match->getGroupingGroupSp().get()->countSpecificSequenceLi(p_protein_match, state, p_msrun));
+    qDebug() << "ComparSpecificSequenceSheet::writeComparValue end";
+}
diff --git a/src/output/ods/comparspecificspectrasheet.h b/src/output/ods/comparspecificspectrasheet.h
index 267389372..eeab2ee9e 100644
--- a/src/output/ods/comparspecificspectrasheet.h
+++ b/src/output/ods/comparspecificspectrasheet.h
@@ -39,4 +39,13 @@ protected :
     virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override;
 };
 
+class ComparSpecificSequenceSheet:public ComparBaseSheet
+{
+public :
+    ComparSpecificSequenceSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project);
+
+protected :
+    virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override;
+};
+
 #endif // COMPARSPECIFICSPECTRASHEET_H
diff --git a/src/output/ods/comparspectrasheet.cpp b/src/output/ods/comparspectrasheet.cpp
index bc15bc522..cfc10cbc9 100644
--- a/src/output/ods/comparspectrasheet.cpp
+++ b/src/output/ods/comparspectrasheet.cpp
@@ -43,3 +43,34 @@ void ComparSpectraSheet::writeComparValue(const ProteinMatch * p_protein_match,
     _p_writer->writeCell(p_protein_match->countSampleScan(state, p_msrun));
     qDebug() << "ComparSpectraSheet::writeComparValue end";
 }
+
+
+ComparSequenceSheet::ComparSequenceSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) {
+    _title_sheet =  "compar unique sequence";
+}
+
+void ComparSequenceSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) {
+    qDebug() << "ComparSequenceSheet::writeComparValue begin";
+    _p_writer->writeCell((unsigned int) p_protein_match->countSequenceLi(state, p_msrun));
+    qDebug() << "ComparSequenceSheet::writeComparValue end";
+}
+
+ComparPaiSheet::ComparPaiSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) {
+    _title_sheet =  "compar PAI";
+}
+
+void ComparPaiSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) {
+    qDebug() << "ComparPaiSheet::writeComparValue begin";
+    _p_writer->writeCell(p_protein_match->getPAI(p_msrun));
+    qDebug() << "ComparPaiSheet::writeComparValue end";
+}
+
+ComparEmpaiSheet::ComparEmpaiSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project): ComparBaseSheet(p_ods_export, p_writer, p_project) {
+    _title_sheet =  "compar emPAI";
+}
+
+void ComparEmpaiSheet::writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) {
+    qDebug() << "ComparEmpaiSheet::writeComparValue begin";
+    _p_writer->writeCell(p_protein_match->getEmPAI(p_msrun));
+    qDebug() << "ComparEmpaiSheet::writeComparValue end";
+}
diff --git a/src/output/ods/comparspectrasheet.h b/src/output/ods/comparspectrasheet.h
index 505b813d1..c3926823f 100644
--- a/src/output/ods/comparspectrasheet.h
+++ b/src/output/ods/comparspectrasheet.h
@@ -41,4 +41,32 @@ protected :
     virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override;
 };
 
+
+class ComparSequenceSheet:public ComparBaseSheet
+{
+public :
+    ComparSequenceSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project);
+
+protected :
+    virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override;
+};
+
+class ComparPaiSheet:public ComparBaseSheet
+{
+public :
+    ComparPaiSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project);
+
+protected :
+    virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override;
+};
+
+class ComparEmpaiSheet:public ComparBaseSheet
+{
+public :
+    ComparEmpaiSheet (OdsExport * p_ods_export, CalcWriterInterface * p_writer, const Project * p_project);
+
+protected :
+    virtual void writeComparValue(const ProteinMatch * p_protein_match, ValidationState state, const MsRun * p_msrun) override;
+};
+
 #endif // COMPARSPECTRASHEET_H
diff --git a/src/output/ods/odsexport.cpp b/src/output/ods/odsexport.cpp
index ab72b09e6..c366808ad 100644
--- a/src/output/ods/odsexport.cpp
+++ b/src/output/ods/odsexport.cpp
@@ -82,4 +82,16 @@ void OdsExport::write(CalcWriterInterface * p_writer) {
     if (settings.value("export_ods/comparspecificspectra", "true").toBool()) {
         ComparSpecificSpectraSheet(this, p_writer, _p_project).writeSheet();
     }
+    if (settings.value("export_ods/comparuniquesequence", "true").toBool()) {
+        ComparSequenceSheet(this, p_writer, _p_project).writeSheet();
+    }
+    if (settings.value("export_ods/comparspecificuniquesequence", "true").toBool()) {
+        ComparSpecificSequenceSheet(this, p_writer, _p_project).writeSheet();
+    }
+    if (settings.value("export_ods/comparpai", "true").toBool()) {
+        ComparPaiSheet(this, p_writer, _p_project).writeSheet();
+    }
+    if (settings.value("export_ods/comparempai", "true").toBool()) {
+        ComparEmpaiSheet(this, p_writer, _p_project).writeSheet();
+    }
 }
diff --git a/src/output/ods/proteinsheet.cpp b/src/output/ods/proteinsheet.cpp
index 150bc996f..0fd9972bb 100644
--- a/src/output/ods/proteinsheet.cpp
+++ b/src/output/ods/proteinsheet.cpp
@@ -136,7 +136,7 @@ void ProteinSheet::writeOneProtein(const GroupingGroup * p_group, const ProteinM
     _p_writer->writeCell((unsigned int) p_group->countSpecificSampleScan(p_protein_match, validation_state));
 
     // _p_writer->writeCell("Uniques");
-    _p_writer->writeCell((unsigned int) p_protein_match->countUniqueSequenceLi(validation_state));
+    _p_writer->writeCell((unsigned int) p_protein_match->countSequenceLi(validation_state));
 
     // _p_writer->writeCell("Specific uniques");
     _p_writer->writeCell((unsigned int) p_group->countSpecificSequenceLi(p_protein_match, validation_state));
-- 
GitLab