From 97b07e8b9f55d236747a1fc9c776ac8368ae9191 Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Wed, 22 Nov 2017 14:30:01 +0100
Subject: [PATCH] peptide evidence store seems to work

---
 src/core/peptideevidence.h         |  4 ----
 src/core/proteinmatch.cpp          |  1 +
 src/utils/peptideevidencestore.cpp | 23 +++++++++++++++++++++++
 src/utils/peptideevidencestore.h   |  3 +++
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/core/peptideevidence.h b/src/core/peptideevidence.h
index 79f140d70..b294cd57f 100644
--- a/src/core/peptideevidence.h
+++ b/src/core/peptideevidence.h
@@ -85,10 +85,6 @@ public :
     const std::map<PeptideMatchParam, QVariant> & getParamList() const;
 
 
-    /** @brief get stop position of this peptide inside the protein sequence
-         * @return stop position in the protein amino acid sequence (starts at 0)
-         * */
-    unsigned int getStop() const;
     void setCharge(unsigned int charge);
     void setPeptideXtpSp (PeptideXtpSp peptide);
     void setIdentificationDataSource(IdentificationDataSource* identification_source);
diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp
index 016645376..e79fdfc1b 100644
--- a/src/core/proteinmatch.cpp
+++ b/src/core/proteinmatch.cpp
@@ -128,6 +128,7 @@ void ProteinMatch::setChecked(bool arg1) {
 }
 
 void ProteinMatch::addPeptideMatch(const PeptideMatch & peptide_match) {
+    qDebug() << "ProteinMatch::addPeptideMatch begin " << peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->toAbsoluteString(); 
     _peptide_match_list.push_back(peptide_match);
 }
 
diff --git a/src/utils/peptideevidencestore.cpp b/src/utils/peptideevidencestore.cpp
index ad3110da7..34384227a 100644
--- a/src/utils/peptideevidencestore.cpp
+++ b/src/utils/peptideevidencestore.cpp
@@ -30,10 +30,33 @@
 ******************************************************************************/
 
 #include "peptideevidencestore.h"
+#include <QDebug>
 
 #include "../core/peptideevidence.h"
 
 std::shared_ptr<PeptideEvidence> & PeptideEvidenceStore::getInstance(const PeptideEvidence * p_peptide_evidence) {
+
+    qDebug() << "PeptideEvidenceStore::getInstance begin" ;
+    std::multimap<unsigned int ,PeptideEvidenceSp>::iterator it = _multimap_scan_evidence.find(p_peptide_evidence->getScan());
+    std::multimap<unsigned int ,PeptideEvidenceSp>::iterator find_it = _multimap_scan_evidence.end();
+
+
+    while ((find_it == _multimap_scan_evidence.end()) && (it->first == p_peptide_evidence->getScan())) {
+        if (it->second.get()->getPeptideXtpSp().get() == p_peptide_evidence->getPeptideXtpSp().get()) {
+            //it is the same peptide
+            find_it = it;
+        }
+        it++;
+    }
+
+    if (find_it == _multimap_scan_evidence.end()) {
+        // insert it
+        find_it = _multimap_scan_evidence.insert(std::pair<unsigned int , PeptideEvidenceSp>(p_peptide_evidence->getScan(), p_peptide_evidence->makePeptideEvidenceSp()));
+        _peptide_evidence_list.push_back(find_it->second);
+    }
+    qDebug() << "PeptideEvidenceStore::getInstance end " << find_it->second.get()->getScan() << " size=" << _multimap_scan_evidence.size();
+    return find_it->second;
+
 }
 
 void PeptideEvidenceStore::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) {
diff --git a/src/utils/peptideevidencestore.h b/src/utils/peptideevidencestore.h
index 374840853..49338ec65 100644
--- a/src/utils/peptideevidencestore.h
+++ b/src/utils/peptideevidencestore.h
@@ -33,6 +33,7 @@
 
 #include <memory>
 #include <vector>
+#include <map>
 #include "../core/automaticfilterparameters.h"
 
 class PeptideEvidence;
@@ -44,6 +45,8 @@ public:
     void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters);
 private:
     std::vector<std::shared_ptr<PeptideEvidence>> _peptide_evidence_list;
+    
+    std::multimap<unsigned int ,std::shared_ptr<PeptideEvidence>> _multimap_scan_evidence;
 };
 
 #endif // PEPTIDEEVIDENCESTORE_H
-- 
GitLab