From 6354d8b10388e8f1837ee692251d93d22611ad98 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Tue, 30 May 2017 17:02:53 +0200 Subject: [PATCH] first PTM island table ! --- src/core/identificationgroup.cpp | 4 +- src/core/identificationgroup.h | 2 + src/grouping/ptm/ptmgroupingexperiment.cpp | 2 +- src/grouping/ptm/ptmgroupingexperiment.h | 2 +- src/gui/project_view/projectwindow.cpp | 61 +++++++++++++++---- src/gui/project_view/projectwindow.h | 7 +++ .../ptmislandlistwindow.cpp | 31 ++++++++++ .../ptmislandlistwindow.h | 5 ++ .../ptmislandtablemodel.cpp | 45 +++++++++++--- .../ptmislandtablemodel.h | 9 ++- src/gui/workerthread.cpp | 27 ++++++++ src/gui/workerthread.h | 2 + 12 files changed, 171 insertions(+), 26 deletions(-) diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index 287f58151..da181d529 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -41,7 +41,9 @@ IdentificationGroup::~IdentificationGroup() } } - +const PtmGroupingExperiment * IdentificationGroup::getPtmGroupingExperiment() const { + return _p_grp_ptm_experiment; +} const GroupStore & IdentificationGroup::getGroupStore() const { return _group_store; } diff --git a/src/core/identificationgroup.h b/src/core/identificationgroup.h index 56ea6baa9..f6d112bfd 100644 --- a/src/core/identificationgroup.h +++ b/src/core/identificationgroup.h @@ -50,6 +50,8 @@ public: void addProteinMatch(ProteinMatch * protein_match); std::vector<ProteinMatch *> & getProteinMatchList(); void addIdentificationDataSourceP(IdentificationDataSource * p_identification_source); + + const PtmGroupingExperiment * getPtmGroupingExperiment() const; /** @brief count groups * */ diff --git a/src/grouping/ptm/ptmgroupingexperiment.cpp b/src/grouping/ptm/ptmgroupingexperiment.cpp index b43e6ff5c..cf62c0ed6 100644 --- a/src/grouping/ptm/ptmgroupingexperiment.cpp +++ b/src/grouping/ptm/ptmgroupingexperiment.cpp @@ -72,7 +72,7 @@ PtmGroupingExperiment::~PtmGroupingExperiment() } -const std::vector<PtmIslandSp> & PtmGroupingExperiment::getPtmIslandList() { +const std::vector<PtmIslandSp> & PtmGroupingExperiment::getPtmIslandList() const { return _ptm_island_list; } diff --git a/src/grouping/ptm/ptmgroupingexperiment.h b/src/grouping/ptm/ptmgroupingexperiment.h index b2f85f491..e51e27cba 100644 --- a/src/grouping/ptm/ptmgroupingexperiment.h +++ b/src/grouping/ptm/ptmgroupingexperiment.h @@ -46,7 +46,7 @@ public: void addProteinMatch(const ProteinMatch* p_protein_match); void startGrouping(); - const std::vector<PtmIslandSp> & getPtmIslandList(); + const std::vector<PtmIslandSp> & getPtmIslandList() const; private: std::vector<unsigned int> getPtmPositions(const ProteinMatch * protein_match) const; diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 7d4810a58..383d64802 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -107,6 +107,12 @@ void ProjectWindow::setDefaultProteinListWindow(ProteinListWindow* p_protein_lis qDebug() << "ProjectWindow::setDefaultProteinListWindow end"; } +void ProjectWindow::connectNewPtmIslandListWindow() { + qDebug() << "ProjectWindow::connectNewPtmIslandListWindow begin"; + _p_current_ptm_island_list_window = new PtmIslandListWindow(this); + _ptm_island_list_window_collection.push_back(_p_current_ptm_island_list_window); + qDebug() << "ProjectWindow::connectNewPtmIslandListWindow end"; +} void ProjectWindow::connectNewProteinListWindow() { qDebug() << "ProjectWindow::connectNewProteinListWindow begin"; _p_current_protein_list_window = new ProteinListWindow(this); @@ -141,6 +147,27 @@ void ProjectWindow::connectNewPeptideListWindow() { qDebug() << "ProjectWindow::connectNewPeptideListWindow end"; } +void ProjectWindow::refreshPtmGroup(IdentificationGroup * p_ident_group) { + qDebug() << "ProjectWindow::refreshPtmGroup begin"; + hideWaitingMessage(); + if (p_ident_group == nullptr) { + qDebug() << "ProjectWindow::refreshPtmGroup p_ident_group == nullptr"; + } + else { + try { + emit identificationPtmGroupGrouped(p_ident_group); + } + catch (pappso::PappsoException exception_pappso) { + QMessageBox::warning(this, + tr("Unable to display project :"), exception_pappso.qwhat()); + } + catch (std::exception exception_std) { + QMessageBox::warning(this, + tr("Unable to display project :"), exception_std.what()); + } + } + qDebug() << "ProjectWindow::refreshPtmGroup end"; +} void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) { qDebug() << "ProjectWindow::refreshGroup begin"; hideWaitingMessage(); @@ -281,7 +308,7 @@ void ProjectWindow::doGroupingFinished() { } refresh(); - + qDebug() << "ProjectWindow::doGroupingFinished end"; } @@ -358,23 +385,29 @@ void ProjectWindow::doViewPtmIslandList(IdentificationGroup* p_identification_gr qDebug() << "ProjectWindow::doViewPtmIslandList begin " << p_identification_group; //if (p_identification_group == nullptr) { //} - if (_protein_list_window_collection.size() == 0) { - connectNewProteinListWindow(); + if (_ptm_island_list_window_collection.size() == 0) { + connectNewPtmIslandListWindow(); } Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); if (modifier == Qt::ControlModifier) { - connectNewProteinListWindow(); + connectNewPtmIslandListWindow(); } - _p_current_protein_list_window->show(); + _p_current_ptm_island_list_window->show(); //_p_current_protein_list_window->raise(); //_p_current_protein_list_window->activateWindow(); qDebug() << "ProjectWindow::doViewPtmIslandList end " << p_identification_group; - _p_current_protein_list_window->setIdentificationGroup(p_identification_group); + _p_current_ptm_island_list_window->setIdentificationGroup(p_identification_group); - emit identificationGroupGrouped(p_identification_group); + + if (p_identification_group->getPtmGroupingExperiment() == nullptr) { + showWaitingMessage(tr("Computing PTM islands")); + emit operatePtmGroupingOnIdentification(p_identification_group); + } + + //emit identificationGroupGrouped(p_identification_group); qDebug() << "ProjectWindow::doViewPtmIslandList end"; } @@ -420,6 +453,12 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { item->setData(QVariant(QString("%1").arg(fasta_file.get()->getAbsoluteFilePath())),Qt::UserRole); } + for (auto && p_window :_ptm_island_list_window_collection) { + delete p_window; + } + _ptm_island_list_window_collection.clear(); + _p_current_ptm_island_list_window = nullptr; + for (auto && p_window :_peptide_list_window_collection) { delete p_window; @@ -450,8 +489,8 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { } std::vector<IdentificationGroup *> identification_list = _project_sp.get()->getIdentificationGroupList(); - - + + doViewProteinList(identification_list[0]); qDebug() << " ProjectWindow::setProjectSp size=" << identification_list.size(); if (identification_list.size() == 1) { @@ -485,8 +524,8 @@ void ProjectWindow::setProjectSp(ProjectSp project_sp) { refresh(); this->setEnabled(true); - - + + } diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h index 857760998..eebbaea80 100644 --- a/src/gui/project_view/projectwindow.h +++ b/src/gui/project_view/projectwindow.h @@ -32,6 +32,7 @@ #include "../edit_modifications/editmodifications.h" #include "../protein_list_view/proteinlistwindow.h" #include "../peptide_list_view/peptidelistwindow.h" +#include "../ptm_island_list_view/ptmislandlistwindow.h" #include "../protein_view/proteinwindow.h" #include "../peptide_detail_view/peptidewindow.h" #include "gui/project_view/automatic_filter_widget/automaticfilterwidget.h" @@ -70,13 +71,16 @@ public slots: void doGroupingFinished(); void doDisplayLoadingMessage(QString message); void refreshGroup(IdentificationGroup * p_ident_group); + void refreshPtmGroup(IdentificationGroup * p_ident_group); void doAcceptedLabelingMethod(); // 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 operateGrouping(ProjectSp project_sp); + void operatePtmGroupingOnIdentification(IdentificationGroup * p_identification_group); void operateGroupingOnIdentification(IdentificationGroup * p_identification_group, GroupingType grouping_type); //void peptideChanged(pappso::PeptideSp peptide); @@ -89,6 +93,7 @@ protected : void computeMassPrecision(); private : + void connectNewPtmIslandListWindow(); void connectNewProteinListWindow(); void connectNewPeptideListWindow(); void connectNewProteinDetailWindow(); @@ -113,6 +118,8 @@ private: ProteinWindow * _p_current_protein_detail_window = nullptr; std::list <PeptideWindow *> _peptide_detail_window_collection; PeptideWindow * _p_current_peptide_detail_window = nullptr; + std::list <PtmIslandListWindow *> _ptm_island_list_window_collection; + PtmIslandListWindow * _p_current_ptm_island_list_window = nullptr; EditModifications * _p_edit_modifications = nullptr; EditLabelMethods * _p_edit_label_methods = nullptr; diff --git a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp index 66fceaba7..b5135ac6c 100644 --- a/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp +++ b/src/gui/ptm_island_list_view/ptmislandlistwindow.cpp @@ -63,6 +63,10 @@ PtmIslandListWindow::PtmIslandListWindow(ProjectWindow *parent): */ #else // Qt4 code +connect (this, SIGNAL(ptmIslandDataChanged()), _ptm_table_model_p, SLOT(onPtmIslandDataChanged())); + + connect (_project_window, SIGNAL(identificationPtmGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationPtmGroupGrouped(IdentificationGroup *))); + #endif } @@ -72,4 +76,31 @@ PtmIslandListWindow::~PtmIslandListWindow() } void PtmIslandListWindow::setIdentificationGroup(IdentificationGroup * p_identification_group) { + + qDebug() << "PtmIslandListWindow::setIdentificationGroup begin " ; + if (p_identification_group != nullptr) { + qDebug() << "PtmIslandListWindow::setIdentificationGroup not null"; + _p_identification_group = p_identification_group; + _ptm_table_model_p->setIdentificationGroup(p_identification_group); + //_p_proxy_model->setSourceModel(_protein_table_model_p); + + + } + else { + qDebug() << "PtmIslandListWindow::setIdentificationGroup null"; + } + + qDebug() << "PtmIslandListWindow::setIdentificationGroup end"; +} + + +void PtmIslandListWindow::doIdentificationPtmGroupGrouped(IdentificationGroup * p_identification_group) { + qDebug() << "PtmIslandListWindow::doIdentificationPtmGroupGrouped begin"; + if (_p_identification_group == p_identification_group) { + //_protein_table_model_p->setIdentificationGroup(p_identification_group); + //_p_proxy_model->setSourceModel(_protein_table_model_p); + emit ptmIslandDataChanged(); + } + + qDebug() << "PtmIslandListWindow::doIdentificationPtmGroupGrouped end"; } diff --git a/src/gui/ptm_island_list_view/ptmislandlistwindow.h b/src/gui/ptm_island_list_view/ptmislandlistwindow.h index 6e30764bc..cba6b04e6 100644 --- a/src/gui/ptm_island_list_view/ptmislandlistwindow.h +++ b/src/gui/ptm_island_list_view/ptmislandlistwindow.h @@ -50,6 +50,11 @@ public: void setIdentificationGroup(IdentificationGroup * p_identification_group); +public slots: + void doIdentificationPtmGroupGrouped(IdentificationGroup * p_identification_group); + +signals: + void ptmIslandDataChanged(); private: IdentificationGroup * _p_identification_group=nullptr; diff --git a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp index d6026e5f7..bfd6082bf 100644 --- a/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp +++ b/src/gui/ptm_island_list_view/ptmislandtablemodel.cpp @@ -39,35 +39,39 @@ PtmIslandTableModel::~PtmIslandTableModel() { } -void PtmIslandTableModel::setPtmGroupingExperiment(PtmGroupingExperiment * p_grp_ptm_experiment) { - qDebug() << "PtmIslandTableModel::setPtmGroupingExperiment begin "; +void PtmIslandTableModel::setIdentificationGroup(IdentificationGroup * p_identification_group) { + qDebug() << "PtmIslandTableModel::setIdentificationGroup begin "; beginResetModel(); - _p_grp_ptm_experiment = p_grp_ptm_experiment; + _p_identification_group = p_identification_group; //emit headerDataChanged(Qt::Horizontal, 0,11); //refresh(); - qDebug() << "PtmIslandTableModel::setPtmGroupingExperiment end "; + qDebug() << "PtmIslandTableModel::setIdentificationGroup end "; endResetModel(); } - +const PtmGroupingExperiment * PtmIslandTableModel::getPtmGroupingExperiment() const { + if (_p_identification_group == nullptr) {return nullptr; + } + return _p_identification_group->getPtmGroupingExperiment(); +} int PtmIslandTableModel::rowCount(const QModelIndex &parent ) const { //qDebug() << "ProteinTableModel::rowCount begin "; - if (_p_grp_ptm_experiment != nullptr) { + if (getPtmGroupingExperiment() != nullptr) { //qDebug() << "ProteinTableModel::rowCount(const QModelIndex &parent ) " << _p_identification_group->getProteinMatchList().size(); - return (int) _p_grp_ptm_experiment->getPtmIslandList().size(); + return (int) getPtmGroupingExperiment()->getPtmIslandList().size(); } return 0; } int PtmIslandTableModel::columnCount(const QModelIndex &parent ) const { //qDebug() << "ProteinTableModel::columnCount begin "; - if (_p_grp_ptm_experiment != nullptr) { + if (getPtmGroupingExperiment() != nullptr) { return 3; } return 0; } QVariant PtmIslandTableModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (_p_grp_ptm_experiment == nullptr) return QVariant(); + if (getPtmGroupingExperiment() == nullptr) return QVariant(); if (orientation == Qt::Horizontal) { } @@ -75,8 +79,29 @@ QVariant PtmIslandTableModel::headerData(int section, Qt::Orientation orientatio } QVariant PtmIslandTableModel::data(const QModelIndex &index, int role ) const { // generate a log message when this method gets called - if (_p_grp_ptm_experiment == nullptr) return QVariant(); + if (getPtmGroupingExperiment() == nullptr) return QVariant(); int row = index.row(); int col = index.column(); + switch(role) { + case Qt::DisplayRole: + if (_p_identification_group == nullptr) { + return QVariant(); + } + switch (col) { + case 0: + return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->getGroupingId()); + break; + case 1: + return QVariant(getPtmGroupingExperiment()->getPtmIslandList().at(row).get()->getProteinMatch()->getProteinXtpSp().get()->getAccession()); + break; + } + } return QVariant(); } + + +void PtmIslandTableModel::onPtmIslandDataChanged() { + qDebug() << "PtmIslandTableModel::onPtmIslandDataChanged begin " << rowCount(); + emit layoutAboutToBeChanged(); + emit layoutChanged(); +} \ No newline at end of file diff --git a/src/gui/ptm_island_list_view/ptmislandtablemodel.h b/src/gui/ptm_island_list_view/ptmislandtablemodel.h index 523770d6e..11ee41c3e 100644 --- a/src/gui/ptm_island_list_view/ptmislandtablemodel.h +++ b/src/gui/ptm_island_list_view/ptmislandtablemodel.h @@ -31,6 +31,7 @@ #define PTMISLANDTABLEMODEL_H #include <QAbstractTableModel> +#include "../../core/identificationgroup.h" #include "../../grouping/ptm/ptmgroupingexperiment.h" class PtmIslandListWindow; @@ -42,14 +43,18 @@ public: ~PtmIslandTableModel(); - void setPtmGroupingExperiment(PtmGroupingExperiment * p_grp_ptm_experiment); + void setIdentificationGroup(IdentificationGroup * p_identification_group); virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; +public slots: + void onPtmIslandDataChanged(); private : - PtmGroupingExperiment * _p_grp_ptm_experiment=nullptr; + const PtmGroupingExperiment * getPtmGroupingExperiment() const; +private : + IdentificationGroup * _p_identification_group=nullptr; }; #endif // PTMISLANDTABLEMODEL_H diff --git a/src/gui/workerthread.cpp b/src/gui/workerthread.cpp index 083e52e0d..2ca0effa8 100644 --- a/src/gui/workerthread.cpp +++ b/src/gui/workerthread.cpp @@ -91,7 +91,12 @@ WorkerThread::WorkerThread(ProjectWindow * p_project_window) //grouping connect(p_project_window, SIGNAL(operateGrouping(ProjectSp)), this,SLOT(doGrouping(ProjectSp))); connect(this, SIGNAL(groupingFinished()), p_project_window,SLOT(doGroupingFinished())); + + //PTM grouping on IdentificationGroup + connect(p_project_window, SIGNAL(operatePtmGroupingOnIdentification(IdentificationGroup *)), this,SLOT(doPtmGroupingOnIdentification(IdentificationGroup *))); + connect(this, SIGNAL(ptmGroupingOnIdentificationFinished(IdentificationGroup *)), p_project_window,SLOT(refreshPtmGroup(IdentificationGroup *))); + //grouping on IdentificationGroup connect(p_project_window, SIGNAL(operateGroupingOnIdentification(IdentificationGroup *, GroupingType)), this,SLOT(doGroupingOnIdentification(IdentificationGroup *, GroupingType))); connect(this, SIGNAL(groupingOnIdentificationFinished(IdentificationGroup *)), p_project_window,SLOT(refreshGroup(IdentificationGroup *))); @@ -128,6 +133,28 @@ void WorkerThread::doXpipFileLoad(QString filename) { qDebug() << "WorkerThread::doXpipFileLoad end"; } +void WorkerThread::doPtmGroupingOnIdentification(IdentificationGroup * p_identification_group) { + qDebug() << "WorkerThread::doPtmGroupingOnIdentification begin "; + try { + emit loadingMessage(tr("computing PTM islands")); + try { + p_identification_group->startPtmGrouping(); + + } + catch (pappso::PappsoException exception_pappso) { + emit operationFailed(tr("Error computing PTM islands : %1").arg(exception_pappso.qwhat())); + } + catch (std::exception exception_std) { + emit operationFailed(tr("Error computing PTM islands : %1").arg(exception_std.what())); + } + emit loadingMessage(tr("computing PTM islands finished")); + emit ptmGroupingOnIdentificationFinished(p_identification_group); + } + catch (pappso::PappsoException & error) { + emit operationFailed(tr("Error while computing PTM islands :\n%1").arg(error.qwhat())); + } + qDebug() << "WorkerThread::doPtmGroupingOnIdentification end "; +} void WorkerThread::doGroupingOnIdentification(IdentificationGroup * p_identification_group, GroupingType grouping_type) { qDebug() << "WorkerThread::doGroupingOnIdentification begin "; diff --git a/src/gui/workerthread.h b/src/gui/workerthread.h index 6cf0c3c9e..7ebca7552 100644 --- a/src/gui/workerthread.h +++ b/src/gui/workerthread.h @@ -61,6 +61,7 @@ public slots: void doWritingProticFile(QString filename, ProjectSp project_sp); void doGrouping(ProjectSp project_sp); void doGroupingOnIdentification(IdentificationGroup * p_identification_group, GroupingType grouping_type); + void doPtmGroupingOnIdentification(IdentificationGroup * p_identification_group); signals: @@ -69,6 +70,7 @@ signals: void projectNotReady(QString error); void groupingFinished(); void groupingOnIdentificationFinished(IdentificationGroup * p_identification_group); + void ptmGroupingOnIdentificationFinished(IdentificationGroup * p_identification_group); void operationFinished(); void operationFailed(QString error); }; -- GitLab