From 5052807750346ef0476407100f4b61745bf96045 Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Tue, 21 Nov 2017 22:30:15 +0100
Subject: [PATCH] WIP: refactoring using PeptideEvidence

---
 src/gui/peptide_detail_view/peptidewindow.cpp | 48 +++++++--------
 src/gui/peptide_detail_view/peptidewindow.h   |  8 +--
 .../peptide_list_view/peptidelistwindow.cpp   |  4 +-
 src/gui/peptide_list_view/peptidelistwindow.h |  2 +-
 .../peptide_list_view/peptidetablemodel.cpp   | 44 +++++++-------
 src/gui/peptide_list_view/peptidetablemodel.h |  2 +-
 .../peptidetableproxymodel.cpp                | 24 ++++----
 src/gui/project_view/projectwindow.cpp        |  6 +-
 src/gui/project_view/projectwindow.h          |  4 +-
 .../proteintableproxymodel.cpp                |  4 +-
 src/gui/protein_view/proteinwindow.cpp        |  8 +--
 src/gui/protein_view/proteinwindow.h          |  2 +-
 .../ptmpeptidelistwindow.cpp                  |  4 +-
 .../ptmpeptidelistwindow.h                    |  4 +-
 .../ptmpeptidetablemodel.cpp                  | 24 ++++----
 .../ptmpeptidetableproxymodel.cpp             | 10 ++--
 src/input/identificationpwizreader.cpp        |  4 +-
 src/output/proticdbml.cpp                     | 58 +++++++++----------
 src/output/xpip.cpp                           | 28 ++++-----
 src/output/xpip.h                             |  2 +-
 20 files changed, 145 insertions(+), 145 deletions(-)

diff --git a/src/gui/peptide_detail_view/peptidewindow.cpp b/src/gui/peptide_detail_view/peptidewindow.cpp
index edf50ac39..4f8011af8 100644
--- a/src/gui/peptide_detail_view/peptidewindow.cpp
+++ b/src/gui/peptide_detail_view/peptidewindow.cpp
@@ -36,11 +36,11 @@
 #include <QMessageBox>
 
 
