From 6b256679fc67c59b0c41918f87be60598b4a92fe Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Thu, 21 Jun 2018 18:14:00 +0200
Subject: [PATCH] Peptide prophet column display

---
 src/core/peptideevidence.h                    | 305 +++++++++---------
 .../peptide_list_view/peptidetablemodel.cpp   |  53 ++-
 src/gui/peptide_list_view/peptidetablemodel.h |  57 ++--
 3 files changed, 236 insertions(+), 179 deletions(-)

diff --git a/src/core/peptideevidence.h b/src/core/peptideevidence.h
index acda0872c..490aec2b7 100644
--- a/src/core/peptideevidence.h
+++ b/src/core/peptideevidence.h
@@ -2,31 +2,33 @@
  * \file utils/peptideevidence.h
  * \date 18/11/2017
  * \author Olivier Langella
- * \brief peptide evidence : a peptide sequence + spectrum + identification engine evaluation (psm)
+ * \brief peptide evidence : a peptide sequence + spectrum + identification
+ * engine evaluation (psm)
  */
 
 
 /*******************************************************************************
-* Copyright (c) 2017 Olivier Langella <Olivier.Langella@u-psud.fr>.
-*
-* This file is part of XTPcpp.
-*
-*     XTPcpp is free software: you can redistribute it and/or modify
-*     it under the terms of the GNU General Public License as published by
-*     the Free Software Foundation, either version 3 of the License, or
-*     (at your option) any later version.
-*
-*     XTPcpp is distributed in the hope that it will be useful,
-*     but WITHOUT ANY WARRANTY; without even the implied warranty of
-*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*     GNU General Public License for more details.
-*
-*     You should have received a copy of the GNU General Public License
-*     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
-*
-* Contributors:
-*     Olivier Langella <Olivier.Langella@u-psud.fr> - initial API and implementation
-******************************************************************************/
+ * Copyright (c) 2017 Olivier Langella <Olivier.Langella@u-psud.fr>.
+ *
+ * This file is part of XTPcpp.
+ *
+ *     XTPcpp is free software: you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation, either version 3 of the License, or
+ *     (at your option) any later version.
+ *
+ *     XTPcpp is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Contributors:
+ *     Olivier Langella <Olivier.Langella@u-psud.fr> - initial API and
+ *implementation
+ ******************************************************************************/
 #ifndef PEPTIDEEVIDENCE_H
 #define PEPTIDEEVIDENCE_H
 
@@ -46,132 +48,139 @@ typedef std::shared_ptr<PeptideEvidence> PeptideEvidenceSp;
 
 class PeptideEvidence
 {
-public :
-    PeptideEvidence(MsRun * msrunid_sp, unsigned int scan);
-    PeptideEvidence(const PeptideEvidence & other);
-    std::size_t getHashSampleScan() const;
-    std::size_t getHashPeptideMassSample() const;
-
-    PeptideEvidenceSp makePeptideEvidenceSp() const;
-
-    void setRetentionTime(pappso::pappso_double rt);
-    void setEvalue(pappso::pappso_double evalue);
-
-    /** @brief get experimental mass of this peptide
-     * @return the computed mass given the precursor measured mass and the deduced peptide charge
-     */
-    pappso::pappso_double getExperimentalMass() const;
-    
-    /** @brief get experimental MH+ of this peptide
-     * @return getExperimentalMass + MHPLUS
-     */
-    pappso::pappso_double getExperimentalMhplus() const;
-
-    /** @brief get experimental mz of this peptide
-    * @return the real mass measured (precuror mass) by the spectrometer
-    */
-    pappso::pappso_double getExperimentalMz() const;
-
-
-    /** @brief set experimental mass of this peptide
-     * @arg exp_mass the computed mass given the precursor measured mass and the deduced peptide charge
-     */
-    void setExperimentalMass(pappso::pappso_double exp_mass);
-
-
-
-    /** \brief set specific parameter value
-     */
-    virtual void setParam(PeptideEvidenceParam param, const QVariant& value);
-    /** \brief get specific parameter value
-     */
-    virtual const QVariant getParam(PeptideEvidenceParam param) const;
-
-    const std::map<PeptideEvidenceParam, QVariant> & getParamList() const;
-
-
-    void setCharge(unsigned int charge);
-    void setPeptideXtpSp (PeptideXtpSp peptide);
-    void setIdentificationDataSource(IdentificationDataSource* identification_source);
-    
-        
-    /** @brief sets the identification engine
-     * 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;
-    bool isValidAndChecked() const;
-    bool isGrouped() const;
-
-    const MsRun * getMsRunP() const;
-    IdentificationDataSource* getIdentificationDataSource () const;
-    unsigned int getScan() const;
-    pappso::pappso_double getRetentionTime() const;
-    unsigned int getCharge() const;
-    const PeptideXtpSp & getPeptideXtpSp() const;
-    pappso::pappso_double getEvalue() const;
-
-    void setGrpPeptideSp(const pappso::GrpPeptideSp & sp_grp_peptide);
-    const pappso::GrpPeptideSp & getGrpPeptideSp() const;
-
-    /** @brief validate or invalidate peptides and proteins based automatic filters and manual checks
-    * */
-    void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters);
-
-    /** @brief get delta between theoretical mhplus mass and mhplus experimental mass
-     * mhplus experimental mass - theoretical mhplus mass
-      */
-    pappso::mz getDeltaMass() const;
-    
-    /** @brief get delta in ppm between theoretical mhplus mass and mhplus experimental mass
-     * @return mhplus experimental mass - theoretical mhplus mass
-      */
-    pappso::mz getPpmDeltaMass() const;
-    
-    /** @brief get theoretical (not observed) m/z based on peptide composition and charge
-     * @return theoretical mz mass
-      */
-    pappso::mz getTheoreticalMz() const;
-
-    ValidationState getValidationState() const;
-
-    /** @brief tells if this peptide contains a protein position
-     * the position is the amino acid position on the protein sequence (starts from 0)
-     * */
-    bool containsPosition(unsigned int position) const;
-
-private :
-    static std::hash<std::string> _hash_fn;
-    MsRun * _msrunid_sp;
-    unsigned int _scan=0;
-    size_t _hash_sample_scan;
-    pappso::GrpPeptideSp _sp_grp_peptide;
-    PeptideXtpSp _peptide_sp;
-    pappso::pappso_double _rt;
-    pappso::pappso_double _evalue=0;
-    pappso::pappso_double _exp_mass;
-    unsigned int _charge;
-    IdentificationDataSource* _p_identification_source = nullptr;
-    std::map<PeptideEvidenceParam, QVariant> _params;
-
-    /** @brief manually checked by user (true by default)
-     */
-    bool _checked = true;
-
-    /** @brief automatic filter result (false by default)
-     */
-    bool _proxy_valid = false;
-    
-    /** @brief the search/identification engine that found this evidence
-     */
-    IdentificationEngine _identification_engine;
+  public:
+  PeptideEvidence(MsRun *msrunid_sp, unsigned int scan);
+  PeptideEvidence(const PeptideEvidence &other);
+  std::size_t getHashSampleScan() const;
+  std::size_t getHashPeptideMassSample() const;
+
+  PeptideEvidenceSp makePeptideEvidenceSp() const;
+
+  void setRetentionTime(pappso::pappso_double rt);
+  void setEvalue(pappso::pappso_double evalue);
+
+  /** @brief get experimental mass of this peptide
+   * @return the computed mass given the precursor measured mass and the deduced
+   * peptide charge
+   */
+  pappso::pappso_double getExperimentalMass() const;
+
+  /** @brief get experimental MH+ of this peptide
+   * @return getExperimentalMass + MHPLUS
+   */
+  pappso::pappso_double getExperimentalMhplus() const;
+
+  /** @brief get experimental mz of this peptide
+   * @return the real mass measured (precuror mass) by the spectrometer
+   */
+  pappso::pappso_double getExperimentalMz() const;
+
+
+  /** @brief set experimental mass of this peptide
+   * @arg exp_mass the computed mass given the precursor measured mass and the
+   * deduced peptide charge
+   */
+  void setExperimentalMass(pappso::pappso_double exp_mass);
+
+
+  /** \brief set specific parameter value
+   */
+  virtual void setParam(PeptideEvidenceParam param, const QVariant &value);
+  /** \brief get specific parameter value
+   */
+  virtual const QVariant getParam(PeptideEvidenceParam param) const;
+
+  const std::map<PeptideEvidenceParam, QVariant> &getParamList() const;
+
+
+  void setCharge(unsigned int charge);
+  void setPeptideXtpSp(PeptideXtpSp peptide);
+  void
+  setIdentificationDataSource(IdentificationDataSource *identification_source);
+
+
+  /** @brief sets the identification engine
+   * 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;
+  bool isValidAndChecked() const;
+  bool isGrouped() const;
+
+  const MsRun *getMsRunP() const;
+  IdentificationDataSource *getIdentificationDataSource() const;
+  unsigned int getScan() const;
+  pappso::pappso_double getRetentionTime() const;
+  unsigned int getCharge() const;
+  const PeptideXtpSp &getPeptideXtpSp() const;
+  pappso::pappso_double getEvalue() const;
+
+  void setGrpPeptideSp(const pappso::GrpPeptideSp &sp_grp_peptide);
+  const pappso::GrpPeptideSp &getGrpPeptideSp() const;
+
+  /** @brief validate or invalidate peptides and proteins based automatic
+   * filters and manual checks
+   * */
+  void updateAutomaticFilters(
+    const AutomaticFilterParameters &automatic_filter_parameters);
+
+  /** @brief get delta between theoretical mhplus mass and mhplus experimental
+   * mass mhplus experimental mass - theoretical mhplus mass
+   */
+  pappso::mz getDeltaMass() const;
+
+  /** @brief get delta in ppm between theoretical mhplus mass and mhplus
+   * experimental mass
+   * @return mhplus experimental mass - theoretical mhplus mass
+   */
+  pappso::mz getPpmDeltaMass() const;
+
+  /** @brief get theoretical (not observed) m/z based on peptide composition and
+   * charge
+   * @return theoretical mz mass
+   */
+  pappso::mz getTheoreticalMz() const;
+
+  ValidationState getValidationState() const;
+
+  /** @brief tells if this peptide contains a protein position
+   * the position is the amino acid position on the protein sequence (starts
+   * from 0)
+   * */
+  bool containsPosition(unsigned int position) const;
+
+  private:
+  static std::hash<std::string> _hash_fn;
+  MsRun *_msrunid_sp;
+  unsigned int _scan = 0;
+  size_t _hash_sample_scan;
+  pappso::GrpPeptideSp _sp_grp_peptide;
+  PeptideXtpSp _peptide_sp;
+  pappso::pappso_double _rt;
+  pappso::pappso_double _evalue = 0;
+  pappso::pappso_double _exp_mass;
+  unsigned int _charge;
+  IdentificationDataSource *_p_identification_source = nullptr;
+  std::map<PeptideEvidenceParam, QVariant> _params;
+
+  /** @brief manually checked by user (true by default)
+   */
+  bool _checked = true;
+
+  /** @brief automatic filter result (false by default)
+   */
+  bool _proxy_valid = false;
+
+  /** @brief the search/identification engine that found this evidence
+   */
+  IdentificationEngine _identification_engine;
 };
 #endif // PEPTIDEEVIDENCE_H
diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp
index c6daa2cc4..b028f6b30 100644
--- a/src/gui/peptide_list_view/peptidetablemodel.cpp
+++ b/src/gui/peptide_list_view/peptidetablemodel.cpp
@@ -56,13 +56,28 @@ PeptideTableModel::setProteinMatch(ProteinMatch *p_protein_match)
   // QModelIndex bottomRight = createIndex(rowCount(),columnCount());
 
   std::set<PeptideListColumn> engine_columns;
+  bool first = true;
   for(auto &&peptide_match : _p_protein_match->getPeptideMatchList())
     {
+      if(first)
+        {
+          QVariant var = peptide_match.getPeptideEvidence()->getParam(
+            PeptideEvidenceParam::peptide_prophet_probability);
+          if(!var.isNull())
+            {
+            }
+          var = peptide_match.getPeptideEvidence()->getParam(
+            PeptideEvidenceParam::peptide_inter_prophet_probability);
+          if(!var.isNull())
+            {
+            }
+          first = false;
+        }
       IdentificationEngine engine =
         peptide_match.getPeptideEvidence()->getIdentificationEngine();
       if(engine == IdentificationEngine::XTandem)
         {
-          engine_columns.insert(PeptideListColumn::hyperscore);
+          engine_columns.insert(PeptideListColumn::tandem_hyperscore);
         }
       else if(engine == IdentificationEngine::mascot)
         {
@@ -95,7 +110,7 @@ PeptideTableModel::rowCount(const QModelIndex &parent) const
 int
 PeptideTableModel::columnCount(const QModelIndex &parent) const
 {
-  return 23;
+  return 33;
 }
 QVariant
 PeptideTableModel::headerData(int section, Qt::Orientation orientation,
@@ -333,7 +348,7 @@ PeptideTableModel::data(const QModelIndex &index, int role) const
                                     .getPeptideEvidence()
                                     ->getPpmDeltaMass());
                   break;
-                case(std::int8_t)PeptideListColumn::hyperscore:
+                case(std::int8_t)PeptideListColumn::tandem_hyperscore:
                   return _p_protein_match->getPeptideMatchList()
                     .at(row)
                     .getPeptideEvidence()
@@ -345,11 +360,25 @@ PeptideTableModel::data(const QModelIndex &index, int role) const
                     .getPeptideEvidence()
                     ->getParam(PeptideEvidenceParam::mascot_score);
                   break;
+
+                case(std::int8_t)PeptideListColumn::peptide_prophet_probability:
+                  return _p_protein_match->getPeptideMatchList()
+                    .at(row)
+                    .getPeptideEvidence()
+                    ->getParam(
+                      PeptideEvidenceParam::peptide_prophet_probability);
+                  break;
+                case(std::int8_t)
+                  PeptideListColumn::peptide_inter_prophet_probability:
+                  return _p_protein_match->getPeptideMatchList()
+                    .at(row)
+                    .getPeptideEvidence()
+                    ->getParam(
+                      PeptideEvidenceParam::peptide_inter_prophet_probability);
+                  break;
               }
           }
