From 3cfeb9e42deef817672b1f0a191321f238b6bdfc Mon Sep 17 00:00:00 2001 From: Olivier Langella <olivier.langella@u-psud.fr> Date: Fri, 12 Jan 2018 16:47:42 +0100 Subject: [PATCH] xic box infrastructure --- src/CMakeLists.txt | 9 +- src/gui/peptide_detail_view/peptidewindow.cpp | 10 --- src/gui/project_view/projectwindow.cpp | 2 + src/gui/xic_view/xic_box/xic_box.ui | 47 ++++++++++ src/gui/xic_view/xic_box/xicbox.cpp | 85 +++++++++++++++++++ src/gui/xic_view/xic_box/xicbox.h | 65 ++++++++++++++ src/gui/xic_view/xicwindow.cpp | 15 +++- src/gui/xic_view/xicwindow.h | 29 +++---- src/gui/xic_view/xicworkerthread.cpp | 46 ++++++++++ src/gui/xic_view/xicworkerthread.h | 49 +++++++++++ src/main.cpp | 6 ++ src/utils/readspectrum.cpp | 8 +- src/utils/readspectrum.h | 2 +- src/utils/types.h | 6 +- 14 files changed, 339 insertions(+), 40 deletions(-) create mode 100644 src/gui/xic_view/xic_box/xic_box.ui create mode 100644 src/gui/xic_view/xic_box/xicbox.cpp create mode 100644 src/gui/xic_view/xic_box/xicbox.h create mode 100644 src/gui/xic_view/xicworkerthread.cpp create mode 100644 src/gui/xic_view/xicworkerthread.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eab1a55a0..159b03b3f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,8 +28,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5 #sudo apt-get install libpappsomspp-dev #FIND_PACKAGE( Pappsomspp REQUIRED ) - SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") -# SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") +# SET (PAPPSOMSPP_DIR "/home/olivier/eclipse/git/pappsomspp") + SET (PAPPSOMSPP_DIR "/home/langella/developpement/git/pappsomspp") SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src") SET (PAPPSOMSPP_QT5_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt5.so") SET (PAPPSOMSPP_WIDGET_QT5_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/pappsomspp/widget/libpappsomspp-widget-qt5.so") @@ -158,7 +158,9 @@ SET(XTPCPP_SRCS ./gui/ptm_peptide_list_view/ptmsequencedelegate.cpp ./gui/tandem_run_dialog/tandemrundialog.cpp ./gui/waiting_message_dialog/waitingmessagedialog.cpp + ./gui/xic_view/xic_box/xicbox.cpp ./gui/xic_view/xicwindow.cpp + ./gui/xic_view/xicworkerthread.cpp ./gui/workerthread.cpp ./utils/workmonitor.cpp ) @@ -183,6 +185,7 @@ SET (GUI_UIS ./gui/ptm_peptide_list_view/ptm_peptide_list_view.ui ./gui/tandem_run_dialog/tandem_run_dialog.ui ./gui/waiting_message_dialog/waiting_message_dialog.ui + ./gui/xic_view/xic_box/xic_box.ui ./gui/xic_view/xic_window.ui ) @@ -215,7 +218,9 @@ SET(XTPCPP_MOC_HDRS ./gui/ptm_peptide_list_view/ptmsequencedelegate.h ./gui/tandem_run_dialog/tandemrundialog.h ./gui/waiting_message_dialog/waitingmessagedialog.h + ./gui/xic_view/xic_box/xicbox.h ./gui/xic_view/xicwindow.h + ./gui/xic_view/xicworkerthread.h ./gui/workerthread.h ./utils/workmonitor.h ) diff --git a/src/gui/peptide_detail_view/peptidewindow.cpp b/src/gui/peptide_detail_view/peptidewindow.cpp index 01bd32985..e1631ddab 100644 --- a/src/gui/peptide_detail_view/peptidewindow.cpp +++ b/src/gui/peptide_detail_view/peptidewindow.cpp @@ -239,16 +239,6 @@ void PeptideWindow::doSpectrumSpReady(pappso::SpectrumSp spectrum_sp, QString er ui->spectrum_widget->rescale(); _spectrum_is_ready = true; - - try { - pappso::MassRange mass_range(_p_peptide_evidence->getPeptideXtpSp().get()->getMz(_p_peptide_evidence->getCharge()), pappso::Precision::getPpmInstance(10)); - - pappso::XicSp xic_sp = SpectrumStore::getXicSpFromMsRunSp(_p_peptide_evidence->getMsRunP(), mass_range, XixExtactMethod::max); - } - catch (pappso::PappsoException & error) { - QMessageBox::warning(this, - tr("Error trying to save spectrum to SVG file :"), error.qwhat()); - } } if (!error.isEmpty()) { //not found diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp index 134f16d82..e8c1f891c 100644 --- a/src/gui/project_view/projectwindow.cpp +++ b/src/gui/project_view/projectwindow.cpp @@ -770,5 +770,7 @@ void ProjectWindow::openInXicViewer(const PeptideEvidence * p_peptide_evidence) } _p_xic_window->show(); + + _p_xic_window->addXic(p_peptide_evidence); qDebug() << "ProjectWindow::openInXicViewer end"; } diff --git a/src/gui/xic_view/xic_box/xic_box.ui b/src/gui/xic_view/xic_box/xic_box.ui new file mode 100644 index 000000000..f6a62be40 --- /dev/null +++ b/src/gui/xic_view/xic_box/xic_box.ui @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>XicBox</class> + <widget class="QWidget" name="XicBox"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="peptide_label"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="pappso::XicWidget" name="xic_widget" native="true"/> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>pappso::XicWidget</class> + <extends>QWidget</extends> + <header>pappsomspp/widget/xicwidget/xicwidget.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/src/gui/xic_view/xic_box/xicbox.cpp b/src/gui/xic_view/xic_box/xicbox.cpp new file mode 100644 index 000000000..4f0819edd --- /dev/null +++ b/src/gui/xic_view/xic_box/xicbox.cpp @@ -0,0 +1,85 @@ +/** + * \file src/gui/xic_view/xic_box/xicbox.cpp + * \date 12/1/2018 + * \author Olivier Langella + * \brief XIC box widget + */ +/******************************************************************************* +* Copyright (c) 2018 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 "xicbox.h" +#include "ui_xic_box.h" +#include <QMessageBox> +#include <pappsomspp/pappsoexception.h> +#include "../xicworkerthread.h" + +XicBox::XicBox(XicWindow *parent): + QWidget(parent), + ui(new Ui::XicBox) +{ + _p_xic_window = parent; + ui->setupUi(this); + + XicWorkerThread * p_worker = new XicWorkerThread(); + p_worker->moveToThread(&_xic_thread); + _xic_thread.start(); + +#if QT_VERSION >= 0x050000 + // Qt5 code + connect(this, &XicBox::loadXic, p_worker, &XicWorkerThread::doXicLoad); + connect(p_worker, &XicWorkerThread::xicLoaded,this, &XicBox::setXic); + connect(p_worker, &XicWorkerThread::operationFailed, this, &XicBox::error); + +#else +// Qt4 code +#endif + + +} + +XicBox::~XicBox() +{ + qDebug() << "XicBox::~XicBox"; + _xic_thread.quit(); + _xic_thread.wait(); +} + +void XicBox::error(QString error_message) { + QMessageBox::warning(this, + tr("Error trying to save spectrum to SVG file :"), error_message); + +} +void XicBox::setPeptideEvidence(const PeptideEvidence * p_peptide_evidence) { + + _p_peptide_evidence = p_peptide_evidence; + ui->peptide_label->setText(_p_peptide_evidence->getPeptideXtpSp().get()->toString()); + + emit loadXic(_p_peptide_evidence->getMsRunP(), _p_peptide_evidence->getPeptideXtpSp().get()->getMz(_p_peptide_evidence->getCharge()), _p_xic_window->getXicExtractPrecision(), XicExtractMethod::max); + +} + + +void XicBox::setXic(pappso::XicSp xic_sp) { + qDebug() << "XicBox::setXic begin"; + qDebug() << "XicBox::setXic end"; + +} diff --git a/src/gui/xic_view/xic_box/xicbox.h b/src/gui/xic_view/xic_box/xicbox.h new file mode 100644 index 000000000..4ad6e9162 --- /dev/null +++ b/src/gui/xic_view/xic_box/xicbox.h @@ -0,0 +1,65 @@ +/** + * \file src/gui/xic_view/xic_box/xicbox.h + * \date 12/1/2018 + * \author Olivier Langella + * \brief XIC box widget + */ +/******************************************************************************* +* Copyright (c) 2018 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 +******************************************************************************/ + +#ifndef XICBOX_H +#define XICBOX_H + +#include <QWidget> +#include <QThread> +#include "../../../utils/types.h" +#include "../../../core/peptideevidence.h" +#include "../xicwindow.h" +#include <pappsomspp/xic/xic.h> + +namespace Ui { +class XicBox; +} + +class XicBox: public QWidget +{ + Q_OBJECT +public: + + explicit XicBox(XicWindow * parent = 0); + ~XicBox(); + void setPeptideEvidence(const PeptideEvidence * p_peptide_evidence) ; + +signals : + void loadXic(const MsRun * p_msrun, pappso::mz mz, pappso::PrecisionP precision, XicExtractMethod method); +private slots: + void setXic(pappso::XicSp xic_sp); + void error(QString error_message); +private: + Ui::XicBox *ui; + QThread _xic_thread; + XicWindow * _p_xic_window; + const PeptideEvidence * _p_peptide_evidence; +}; + + +#endif // XICBOX_H diff --git a/src/gui/xic_view/xicwindow.cpp b/src/gui/xic_view/xicwindow.cpp index 4c5f13f2e..56118dbd4 100644 --- a/src/gui/xic_view/xicwindow.cpp +++ b/src/gui/xic_view/xicwindow.cpp @@ -30,7 +30,7 @@ #include "xicwindow.h" #include "ui_xic_window.h" #include "../project_view/projectwindow.h" - +#include "xic_box/xicbox.h" XicWindow::XicWindow(ProjectWindow *parent): QMainWindow(parent), @@ -39,9 +39,6 @@ XicWindow::XicWindow(ProjectWindow *parent): _project_window = parent; ui->setupUi(this); - XicWorkerThread * p_worker = new XicWorkerThread(); - p_worker->moveToThread(&_xic_thread); - _xic_thread.start(); #if QT_VERSION >= 0x050000 @@ -58,3 +55,13 @@ XicWindow::~XicWindow() { qDebug() << "XicWindow::~XicWindow"; } + +void XicWindow::addXic(const PeptideEvidence * p_peptide_evidence) { + XicBox * p_box = new XicBox(this); + p_box->setPeptideEvidence(p_peptide_evidence); + ui->xic_vertical_layout->addWidget(p_box); +} + +pappso::PrecisionP XicWindow::getXicExtractPrecision() const { + return (pappso::Precision::getPpmInstance(10)); +} diff --git a/src/gui/xic_view/xicwindow.h b/src/gui/xic_view/xicwindow.h index 6cfe806be..b6462314a 100644 --- a/src/gui/xic_view/xicwindow.h +++ b/src/gui/xic_view/xicwindow.h @@ -29,41 +29,38 @@ #ifndef XICWINDOW_H #define XICWINDOW_H -#include <QThread> #include <QMainWindow> -class ProjectWindow; - - -class XicWorkerThread : public QObject -{ - Q_OBJECT -public: - - -protected: +#include "../../core/peptideevidence.h" - void closeEvent(QCloseEvent *event); +class ProjectWindow; -}; namespace Ui { class XicWindow; } +class XicBox; + class XicWindow: public QMainWindow { Q_OBJECT - +friend XicBox; public: explicit XicWindow(ProjectWindow * parent = 0); ~XicWindow(); - + void addXic(const PeptideEvidence * p_peptide_evidence); + + pappso::PrecisionP getXicExtractPrecision() const; + +protected: + private: ProjectWindow * _project_window; - QThread _xic_thread; Ui::XicWindow *ui; + pappso::PrecisionP _xic_extract_precision; }; + #endif // XICWINDOW_H diff --git a/src/gui/xic_view/xicworkerthread.cpp b/src/gui/xic_view/xicworkerthread.cpp new file mode 100644 index 000000000..4f681ef7f --- /dev/null +++ b/src/gui/xic_view/xicworkerthread.cpp @@ -0,0 +1,46 @@ +/** + * \file src/gui/xic_view/xicworkerthread.cpp + * \date 12/1/2018 + * \author Olivier Langella + * \brief XIC worker + */ +/******************************************************************************* +* Copyright (c) 2018 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 "xicworkerthread.h" +#include "../../utils/readspectrum.h" +#include <pappsomspp/pappsoexception.h> + +void XicWorkerThread::doXicLoad(const MsRun * p_msrun, pappso::mz mz, pappso::PrecisionP precision, XicExtractMethod method) { + + try { + pappso::MassRange mass_range(mz, precision); + pappso::XicSp xic_sp = SpectrumStore::getXicSpFromMsRunSp(p_msrun, mass_range, method); + + emit xicLoaded(xic_sp); + + } + catch (pappso::PappsoException & error) { + emit operationFailed(tr("Error extracting XIC :\n%1").arg(error.qwhat())); + } +} diff --git a/src/gui/xic_view/xicworkerthread.h b/src/gui/xic_view/xicworkerthread.h new file mode 100644 index 000000000..21455c8d2 --- /dev/null +++ b/src/gui/xic_view/xicworkerthread.h @@ -0,0 +1,49 @@ +/** + * \file src/gui/xic_view/xicworkerthread.h + * \date 12/1/2018 + * \author Olivier Langella + * \brief XIC worker + */ +/******************************************************************************* +* Copyright (c) 2018 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 +******************************************************************************/ + +#ifndef XICWORKERTHREAD_H +#define XICWORKERTHREAD_H + +#include <pappsomspp/xic/xic.h> +#include<QObject> +#include "../../core/msrun.h" + +class XicWorkerThread : public QObject +{ + Q_OBJECT +public: + +public slots: + void doXicLoad(const MsRun * p_msrun, pappso::mz mz, pappso::PrecisionP precision, XicExtractMethod method); + +signals: + void xicLoaded(pappso::XicSp xic_sp); + void operationFailed(QString error); + +}; +#endif // XICWORKERTHREAD_H diff --git a/src/main.cpp b/src/main.cpp index 45a4f7bf3..2c252bb97 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,6 +27,7 @@ #include <pappsomspp/pappsoexception.h> #include "config.h" #include "gui/mainwindow.h" +#include "utils/types.h" using namespace std; @@ -36,6 +37,11 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); qRegisterMetaType<TandemRunBatch>("TandemRunBatch"); + qRegisterMetaType<pappso::mz>("pappso::mz"); + qRegisterMetaType<pappso::PrecisionP>("pappso::PrecisionP"); + qRegisterMetaType<pappso::XicSp>("pappso::XicSp"); + qRegisterMetaType<XicExtractMethod>("XicExtractMethod"); + try { QCoreApplication::setOrganizationName("PAPPSO"); diff --git a/src/utils/readspectrum.cpp b/src/utils/readspectrum.cpp index bb9d4082f..50f208feb 100644 --- a/src/utils/readspectrum.cpp +++ b/src/utils/readspectrum.cpp @@ -47,7 +47,7 @@ pwiz::msdata::MSDataFile * getPwizMSDataFile(const QString & filename); pappso::QualifiedSpectrum getQualifiedSpectrumFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, unsigned int scan_num); -void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_mzdata, pappso::Xic * p_xic, const pappso::MassRange & mass_range, XixExtactMethod method); +void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_mzdata, pappso::Xic * p_xic, const pappso::MassRange & mass_range, XicExtractMethod method); pwiz::msdata::MSDataFile * getPwizMSDataFile(const QString & filename) { @@ -78,7 +78,7 @@ pwiz::msdata::MSDataFile * getPwizMSDataFile(const QString & filename) { return dataFile; } -void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, pappso::Xic * p_xic, const pappso::MassRange & mass_range, XixExtactMethod method) { +void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, pappso::Xic * p_xic, const pappso::MassRange & mass_range, XicExtractMethod method) { std::string env; env=setlocale(LC_ALL,""); @@ -110,7 +110,7 @@ void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, pappso: { //qDebug() << "it->mz " << it->mz << " it->intensity" << it->intensity; if (mass_range.contains(it->mz)) { - if (method == XixExtactMethod::max) { + if (method == XicExtractMethod::max) { if (peak.intensity < it->intensity) { peak.intensity = it->intensity; } @@ -380,7 +380,7 @@ pappso::SpectrumSp SpectrumStore::getSpectrumSpFromMsRunSp(MsRun * msrun, unsign } -pappso::XicSp SpectrumStore::getXicSpFromMsRunSp(const MsRun * p_msrun, const pappso::MassRange & mass_range, XixExtactMethod method) { +pappso::XicSp SpectrumStore::getXicSpFromMsRunSp(const MsRun * p_msrun, const pappso::MassRange & mass_range, XicExtractMethod method) { qDebug() << "SpectrumStore::getXicSpFromMsRunSp begin" ; pwiz::msdata::MSDataFile * p_msdatafile = findPwizMSDataFile(p_msrun); diff --git a/src/utils/readspectrum.h b/src/utils/readspectrum.h index c8eef8cc1..cd8fe5657 100644 --- a/src/utils/readspectrum.h +++ b/src/utils/readspectrum.h @@ -43,7 +43,7 @@ class MSDataFile; class SpectrumStore { public: static pappso::SpectrumSp getSpectrumSpFromMsRunSp(MsRun * p_msrun, unsigned int scan_num); - static pappso::XicSp getXicSpFromMsRunSp(const MsRun * p_msrun, const pappso::MassRange & mass_range, XixExtactMethod method); + static pappso::XicSp getXicSpFromMsRunSp(const MsRun * p_msrun, const pappso::MassRange & mass_range, XicExtractMethod method); /** @brief try to find MS run statistics */ static void checkMsRunStatistics(MsRun *); diff --git a/src/utils/types.h b/src/utils/types.h index 4800b26e9..c228b07d8 100644 --- a/src/utils/types.h +++ b/src/utils/types.h @@ -91,9 +91,9 @@ enum class MsRunStatistics: std::int8_t { /** \def XixExtactMethod method to extract Xic * */ -enum class XixExtactMethod { - sum, ///< sum of intensities - max ///< maximum of intensities +enum class XicExtractMethod: std::int8_t { + sum=1, ///< sum of intensities + max=2 ///< maximum of intensities }; -- GitLab