Skip to content
Snippets Groups Projects
Commit ed64eaf9 authored by Renne Thomas's avatar Renne Thomas
Browse files

Add handler on MsIdList and allow to stop computing

parent c37b2431
No related branches found
No related tags found
No related merge requests found
......@@ -263,6 +263,38 @@ MsRun::checkMsRunStatistics()
}
}
void
MsRun::checkMsRunStatistics(MsRunStatisticsHandler *currentHandler)
{
QVariant msrun_var = getMsRunStatistics(MsRunStatistics::total_spectra);
if(msrun_var.isNull())
{
try
{
_msrun_reader_sp.get()->readSpectrumCollection(*currentHandler);
setMsRunStatistics(MsRunStatistics::total_spectra,
(unsigned int)currentHandler->getTotalCount());
setMsRunStatistics(MsRunStatistics::total_spectra_ms1,
(unsigned int)currentHandler->getMsLevelCount(1));
setMsRunStatistics(MsRunStatistics::total_spectra_ms2,
(unsigned int)currentHandler->getMsLevelCount(2));
setMsRunStatistics(MsRunStatistics::total_spectra_ms3,
(unsigned int)currentHandler->getMsLevelCount(3));
setMsRunStatistics(MsRunStatistics::tic_spectra_ms1,
currentHandler->getMsLevelTic(1));
setMsRunStatistics(MsRunStatistics::tic_spectra_ms2,
currentHandler->getMsLevelTic(2));
setMsRunStatistics(MsRunStatistics::tic_spectra_ms3,
currentHandler->getMsLevelTic(3));
}
catch(pappso::ExceptionNotFound &error)
{
// no file found, no statistics
}
}
}
pappso::MsRunXicExtractorInterfaceSp
MsRun::getMsRunXicExtractorInterfaceSp()
{
......@@ -317,9 +349,11 @@ MsRun::buildMsRunRetentionTime(
if(reader == nullptr)
{
throw pappso::ExceptionNotFound(
QObject::tr("MSrun \"%1\" for sample named \"%2\" file \"%3\" not found")
QObject::tr(
"MSrun \"%1\" for sample named \"%2\" file \"%3\" not found")
.arg(getXmlId())
.arg(getSampleName()).arg(getFileName()));
.arg(getSampleName())
.arg(getFileName()));
}
if(mpa_msrunRetentionTime == nullptr)
{
......
......@@ -42,6 +42,7 @@
#include <pappsomspp/peptide/peptide.h>
#include "../utils/types.h"
#include "../utils/peptideevidencestore.h"
#include <utils/msrunstatisticshandler.h>
class MsRun;
typedef std::shared_ptr<MsRun> MsRunSp;
......@@ -78,6 +79,7 @@ class MsRun : public pappso::MsRunId
void freeMsRunReaderSp();
void checkMsRunStatistics();
void checkMsRunStatistics(MsRunStatisticsHandler *currentHandler);
pappso::MsRunXicExtractorInterfaceSp getMsRunXicExtractorInterfaceSp();
......
......@@ -29,12 +29,13 @@
#include <pappsomspp/pappsoexception.h>
#include <pappsomspp/exception/exceptionnotfound.h>
#include <gui/lists/ms_identification_run_list_view/msidentificationtablemodel.h>
#include <gui/lists/ms_identification_run_list_view/msidentificationlistwindow.h>
bool
MsIdentificationTableMsRunStatisticsHandler::shouldStop()
{
QMutexLocker locker(&m_mutex);
return true;
return m_stopRequired;
}
void
......@@ -47,26 +48,24 @@ MsIdentificationTableMsRunStatisticsHandler::requireStop(bool stop)
MsIdListWorkerStatus::MsIdListWorkerStatus()
{
mpa_currentHandler = nullptr;
}
MsIdListWorkerStatus::~MsIdListWorkerStatus()
{
if(mpa_currentHandler != nullptr)
{
delete mpa_currentHandler;
}
}
WorkerStatus
MsIdListWorkerStatus::getStatus(
IdentificationDataSourceSp identificationDataSource)
IdentificationDataSourceSp identificationDataSource,
MsIdentificationListWindow *msIdListWindow)
{
if(std::find(m_list_idSources.begin(),
m_list_idSources.end(),
identificationDataSource) != m_list_idSources.end())
if(std::find(m_listIdSources.begin(),
m_listIdSources.end(),
identificationDataSource) != m_listIdSources.end())
{
if(identificationDataSource == m_runningIdData)
if(std::find(m_listRunnigId.begin(),
m_listRunnigId.end(),
identificationDataSource) != m_listRunnigId.end())
{
return WorkerStatus::Running;
}
......@@ -77,18 +76,12 @@ MsIdListWorkerStatus::getStatus(
}
else
{
if(mpa_currentHandler != nullptr)
{
delete mpa_currentHandler;
}
// mpa_currentHandler = new MsIdentificationTableMsRunStatisticsHandler();
// qDebug() << "DDDDDDDDDDDDDD" << mpa_currentHandler->shouldStop();
m_msIdListWindow = msIdListWindow;
QFuture<void> t1 =
QtConcurrent::run(this,
&MsIdListWorkerStatus::doComputeMsNumber,
identificationDataSource);
m_list_idSources.push_back(identificationDataSource);
m_listIdSources.push_back(identificationDataSource);
return WorkerStatus::Waiting;
}
......@@ -99,12 +92,11 @@ void
MsIdListWorkerStatus::doComputeMsNumber(
IdentificationDataSourceSp identificationDataSource)
{
qDebug() << "QConcurrent " << QThread::currentThread();
m_runningIdData = identificationDataSource;
m_listRunnigId.push_back(identificationDataSource);
if(identificationDataSource->getMsRunSp()->findMsRunFile())
{
identificationDataSource->getMsRunSp()->checkMsRunStatistics();
identificationDataSource->getMsRunSp()->checkMsRunStatistics(
m_msIdListWindow->getMsIdentificationTableMsRunStatisticsHandler());
}
identificationDataSource->getMsRunSp()->freeMsRunReaderSp();
emit MsNumberComputed();
......
......@@ -31,7 +31,8 @@
#include "core/identification_sources/identificationdatasource.h"
class MsIdentificationTableMsRunStatisticsHandler :public MsRunStatisticsHandler
class MsIdentificationTableMsRunStatisticsHandler
: public MsRunStatisticsHandler
{
public:
unsigned long getMsLevelCount(unsigned int ms_level) const;
......@@ -41,15 +42,14 @@ class MsIdentificationTableMsRunStatisticsHandler :public MsRunStatisticsHandler
unsigned long getTotalCount() const;
virtual bool shouldStop() override;
void requireStop(bool stop);
virtual void requireStop(bool stop);
private:
std::vector<unsigned long> _count_ms_level_spectrum;
std::vector<pappso::pappso_double> _tic_ms_level_spectrum;
QMutex m_mutex;
bool m_stopRequired = true;
bool m_stopRequired = false;
};
class MsIdentificationTableModel;
......@@ -60,7 +60,7 @@ enum class WorkerStatus : std::int8_t
Waiting = 1,
Nothing = 2,
};
class MsIdListWorkerThread;
class MsIdentificationListWindow;
class MsIdListWorkerStatus : public QObject
{
Q_OBJECT
......@@ -70,16 +70,16 @@ class MsIdListWorkerStatus : public QObject
virtual ~MsIdListWorkerStatus();
WorkerStatus getStatus(IdentificationDataSourceSp identificationDataSource);
WorkerStatus getStatus(IdentificationDataSourceSp identificationDataSource,
MsIdentificationListWindow *msIdListWindow);
void doComputeMsNumber(IdentificationDataSourceSp identificationDataSource);
signals:
void MsNumberComputed();
protected:
IdentificationDataSourceSp m_runningIdData;
private:
std::vector<IdentificationDataSourceSp> m_list_idSources;
pappso::SpectrumCollectionHandlerInterface *mpa_currentHandler = nullptr;
MsIdentificationListWindow *m_msIdListWindow;
MsIdentificationTableMsRunStatisticsHandler *mp_handler = nullptr;
std::vector<IdentificationDataSourceSp> m_listRunnigId;
std::vector<IdentificationDataSourceSp> m_listIdSources;
};
......@@ -40,10 +40,6 @@ MsIdentificationListQActionColumn::MsIdentificationListQActionColumn(
this->setCheckable(true);
this->setChecked(parent->getMsIdentificationListColumnDisplay(column));
// evalue_action.setChecked(_display_evalue);
// connect(p_action, SIGNAL(toggled(bool)), this,
// SLOT(showEvalueColumn(bool)));
m_column = column;
m_msid_list_window = parent;
......@@ -84,9 +80,9 @@ MsIdentificationListWindow::MsIdentificationListWindow(ProjectWindow *parent)
ui->setupUi(this);
setWindowIcon(QIcon(":/xtpcpp_icon/resources/xtandempipeline_icon.svg"));
mpa_currentHandler = new MsIdentificationTableMsRunStatisticsHandler();
m_msid_table_model_p = new MsIdentificationTableModel(this);
m_proxy_model =
new MsIdentificationTableProxyModel(this, m_msid_table_model_p);
m_proxy_model->setSourceModel(m_msid_table_model_p);
......@@ -129,6 +125,7 @@ MsIdentificationListWindow::~MsIdentificationListWindow()
void
MsIdentificationListWindow::closeEvent(QCloseEvent *event)
{
mpa_currentHandler->requireStop(true);
if(m_context_menu != nullptr)
{
m_context_menu->hide();
......@@ -136,6 +133,12 @@ MsIdentificationListWindow::closeEvent(QCloseEvent *event)
event->accept();
}
MsIdentificationTableMsRunStatisticsHandler *
MsIdentificationListWindow::getMsIdentificationTableMsRunStatisticsHandler()
{
return mpa_currentHandler;
}
void
MsIdentificationListWindow::resizeColumnsToContents()
......@@ -221,7 +224,8 @@ MsIdentificationListWindow::doExportAsOdsFile()
if(!filename.isEmpty())
{
CalcWriterInterface *p_writer = new OdsDocWriter(filename);
CalcWriterInterface *p_writer = new OdsDocWriter(filename);
const QAbstractProxyModel *p_table_model = m_proxy_model;
QtableWriter table_writer(p_writer, p_table_model);
......
......@@ -74,10 +74,13 @@ class MsIdentificationListWindow : public QMainWindow
bool
getMsIdentificationListColumnDisplay(msIdentificationListColumn column) const;
MsIdentificationTableMsRunStatisticsHandler *
getMsIdentificationTableMsRunStatisticsHandler();
void resizeColumnsToContents();
void virtual closeEvent(QCloseEvent *event) override;
public slots:
void doExportAsOdsFile();
......@@ -98,7 +101,6 @@ class MsIdentificationListWindow : public QMainWindow
MsIdentificationTableModel *m_msid_table_model_p = nullptr;
MsIdentificationTableProxyModel *m_proxy_model = nullptr;
ProjectWindow *m_project_window;
QMenu *m_context_menu = nullptr;
bool _display_evalue = true;
bool _display_accession = true;
QMenu *m_context_menu = nullptr;
MsIdentificationTableMsRunStatisticsHandler *mpa_currentHandler = nullptr;
};
......@@ -35,8 +35,8 @@ MsIdentificationTableModel::MsIdentificationTableModel(
: QAbstractTableModel(ms_id_list_window)
{
m_ms_id_list_window = ms_id_list_window;
msp_workerStatus = std::make_shared<MsIdListWorkerStatus>();
msp_workerStatus = std::make_shared<MsIdListWorkerStatus>();
mp_movie = new QMovie("/home/trenne/Documents/graph/iconWait.gif");
mp_movie->start();
mp_movie->setScaledSize(QSize(20, 20));
......@@ -449,7 +449,7 @@ MsIdentificationTableModel::getMsRunStatisticsNumber(
if(nb_ms.isNull())
{
WorkerStatus temp = msp_workerStatus.get()->getStatus(
m_identificationDataSourceSpList.at(row));
m_identificationDataSourceSpList.at(row), m_ms_id_list_window);
if(temp == WorkerStatus::Running)
{
......@@ -480,7 +480,7 @@ MsIdentificationTableModel::showMsRunStatisticsStatus(
if(nb_ms.isNull())
{
WorkerStatus temp = msp_workerStatus.get()->getStatus(
m_identificationDataSourceSpList.at(row));
m_identificationDataSourceSpList.at(row), m_ms_id_list_window);
if(temp == WorkerStatus::Running)
{
......
......@@ -25,7 +25,6 @@
#include <QAbstractTableModel>
#include "../../../core/project.h"
#include <QThread>
#include <memory>
#include "ms_identification_worker/msidlistworkerstatus.h"
#include <QMovie>
......@@ -49,9 +48,9 @@ enum class msIdentificationListColumn : std::int8_t
id_msrun_id = 8, ///< identification of MsRunId
nb_ms_1 = 9, ///< number of ms1
nb_ms_2 = 10, ///< number of ms2
nb_ms_3 = 11, ///< number of ms1
nb_ms_3 = 11, ///< number of ms1
nb_tic_1 = 12, ///< number of ms2
nb_tic_2 = 13, ///< number of ms1
nb_tic_2 = 13, ///< number of ms1
nb_tic_3 = 14, ///< number of ms2
last = 15, ///< get list size
};
......@@ -63,6 +62,7 @@ class MsIdentificationTableModel : public QAbstractTableModel
Q_OBJECT
public:
MsIdentificationTableModel(MsIdentificationListWindow *ms_id_list_window);
virtual ~MsIdentificationTableModel();
virtual int
rowCount(const QModelIndex &parent = QModelIndex()) const override;
......@@ -72,17 +72,17 @@ class MsIdentificationTableModel : public QAbstractTableModel
headerData(int section, Qt::Orientation orientation, int role) const override;
virtual QVariant data(const QModelIndex &index,
int role = Qt::DisplayRole) const override;
static const QString getTitle(msIdentificationListColumn column);
static const QString getDescription(msIdentificationListColumn column);
static const QString getTitle(std::int8_t column);
static const QString getDescription(std::int8_t column);
static msIdentificationListColumn
getMsIdentificationListColumn(std::int8_t column);
QVariant getMsRunStatisticsNumber(int row, MsRunStatistics column) const;
QVariant showMsRunStatisticsStatus(int row, MsRunStatistics column) const;
void setIdentificationDataSourceSpList(
std::vector<IdentificationDataSourceSp> &identificationDataSourceSpList);
......@@ -101,7 +101,6 @@ class MsIdentificationTableModel : public QAbstractTableModel
private:
std::vector<IdentificationDataSourceSp> m_identificationDataSourceSpList;
MsIdentificationListWindow *m_ms_id_list_window;
QThread m_ms_id_list_thread;
std::shared_ptr<MsIdListWorkerStatus> msp_workerStatus = nullptr;
QMovie *mp_movie;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment