/******************************************************************************* * Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>. * * This file is part of XTPcpp. * * XTPcpp is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * XTPcpp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XTPcpp. If not, see <http://www.gnu.org/licenses/>. * * Contributors: * Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation ******************************************************************************/ #include "proteinwindow.h" #include "../project_view/projectwindow.h" #include "ui_protein_detail_view.h" #include <pappsomspp/pappsoexception.h> #include <QMessageBox> #include <cmath> ProteinWindow::ProteinWindow(ProjectWindow *parent): QMainWindow(parent), ui(new Ui::ProteinDetailView) { _p_project_window = parent; ui->setupUi(this); /* */ #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_project_window, SIGNAL(identificationGroupGrouped(IdentificationGroup *)), this,SLOT(doIdentificationGroupGrouped(IdentificationGroup *))); connect (_p_project_window, SIGNAL(peptideMatchSelected(PeptideMatch*)), this,SLOT(doPeptideMatchSelected(PeptideMatch*))); //connect(_protein_table_model_p, SIGNAL(layoutChanged()), this, SLOT(updateStatusBar())); #endif } ProteinWindow::~ProteinWindow() { delete ui; } void ProteinWindow::doIdentificationGroupGrouped(IdentificationGroup * p_identification_group) { updateDisplay(); } void ProteinWindow::doPeptideMatchSelected(PeptideMatch * peptide_match) { if (_p_protein_match != nullptr) { ui->sequenceTextEdit->setText(_p_protein_match->getHtmlSequence(peptide_match)); } } void ProteinWindow::updateDisplay() { try { ui->validCheckBox->setCheckState(Qt::Unchecked); if (_p_protein_match->isValid()) ui->validCheckBox->setCheckState(Qt::Checked); ui->accession_label->setText(_p_protein_match->getProteinXtpSp().get()->getAccession()); ui->description_label->setText(_p_protein_match->getProteinXtpSp().get()->getDescription()); 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()))); } catch (pappso::PappsoException exception_pappso) { QMessageBox::warning(this, tr("Unable to display protein details :"), exception_pappso.qwhat()); } catch (std::exception exception_std) { 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(); }