From f0100c37a2579dd1e0812ed4ec757f6f0c0b2b51 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Thu, 20 Apr 2017 13:46:42 +0200 Subject: [PATCH] check psimod compliance --- src/core/project.cpp | 4 +++- src/core/project.h | 4 ++++ src/gui/mainwindow.cpp | 20 +++++++++++--------- src/utils/peptidestore.cpp | 14 +++++++++++++- src/utils/peptidestore.h | 4 ++++ 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/core/project.cpp b/src/core/project.cpp index ad3de8ff1..e21a90c2c 100644 --- a/src/core/project.cpp +++ b/src/core/project.cpp @@ -39,7 +39,9 @@ Project::~Project() } } - +bool Project::checkPsimodCompliance() const { + return _peptide_store.checkPsimodCompliance(); +} void Project::readResultFile(QString filename) { IdentificationDataSourceSp ident_source = _identification_data_source_store.getInstance(filename); diff --git a/src/core/project.h b/src/core/project.h index ead40c37e..544de7dc9 100644 --- a/src/core/project.h +++ b/src/core/project.h @@ -65,6 +65,10 @@ public: void setCombineMode(bool is_combine_mode); bool isCombineMode() const; void readResultFile(QString filename); + + /** @brief check that modifications are coded with PSI MOD accessions + */ + bool checkPsimodCompliance() const; private : bool _is_combine_mode =true; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 43a3fab5c..1068cfe0a 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -179,11 +179,11 @@ void MainWindow::doAcceptedExportSpreadsheetDialog() { } settings.setValue("path/export_ods", QFileInfo(filename).absolutePath()); - + OdsDocWriter writer(filename); OdsExport export_ods(_project_sp.get()); export_ods.write(&writer); - + writer.close(); //emit operateXpipFile(filename); } @@ -222,7 +222,7 @@ void MainWindow::doProjectReady(ProjectSp project_sp) { viewError(tr("Error while grouping :\n%1").arg(error.qwhat())); } _project_window->setProjectSp(project_sp); -ui->menu_export_files->setDisabled(false); + ui->menu_export_files->setDisabled(false); qDebug() << "MainWindow::doProjectReady end"; } @@ -259,22 +259,24 @@ void MainWindow::selectXpipFile() { } - void MainWindow::doActionSpreadsheet() { +void MainWindow::doActionSpreadsheet() { qDebug() << "MainWindow::doActionSpreadsheet begin"; try { - - _p_export_spreadsheet_dialog->show(); - _p_export_spreadsheet_dialog->raise(); - _p_export_spreadsheet_dialog->activateWindow(); + + _p_export_spreadsheet_dialog->show(); + _p_export_spreadsheet_dialog->raise(); + _p_export_spreadsheet_dialog->activateWindow(); } catch (pappso::PappsoException & error) { viewError(tr("Error doActionSpreadsheet :\n%1").arg(error.qwhat())); } qDebug() << "MainWindow::doActionSpreadsheet end"; - } +} void MainWindow::doActionMassChroQ() { qDebug() << "MainWindow::doActionMassChroQ begin"; try { + _project_sp.get()->checkPsimodCompliance(); + QSettings settings; QString default_location = settings.value("path/mcqfile", "").toString(); diff --git a/src/utils/peptidestore.cpp b/src/utils/peptidestore.cpp index 1fe1dcf1a..f1bd04adb 100644 --- a/src/utils/peptidestore.cpp +++ b/src/utils/peptidestore.cpp @@ -29,6 +29,7 @@ #include "peptidestore.h" #include <pappsomspp/amino_acid/Aa.h> +#include <pappsomspp/pappsoexception.h> PeptideStore::PeptideStore() { @@ -52,9 +53,20 @@ PeptideXtpSp & PeptideStore::getInstance(PeptideXtpSp & peptide_in) { for (auto && aa : *(ret.first->second.get())) { std::list<pappso::AaModificationP> mod_list = aa.getModificationList(); - _modification_collection.insert(mod_list.begin(), mod_list.end()); + _modification_collection.insert(mod_list.begin(), mod_list.end()); } } return ret.first->second; } + +bool PeptideStore::checkPsimodCompliance() const { + for (pappso::AaModificationP modification :_modification_collection) { + if (modification->getAccession().startsWith("MOD:")) { + } + else { + throw pappso::PappsoException(QObject::tr("Modification %1 is not a PSIMOD accession").arg(modification->getAccession())); + } + } + return true; +} diff --git a/src/utils/peptidestore.h b/src/utils/peptidestore.h index 1d5d9de2e..5221b31a4 100644 --- a/src/utils/peptidestore.h +++ b/src/utils/peptidestore.h @@ -41,6 +41,10 @@ public: ~PeptideStore(); PeptideXtpSp & getInstance(PeptideXtpSp & peptide_in); + + /** @brief check that modifications are coded with PSI MOD accessions + */ + bool checkPsimodCompliance() const; private : -- GitLab