Commit fa88f4b8 authored by Edlira Nano's avatar Edlira Nano
Browse files

threaded msrun loadind

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2250 e4b6dbb4-9209-464b-83f7-6257456c460c
parent 65d2315f
......@@ -135,7 +135,7 @@ SET(GUI_SRCS
./gui/xicProfile.cpp
./gui/xicPlot.cpp
./gui/plot.cpp
./gui/msrunLoaderThread.cpp
)
# another list, this time it includes all header files that should be treated with moc
......@@ -147,6 +147,7 @@ SET(GUI_MOC_HDRS
./gui/xicProfile.h
./gui/xicPlot.h
./gui/plot.h
./gui/msrunLoaderThread.h
)
set(CMAKE_MODULE_PATH ${masschroq_SOURCE_DIR}/modules)
......
......@@ -3,11 +3,14 @@
#include <QMessageBox>
#include <QDockWidget>
#include <QStatusBar>
#include <QProgressDialog>
#include <QApplication>
#include "mainwindow.h"
#include "xicSelectionWidget.h"
#include "xicProfile.h"
#include "xicPlot.h"
//#include "msrunLoaderThread.h"
......@@ -97,10 +100,35 @@ MainWindow::loadMsrun() {
if (!filename.isEmpty()) {
_current_msrun_file = filename;
_masschroq_gui->setMsRun(filename);
QProgressDialog progressDialog(QObject::tr("Loading MS run %1...").arg(strippedFilename(filename)), QObject::tr("Cancel"), 0, 2, this);
progressDialog.show();
progressDialog.setValue(0);
connect(&_msrun_loader_thread, SIGNAL(loadedMsrun(Msrun *)),
this, SLOT(doneLoading(Msrun *)));
_masschroq_gui->setMsRun(filename, &_msrun_loader_thread);//, &progressDialog);
// progressDialog.setCancelButtonText(QObject::tr("&Cancel"));
//connect(_progressDialog, SIGNAL(canceled()), this, SLOT(cancelLoadMsrun()));
// progressDialog.setRange(0, 2);
//_mainwindow->statusBar()->addWidget(&progressDialog);
//progressDialog.setValue(0);
//progressDialog.setValue(1);
// QApplication::processEvents();
//progressDialog.setValue(2);
}
}
void
MainWindow::doneLoading(Msrun * msrun) {
QString filename = (msrun->getXmlFileInfo()).filePath();
_masschroq_gui->addMsRun(filename, msrun);
this->statusBar()->showMessage(QObject::tr("MS run '%1' loaded").arg(filename), 4000);
this->setPlotAreaTitle(filename);
}
void
MainWindow::extractXicWidget() {
QDockWidget * dock = new QDockWidget(tr("XIC extraction"), this);
......
......@@ -2,9 +2,11 @@
#include <QMenu>
#include <QToolBar>
#include <QAction>
#include <QProgressDialog>
#include "masschroq_gui.h"
#include "plot.h"
#include "msrunLoaderThread.h"
class MainWindow : public QMainWindow
{
......@@ -24,6 +26,7 @@ private slots:
void plotNewXic(XicProfile * xic_profile);
void filterXic();
void about();
void doneLoading(Msrun * msrun);
protected:
......@@ -61,6 +64,8 @@ private:
QAction * _aboutAct;
QAction * _quitAct;
QProgressDialog _progressDialog;
MsrunLoaderThread _msrun_loader_thread;
QString _current_msrun_file;
std::vector<XicProfile *> _xic_profiles;
......
......@@ -4,17 +4,18 @@
* \author Edlira Nano
*/
#include "masschroq_gui.h"
#include "mainwindow.h"
#include "xicProfile.h"
#include "xicSelectionWidget.h"
#include "msrunLoaderThread.h"
#include "../lib/mcq_error.h"
#include "../lib/msrun/msrun_classic.h"
#include "../lib/msrun/msrun_sliced.h"
#include "../lib/xicExtractionMethods/xicExtractionMethodBase.h"
#include "../lib/quanti_items/quantiItemMzRt.h"
#include "../lib/xic/xic_base.h"
#include <QMessageBox>
#include <QStatusBar>
......@@ -30,9 +31,10 @@ MasschroqGui::~MasschroqGui() {
}
void
MasschroqGui::setMsRun(const QString & filename) {
MasschroqGui::setMsRun(const QString & filename,
MsrunLoaderThread * thread) {
// QProgressDialog * progressDialog) {
QFileInfo filenameInfo(filename);
if (! filenameInfo.exists()) {
......@@ -62,9 +64,10 @@ MasschroqGui::setMsRun(const QString & filename) {
msgBox.exec();
return;
}
mcq_double size_in_bytes = filenameInfo.size();
Msrun * msrun;
if (size_in_bytes < MAX_SLICE_SIZE ) {
msrun = new MsrunClassic(filename);
cout << "MS run classic '"
......@@ -79,15 +82,10 @@ MasschroqGui::setMsRun(const QString & filename) {
<< "', number of slices " << nb_of_slices
<<", : parsing begin" << endl;
}
try {
msrun->set_from_xml(filename, format);
this->addMsRun(filename, msrun);
_current_loaded_msrun = msrun;
// Parsing of Msrun spectra
msrun->prepareSpectraForQuantification(NULL);
_mainwindow->statusBar()->showMessage(QObject::tr("MS run '%1' loaded").arg(filename), 4000);
_mainwindow->setPlotAreaTitle(filename);
thread->loadMsrun(msrun, filename, format);
} catch (mcqError error) {
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
......@@ -95,12 +93,13 @@ MasschroqGui::setMsRun(const QString & filename) {
msgBox.exec();
return;
}
}
void
MasschroqGui::addMsRun(const QString & filename, Msrun * msrun) {
_msrun_map[filename] = msrun;
_msrun_map[filename] = msrun;
_current_loaded_msrun = msrun;
}
Msrun *
......@@ -115,8 +114,8 @@ MasschroqGui::getMsRun(const QString & filename) const {
}
void
MasschroqGui::extractXicProfile(XicProfile * xic_profile,
const QString & msrun_filename,
MasschroqGui::extractXicProfile(XicProfile * xic_profile,
const QString & msrun_filename,
XicSelectionWidget * xic) {
Msrun * msrun = getMsRun(msrun_filename);
......@@ -160,3 +159,8 @@ MasschroqGui::extractXicProfile(XicProfile * xic_profile,
delete (current_xic);
}
QString
MasschroqGui::strippedFilename(const QString & fullFilename) {
return QFileInfo(fullFilename).fileName();
}
......@@ -31,16 +31,13 @@
#include <QFileInfo>
#include "../lib/msrun/msrun.h"
/* #include "msrun/ms_run_hash_group.h" */
/* #include "alignments/alignment_base.h" */
/* #include "quantifications/quantificationMethod.h" */
/* #include "peptides/peptide_list.h" */
/* #include "peptides/protein.h" */
/* #include "peptides/isotope_label.h" */
class XicProfile;
class XicSelectionWidget;
class MainWindow;
class QProgressDialog;
class MsrunLoaderThread;
/**
* \class MasschroqGui
......@@ -55,17 +52,22 @@ class MasschroqGui {
virtual ~MasschroqGui();
/// creates and sets an msrun
void setMsRun(const QString & filename);
void setMsRun(const QString & filename,
MsrunLoaderThread * thread);
//QProgressDialog * progressDialog);
void extractXicProfile(XicProfile * xic_profile,
const QString & msrun_filename,
XicSelectionWidget * xic);
void addMsRun(const QString & filename, Msrun * msrun);
private :
void addMsRun(const QString & filename, Msrun * msrun);
Msrun * getMsRun(const QString & filename) const;
QString strippedFilename(const QString & fullFilename);
std::map<QString, Msrun *> _msrun_map;
Msrun * _current_loaded_msrun;
......
/**
* \file msrunLoaderThread.cpp
* \date December 09, 2011
* \author Edlira Nano
*/
#include "msrunLoaderThread.h"
MsrunLoaderThread::MsrunLoaderThread(QObject * parent)
:
QThread(parent)
{
restart = false;
abort = false;
}
MsrunLoaderThread::~MsrunLoaderThread() {
mutex.lock();
abort = true;
condition.wakeOne();
mutex.unlock();
wait();
}
void
MsrunLoaderThread::loadMsrun(Msrun * msrun,
const QString & filename,
const mcq_xml_format & format) {
// QProgressDialog * progressDialog) {
_current_msrun = msrun;
_msrun_filename = filename;
_msrun_format = format;
//_progressDialog = progressDialog;
if (!isRunning()) {
start();
} else {
restart = true;
condition.wakeOne();
}
}
void
MsrunLoaderThread::run() {
forever {
mutex.lock();
Msrun * msrun = this->_current_msrun;
QString filename = this->_msrun_filename;
mcq_xml_format format = this->_msrun_format;
// QProgressDialog * progressDialog = this->_progressDialog;
mutex.unlock();
cout << "Yo 1" << endl;
if (restart) {
cout << "Yo 2" << endl;
break;
}
if (abort) {
cout << "Yo 3" << endl;
return;
}
msrun->set_from_xml(filename, format);
cout << "Yo 4" << endl;
//progressDialog->setValue(1);
msrun->prepareSpectraForQuantification(NULL);
//progressDialog->setValue(2);
if (!restart)
emit loadedMsrun(msrun);
mutex.lock();
if (!restart)
condition.wait(&mutex);
restart = false;
mutex.unlock();
}
}
/*
*
* MassChroQ: Mass Chromatogram Quantification software.
* Copyright (C) 2010 Olivier Langella, Edlira Nano, Benoit Valot, Michel Zivy.
*
* This program 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.
*
* This program is distributed in the hope thatx 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file msrunLoaderThread.h
* \date December 09, 2011
* \author Edlira Nano
*/
#ifndef MSRUN_LOADER_THREAD_H_
#define MSRUN_LOADER_THREAD_H_ 1
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QProgressDialog>
#include "../lib/msrun/msrun.h"
/**
* \class MsrunLoaderThread
* \brief The thread that loads MSrun files in the MassChroq GUI.
*/
class MsrunLoaderThread : public QThread {
Q_OBJECT
public:
MsrunLoaderThread(QObject *parent = 0);
~MsrunLoaderThread();
void loadMsrun(Msrun * msrun,
const QString & filename,
const mcq_xml_format & format);
// QProgressDialog * progressDialog);
signals:
void loadedMsrun(Msrun *);
protected :
void run();
private:
QMutex mutex;
QWaitCondition condition;
bool restart;
bool abort;
Msrun * _current_msrun;
QString _msrun_filename;
mcq_xml_format _msrun_format;
//QProgressDialog * _progressDialog;
};
#endif /* MSRUN_LOADER_THREAD_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment