From 86b2c9df5d737166481213b39fab2c6e9d238741 Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Tue, 19 Jun 2018 15:26:55 +0200
Subject: [PATCH] new: store identification engine in peptide evidence

---
 src/core/peptideevidence.cpp    |  6 ++++++
 src/core/peptideevidence.h      |  6 ++++++
 src/input/pepxmlsaxhandler.cpp  | 21 ++++++++++++++++++---
 src/input/xtpxpipsaxhandler.cpp |  1 +
 src/output/xpip.cpp             |  1 +
 src/utils/types.h               |  4 ++++
 6 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/src/core/peptideevidence.cpp b/src/core/peptideevidence.cpp
index 5cfd69cf4..be909da73 100644
--- a/src/core/peptideevidence.cpp
+++ b/src/core/peptideevidence.cpp
@@ -102,6 +102,12 @@ PeptideEvidence::setIdentificationEngine(
   _identification_engine = identification_engine;
 }
 
+IdentificationEngine
+PeptideEvidence::getIdentificationEngine() const
+{
+  return _identification_engine;
+}
+
 /** \brief set specific parameter value
  */
 void
diff --git a/src/core/peptideevidence.h b/src/core/peptideevidence.h
index 628aaf09e..acda0872c 100644
--- a/src/core/peptideevidence.h
+++ b/src/core/peptideevidence.h
@@ -99,6 +99,12 @@ public :
      * by default, this is the identification engine of the datasource
      */
     void setIdentificationEngine(IdentificationEngine identification_engine);
+    
+    /** @brief get the identification engine
+     * by default, this is the identification engine of the datasource
+     */
+    IdentificationEngine getIdentificationEngine() const;
+    
     void setChecked(bool arg1);
     bool isChecked() const;
     bool isValid() const;
diff --git a/src/input/pepxmlsaxhandler.cpp b/src/input/pepxmlsaxhandler.cpp
index a031df10c..05090d158 100644
--- a/src/input/pepxmlsaxhandler.cpp
+++ b/src/input/pepxmlsaxhandler.cpp
@@ -297,7 +297,7 @@ PepXmlSaxHandler::startElement_spectrum_query(QXmlAttributes attributes)
 
 //<alternative_protein protein="sp|P46784|RS10B_YEAST" protein_descr="40S
 //       ribosomal protein S10-B OS=Saccharomyces cerevisiae (strain ATCC 204508
-//                 \
+//                   \
 //S288c) GN=RPS10B PE=1 SV=1" num_tol_term="2" peptide_prev_aa="K"
 // peptide_next_aa="N"/>
 bool
@@ -482,18 +482,33 @@ PepXmlSaxHandler::startElement_search_score(QXmlAttributes attributes)
       if(name == "expect")
         {
           _p_peptide_evidence->setEvalue(valueStr.simplified().toDouble());
+          if(_p_peptide_evidence->getIdentificationEngine() ==
+             IdentificationEngine::OMSSA)
+            {
+              _p_peptide_evidence->setParam(PeptideEvidenceParam::omssa_evalue,
+                                            valueStr.simplified().toDouble());
+            }
         }
-      if(name == "EValue")
+      else if(name == "EValue")
         {
           _p_peptide_evidence->setEvalue(valueStr.simplified().toDouble());
         }
       // <search_score name="hyperscore" value="232"/>
-      if(name == "hyperscore")
+      else if(name == "hyperscore")
         {
           _p_peptide_evidence->setParam(
             PeptideEvidenceParam::tandem_hyperscore,
             QVariant(attributes.value("hyperscore").toDouble()));
         }
+      else if(name == "pvalue")
+        {
+          if(_p_peptide_evidence->getIdentificationEngine() ==
+             IdentificationEngine::OMSSA)
+            {
+              _p_peptide_evidence->setParam(PeptideEvidenceParam::omssa_pvalue,
+                                            valueStr.simplified().toDouble());
+            }
+        }
     }
   return is_ok;
 }
diff --git a/src/input/xtpxpipsaxhandler.cpp b/src/input/xtpxpipsaxhandler.cpp
index 3d9fa5c31..596759c86 100644
--- a/src/input/xtpxpipsaxhandler.cpp
+++ b/src/input/xtpxpipsaxhandler.cpp
@@ -423,6 +423,7 @@ bool XtpXpipSaxHandler::startElement_peptide_evidence(QXmlAttributes attributes)
         _p_peptide_evidence->setChecked(true);
     }
     _p_peptide_evidence->setCharge(attributes.value("charge").toUInt());
+    _p_peptide_evidence->setIdentificationEngine(static_cast<IdentificationEngine>(attributes.value("eng").toUInt()));
     _p_peptide_evidence->setRetentionTime(attributes.value("rt").toDouble());
     _p_peptide_evidence->setEvalue(attributes.value("evalue").toDouble());
     _p_peptide_evidence->setExperimentalMass(attributes.value("exp_mass").toDouble());
diff --git a/src/output/xpip.cpp b/src/output/xpip.cpp
index ce0ecf20b..5a7761cd3 100644
--- a/src/output/xpip.cpp
+++ b/src/output/xpip.cpp
@@ -438,6 +438,7 @@ void Xpip::writePeptideEvidence(const PeptideEvidence * p_peptide_evidence) {
     qDebug() << "Xpip::writePeptideEvidence scan";
     _output_stream->writeAttribute("scan",QString("%1").arg(p_peptide_evidence->getScan()));
     writeDoubleAttribute("rt",p_peptide_evidence->getRetentionTime());
+    _output_stream->writeAttribute("eng",QString("%1").arg((unsigned int) p_peptide_evidence->getIdentificationEngine()));
     writeDoubleAttribute("evalue",p_peptide_evidence->getEvalue());
     writeDoubleAttribute("exp_mass",p_peptide_evidence->getExperimentalMass());
     _output_stream->writeAttribute("charge",QString("%1").arg(p_peptide_evidence->getCharge()));
diff --git a/src/utils/types.h b/src/utils/types.h
index 1a193327c..9c7ed47c5 100644
--- a/src/utils/types.h
+++ b/src/utils/types.h
@@ -73,6 +73,10 @@ enum class PeptideEvidenceParam : std::int8_t
     3, ///< PSI-MS MS:1001172 mascot:expectation value 2.42102904673618e-006
   peptide_prophet_probability       = 4, ///< no PSI MS description
   peptide_inter_prophet_probability = 5, ///< no PSI MS description
+  omssa_evalue = 6, ///< MS:1001328  "OMSSA E-value." [PSI:PI]
+  omssa_pvalue = 7, ///< MS:1001329  "OMSSA p-value." [PSI:PI]
+  
+
 };
 
 /** \def IdentificationEngineParam identification engine parameters
-- 
GitLab