-        return QString("Row%1, Column%2")
-          .arg(index.row() + 1)
-          .arg(index.column() + 1);
+        return QString();
     }
   return QVariant();
 }
@@ -454,11 +483,15 @@ PeptideTableModel::getTitle(std::int8_t column)
       case(std::int8_t)PeptideListColumn::delta_ppm:
         return "delta ppm";
         break;
-      case(std::int8_t)PeptideListColumn::hyperscore:
+      case(std::int8_t)PeptideListColumn::tandem_hyperscore:
         return "hyperscore";
         break;
       case(std::int8_t)PeptideListColumn::mascot_score:
         return "mascot score";
+      case(std::int8_t)PeptideListColumn::peptide_prophet_probability:
+        return "Prophet probability";
+      case(std::int8_t)PeptideListColumn::peptide_inter_prophet_probability:
+        return "Inter prophet probability";
     }
   return "";
 }
@@ -537,11 +570,15 @@ PeptideTableModel::getDescription(std::int8_t column)
         return "peptide mass difference in ppm between observed mass and "
                "theoretical mass";
         break;
-      case(std::int8_t)PeptideListColumn::hyperscore:
+      case(std::int8_t)PeptideListColumn::tandem_hyperscore:
         return "X!Tandem hyperscore";
         break;
       case(std::int8_t)PeptideListColumn::mascot_score:
         return "Mascot ion score";
