From 4af832a3aa752b2181fb4d3d3110cb9f464edd10 Mon Sep 17 00:00:00 2001 From: Olivier Langella <Olivier.Langella@moulon.inra.fr> Date: Sat, 1 Apr 2017 11:46:45 +0200 Subject: [PATCH] windows connection OK --- src/core/identificationgroup.cpp | 2 + src/core/proteinmatch.cpp | 4 +- .../peptide_list_view/peptidelistwindow.cpp | 16 ++- src/gui/peptide_list_view/peptidelistwindow.h | 2 +- .../peptide_list_view/peptidetablemodel.cpp | 3 +- src/gui/peptide_list_view/peptidetablemodel.h | 3 +- src/gui/project_view/projectwindow.cpp | 102 ++++++++---------- src/gui/project_view/projectwindow.h | 2 +- .../protein_list_view/proteinlistwindow.cpp | 4 +- src/gui/protein_view/proteinwindow.cpp | 26 +++-- src/gui/protein_view/proteinwindow.h | 9 ++ 11 files changed, 96 insertions(+), 77 deletions(-) diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index 4ccd2196..790e6ddb 100644 --- a/src/core/identificationgroup.cpp +++ b/src/core/identificationgroup.cpp @@ -102,6 +102,7 @@ std::size_t IdentificationGroup::countSubGroup()const { void IdentificationGroup::startGrouping (const GroupingType & grouping_type) { + qDebug() << "IdentificationGroup::startGrouping begin "; if (_p_grp_experiment != nullptr) { delete _p_grp_experiment; } @@ -116,4 +117,5 @@ void IdentificationGroup::startGrouping (const GroupingType & grouping_type) { p_protein_match->setGroupInstance(_group_store); } + qDebug() << "IdentificationGroup::startGrouping end "; } diff --git a/src/core/proteinmatch.cpp b/src/core/proteinmatch.cpp index 0b046a4c..e00020a3 100644 --- a/src/core/proteinmatch.cpp +++ b/src/core/proteinmatch.cpp @@ -228,7 +228,7 @@ pappso::pappso_double ProteinMatch::getEvalue(const pappso::MsRunIdSp & sp_msrun if (p_peptide_match->getMsRunIdSp().get() == sp_msrun_id.get()) { auto ret = map_sequence_evalue.insert(std::pair<QString, pappso::pappso_double>(sequence, evalue)); if (ret.second == false) { - if (ret.first->second < evalue) {//get best evalue for sequence + if (ret.first->second > evalue) {//get best evalue for sequence ret.first->second = evalue; } } @@ -238,7 +238,7 @@ pappso::pappso_double ProteinMatch::getEvalue(const pappso::MsRunIdSp & sp_msrun //overall samples auto ret = map_sequence_evalue.insert(std::pair<QString, pappso::pappso_double>(sequence, evalue)); if (ret.second == false) { - if (ret.first->second < evalue) {//get best evalue for sequence + if (ret.first->second > evalue) {//get best evalue for sequence ret.first->second = evalue; } } diff --git a/src/gui/peptide_list_view/peptidelistwindow.cpp b/src/gui/peptide_list_view/peptidelistwindow.cpp index 02b92956..ed693ec9 100644 --- a/src/gui/peptide_list_view/peptidelistwindow.cpp +++ b/src/gui/peptide_list_view/peptidelistwindow.cpp @@ -45,8 +45,8 @@ PeptideListWindow::PeptideListWindow(ProjectWindow *parent): ui->tableView->setSortingEnabled(true); //connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); - - + + #if QT_VERSION >= 0x050000 // Qt5 code /* @@ -56,7 +56,12 @@ PeptideListWindow::PeptideListWindow(ProjectWindow *parent): */ #else // Qt4 code -connect (this, SIGNAL(peptideDataChanged()), _peptide_table_model_p, SLOT(onPeptideDataChanged())); + connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + + connect (this, SIGNAL(peptideDataChanged()), _peptide_table_model_p, SLOT(onPeptideDataChanged())); + + connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); + /* connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater())); connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString))); @@ -79,10 +84,11 @@ PeptideListWindow::~PeptideListWindow() void PeptideListWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { } -void PeptideListWindow::setProteinMatch(Project * p_project, ProteinMatch * p_protein_match) { +void PeptideListWindow::setProteinMatch(IdentificationGroup * p_identification_group, ProteinMatch * p_protein_match) { if (_p_protein_match != p_protein_match) { + _p_identification_group = p_identification_group; _p_protein_match = p_protein_match; - _peptide_table_model_p->setProteinMatch(p_project, p_protein_match); + _peptide_table_model_p->setProteinMatch( p_protein_match); _p_proxy_model->setSourceModel(_peptide_table_model_p); ui->proteinLabel->setText(p_protein_match->getProteinXtpSp().get()->getDescription()); } diff --git a/src/gui/peptide_list_view/peptidelistwindow.h b/src/gui/peptide_list_view/peptidelistwindow.h index d9448541..b788acd4 100644 --- a/src/gui/peptide_list_view/peptidelistwindow.h +++ b/src/gui/peptide_list_view/peptidelistwindow.h @@ -46,7 +46,7 @@ public: explicit PeptideListWindow(ProjectWindow * parent = 0); ~PeptideListWindow(); - void setProteinMatch(Project * p_project, ProteinMatch * p_protein_match); + void setProteinMatch(IdentificationGroup * p_identification_group, ProteinMatch * p_protein_match); void edited(); public slots: diff --git a/src/gui/peptide_list_view/peptidetablemodel.cpp b/src/gui/peptide_list_view/peptidetablemodel.cpp index c29eaf64..27d9e3d4 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.cpp +++ b/src/gui/peptide_list_view/peptidetablemodel.cpp @@ -39,9 +39,8 @@ PeptideTableModel::PeptideTableModel(QObject *parent) } -void PeptideTableModel::setProteinMatch(Project * p_project, ProteinMatch * p_protein_match) { +void PeptideTableModel::setProteinMatch(ProteinMatch * p_protein_match) { qDebug() << "PeptideTableModel::setProteinMatch begin " ; - _p_project = p_project; _p_protein_match = p_protein_match; QModelIndex topLeft = createIndex(0,0); diff --git a/src/gui/peptide_list_view/peptidetablemodel.h b/src/gui/peptide_list_view/peptidetablemodel.h index 78514420..8cd24552 100644 --- a/src/gui/peptide_list_view/peptidetablemodel.h +++ b/src/gui/peptide_list_view/peptidetablemodel.h @@ -39,7 +39,7 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - void setProteinMatch(Project * p_project, ProteinMatch * p_protein_match); + void setProteinMatch(ProteinMatch * p_protein_match); ProteinMatch * getProteinMatch(); signals: void peptideMatchClicked(PeptideMatch * p_peptide_match); @@ -50,7 +50,6 @@ public slots: void onTableClicked(const QModelIndex &index); private : - Project * _p_project; ProteinMatch * _p_protein_match= nullptr; }; diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index b754827d..45d9fa46 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -28,6 +28,8 @@ #include "gui/protein_list_view/proteinlistwindow.h" #include <QDebug> #include <QApplication> +#include <QMessageBox> +#include <pappsomspp/pappsoexception.h> ProjectWindow::ProjectWindow(MainWindow *parent): @@ -74,20 +76,6 @@ void ProjectWindow::connectNewProteinListWindow() { _p_current_protein_list_window = new ProteinListWindow(this); _protein_list_window_collection.push_back(_p_current_protein_list_window); -#if QT_VERSION >= 0x050000 - // Qt5 code - /* - connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater); - connect(this, &PtSpectrumViewer::operateMsDataFile, worker, &PwizLoaderThread::doMsDataFileLoad); - connect(worker, &PwizLoaderThread::msDataReady, this, &PtSpectrumViewer::handleMsDataFile); - */ -#else -// Qt4 code -//connect (_p_current_protein_list_window, SIGNAL(proteinMatchDoubleClicked(ProteinMatch *)), this,SLOT(doViewProteinDetail(ProteinMatch *))); - connect (this, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), _p_current_protein_list_window,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - -#endif - qDebug() << "ProjectWindow::connectNewProteinListWindow end"; } @@ -97,19 +85,6 @@ void ProjectWindow::connectNewProteinDetailWindow() { _p_current_protein_detail_window = new ProteinWindow(this); _protein_detail_window_collection.push_back(_p_current_protein_detail_window); -#if QT_VERSION >= 0x050000 - // Qt5 code - /* - connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater); - connect(this, &PtSpectrumViewer::operateMsDataFile, worker, &PwizLoaderThread::doMsDataFileLoad); - connect(worker, &PwizLoaderThread::msDataReady, this, &PtSpectrumViewer::handleMsDataFile); - */ -#else -// Qt4 code - //connect (_p_current_peptide_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this,SLOT(doViewPeptideList(ProteinMatch *))); - -#endif - qDebug() << "ProjectWindow::connectNewProteinDetailWindow end"; } @@ -119,47 +94,62 @@ void ProjectWindow::connectNewPeptideListWindow() { _p_current_peptide_list_window = new PeptideListWindow(this); _peptide_list_window_collection.push_back(_p_current_peptide_list_window); -#if QT_VERSION >= 0x050000 - // Qt5 code - /* - connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater); - connect(this, &PtSpectrumViewer::operateMsDataFile, worker, &PwizLoaderThread::doMsDataFileLoad); - connect(worker, &PwizLoaderThread::msDataReady, this, &PtSpectrumViewer::handleMsDataFile); - */ -#else -// Qt4 code - //connect (_p_current_peptide_list_window, SIGNAL(proteinMatchClicked(ProteinMatch *)), this,SLOT(doViewPeptideList(ProteinMatch *))); - //connect (_p_current_peptide_list_window, SIGNAL(identificationGroupEdited(IdentificationGroup *)), this,SLOT(doIdentificationGroupEdited(IdentificationGroup *))); - // connect (this, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), _p_current_peptide_list_window,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); - -#endif - qDebug() << "ProjectWindow::connectNewPeptideListWindow end"; } void ProjectWindow::refreshGroup(IdentificationGroup * p_ident_group) { qDebug() << "ProjectWindow::refreshGroup begin"; - vector< MsRunIdSp > ms_run_list = p_ident_group->getMsRunIdSpList(); - ui->sample_number_display->setText(QString("%1").arg(ms_run_list.size())); - - ui->group_number_display->setText(QString("%1").arg(p_ident_group->countGroup())); - ui->subgroup_number_display->setText(QString("%1").arg(p_ident_group->countSubGroup())); - ui->protein_number_display->setText(QString("%1").arg(p_ident_group->countGrouped())); - emit identificationGroupGrouped(p_ident_group); + if (p_ident_group == nullptr) { + qDebug() << "ProjectWindow::refreshGroup p_ident_group == nullptr"; + } + else { + try { + vector< MsRunIdSp > ms_run_list = p_ident_group->getMsRunIdSpList(); + ui->sample_number_display->setText(QString("%1").arg(ms_run_list.size())); + + ui->group_number_display->setText(QString("%1").arg(p_ident_group->countGroup())); + ui->subgroup_number_display->setText(QString("%1").arg(p_ident_group->countSubGroup())); + ui->protein_number_display->setText(QString("%1").arg(p_ident_group->countGrouped())); + emit identificationGroupGrouped(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::refreshGroup end"; } void ProjectWindow::doIdentificationGroupEdited(IdentificationGroup * p_ident_group) { - qDebug() << "ProjectWindow::doIdentificationGroupEdited begin"; - p_ident_group->startGrouping(_project_sp.get()->getGroupingType()); - - - refreshGroup(p_ident_group); + qDebug() << "ProjectWindow::doIdentificationGroupEdited begin " << p_ident_group; + if (p_ident_group == nullptr) { + qDebug() << "ProjectWindow::doIdentificationGroupEdited p_ident_group == nullptr"; + } + else { + try { + p_ident_group->startGrouping(_project_sp.get()->getGroupingType()); + + } + catch (pappso::PappsoException exception_pappso) { + QMessageBox::warning(this, + tr("Error grouping project :"), exception_pappso.qwhat()); + } + catch (std::exception exception_std) { + QMessageBox::warning(this, + tr("Error grouping project :"), exception_std.what()); + } + + refreshGroup(p_ident_group); + } qDebug() << "ProjectWindow::doIdentificationGroupEdited end"; } -void ProjectWindow::doViewPeptideList(ProteinMatch * protein_match) { +void ProjectWindow::doViewPeptideList(IdentificationGroup * p_ident_group, ProteinMatch * protein_match) { qDebug() << "ProjectWindow::doViewPeptideList begin"; @@ -172,7 +162,7 @@ void ProjectWindow::doViewPeptideList(ProteinMatch * protein_match) { } - _p_current_peptide_list_window->setProteinMatch(_project_sp.get(), protein_match); + _p_current_peptide_list_window->setProteinMatch(p_ident_group, protein_match); _p_current_peptide_list_window->show(); qDebug() << "ProjectWindow::doViewPeptideList end"; } diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h index bcf8ee97..c82caf7b 100644 --- a/src/gui/project_view/projectwindow.h +++ b/src/gui/project_view/projectwindow.h @@ -58,7 +58,7 @@ signals: //void peptideChanged(pappso::PeptideSp peptide); protected : - void doViewPeptideList(ProteinMatch * protein_match); + void doViewPeptideList(IdentificationGroup * p_ident_group, ProteinMatch * protein_match); void doViewProteinDetail(ProteinMatch * protein_match); void doViewPeptideDetail(PeptideMatch * peptide_match); void doIdentificationGroupEdited(IdentificationGroup * p_identification_group); diff --git a/src/gui/protein_list_view/proteinlistwindow.cpp b/src/gui/protein_list_view/proteinlistwindow.cpp index 1b313d2c..d58d8dfc 100644 --- a/src/gui/protein_list_view/proteinlistwindow.cpp +++ b/src/gui/protein_list_view/proteinlistwindow.cpp @@ -72,6 +72,8 @@ ProteinListWindow::ProteinListWindow(ProjectWindow *parent): */ #else // Qt4 code + connect (_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + connect (this, SIGNAL(proteinDataChanged()), _protein_table_model_p, SLOT(onProteinDataChanged())); connect(ui->tableView, SIGNAL(clicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableClicked(const QModelIndex &))); //connect(ui->tableView, SIGNAL(doubleClicked(const QModelIndex &)), _p_proxy_model, SLOT(onTableDoubleClicked(const QModelIndex &))); @@ -106,7 +108,7 @@ void ProteinListWindow::showAccessionColumn(bool show) { void ProteinListWindow::askPeptideListView(ProteinMatch * p_protein_match) { qDebug() << "ProteinListWindow::askPeptideListView begin"; - _project_window->doViewPeptideList(p_protein_match); + _project_window->doViewPeptideList(_p_identification_group, p_protein_match); qDebug() << "ProteinListWindow::askPeptideListView end"; //updateStatusBar(); } diff --git a/src/gui/protein_view/proteinwindow.cpp b/src/gui/protein_view/proteinwindow.cpp index 9fea5f2e..5dc6e5de 100644 --- a/src/gui/protein_view/proteinwindow.cpp +++ b/src/gui/protein_view/proteinwindow.cpp @@ -32,6 +32,7 @@ ProteinWindow::ProteinWindow(ProjectWindow *parent): QMainWindow(parent), ui(new Ui::ProteinDetailView) { + _p_project_window = parent; ui->setupUi(this); /* */ @@ -46,6 +47,8 @@ ProteinWindow::ProteinWindow(ProjectWindow *parent): */ #else // Qt4 code + connect (_p_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); + //connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar())); #endif } @@ -54,16 +57,19 @@ ProteinWindow::~ProteinWindow() { delete ui; } +void ProteinWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { + updateDisplay(); +} -void ProteinWindow::setProteinMatch(ProteinMatch * p_protein_match) { +void ProteinWindow::updateDisplay() { try { - ui->descriptionLabel->setText(p_protein_match->getProteinXtpSp().get()->getAccession()); - //ui->sequenceLabel->setText(p_protein_match->getProteinXtpSp().get()->getSequence()); - ui->sequenceTextEdit->setText(p_protein_match->getHtmlSequence()); - ui->coverage_label->setText(QString("%1 %").arg(p_protein_match->getCoverage()*100)); - pappso::Peptide peptide(p_protein_match->getProteinXtpSp().get()->getSequence()); + ui->descriptionLabel->setText(_p_protein_match->getProteinXtpSp().get()->getAccession()); + //ui->sequenceLabel->setText(_p_protein_match->getProteinXtpSp().get()->getSequence()); + ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence()); + ui->coverage_label->setText(QString("%1 %").arg(_p_protein_match->getCoverage()*100)); + pappso::Peptide peptide(_p_protein_match->getProteinXtpSp().get()->getSequence()); ui->mw_label->setText(QString("%1 kDa").arg(peptide.getMass()/1000)); - ui->evalue_label->setText(QString("%1 (log10: %2)").arg(p_protein_match->getEvalue()).arg(std::log10(p_protein_match->getEvalue()))); + ui->evalue_label->setText(QString("%1 (log10: %2)").arg(_p_protein_match->getEvalue()).arg(std::log10(_p_protein_match->getEvalue()))); } catch (pappso::PappsoException exception_pappso) { QMessageBox::warning(this, @@ -73,4 +79,10 @@ void ProteinWindow::setProteinMatch(ProteinMatch * p_protein_match) { QMessageBox::warning(this, tr("Unable to display protein details :"), exception_std.what()); } + +} + +void ProteinWindow::setProteinMatch(ProteinMatch * p_protein_match) { + _p_protein_match = p_protein_match; + updateDisplay(); } diff --git a/src/gui/protein_view/proteinwindow.h b/src/gui/protein_view/proteinwindow.h index f3c024c9..3dfeeda5 100644 --- a/src/gui/protein_view/proteinwindow.h +++ b/src/gui/protein_view/proteinwindow.h @@ -42,9 +42,18 @@ public: explicit ProteinWindow(ProjectWindow * parent = 0); ~ProteinWindow(); void setProteinMatch(ProteinMatch * p_protein_match); + +public slots: + void doIdentificationGroupGrouped(IdentificationGroup * p_identification_group); + +protected : + void updateDisplay(); + private: Ui::ProteinDetailView *ui; QTextDocument sequence_text; + ProjectWindow * _p_project_window; + ProteinMatch * _p_protein_match = nullptr; }; -- GitLab