-void SpectrumSpLoaderThread::doLoadSpectrumSp (PeptideMatch * p_peptide_match) {
+void SpectrumSpLoaderThread::doLoadSpectrumSp (PeptideEvidence * p_peptide_evidence) {
     qDebug() << "SpectrumSpLoaderThread::doLoadSpectrumSp begin";
     pappso::SpectrumSp spectrum;
     try {
-        spectrum = p_peptide_match->getIdentificationDataSource()->getSpectrumSp(p_peptide_match->getScan());
+        spectrum = p_peptide_evidence->getIdentificationDataSource()->getSpectrumSp(p_peptide_evidence->getScan());
         emit spectrumSpReady(spectrum, QString(""), QString(""));
     }
 
@@ -132,18 +132,18 @@ void PeptideWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identif
 
 void PeptideWindow::updateDisplay() {
     try {
-        ui->sequence_label->setText(_p_peptide_match->getPeptideXtpSp().get()->toString());
-        ui->mz_label->setText(QString("%1").arg(_p_peptide_match->getPeptideXtpSp().get()->getMz(_p_peptide_match->getCharge())));
-        ui->z_label->setText(QString("%1").arg(_p_peptide_match->getCharge()));
-        ui->scan_label->setText(QString("%1").arg(_p_peptide_match->getScan()));
-        ui->sample_label->setText(_p_peptide_match->getMsRunP()->getSampleName());
-        ui->modification_label->setText(_p_peptide_match->getPeptideXtpSp().get()->getModifString());
-        ui->hyperscore_label->setText(_p_peptide_match->getParam(PeptideMatchParam::tandem_hyperscore).toString());
-        ui->evalue_label->setText(QString::number(_p_peptide_match->getEvalue(), 'g', 4));
-        ui->mh_label->setText(QString::number(_p_peptide_match->getPeptideXtpSp().get()->getMz(1), 'f', 4));
-        ui->mz_label->setText(QString::number(_p_peptide_match->getPeptideXtpSp().get()->getMz(_p_peptide_match->getCharge()), 'f', 4));
-        ui->expmz_label->setText(QString::number(_p_peptide_match->getExperimentalMz(), 'f', 4));
-        ui->delta_label->setText(QString::number(_p_peptide_match->getDeltaMass(), 'g', 4));
+        ui->sequence_label->setText(_p_peptide_evidence->getPeptideXtpSp().get()->toString());
+        ui->mz_label->setText(QString("%1").arg(_p_peptide_evidence->getPeptideXtpSp().get()->getMz(_p_peptide_evidence->getCharge())));
+        ui->z_label->setText(QString("%1").arg(_p_peptide_evidence->getCharge()));
+        ui->scan_label->setText(QString("%1").arg(_p_peptide_evidence->getScan()));
+        ui->sample_label->setText(_p_peptide_evidence->getMsRunP()->getSampleName());
+        ui->modification_label->setText(_p_peptide_evidence->getPeptideXtpSp().get()->getModifString());
+        ui->hyperscore_label->setText(_p_peptide_evidence->getParam(PeptideMatchParam::tandem_hyperscore).toString());
+        ui->evalue_label->setText(QString::number(_p_peptide_evidence->getEvalue(), 'g', 4));
+        ui->mh_label->setText(QString::number(_p_peptide_evidence->getPeptideXtpSp().get()->getMz(1), 'f', 4));
+        ui->mz_label->setText(QString::number(_p_peptide_evidence->getPeptideXtpSp().get()->getMz(_p_peptide_evidence->getCharge()), 'f', 4));
+        ui->expmz_label->setText(QString::number(_p_peptide_evidence->getExperimentalMz(), 'f', 4));
+        ui->delta_label->setText(QString::number(_p_peptide_evidence->getDeltaMass(), 'g', 4));
 
 
     }
@@ -179,7 +179,7 @@ void PeptideWindow::chooseDefaultMzDataDir() {
     _p_spectrum_overlay->displayLoadingMessage();
     ui->file_not_found->setVisible(false);
     ui->spectrumWidget->setVisible(true);
-    emit loadSpectrumSp(_p_peptide_match);
+    emit loadSpectrumSp(_p_peptide_evidence);
     ui->statusbar->showMessage(tr("loading spectrum"));
 
 }
@@ -188,7 +188,7 @@ void PeptideWindow::openInPeptideViewer() {
     QSettings settings;
     QString program = settings.value("application/peptideviewer", "/usr/bin/pt-peptideviewer").toString();
     QStringList arguments;
-    arguments << _p_peptide_match->getPeptideXtpSp().get()->toString() << QString("%1").arg(_p_peptide_match->getCharge()) << _p_peptide_match->getMsRunP()->getFilename() << QString("%1").arg(_p_peptide_match->getScan());
+    arguments << _p_peptide_evidence->getPeptideXtpSp().get()->toString() << QString("%1").arg(_p_peptide_evidence->getCharge()) << _p_peptide_evidence->getMsRunP()->getFilename() << QString("%1").arg(_p_peptide_evidence->getScan());
 
     qDebug() << "PeptideWindow::openInPeptideViewer " << program << " " << arguments.join(" ");
     QProcess *myProcess = new QProcess(this);
@@ -201,7 +201,7 @@ void PeptideWindow::doSpectrumSpReady(SpectrumSp spectrum_sp, QString error, QSt
     if ((error.isEmpty()) && (fatal_error.isEmpty())) {
         ui->statusbar->showMessage(tr(""));
         pappso::QualifiedSpectrum spectrum_copy;
-        spectrum_copy.setPrecursorCharge(_p_peptide_match->getCharge());
+        spectrum_copy.setPrecursorCharge(_p_peptide_evidence->getCharge());
         spectrum_copy.setOriginalSpectrumSp(spectrum_sp);
 
         ui->spectrumWidget->setQualifiedSpectrum(spectrum_copy);
@@ -241,20 +241,20 @@ void PeptideWindow::doSpectrumSpReady(SpectrumSp spectrum_sp, QString error, QSt
 
 }
 
-void PeptideWindow::setPeptideMatch(PeptideMatch * p_peptide_match) {
+void PeptideWindow::setPeptideEvidence(PeptideEvidence * p_peptide_evidence) {
     qDebug() << "PeptideWindow::setPeptideMatch begin";
-    _p_peptide_match = p_peptide_match;
+    _p_peptide_evidence = p_peptide_evidence;
     _spectrum_is_ready = false;
 
     qDebug() << "PeptideWindow::setPeptideMatch emit loadSpectrumSp(_p_peptide_match)";
-    emit loadSpectrumSp(_p_peptide_match);
+    emit loadSpectrumSp(_p_peptide_evidence);
 
     _p_spectrum_overlay->displayLoadingMessage();
     ui->file_not_found->setVisible(false);
     ui->spectrumWidget->setVisible(true);
     ui->statusbar->showMessage(tr("loading spectrum"));
 
-    pappso::PeptideSp peptide = _p_peptide_match->getPeptideXtpSp();
+    pappso::PeptideSp peptide = _p_peptide_evidence->getPeptideXtpSp();
     ui->spectrumWidget->setPrecision(_p_precision);
     ui->spectrumWidget->setPeptideSp(peptide);
 
@@ -305,10 +305,10 @@ void PeptideWindow::doSaveSvg() {
         QSettings settings;
         QString default_location = settings.value("path/export_svg", "").toString();
 
-        QString proposed_filename = QString("%1/%2_%3.svg").arg(default_location).arg(_p_peptide_match->getMsRunP()->getSampleName()).arg(_p_peptide_match->getScan());
+        QString proposed_filename = QString("%1/%2_%3.svg").arg(default_location).arg(_p_peptide_evidence->getMsRunP()->getSampleName()).arg(_p_peptide_evidence->getScan());
 
-        if (_p_peptide_match->getValidationState() == ValidationState::grouped) {
-            proposed_filename = QString("%1/%2_%3_%4.svg").arg(default_location).arg(_p_peptide_match->getGrpPeptideSp().get()->getGroupingId()).arg(_p_peptide_match->getMsRunP()->getSampleName()).arg(_p_peptide_match->getScan());
+        if (_p_peptide_evidence->getValidationState() == ValidationState::grouped) {
+            proposed_filename = QString("%1/%2_%3_%4.svg").arg(default_location).arg(_p_peptide_evidence->getGrpPeptideSp().get()->getGroupingId()).arg(_p_peptide_evidence->getMsRunP()->getSampleName()).arg(_p_peptide_evidence->getScan());
         }
 
         QString filename = QFileDialog::getSaveFileName(this, tr("Save SVG file"),
diff --git a/src/gui/peptide_detail_view/peptidewindow.h b/src/gui/peptide_detail_view/peptidewindow.h
index ec52c982c..419cd3b39 100644
--- a/src/gui/peptide_detail_view/peptidewindow.h
+++ b/src/gui/peptide_detail_view/peptidewindow.h
@@ -46,7 +46,7 @@ public:
 
 
 public slots:
-    void doLoadSpectrumSp(PeptideMatch * p_peptide_match);
+    void doLoadSpectrumSp(PeptideEvidence * p_peptide_evidence);
 
 signals:
     void spectrumSpReady(pappso::SpectrumSp spectrum_sp, QString error, QString fatal_error);
@@ -65,14 +65,14 @@ public:
 
     explicit PeptideWindow(ProjectWindow * parent = 0);
     ~PeptideWindow();
-    void setPeptideMatch(PeptideMatch * p_peptide_match);
+    void setPeptideEvidence(PeptideEvidence * p_peptide_evidence);
     
 public slots:
     void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group);
     void setMz(double);
     
 signals:
-    void loadSpectrumSp(PeptideMatch * p_peptide_match);
+    void loadSpectrumSp(PeptideEvidence * p_peptide_evidence);
     
 protected slots:
     void doSpectrumSpReady(pappso::SpectrumSp spectrum_sp, QString error, QString fatal_error);
@@ -90,7 +90,7 @@ private:
     
     Ui::PeptideDetailView *ui;
     ProjectWindow * _p_project_window;
-    PeptideMatch * _p_peptide_match = nullptr;
+    PeptideEvidence * _p_peptide_evidence = nullptr;
     pappso::PrecisionP _p_precision;
     
     LoadingOverlay * _p_spectrum_overlay;
diff --git a/src/gui/peptide_list_view/peptidelistwindow.cpp b/src/gui/peptide_list_view/peptidelistwindow.cpp
index 8d3630e52..b57498227 100644
--- a/src/gui/peptide_list_view/peptidelistwindow.cpp
+++ b/src/gui/peptide_list_view/peptidelistwindow.cpp
@@ -158,9 +158,9 @@ void PeptideListWindow::doNotGroupedHide(bool hide) {
 }
 
 
-void PeptideListWindow::askPeptideDetailView(PeptideMatch * p_peptide_match) {
+void PeptideListWindow::askPeptideDetailView(PeptideEvidence * p_peptide_evidence) {
     qDebug() << "PeptideListWindow::askPeptideDetailView begin";
-    _project_window->doViewPeptideDetail(p_peptide_match);
+    _project_window->doViewPeptideDetail(p_peptide_evidence);
     qDebug() << "PeptideListWindow::askPeptideDetailView end";
     //updateStatusBar();
 }
diff --git a/src/gui/peptide_list_view/peptidelistwindow.h b/src/gui/peptide_list_view/peptidelistwindow.h
index d6d291e8b..b90f64ad5 100644
--- a/src/gui/peptide_list_view/peptidelistwindow.h
+++ b/src/gui/peptide_list_view/peptidelistwindow.h
@@ -63,7 +63,7 @@ signals:
 
       
 protected :
-    void askPeptideDetailView(PeptideMatch * p_peptide_match);
+    void askPeptideDetailView(PeptideEvidence * p_peptide_evidence);
 
 protected slots:
     void doNotValidHide(bool hide);
diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp
index 6c091efc1..8dcdeb6d8 100644
--- a/src/gui/peptide_list_view/peptidetablemodel.cpp
+++ b/src/gui/peptide_list_view/peptidetablemodel.cpp
@@ -98,7 +98,7 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
 
         if (col == 0) //add a checkbox to cell(1,0)
         {
-            if ( _p_protein_match->getPeptideMatchList().at(row)->isChecked()) {
+            if ( _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->isChecked()) {
                 return Qt::Checked;
             }
             else {
@@ -107,7 +107,7 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
         }
         break;
     case Qt::BackgroundRole:
-        if (_p_protein_match->getPeptideMatchList().at(row)->isValid() == false)
+        if (_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->isValid() == false)
         {
             return QVariant(QColor("grey"));
         }
@@ -129,30 +129,30 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
                 break;
 
             case (std::int8_t)PeptideListColumn::peptide_grouping_id:
-                p_grp_peptide = _p_protein_match->getPeptideMatchList().at(row)->getGrpPeptideSp().get();
+                p_grp_peptide = _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getGrpPeptideSp().get();
                 if (p_grp_peptide != nullptr) return p_grp_peptide->getGroupingId();
                 return QVariant();
                 break;
             case (std::int8_t)PeptideListColumn::sample:
-                return _p_protein_match->getPeptideMatchList().at(row)->getIdentificationDataSource()->getSampleName();
+                return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getIdentificationDataSource()->getSampleName();
                 break;
             case (std::int8_t)PeptideListColumn::scan:
-                return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row)->getScan());
+                return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getScan());
                 break;
             case (std::int8_t)PeptideListColumn::rt:
-                return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row)->getRetentionTime());
+                return QVariant ((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getRetentionTime());
                 break;
             case (std::int8_t)PeptideListColumn::charge:
-                return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row)->getCharge());
+                return QVariant ((quint32) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getCharge());
                 break;
             case (std::int8_t)PeptideListColumn::sequence:
-                return _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getSequence();
+                return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getSequence();
                 break;
             case (std::int8_t)PeptideListColumn::modifs:
-                return _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getModifString();
+                return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getModifString();
                 break;
             case (std::int8_t)PeptideListColumn::label:
-                p_label = _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getLabel();
+                p_label = _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getLabel();
                 if (p_label != nullptr) {
                     return QVariant(p_label->getXmlId());
                 }
@@ -161,32 +161,32 @@ QVariant PeptideTableModel::data(const QModelIndex &index, int role ) const {
                 }
                 break;
             case (std::int8_t)PeptideListColumn::start:
-                return QVariant((quint32) _p_protein_match->getPeptideMatchList().at(row)->getStart()+1);
+                return QVariant((quint32) _p_protein_match->getPeptideMatchList().at(row).getStart()+1);
                 break;
             case (std::int8_t)PeptideListColumn::length:
-                return QVariant((quint32) _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->size());
+                return QVariant((quint32) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->size());
                 break;
             case (std::int8_t)PeptideListColumn::used:
                 p_grp = _p_protein_match->getGroupingGroupSp().get();
-                if (p_grp != nullptr) return QVariant((qreal)  p_grp->countSubgroupPresence(_p_protein_match->getPeptideMatchList().at(row)));
+                if (p_grp != nullptr) return QVariant((qreal)  p_grp->countSubgroupPresence(_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()));
                 return QVariant();
                 break;
             case (std::int8_t)PeptideListColumn::subgroups:
                 p_grp = _p_protein_match->getGroupingGroupSp().get();
-                if (p_grp != nullptr) return QVariant( p_grp->getSubgroupIdList(_p_protein_match->getPeptideMatchList().at(row)).join(" "));
+                if (p_grp != nullptr) return QVariant( p_grp->getSubgroupIdList(_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()).join(" "));
                 return QVariant();
                 break;
             case (std::int8_t)PeptideListColumn::Evalue:
-                return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getEvalue());
+                return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getEvalue());
                 break;
             case (std::int8_t)PeptideListColumn::theoretical_mhplus:
-                return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getPeptideXtpSp().get()->getMz(1));
+                return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getPeptideXtpSp().get()->getMz(1));
                 break;
             case (std::int8_t)PeptideListColumn::delta_mhplus:
-                return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row)->getDeltaMass());
+                return QVariant((qreal) _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getDeltaMass());
                 break;
             case (std::int8_t)PeptideListColumn::hyperscore:
-                return _p_protein_match->getPeptideMatchList().at(row)->getParam(PeptideMatchParam::tandem_hyperscore);
+                return _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->getParam(PeptideMatchParam::tandem_hyperscore);
                 break;
             }
         }
