From 11b044ef970faed3d4279f332b7ea8752498895b Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Sat, 27 Jan 2018 14:19:46 +0100
Subject: [PATCH] look for peptide evidence in Msrun

---
 src/core/identificationgroup.cpp    | 8 ++++----
 src/core/identificationgroup.h      | 6 ++++--
 src/core/project.cpp                | 4 ++--
 src/core/project.h                  | 6 ++++--
 src/gui/xic_view/xic_box/xicbox.cpp | 6 ++++--
 src/utils/peptideevidencestore.cpp  | 8 ++++----
 src/utils/peptideevidencestore.h    | 8 ++++++--
 7 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp
index 267c9e895..9825c9f18 100644
--- a/src/core/identificationgroup.cpp
+++ b/src/core/identificationgroup.cpp
@@ -321,11 +321,11 @@ pappso::pappso_double IdentificationGroup::getProteinFdr(ValidationState state)
 }
 
 
-void IdentificationGroup::getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const {
-    if (!contains(p_peptide_evidence->getMsRunP())) return;
+void IdentificationGroup::getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const {
+    if (!contains(p_msrun)) return;
     for (const IdentificationDataSource * p_identification_source:_id_source_list) {
-        if (p_peptide_evidence->getMsRunP() == p_identification_source->getMsRunSp().get()) {
-            p_identification_source->getPeptideEvidenceStore().getSameXicPeptideEvidenceList(p_peptide_evidence, peptide_evidence_list);
+        if (p_msrun == p_identification_source->getMsRunSp().get()) {
+            p_identification_source->getPeptideEvidenceStore().getSameXicPeptideEvidenceList(peptide_evidence_list, p_msrun, p_peptide, charge);
         }
     }
 }
diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h
index ea4ade657..110d7d9af 100644
--- a/src/core/identificationgroup.h
+++ b/src/core/identificationgroup.h
@@ -135,10 +135,12 @@ public:
     
     
     /** @brief look for a peptide in the same XIC
-     * @param p_peptide_evidence the peptide to look for
      * @param peptide_evidence_list the peptide evidence list to build
+     * @param p_msrun MSrun to look for 
+     * @param p_peptide peptide to look for 
+     * @param charge charge to look for 
      */
-    void getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const;
+    void getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const;
 
 private :
 
diff --git a/src/core/project.cpp b/src/core/project.cpp
index 1bd84997c..9beaae9a6 100644
--- a/src/core/project.cpp
+++ b/src/core/project.cpp
@@ -201,8 +201,8 @@ bool Project::hasPtmExperiment() const {
     return false;
 }
 
-void Project::getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const {
+void Project::getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const {
     for (const IdentificationGroup * p_ident_group: _identification_goup_list) {
-        p_ident_group->getSameXicPeptideEvidenceList(p_peptide_evidence, peptide_evidence_list);
+        p_ident_group->getSameXicPeptideEvidenceList(peptide_evidence_list, p_msrun,  p_peptide, charge);
     }
 }
diff --git a/src/core/project.h b/src/core/project.h
index b21d48385..3710b3d3e 100644
--- a/src/core/project.h
+++ b/src/core/project.h
@@ -88,10 +88,12 @@ public:
     bool hasPtmExperiment() const;
 
     /** @brief look for a peptide in the same XIC
-     * @param p_peptide_evidence the peptide to look for
      * @param peptide_evidence_list the peptide evidence list to build
+     * @param p_msrun MSrun to look for 
+     * @param p_peptide peptide to look for 
+     * @param charge charge to look for 
      */
-    void getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const;
+    void getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const;
 
 private :
     LabelingMethodSp _labeling_method_sp;
diff --git a/src/gui/xic_view/xic_box/xicbox.cpp b/src/gui/xic_view/xic_box/xicbox.cpp
index 6abf1eaae..8f7dd617c 100644
--- a/src/gui/xic_view/xic_box/xicbox.cpp
+++ b/src/gui/xic_view/xic_box/xicbox.cpp
@@ -167,14 +167,14 @@ void XicBox::setPeptideEvidence(const PeptideEvidence * p_peptide_evidence) {
     //get same xic peptide evidence (msrun, peptide, charge)
     //p_projet
     _peptide_evidence_list.clear();
-    _p_xic_window->getProjectWindow()->getProjectP()->getSameXicPeptideEvidenceList(p_peptide_evidence, _peptide_evidence_list);
+    _p_xic_window->getProjectWindow()->getProjectP()->getSameXicPeptideEvidenceList(_peptide_evidence_list, _msrun_sp.get(),_p_peptide_evidence->getPeptideXtpSp().get(),_p_peptide_evidence->getCharge());
 
     emit computeIsotopeMassList(_p_peptide_evidence->getPeptideXtpSp(), _p_peptide_evidence->getCharge(), _p_xic_window->getXicExtractPrecision(), 0.8);
 
 }
 
 void XicBox::setPeptideEvidenceInMsRun(const PeptideEvidence * p_peptide_evidence, MsRunSp msrun_sp) {
-        _p_peptide_evidence = p_peptide_evidence;
+    _p_peptide_evidence = p_peptide_evidence;
     _msrun_sp = msrun_sp;
 
     ui->peptide_label->setText(_p_peptide_evidence->getPeptideXtpSp().get()->toString());
@@ -185,6 +185,8 @@ void XicBox::setPeptideEvidenceInMsRun(const PeptideEvidence * p_peptide_evidenc
     //get same xic peptide evidence (msrun, peptide, charge)
     //p_projet
     _peptide_evidence_list.clear();
+
+    _p_xic_window->getProjectWindow()->getProjectP()->getSameXicPeptideEvidenceList(_peptide_evidence_list, _msrun_sp.get(),_p_peptide_evidence->getPeptideXtpSp().get(),_p_peptide_evidence->getCharge());
     //_p_xic_window->getProjectWindow()->getProjectP()->getSameXicPeptideEvidenceList(p_peptide_evidence, _peptide_evidence_list);
 
     emit computeIsotopeMassList(_p_peptide_evidence->getPeptideXtpSp(), _p_peptide_evidence->getCharge(), _p_xic_window->getXicExtractPrecision(), 0.8);
diff --git a/src/utils/peptideevidencestore.cpp b/src/utils/peptideevidencestore.cpp
index 28b2928f6..c6ab7295f 100644
--- a/src/utils/peptideevidencestore.cpp
+++ b/src/utils/peptideevidencestore.cpp
@@ -95,11 +95,11 @@ const std::vector<std::shared_ptr<PeptideEvidence>> & PeptideEvidenceStore::getP
 }
 
 
-void PeptideEvidenceStore::getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const {
+void PeptideEvidenceStore::getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const {
     for (const PeptideEvidenceSp & peptide_evidence_sp:_peptide_evidence_list) {
-        if (p_peptide_evidence->getMsRunP() != peptide_evidence_sp.get()->getMsRunP()) continue;
-        if (p_peptide_evidence->getPeptideXtpSp().get() != peptide_evidence_sp.get()->getPeptideXtpSp().get()) continue;
-        if (p_peptide_evidence->getCharge() != peptide_evidence_sp.get()->getCharge()) continue;
+        if (p_msrun != peptide_evidence_sp.get()->getMsRunP()) continue;
+        else if (p_peptide != peptide_evidence_sp.get()->getPeptideXtpSp().get()) continue;
+        else if (charge != peptide_evidence_sp.get()->getCharge()) continue;
         peptide_evidence_list.push_back(peptide_evidence_sp.get());
     }
 }
diff --git a/src/utils/peptideevidencestore.h b/src/utils/peptideevidencestore.h
index c1d4ff894..1ae1889c3 100644
--- a/src/utils/peptideevidencestore.h
+++ b/src/utils/peptideevidencestore.h
@@ -35,6 +35,8 @@
 #include <vector>
 #include <map>
 #include "../core/automaticfilterparameters.h"
+#include "../core/peptidextp.h"
+#include "../core/msrun.h"
 
 class PeptideEvidence;
 
@@ -56,10 +58,12 @@ public:
        
     
     /** @brief look for a peptide in the same XIC
-     * @param p_peptide_evidence the peptide to look for
      * @param peptide_evidence_list the peptide evidence list to build
+     * @param p_msrun MSrun to look for 
+     * @param p_peptide peptide to look for 
+     * @param charge charge to look for 
      */
-    void getSameXicPeptideEvidenceList(const PeptideEvidence * p_peptide_evidence, std::vector<const PeptideEvidence *> & peptide_evidence_list) const;
+    void getSameXicPeptideEvidenceList(std::vector<const PeptideEvidence *> & peptide_evidence_list, const MsRun * p_msrun, const PeptideXtp * p_peptide, unsigned int charge) const;
 
 private:
     std::vector<std::shared_ptr<PeptideEvidence>> _peptide_evidence_list;
-- 
GitLab