+      case(std::int8_t)PeptideListColumn::peptide_prophet_probability:
+        return "Peptide prophet probability";
+      case(std::int8_t)PeptideListColumn::peptide_inter_prophet_probability:
+        return "Peptide inter prophet probability";
     }
   return "";
 }
diff --git a/src/gui/peptide_list_view/peptidetablemodel.h b/src/gui/peptide_list_view/peptidetablemodel.h
index 85c719227..549aa3378 100644
--- a/src/gui/peptide_list_view/peptidetablemodel.h
+++ b/src/gui/peptide_list_view/peptidetablemodel.h
@@ -34,29 +34,40 @@
 
 enum class PeptideListColumn : std::int8_t
 {
-  checked             = 0, ///< manual checked
-  peptide_grouping_id = 1, ///< manual checked
-  engine              = 2,
-  sample              = 3,
-  scan                = 4,
-  rtmin               = 5,
-  rt                  = 6,
-  charge              = 7,
-  experimental_mz     = 8,
-  sequence            = 9,
-  modifs              = 10,
-  label               = 11,
-  start               = 12,
-  length              = 13,
-  used                = 14,
-  subgroups           = 15,
-  Evalue              = 16,
-  experimental_mhplus = 17,
-  theoretical_mhplus  = 18,
-  delta_mhplus        = 19,
-  delta_ppm           = 20,
-  hyperscore          = 21,
-  mascot_score        = 22
+  checked                           = 0, ///< manual checked
+  peptide_grouping_id               = 1, ///< manual checked
+  engine                            = 2,
+  sample                            = 3,
+  scan                              = 4,
+  rtmin                             = 5,
+  rt                                = 6,
+  charge                            = 7,
+  experimental_mz                   = 8,
+  sequence                          = 9,
+  modifs                            = 10,
+  label                             = 11,
+  start                             = 12,
+  length                            = 13,
+  used                              = 14,
+  subgroups                         = 15,
+  Evalue                            = 16,
+  experimental_mhplus               = 17,
+  theoretical_mhplus                = 18,
+  delta_mhplus                      = 19,
+  delta_ppm                         = 20,
+  peptide_prophet_probability       = 21, ///< no PSI MS description
+  peptide_inter_prophet_probability = 22, ///< no PSI MS description
+  tandem_hyperscore                 = 23, ///< X!Tandem hyperscore MS:1001331
+  mascot_score = 24, ///< PSI-MS MS:1001171 mascot:score 56.16
+  mascot_expectation_value =
+    25, ///< PSI-MS MS:1001172 mascot:expectation value 2.42102904673618e-006
+  omssa_evalue        = 26, ///< MS:1001328  "OMSSA E-value." [PSI:PI]
+  omssa_pvalue        = 27, ///< MS:1001329  "OMSSA p-value." [PSI:PI]
+  msgfplus_raw        = 28, ///< MS:1002049  "MS-GF raw score." [PSI:PI]
+  msgfplus_denovo     = 29, ///< MS:1002050  "MS-GF de novo score." [PSI:PI]
+  msgfplus_energy     = 30, ///< MS:1002051  "MS-GF energy score." [PSI:PI]
+  msgfplus_SpecEValue = 31, ///< MS:1002052  "MS-GF spectral E-value." [PSI:PI]
+  msgfplus_EValue     = 32, ///< MS:1002053  "MS-GF E-value." [PSI:PI]
 };
 
 class PeptideListWindow;
-- 
GitLab