diff --git a/src/core/identificationgroup.cpp b/src/core/identificationgroup.cpp index 4ccd2196345abad23535c73f7d38f1e962a74b7d..790e6ddb18acfe5d582e3618b1e7046d5ac0e087 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 0b046a4c658b1cc9bc164998ef2c87c5e989435f..e00020a32482f2fa526f5f43f5abdd7206ee2429 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 02b9295664e487734b1ec6837c2cf18cc8476495..ed693ec9ca72e1312ea15e5b77ef4f8ec42d1705 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 d944854174aa95f1fc319775a70b55c233a7d242..b788acd4a7dc53dfd5ba8cea8f71e779d8f883c4 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 c29eaf643a72b25357695d8908dbb76c0c37f11d..27d9e3d4aa5742ac25a02a76a655ba8f75e372d2 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 78514420a4930a848a764574f493d4cb1b290a40..8cd2455286e2c86bf14ed847491db8444910033d 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 b754827d11f7c1070c6ea01a0567e9c81d3b3856..45d9fa46923a124dabd537f5aa68d016e449bb0a 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 bcf8ee97f5f1ba6a03e962fcbe65326eec930c33..c82caf7bc90824a5ea15a3ac2a85e410ca6d61f3 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 1b313d2cae58caf1d521fa519cea51917d331089..d58d8dfc21017809493b8ec3835ac428727e26f4 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 9fea5f2e0fe5f2afaf1fe97cb8a131a04f883b32..5dc6e5de5e81cbf596957983a5ae8b3721ade665 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 f3c024c93f900c2b3010be02e182ccd0ede6089a..3dfeeda52ab5bdd0cd2edca889986687e70b2d2d 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; };