From 7ff56874254bcba663bc231fbca9513eb433ef9d Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Sat, 7 Nov 2020 19:33:19 +0100
Subject: [PATCH] new function to collect mass delta for any kind of sequence
 hit (target or decoy)

---
 src/core/identificationgroup.cpp | 30 ++++++++++++++++++++++++++++++
 src/core/identificationgroup.h   | 23 +++++++++++++++++++++--
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp
index 6f21a31e..2be63cef 100644
--- a/src/core/identificationgroup.cpp
+++ b/src/core/identificationgroup.cpp
@@ -385,6 +385,36 @@ IdentificationGroup::collectMhDelta(
         }
     }
 }
+
+
+void
+IdentificationGroup::collectTargetDecoyMhDelta(
+  std::vector<pappso::pappso_double> &delta_list,
+  pappso::PrecisionUnit unit,
+  ValidationState state) const
+{
+  std::set<const PeptideEvidence *> peptide_evidence_list;
+  for(auto &p_protein_match : _protein_match_list)
+    {
+      if(p_protein_match->getValidationState() == state)
+        {
+          p_protein_match->collectPeptideEvidences(peptide_evidence_list,
+                                                   state);
+        }
+    }
+  for(const PeptideEvidence *p_peptide_evidence : peptide_evidence_list)
+    {
+      if(unit == pappso::PrecisionUnit::ppm)
+        {
+          delta_list.push_back(p_peptide_evidence->getPpmDeltaMass());
+        }
+      else
+        {
+          delta_list.push_back(p_peptide_evidence->getDeltaMass());
+        }
+    }
+}
+
 void
 IdentificationGroup::startGrouping(
   ContaminantRemovalMode contaminantRemovalMode,
diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h
index 35bd50db..8a285a5b 100644
--- a/src/core/identificationgroup.h
+++ b/src/core/identificationgroup.h
@@ -157,14 +157,33 @@ class IdentificationGroup
   bool containSample(const QString &sample) const;
 
 
-  /** @brief collect mass delta between theoretical mass and observed mass
-   * each peptide evidence is only counted once
+  /** @brief collect mass delta between theoretical mass and observed mass for
+   * target sequences
+   *
+   * each peptide evidence is only counted once it counts only
+   * peptide evidence for target Sequences
+   * @param delta_list list of mass delta
+   * @param unit precision unit, ppm or dalton
+   * @param state validation state of the peptides to collect
    */
   void collectMhDelta(std::vector<pappso::pappso_double> &delta_list,
                       pappso::PrecisionUnit unit,
                       ValidationState state) const;
 
 
+  /** @brief collect mass delta between theoretical mass and observed mass
+   *
+   * each peptide evidence is only counted once it counts target or decoy
+   * peptide evidence
+   * @param delta_list list of mass delta
+   * @param unit precision unit, ppm or dalton
+   * @param state validation state of the peptides to collect
+   */
+  void collectTargetDecoyMhDelta(std::vector<pappso::pappso_double> &delta_list,
+                                 pappso::PrecisionUnit unit,
+                                 ValidationState state) const;
+
+
   /** @brief look for a peptide in the same XIC
    * @param peptide_evidence_list the peptide evidence list to build
    * @param p_msrun MSrun to look for
-- 
GitLab