Skip to content
Snippets Groups Projects
Commit fdc69f0e authored by Langella Olivier's avatar Langella Olivier
Browse files

better error messages, MS run file check is made by workerthread

parent 44133390
No related branches found
No related tags found
No related merge requests found
......@@ -66,20 +66,46 @@ MsRun::getMsRunReaderSPtr()
<< " filename=" << getFileName();
if(_msrun_reader_sp == nullptr)
{
qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
<< " runid=" << getRunId() << " xmlid=" << getXmlId();
pappso::MsFileAccessor *p_accessor = nullptr;
try
{
pappso::MsFileAccessor accessor(getFileName(), "");
qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
<< " runid=" << getRunId() << " xmlid=" << getXmlId();
_msrun_reader_sp =
accessor.getMsRunReaderSPtrByRunId(getRunId(), getXmlId());
// pappso::MsFileAccessor accessor(getFileName(), "");
p_accessor = new pappso::MsFileAccessor(getFileName(), "");
}
catch(pappso::PappsoException &error)
catch(pappso::ExceptionNotFound &error)
{
_msrun_reader_sp = nullptr;
// throw error;
// file not found, don't throw exception, we'll try another location
}
if(p_accessor != nullptr)
{
try
{
_msrun_reader_sp =
p_accessor->getMsRunReaderSPtrByRunId(getRunId(), getXmlId());
delete p_accessor;
p_accessor = nullptr;
}
catch(pappso::PappsoException &error2)
{
_msrun_reader_sp = nullptr;
if(p_accessor != nullptr)
{
delete p_accessor;
p_accessor = nullptr;
}
throw error2;
}
}
}
return _msrun_reader_sp;
}
......@@ -274,13 +300,26 @@ void
MsRun::buildMsRunRetentionTime(
const PeptideEvidenceStore &peptide_evidence_store)
{
pappso::MsRunReaderSPtr reader = getMsRunReaderSPtr();
pappso::MsRunReaderSPtr reader;
try
{
reader = getMsRunReaderSPtr();
}
catch(pappso::PappsoException &error)
{
throw pappso::ExceptionNotFound(
QObject::tr(
"Error while processing MSrun \"%1\" for sample named \"%2\" :\n%3")
.arg(getXmlId())
.arg(getSampleName())
.arg(error.qwhat()));
}
if(reader == nullptr)
{
throw pappso::ExceptionNotFound(
QObject::tr("MSrun \"%1\" for sample named \"%2\" not found")
QObject::tr("MSrun \"%1\" for sample named \"%2\" file \"%3\" not found")
.arg(getXmlId())
.arg(getSampleName()));
.arg(getSampleName()).arg(getFileName()));
}
if(mpa_msrunRetentionTime == nullptr)
{
......
......@@ -62,12 +62,22 @@ ExportMasschroqDialog::ExportMasschroqDialog(MainWindow *parent,
&ExportMasschroqDialog::operateFindBestMsrunForAlignment,
p_worker,
&WorkerThread::doFindBestMsrunForAlignment);
connect(p_worker,
&WorkerThread::findingBestMsrunForAlignmentFinished,
this,
&ExportMasschroqDialog::setBestMsrunForAlignment);
connect(this,
&ExportMasschroqDialog::operateCheckingMsrunFilePath,
p_worker,
&WorkerThread::doCheckMsrunFilePath);
connect(p_worker,
&WorkerThread::checkingMsrunFilePathFinished,
this,
&ExportMasschroqDialog::setCheckMsrunFilePathOk);
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
}
......@@ -237,39 +247,9 @@ void
ExportMasschroqDialog::doCheckMsrunFilepath()
{
ui->msrunFilepathOkLabel->setHidden(true);
bool is_ok = true;
for(IdentificationDataSourceSp p_ident_data_source :
msp_project->getIdentificationDataSourceStore()
.getIdentificationDataSourceList())
{
MsRunSp msrun_sp = p_ident_data_source->getMsRunSp();
if(msrun_sp->findMsRunFile())
{
// msrun_sp->checkMsRunStatistics();
}
else
{
is_ok = false;
}
if(!is_ok)
{
ui->warningDirectoryLabel->setText(
tr("%1 not found : Please choose the directory to look for this MS "
"run file.")
.arg(msrun_sp.get()->getFileName()));
ui->directorySelectWidget->setHidden(false);
break;
}
}
if(is_ok)
{
ui->directorySelectWidget->setHidden(true);
mp_main->showWaitingMessage(tr("Checking MSrun files path"));
emit operateCheckingMsrunFilePath(msp_project);
ui->msrunFilepathOkLabel->setText(tr("All MS run files found"));
ui->msrunFilepathOkLabel->setHidden(false);
}
}
void
......@@ -298,89 +278,6 @@ ExportMasschroqDialog::doFindBestMsrunForAlignment()
{
mp_main->showWaitingMessage(tr("Looking for MSrun reference"));
emit operateFindBestMsrunForAlignment(msp_project);
/*
bool is_ok = true;
for(auto &msrun_sp : msp_project->getMsRunStore().getMsRunList())
{
if(msrun_sp->findMsRunFile())
{
}
else
{
is_ok = false;
ui->warningDirectoryLabel->setText(
tr("%1 not found : Please choose the directory to look for this MS "
"run file.")
.arg(msrun_sp.get()->getFileName()));
ui->directorySelectWidget->setHidden(false);
break;
}
}
try
{
msp_project->prepareMsrunRetentionTimesForAlignment();
MsRunSp ms_run_best_reference;
std::size_t best_number = 0;
for(auto &msrun_ref_sp : msp_project->getMsRunStore().getMsRunList())
{
if(ms_run_best_reference == nullptr)
{
ms_run_best_reference = msrun_ref_sp;
}
std::size_t min_number = std::numeric_limits<std::size_t>::max();
for(auto &msrun_sp : msp_project->getMsRunStore().getMsRunList())
{
if(msrun_sp.get() != msrun_ref_sp.get())
{
pappso::Trace trace;
trace = msrun_sp.get()
->getMsRunRetentionTimePtr()
->getCommonDeltaRt(msrun_ref_sp.get()
->getMsRunRetentionTimePtr()
->getSeamarks());
if(trace.size() < min_number)
{
min_number = trace.size();
}
}
}
if(min_number > best_number)
{
best_number = min_number;
ms_run_best_reference = msrun_ref_sp;
}
}
if(ms_run_best_reference != nullptr)
{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
<< ms_run_best_reference.get()->getXmlId()
<< " best_number=" << best_number;
for(int index = 0; index < ui->msrun_list_combo_box->count(); index++)
{
MsRunSp msrun_sp = qvariant_cast<MsRunSp>(
ui->msrun_list_combo_box->itemData(index));
if(msrun_sp.get() == ms_run_best_reference.get())
{
ui->msrun_list_combo_box->setCurrentIndex(index);
}
}
}
}
catch(pappso::PappsoException &error)
{
QMessageBox msgBox;
msgBox.setWindowTitle("Error");
msgBox.setText(
tr("Error preparing MS run retention times: %1").arg(error.qwhat()));
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
}
*/
}
void
......@@ -405,6 +302,28 @@ ExportMasschroqDialog::setBestMsrunForAlignment(MsRunSp best_msrun_sp)
}
}
void
ExportMasschroqDialog::setCheckMsrunFilePathOk(MsRunSp msrun_sp)
{
mp_main->hideWaitingMessage();
if(msrun_sp == nullptr)
{
ui->directorySelectWidget->setHidden(true);
ui->msrunFilepathOkLabel->setText(tr("All MS run files found"));
ui->msrunFilepathOkLabel->setHidden(false);
}
else
{
ui->warningDirectoryLabel->setText(
tr("\"%1\" not found : Please choose the directory to look for this MS "
"run file.")
.arg(msrun_sp.get()->getFileName()));
ui->directorySelectWidget->setHidden(false);
}
}
void
ExportMasschroqDialog::fillMsrunListComboBox()
{
......
......@@ -61,10 +61,12 @@ class ExportMasschroqDialog : public QDialog
signals:
// void peptideChanged(pappso::PeptideSp peptide);
void operateFindBestMsrunForAlignment(ProjectSp project_sp);
void operateCheckingMsrunFilePath(ProjectSp project_sp);
public slots:
void setBestMsrunForAlignment(MsRunSp msrun_sp);
void setCheckMsrunFilePathOk(MsRunSp msrun_sp);
private:
Ui::ExportMasschroqDialog *ui;
......@@ -79,6 +81,4 @@ class ExportMasschroqDialog : public QDialog
private:
void fillMsrunListComboBox();
signals:
};
......@@ -807,57 +807,80 @@ WorkerThread::doFindBestMsrunForAlignment(ProjectSp project_sp)
}
else
{
throw pappso::PappsoException(
tr("Error while checking MS run file path :\nMSrun \"%1\" for "
"sample named \"%2\" not found")
.arg(msrun_sp->getXmlId())
.arg(msrun_sp->getSampleName()));
}
i++;
}
_p_work_monitor->message("preparing MS run retention times");
project_sp->prepareMsrunRetentionTimesForAlignment();
try
{
project_sp->prepareMsrunRetentionTimesForAlignment();
}
catch(pappso::PappsoException &error)
{
throw pappso::PappsoException(
tr("Error while preparing MS run retention times :\n%1")
.arg(error.qwhat()));
}
_p_work_monitor->message("choosing MS run");
MsRunSp ms_run_best_reference;
std::size_t best_number = 0;
for(auto &msrun_ref_sp : project_sp->getMsRunStore().getMsRunList())
try
{
if(ms_run_best_reference == nullptr)
MsRunSp ms_run_best_reference;
std::size_t best_number = 0;
for(auto &msrun_ref_sp : project_sp->getMsRunStore().getMsRunList())
{
ms_run_best_reference = msrun_ref_sp;
}
if(ms_run_best_reference == nullptr)
{
ms_run_best_reference = msrun_ref_sp;
}
std::size_t min_number = std::numeric_limits<std::size_t>::max();
for(auto &msrun_sp : project_sp->getMsRunStore().getMsRunList())
{
if(msrun_sp.get() != msrun_ref_sp.get())
std::size_t min_number = std::numeric_limits<std::size_t>::max();
for(auto &msrun_sp : project_sp->getMsRunStore().getMsRunList())
{
pappso::Trace trace;
trace = msrun_sp.get()
->getMsRunRetentionTimePtr()
->getCommonDeltaRt(msrun_ref_sp.get()
->getMsRunRetentionTimePtr()
->getSeamarks());
if(trace.size() < min_number)
if(msrun_sp.get() != msrun_ref_sp.get())
{
min_number = trace.size();
pappso::Trace trace;
trace =
msrun_sp.get()
->getMsRunRetentionTimePtr()
->getCommonDeltaRt(msrun_ref_sp.get()
->getMsRunRetentionTimePtr()
->getSeamarks());
if(trace.size() < min_number)
{
min_number = trace.size();
}
}
}
}
if(min_number > best_number)
{
best_number = min_number;
if(min_number > best_number)
{
best_number = min_number;
ms_run_best_reference = msrun_ref_sp;
ms_run_best_reference = msrun_ref_sp;
}
}
if(ms_run_best_reference != nullptr)
{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
<< " " << ms_run_best_reference.get()->getXmlId()
<< " best_number=" << best_number;
}
_p_work_monitor->message("done");
// emit operateXpipFile(filename);
emit findingBestMsrunForAlignmentFinished(ms_run_best_reference);
}
if(ms_run_best_reference != nullptr)
catch(pappso::PappsoException &error)
{
qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
<< ms_run_best_reference.get()->getXmlId()
<< " best_number=" << best_number;
throw pappso::PappsoException(
tr("Error while choosing best MS run :\n%1").arg(error.qwhat()));
}
_p_work_monitor->message("done");
// emit operateXpipFile(filename);
emit findingBestMsrunForAlignmentFinished(ms_run_best_reference);
}
catch(pappso::PappsoException &error)
{
......@@ -866,3 +889,52 @@ WorkerThread::doFindBestMsrunForAlignment(ProjectSp project_sp)
.arg(error.qwhat()));
}
}
void
WorkerThread::doCheckMsrunFilePath(ProjectSp msp_project)
{
MsRunSp msrun_sp = nullptr;
try
{
_p_work_monitor->setProgressMaximumValue(
msp_project->getIdentificationDataSourceStore()
.getIdentificationDataSourceList()
.size());
std::size_t i = 0;
for(IdentificationDataSourceSp p_ident_data_source :
msp_project->getIdentificationDataSourceStore()
.getIdentificationDataSourceList())
{
msrun_sp = p_ident_data_source->getMsRunSp();
_p_work_monitor->message(
tr("checking MS run file path for \"%1\", named \"%2\"")
.arg(msrun_sp.get()->getXmlId())
.arg(msrun_sp.get()->getSampleName()),
i);
if(msrun_sp->findMsRunFile())
{
// msrun_sp->checkMsRunStatistics();
msrun_sp = nullptr;
}
else
{
// is_ok = false;
break;
}
i++;
}
}
catch(pappso::PappsoException &error)
{
emit operationFailed(
tr("Error checking MSrun files path :\n%1").arg(error.qwhat()));
}
emit checkingMsrunFilePathFinished(msrun_sp);
}
......@@ -79,6 +79,7 @@ class WorkerThread : public QObject
doPtmGroupingOnIdentification(IdentificationGroup *p_identification_group);
void doRunningXtandem(TandemRunBatch tandem_run_batch);
void doFindBestMsrunForAlignment(ProjectSp project_sp);
void doCheckMsrunFilePath(ProjectSp project_sp);
signals:
......@@ -94,6 +95,7 @@ class WorkerThread : public QObject
void operationFinished();
void operationFailed(QString error);
void findingBestMsrunForAlignmentFinished(MsRunSp msrun_sp);
void checkingMsrunFilePathFinished(MsRunSp msrun_sp);
private:
WorkMonitor *_p_work_monitor;
......
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