@@ -203,16 +203,16 @@ void PeptideTableModel::onTableClicked(const QModelIndex &index)
     int col = index.column();
     if (col == 0) //add a checkbox to cell(1,0)
     {
-        if ( _p_protein_match->getPeptideMatchList().at(row)->isChecked()) {
-            _p_protein_match->getPeptideMatchList().at(row)->setChecked(false);
+        if ( _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->isChecked()) {
+            _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->setChecked(false);
         }
         else {
-            _p_protein_match->getPeptideMatchList().at(row)->setChecked(true);
+            _p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence()->setChecked(true);
         }
         //emit dataChanged(index, index);
     }
     else {
-        emit peptideMatchClicked(_p_protein_match->getPeptideMatchList().at(row));
+        emit peptideEvidenceClicked(_p_protein_match->getPeptideMatchList().at(row).getPeptideEvidence());
     }
 }
 
diff --git a/src/gui/peptide_list_view/peptidetablemodel.h b/src/gui/peptide_list_view/peptidetablemodel.h
index 7efe6a53c..9d9b90cf2 100644
--- a/src/gui/peptide_list_view/peptidetablemodel.h
+++ b/src/gui/peptide_list_view/peptidetablemodel.h
@@ -70,7 +70,7 @@ public:
     void setProteinMatch(ProteinMatch * p_protein_match);
     ProteinMatch * getProteinMatch();
 signals:
-    void peptideMatchClicked(PeptideMatch * p_peptide_match);
+    void peptideEvidenceClicked(PeptideEvidence * p_peptide_evidence);
 
 public slots:
     void onPeptideDataChanged();
diff --git a/src/gui/peptide_list_view/peptidetableproxymodel.cpp b/src/gui/peptide_list_view/peptidetableproxymodel.cpp
index 981ae5e58..a62ccb55b 100644
--- a/src/gui/peptide_list_view/peptidetableproxymodel.cpp
+++ b/src/gui/peptide_list_view/peptidetableproxymodel.cpp
@@ -50,21 +50,21 @@ bool PeptideTableProxyModel::filterAcceptsRow(int source_row,
         const QModelIndex &source_parent) const {
     try {
         qDebug() << "PeptideTableProxyModel::filterAcceptsRow begin " << source_row;
-        PeptideMatch * peptide_match = _peptide_table_model_p->getProteinMatch()->getPeptideMatchList().at(source_row);
+        PeptideEvidence * peptide_evidence = _peptide_table_model_p->getProteinMatch()->getPeptideMatchList().at(source_row).getPeptideEvidence();
         qDebug() << "PeptideTableProxyModel::filterAcceptsRow protein_match " << source_row;
 
         if (!_peptide_search_string.isEmpty()) {
             if (_search_on == "peptide") {
-                if (!peptide_match->getPeptideXtpSp().get()->getSequence().contains(_peptide_search_string)) {
+                if (!peptide_evidence->getPeptideXtpSp().get()->getSequence().contains(_peptide_search_string)) {
                     return false;
                 }
             }
             else if (_search_on == "sample") {
-                if (!peptide_match->getMsRunP()->getSampleName().contains(_peptide_search_string)) {
+                if (!peptide_evidence->getMsRunP()->getSampleName().contains(_peptide_search_string)) {
                     return false;
                 }
             } else if (_search_on == "subgroup") {
-                if (peptide_match->getValidationState() != ValidationState::grouped) {
+                if (peptide_evidence->getValidationState() != ValidationState::grouped) {
                     return false;
                 }
                 unsigned int subgroup = _peptide_search_string.toUInt();
@@ -76,20 +76,20 @@ bool PeptideTableProxyModel::filterAcceptsRow(int source_row,
 
         qDebug() << "PeptideTableProxyModel::filterAcceptsRow valid ";
         if (_hide_not_valid) {
-            if (! peptide_match->isValid()) {
+            if (! peptide_evidence->isValid()) {
                 return false;
             }
         }
         qDebug() << "PeptideTableProxyModel::filterAcceptsRow checked ";
         if (_hide_not_checked) {
-            if (! peptide_match->isChecked()) {
+            if (! peptide_evidence->isChecked()) {
                 return false;
             }
         }
 
         qDebug() << "PeptideTableProxyModel::filterAcceptsRow grouped ";
         if (_hide_not_grouped) {
-            if (! peptide_match->isGrouped()) {
+            if (! peptide_evidence->isGrouped()) {
                 return false;
             }
 
@@ -124,20 +124,20 @@ void PeptideTableProxyModel::onTableClicked(const QModelIndex &index)
     QModelIndex source_index(this->mapToSource(index));
     int row = source_index.row();
     int col = source_index.column();
-    PeptideMatch * peptide_match = _peptide_table_model_p->getProteinMatch()->getPeptideMatchList().at(row);
+    PeptideMatch * peptide_match = &_peptide_table_model_p->getProteinMatch()->getPeptideMatchList().at(row);
     if (col == 0) //add a checkbox to cell(1,0)
     {
 
-        if ( peptide_match->isChecked()) {
-            peptide_match->setChecked(false);
+        if ( peptide_match->getPeptideEvidence()->isChecked()) {
+            peptide_match->getPeptideEvidence()->setChecked(false);
         }
         else {
-            peptide_match->setChecked(true);
+            peptide_match->getPeptideEvidence()->setChecked(true);
         }
         _p_peptide_list_window->edited();
     }
     else {
-        _p_peptide_list_window->askPeptideDetailView(peptide_match);
+        _p_peptide_list_window->askPeptideDetailView(peptide_match->getPeptideEvidence());
     }
     qDebug() << "PeptideTableProxyModel::onTableClicked end " << index.row();
 
diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp
index 755cfdfc0..ba6779254 100644
--- a/src/gui/project_view/projectwindow.cpp
+++ b/src/gui/project_view/projectwindow.cpp
@@ -445,7 +445,7 @@ void ProjectWindow::doViewPeptideList(IdentificationGroup * p_ident_group, Prote
     qDebug() << "ProjectWindow::doViewPeptideList end";
 }
 
-void ProjectWindow::doViewPeptideDetail(PeptideMatch * peptide_match) {
+void ProjectWindow::doViewPeptideDetail(PeptideEvidence * peptide_evidence) {
 
     qDebug() << "ProjectWindow::doViewPeptideDetail begin";
     if (_peptide_detail_window_collection.size() == 0) {
@@ -457,12 +457,12 @@ void ProjectWindow::doViewPeptideDetail(PeptideMatch * peptide_match) {
     }
 
 
-    _p_current_peptide_detail_window->setPeptideMatch(peptide_match);
+    _p_current_peptide_detail_window->setPeptideEvidence(peptide_evidence);
     _p_current_peptide_detail_window->show();
     //_p_current_peptide_detail_window->raise();
     //_p_current_peptide_detail_window->activateWindow();
 
-    emit peptideMatchSelected(peptide_match);
+    emit peptideEvidenceSelected(peptide_evidence);
     qDebug() << "ProjectWindow::doViewPeptideDetail end";
 }
 
diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h
index 773d4a756..713be30e4 100644
--- a/src/gui/project_view/projectwindow.h
+++ b/src/gui/project_view/projectwindow.h
@@ -75,13 +75,13 @@ public slots:
     void refreshGroup(IdentificationGroup * p_ident_group);
     void refreshPtmGroup(IdentificationGroup * p_ident_group);
     void doAcceptedLabelingMethod();
-    void doViewPeptideDetail(PeptideMatch * peptide_match);
+    void doViewPeptideDetail(PeptideEvidence * peptide_evidence);
     // void setColor(const QColor &color);
     // void setShape(Shape shape);
 signals:
     void identificationGroupGrouped(IdentificationGroup * p_identification_group);
     void identificationPtmGroupGrouped(IdentificationGroup * p_identification_group);
-    void peptideMatchSelected(PeptideMatch * peptide_match);
+    void peptideEvidenceSelected(PeptideEvidence * peptide_evidence);
     void operateGrouping(ProjectSp project_sp);
     void operatePtmGroupingOnIdentification(IdentificationGroup * p_identification_group);
     void operateGroupingOnIdentification(IdentificationGroup * p_identification_group, GroupingType grouping_type);
diff --git a/src/gui/protein_list_view/proteintableproxymodel.cpp b/src/gui/protein_list_view/proteintableproxymodel.cpp
index d1169018a..e133174cd 100644
--- a/src/gui/protein_list_view/proteintableproxymodel.cpp
+++ b/src/gui/protein_list_view/proteintableproxymodel.cpp
@@ -73,8 +73,8 @@ bool ProteinTableProxyModel::filterAcceptsRow(int source_row,
             }
             else if (_search_on == "peptide") {
                 QString peptide_search_string = QString(_protein_search_string).replace("L","I");
-                for (PeptideMatch * p_peptide_match: protein_match->getPeptideMatchList()) {
-                    if (p_peptide_match->getPeptideXtpSp().get()->getSequenceLi().contains(peptide_search_string)) {
+                for (const PeptideMatch & p_peptide_match: protein_match->getPeptideMatchList()) {
+                    if (p_peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->getSequenceLi().contains(peptide_search_string)) {
                         return true;
                     }
                 }
diff --git a/src/gui/protein_view/proteinwindow.cpp b/src/gui/protein_view/proteinwindow.cpp
index 21c066466..ef29d4712 100644
--- a/src/gui/protein_view/proteinwindow.cpp
+++ b/src/gui/protein_view/proteinwindow.cpp
@@ -60,7 +60,7 @@ ProteinWindow::ProteinWindow(ProjectWindow *parent):
 #if QT_VERSION >= 0x050000
     // Qt5 code
     connect (_p_project_window, &ProjectWindow::identificationGroupGrouped, this,&ProteinWindow::doIdentificationGroupGrouped);
-    connect (_p_project_window, &ProjectWindow::peptideMatchSelected, this,&ProteinWindow::doPeptideMatchSelected);
+    connect (_p_project_window, &ProjectWindow::peptideEvidenceSelected, this,&ProteinWindow::doPeptideEvidenceSelected);
 #else
 // Qt4 code
     connect (_p_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *)));
@@ -79,9 +79,9 @@ void ProteinWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identif
     updateDisplay();
 }
 
-void ProteinWindow::doPeptideMatchSelected(PeptideMatch * peptide_match) {
-    if (_p_protein_match != nullptr) {
-        ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence(peptide_match));
+void ProteinWindow::doPeptideEvidenceSelected(PeptideEvidence * peptide_evidence) {
+    if (peptide_evidence != nullptr) {
+        ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence(peptide_evidence));
 
     }
 }
diff --git a/src/gui/protein_view/proteinwindow.h b/src/gui/protein_view/proteinwindow.h
index f5bbe42dd..68e61560a 100644
--- a/src/gui/protein_view/proteinwindow.h
+++ b/src/gui/protein_view/proteinwindow.h
@@ -56,7 +56,7 @@ public:
     
 public slots:
     void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group);
-    void doPeptideMatchSelected(PeptideMatch * peptide_match);
+    void doPeptideEvidenceSelected(PeptideEvidence * peptide_evidence);
  protected slots:
     void browseUrl(int i);
    
diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp
index 3a459722d..bae3597fd 100644
--- a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp
+++ b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.cpp
@@ -81,9 +81,9 @@ void PtmPeptideListWindow::setPtmIsland(PtmIsland * p_ptm_island) {
     _ptm_table_model_p->setPtmIsland(_p_ptm_island_list_window->getIdentificationGroup()->getPtmGroupingExperiment(), _p_ptm_island);
 }
 
-void PtmPeptideListWindow::askPeptideDetailView(PeptideMatch * p_peptide_match) {
+void PtmPeptideListWindow::askPeptideDetailView(PeptideMatch p_peptide_match) {
     qDebug() << "PtmPeptideListWindow::askPeptideDetailView begin";
-    emit requestPeptideDetailView(p_peptide_match);
+    emit requestPeptideDetailView(p_peptide_match.getPeptideEvidence());
     qDebug() << "PtmPeptideListWindow::askPeptideDetailView end";
     //updateStatusBar();
 }
diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h
index 7ef95d5a9..de7c6288d 100644
--- a/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h
+++ b/src/gui/ptm_peptide_list_view/ptmpeptidelistwindow.h
@@ -49,10 +49,10 @@ public:
     explicit PtmPeptideListWindow(PtmIslandListWindow * parent = 0);
     ~PtmPeptideListWindow();
     void setPtmIsland(PtmIsland * p_ptm_island);
-    void askPeptideDetailView(PeptideMatch * p_peptide_match);
+    void askPeptideDetailView(PeptideMatch p_peptide_match);
     
 signals:
-    void requestPeptideDetailView(PeptideMatch * p_peptide_match);
+    void requestPeptideDetailView(PeptideEvidence * p_peptide_evidence);
 
     
 private:
diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp
index 8b455b208..a68a0ad09 100644
--- a/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp
+++ b/src/gui/ptm_peptide_list_view/ptmpeptidetablemodel.cpp
@@ -192,43 +192,43 @@ QVariant PtmPeptideTableModel::data(const QModelIndex &index, int role ) const {
         switch (col) {
 
             case (std::int8_t)PtmPeptideListColumn::peptide_ptm_grouping_id:
-                return QVariant (_ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getGrpPeptideSp().get()->getGroupingId());
+                return QVariant (_ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getGrpPeptideSp().get()->getGroupingId());
                 break;
             case (std::int8_t)PtmPeptideListColumn::sample:
-                return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getIdentificationDataSource()->getSampleName();
+                return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getIdentificationDataSource()->getSampleName();
                 break;
             case (std::int8_t)PtmPeptideListColumn::scan:
-                return QVariant ((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getScan());
+                return QVariant ((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getScan());
                 break;
             case (std::int8_t)PtmPeptideListColumn::rt:
-                return QVariant ((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getRetentionTime());
+                return QVariant ((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getRetentionTime());
                 break;
             case (std::int8_t)PtmPeptideListColumn::charge:
-                return QVariant ((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getCharge());
+                return QVariant ((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getCharge());
                 break;
             case (std::int8_t)PtmPeptideListColumn::sequence:
                 return QVariant::fromValue( _ptm_sample_scan_list.at(row).get());
                 break;
             case (std::int8_t)PtmPeptideListColumn::modifs:
-                return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->getModifString();
+                return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->getModifString();
                 break;
             case (std::int8_t)PtmPeptideListColumn::start:
-                return QVariant((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getStart()+1);
+                return QVariant((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getStart()+1);
                 break;
             case (std::int8_t)PtmPeptideListColumn::length:
-                return QVariant((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->size());
+                return QVariant((quint32) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->size());
                 break;
             case (std::int8_t)PtmPeptideListColumn::bestEvalue:
-                return QVariant((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getEvalue());
+                return QVariant((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getEvalue());
                 break;
             case (std::int8_t)PtmPeptideListColumn::theoretical_mhplus:
-                return QVariant((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->getMz(1));
+                return QVariant((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->getMz(1));
                 break;
             case (std::int8_t)PtmPeptideListColumn::delta_mhplus:
-                return QVariant((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getDeltaMass());
+                return QVariant((qreal) _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getDeltaMass());
                 break;
             case (std::int8_t)PtmPeptideListColumn::besthyperscore:
-                return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch()->getParam(PeptideMatchParam::tandem_hyperscore);
+                return _ptm_sample_scan_list.at(row).get()->getRepresentativePeptideMatch().getPeptideEvidence()->getParam(PeptideMatchParam::tandem_hyperscore);
                 break;
             case (std::int8_t)PtmPeptideListColumn::bestposition:
                 for (unsigned int position :_ptm_sample_scan_list.at(row).get()->getBestPtmPositionList(_p_ptm_grouping_experiment)) {
diff --git a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp
index 2f03ac690..f049f03c3 100644
--- a/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp
+++ b/src/gui/ptm_peptide_list_view/ptmpeptidetableproxymodel.cpp
@@ -65,10 +65,10 @@ PtmPeptideMenuQaction::PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent,
     //this->setText(p_peptide_match->getPeptideXtpSp().get()->getSequence());
 
     QStringList position_list;
-    for (unsigned int position : p_ptm_grouping_experiment->getPtmPositions(p_peptide_match)) {
+    for (unsigned int position : p_ptm_grouping_experiment->getPtmPositions(*p_peptide_match)) {
         position_list << QString("%1").arg(position+1);
     }
-    this->setText(QString("%1 (%2)").arg(p_peptide_match->getPeptideXtpSp().get()->toString()).arg(position_list.join(" ")));
+    this->setText(QString("%1 (%2)").arg(p_peptide_match->getPeptideEvidence()->getPeptideXtpSp().get()->toString()).arg(position_list.join(" ")));
     //evalue_action.setChecked(_display_evalue);
     //connect(p_action, SIGNAL(toggled(bool)), this, SLOT(showEvalueColumn(bool)));
 
@@ -81,7 +81,7 @@ PtmPeptideMenuQaction::PtmPeptideMenuQaction(PtmPeptideTableProxyModel * parent,
 #endif
 }
 void PtmPeptideMenuQaction::doTriggered(bool triggered) {
-    _p_ptm_peptide_table_proxy_model->getPtmPeptideListWindowP()->askPeptideDetailView(_p_peptide_match);
+    _p_ptm_peptide_table_proxy_model->getPtmPeptideListWindowP()->askPeptideDetailView(*_p_peptide_match);
 }
 
 PtmPeptideMenuQaction::~PtmPeptideMenuQaction()
@@ -113,7 +113,7 @@ bool PtmPeptideTableProxyModel::lessThan(const QModelIndex &left,
     if (leftData.canConvert<PtmSampleScan *>()) {
         PtmSampleScan * p_ptm_sample_scan_left = qvariant_cast<PtmSampleScan *>(leftData);
         PtmSampleScan * p_ptm_sample_scan_right = qvariant_cast<PtmSampleScan *>(rightData);
-        return p_ptm_sample_scan_left->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->toAbsoluteString() < p_ptm_sample_scan_right->getRepresentativePeptideMatch()->getPeptideXtpSp().get()->toAbsoluteString();
+        return p_ptm_sample_scan_left->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->toAbsoluteString() < p_ptm_sample_scan_right->getRepresentativePeptideMatch().getPeptideEvidence()->getPeptideXtpSp().get()->toAbsoluteString();
     } else {
         return QSortFilterProxyModel::lessThan(left, right);
     }
@@ -130,7 +130,7 @@ void PtmPeptideTableProxyModel::showContextMenu(const QModelIndex &index) {
 
     PtmPeptideMenuQaction * p_action;
     for (auto p_peptide_match : sp_ptm_sample_scan.get()->getPeptideMatchList()) {
-        p_action = new PtmPeptideMenuQaction(this, _p_ptm_table_model->getPtmGroupingExperiment(), sp_ptm_sample_scan.get(), p_peptide_match);
+        p_action = new PtmPeptideMenuQaction(this, _p_ptm_table_model->getPtmGroupingExperiment(), sp_ptm_sample_scan.get(), &p_peptide_match);
         _p_context_menu->addAction(p_action);
     }
 
diff --git a/src/input/identificationpwizreader.cpp b/src/input/identificationpwizreader.cpp
index 78d69dacf..11680a241 100644
--- a/src/input/identificationpwizreader.cpp
+++ b/src/input/identificationpwizreader.cpp
@@ -274,9 +274,9 @@ void IdentificationPwizReader::read(
 
 
                         p_peptide_evidence->setPeptideXtpSp(it_pep->second);
-                        PeptideEvidenceSp peptide_evidence_sp = p_identification_data_source->getPeptideEvidenceStore().getInstance(p_peptide_evidence);
+                        PeptideEvidenceSp peptide_evidence_sp_pappso = p_identification_data_source->getPeptideEvidenceStore().getInstance(p_peptide_evidence);
 
-                        peptide_match.setPeptideEvidenceSp(peptide_evidence_sp);
+                        peptide_match.setPeptideEvidenceSp(peptide_evidence_sp_pappso);
 
                         auto it = map_id2protein.find(QString::fromStdString(peptide_evidence_sp.get()->dbSequencePtr.get()->id));
                         if (it == map_id2protein.end()) {
diff --git a/src/output/proticdbml.cpp b/src/output/proticdbml.cpp
index 7fe9ae170..c70fb5af5 100644
--- a/src/output/proticdbml.cpp
+++ b/src/output/proticdbml.cpp
@@ -461,16 +461,16 @@ void ProticdbMl::writePeptideHit(QString xml_id, ProticPeptideHit & protic_pepti
 
     // param par default
     _output_stream->writeStartElement("peptideHit");
-    _output_stream->writeAttribute("calc_mr", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getPeptideXtpSp().get()->getMass()));
-    _output_stream->writeAttribute("exp_mz", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getExperimentalMz()));
-    _output_stream->writeAttribute("delta", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getDeltaMass()));
-    _output_stream->writeAttribute("exp_mr", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getExperimentalMz()- pappso::MHPLUS));
-    _output_stream->writeAttribute("acq_number", QString ("%1").arg(protic_peptide_hit.peptide_match->getScan()));
-    _output_stream->writeAttribute("ms_run_id", protic_peptide_hit.peptide_match->getMsRunP()->getXmlId());
+    _output_stream->writeAttribute("calc_mr", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getPeptideEvidence()->getPeptideXtpSp().get()->getMass()));
+    _output_stream->writeAttribute("exp_mz", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getPeptideEvidence()->getExperimentalMz()));
+    _output_stream->writeAttribute("delta", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getPeptideEvidence()->getDeltaMass()));
+    _output_stream->writeAttribute("exp_mr", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getPeptideEvidence()->getExperimentalMz()- pappso::MHPLUS));
+    _output_stream->writeAttribute("acq_number", QString ("%1").arg(protic_peptide_hit.peptide_match->getPeptideEvidence()->getScan()));
+    _output_stream->writeAttribute("ms_run_id", protic_peptide_hit.peptide_match->getPeptideEvidence()->getMsRunP()->getXmlId());
     _output_stream->writeAttribute("id", xml_id);
-    _output_stream->writeAttribute("exp_z", QString ("%1").arg(protic_peptide_hit.peptide_match->getCharge()));
+    _output_stream->writeAttribute("exp_z", QString ("%1").arg(protic_peptide_hit.peptide_match->getPeptideEvidence()->getCharge()));
 
-    writeCvParam("PROTICdbO:0000339",protic_peptide_hit.peptide_match->getGrpPeptideSp().get()->getGroupingId(),
+    writeCvParam("PROTICdbO:0000339",protic_peptide_hit.peptide_match->getPeptideEvidence()->getGrpPeptideSp().get()->getGroupingId(),
                  "peptide mass id");
     /*
         if (xtpExperimentType.equals("phospho")) {
@@ -480,28 +480,28 @@ void ProticdbMl::writePeptideHit(QString xml_id, ProticPeptideHit & protic_pepti
         }
     */
     // pep.getMsRun().
-    IdentificationEngine identification_engine = protic_peptide_hit.peptide_match->getIdentificationDataSource()->getIdentificationEngine();
+    IdentificationEngine identification_engine = protic_peptide_hit.peptide_match->getPeptideEvidence()->getIdentificationDataSource()->getIdentificationEngine();
     if (identification_engine == IdentificationEngine::XTandem) {
         // cvparam specifique xtandem
 
-        writeCvParam("PROTICdbO:0000287", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getEvalue()),
+        writeCvParam("PROTICdbO:0000287", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getPeptideEvidence()->getEvalue()),
                      "xtandem peptide evalue");
 
-        writeCvParam("PROTICdbO:0000288", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getParam(PeptideMatchParam::tandem_hyperscore).toDouble()),
+        writeCvParam("PROTICdbO:0000288", Utils::getXmlDouble(protic_peptide_hit.peptide_match->getPeptideEvidence()->getParam(PeptideMatchParam::tandem_hyperscore).toDouble()),
                      "xtandem peptide hyperscore");
     }
 
-    writeCvParam("PROTICdbO:0000289",QString ("%1").arg(protic_peptide_hit.peptide_match->getRetentionTime()),
+    writeCvParam("PROTICdbO:0000289",QString ("%1").arg(protic_peptide_hit.peptide_match->getPeptideEvidence()->getRetentionTime()),
                  "xtandem peptide retention time");
 
     // sequences avec les modifs
     _output_stream->writeStartElement("pepSeq");
     _output_stream->writeStartElement("peptide");
-    _output_stream->writeCharacters(protic_peptide_hit.peptide_match->getPeptideXtpSp().get()->getSequence());
+    _output_stream->writeCharacters(protic_peptide_hit.peptide_match->getPeptideEvidence()->getPeptideXtpSp().get()->getSequence());
     _output_stream->writeEndElement();// peptide
 
-    if (!protic_peptide_hit.peptide_match->getPeptideXtpSp().get()->getModifString().isEmpty()) {
-        writePtms(protic_peptide_hit.peptide_match->getPeptideXtpSp().get());
+    if (!protic_peptide_hit.peptide_match->getPeptideEvidence()->getPeptideXtpSp().get()->getModifString().isEmpty()) {
+        writePtms(protic_peptide_hit.peptide_match->getPeptideEvidence()->getPeptideXtpSp().get());
     }
     _output_stream->writeEndElement();// pepSeq
     _output_stream->writeEndElement();// peptideHit
@@ -566,13 +566,13 @@ void ProticdbMl::writeMatchs(IdentificationGroup * p_identification) {
 }
 
 const QString & ProticdbMl::getPeptideXmlId(const PeptideMatch* p_peptide_match) const {
-    QString peptide_key = getProticPeptideHitKey(p_peptide_match);
+    QString peptide_key = getProticPeptideHitKey(p_peptide_match->getPeptideEvidence());
     auto it = _peptidekey_to_id.find(peptide_key);
     if (it == _peptidekey_to_id.end()) {
         throw pappso::PappsoException(QObject::tr("Error peptide key %1 not found for peptide match %2 sample=%3 scan=%4 start=%5").arg(peptide_key)
-	.arg(p_peptide_match->getPeptideXtpSp().get()->toString())
-	.arg(p_peptide_match->getMsRunP()->getXmlId())
-	  .arg(p_peptide_match->getScan())
+	.arg(p_peptide_match->getPeptideEvidence()->getPeptideXtpSp().get()->toString())
+	.arg(p_peptide_match->getPeptideEvidence()->getMsRunP()->getXmlId())
+	  .arg(p_peptide_match->getPeptideEvidence()->getScan())
 	  .arg(p_peptide_match->getStart())
 	);
     }
@@ -596,8 +596,8 @@ void ProticdbMl::writeMatch(std::vector<const ProteinMatch *> & protein_match_sg
 
         // samples
         QStringList sample_name_list;
-        for (const PeptideMatch * p_peptide_match: protein_match_sg_list[0]->getPeptideMatchList(ValidationState::grouped)) {
-            sample_name_list << p_peptide_match->getMsRunP()->getSampleName();
+        for (const PeptideMatch & peptide_match: protein_match_sg_list[0]->getPeptideMatchList(ValidationState::grouped)) {
+            sample_name_list << peptide_match.getPeptideEvidence()->getMsRunP()->getSampleName();
         }
         sample_name_list = sample_name_list.toSet().toList();
         for (QString sample_name :sample_name_list) {
@@ -642,9 +642,9 @@ void ProticdbMl::writeMatch(std::vector<const ProteinMatch *> & protein_match_sg
 
         for (const ProteinMatch * p_protein_match: protein_match_sg_list) {
             //peptides
-            for (const PeptideMatch * p_peptide_match: p_protein_match->getPeptideMatchList(ValidationState::grouped)) {
+            for (const PeptideMatch & peptide_match: p_protein_match->getPeptideMatchList(ValidationState::grouped)) {
                 // peptidesHitRef
-                QString peptide_xml_id = getPeptideXmlId(p_peptide_match);
+                QString peptide_xml_id = getPeptideXmlId(&peptide_match);
 
                 _output_stream->writeStartElement("peptideHitRef");
                 _output_stream->writeAttribute("peptide_hit_id", peptide_xml_id);
@@ -652,16 +652,16 @@ void ProticdbMl::writeMatch(std::vector<const ProteinMatch *> & protein_match_sg
                 _output_stream->writeStartElement("fromSeq");
                 _output_stream->writeAttribute(
                     "seq_id", getProteinXmlId(p_protein_match));
-                _output_stream->writeAttribute("start", QString("%1").arg(p_peptide_match->getStart()+1));
-                _output_stream->writeAttribute("stop", QString("%1").arg(p_peptide_match->getStop()+1));
+                _output_stream->writeAttribute("start", QString("%1").arg(peptide_match.getStart()+1));
+                _output_stream->writeAttribute("stop", QString("%1").arg(peptide_match.getStop()+1));
                 QString residue_before_nter = "-";
-                if (p_peptide_match->getStart() > 0) {
-                    residue_before_nter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(p_peptide_match->getStart()-1,1);
+                if (peptide_match.getStart() > 0) {
+                    residue_before_nter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(peptide_match.getStart()-1,1);
                 }
                 _output_stream->writeAttribute("residue_before_nter", residue_before_nter);
                 QString residue_after_cter = "-";
-                if (p_peptide_match->getStop() < (p_protein_match->getProteinXtpSp().get()->getSequence().size()-1)) {
-                    residue_after_cter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(p_peptide_match->getStop(),1);
+                if (peptide_match.getStop() < (p_protein_match->getProteinXtpSp().get()->getSequence().size()-1)) {
+                    residue_after_cter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(peptide_match.getStop(),1);
                 }
                 _output_stream->writeAttribute("residue_after_cter", residue_after_cter);
 
diff --git a/src/output/xpip.cpp b/src/output/xpip.cpp
index ab80b93f8..1d1edf391 100644
--- a/src/output/xpip.cpp
+++ b/src/output/xpip.cpp
@@ -396,8 +396,8 @@ void Xpip::writeIdentificationGroup(const IdentificationGroup * p_identification
         else {
             _output_stream->writeAttribute("checked","false");
         }
-        for (const PeptideMatch * p_peptide_match : p_protein_match->getPeptideMatchList()) {
-            writePeptideMatch(p_peptide_match);
+        for (const PeptideMatch & peptide_match : p_protein_match->getPeptideMatchList()) {
+            writePeptideMatch(peptide_match);
         }
         _output_stream->writeEndElement();// protein_match
     }
@@ -406,27 +406,27 @@ void Xpip::writeIdentificationGroup(const IdentificationGroup * p_identification
     qDebug() << "Xpip::writeIdentificationGroup end";
 }
 
-void Xpip::writePeptideMatch(const PeptideMatch * p_peptide_match) {
+void Xpip::writePeptideMatch(const PeptideMatch & peptide_match) {
     qDebug() << "Xpip::writePeptideMatch begin";
     _output_stream->writeStartElement("peptide_match");
-    _output_stream->writeAttribute("source_id",p_peptide_match->getIdentificationDataSource()->getXmlId());
+    _output_stream->writeAttribute("source_id",peptide_match.getPeptideEvidence()->getIdentificationDataSource()->getXmlId());
     //_output_stream->writeAttribute("ms_id",p_peptide_match->getMsRunP()->getXmlId());
-    _output_stream->writeAttribute("peptide_id",_map_peptides.at( p_peptide_match->getPeptideXtpSp().get()));
-    _output_stream->writeAttribute("scan",QString("%1").arg(p_peptide_match->getScan()));
-    writeDoubleAttribute("rt",p_peptide_match->getRetentionTime());
-    writeDoubleAttribute("evalue",p_peptide_match->getEvalue());
-    writeDoubleAttribute("exp_mass",p_peptide_match->getExperimentalMass());
-    _output_stream->writeAttribute("start",QString("%1").arg(p_peptide_match->getStart()));
-    _output_stream->writeAttribute("charge",QString("%1").arg(p_peptide_match->getCharge()));
-
-    if (p_peptide_match->isChecked()) {
+    _output_stream->writeAttribute("peptide_id",_map_peptides.at( peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()));
+    _output_stream->writeAttribute("scan",QString("%1").arg(peptide_match.getPeptideEvidence()->getScan()));
+    writeDoubleAttribute("rt",peptide_match.getPeptideEvidence()->getRetentionTime());
+    writeDoubleAttribute("evalue",peptide_match.getPeptideEvidence()->getEvalue());
+    writeDoubleAttribute("exp_mass",peptide_match.getPeptideEvidence()->getExperimentalMass());
+    _output_stream->writeAttribute("start",QString("%1").arg(peptide_match.getStart()));
+    _output_stream->writeAttribute("charge",QString("%1").arg(peptide_match.getPeptideEvidence()->getCharge()));
+
+    if (peptide_match.getPeptideEvidence()->isChecked()) {
         _output_stream->writeAttribute("checked","true");
     }
     else {
         _output_stream->writeAttribute("checked","false");
     }
 
-    const std::map<PeptideMatchParam, QVariant> & params = p_peptide_match->getParamList();
+    const std::map<PeptideMatchParam, QVariant> & params = peptide_match.getPeptideEvidence()->getParamList();
 
     //if (params.size() > 0) {
     //   _output_stream->writeStartElement("stats");
diff --git a/src/output/xpip.h b/src/output/xpip.h
index 6e0a37287..169719c9b 100644
--- a/src/output/xpip.h
+++ b/src/output/xpip.h
@@ -61,7 +61,7 @@ private :
     void writeIdentificationGroup(const IdentificationGroup * p_identification_group);
     void dedupPeptideMatch(const IdentificationGroup * p_identification_group);
     void writeUniquePeptideMatch(const IdentificationGroup * p_identification_group);
-    void writePeptideMatch(const PeptideMatch * p_peptide_match);
+    void writePeptideMatch(const PeptideMatch & peptide_match);
 
     QString getPeptideId(std::size_t crc_peptide) const;
 
-- 
GitLab