Commit 02ada02c authored by Langella Olivier's avatar Langella Olivier
Browse files

The msrun object now handles locally any specific statistics computation on any msrun file format

parent 5a44352b
......@@ -290,55 +290,62 @@ MsRun::findMsRunFile()
void
MsRun::checkMsRunStatistics()
{
QVariant msrun_var = getMsRunStatistics(MsRunStatistics::total_spectra);
if(msrun_var.isNull())
{
try
{
MsRunStatisticsHandler stats;
_msrun_reader_sp = getMsRunReaderSPtr();
_msrun_reader_sp.get()->readSpectrumCollection(stats);
setMsRunStatistics(MsRunStatistics::total_spectra,
(unsigned int)stats.getTotalCount());
setMsRunStatistics(MsRunStatistics::total_spectra_ms1,
(unsigned int)stats.getMsLevelCount(1));
setMsRunStatistics(MsRunStatistics::total_spectra_ms2,
(unsigned int)stats.getMsLevelCount(2));
setMsRunStatistics(MsRunStatistics::total_spectra_ms3,
(unsigned int)stats.getMsLevelCount(3));
setMsRunStatistics(MsRunStatistics::tic_spectra_ms1,
stats.getMsLevelTic(1));
setMsRunStatistics(MsRunStatistics::tic_spectra_ms2,
stats.getMsLevelTic(2));
setMsRunStatistics(MsRunStatistics::tic_spectra_ms3,
stats.getMsLevelTic(3));
}
catch(pappso::ExceptionNotFound &error)
{
// no file found, no statistics
}
}
freeMsRunReaderSp();
MsRunStatisticsHandler stats;
checkMsRunStatistics(&stats);
}
void
MsRun::checkMsRunStatistics(MsRunStatisticsHandler *currentHandler)
{
QVariant msrun_var = getMsRunStatistics(MsRunStatistics::total_spectra);
if(msrun_var.isNull())
{
try
{
_msrun_reader_sp = getMsRunReaderSPtr();
_msrun_reader_sp.get()->readSpectrumCollection(*currentHandler);
if(currentHandler->shouldStop())
{ // statistics handler was stopped : don't use collected statistics
// because it is only partial
if(this->getMzFormat() == pappso::MzFormat::brukerTims)
{
pappso::TimsMsRunReaderMs2 *tims2_reader =
dynamic_cast<pappso::TimsMsRunReaderMs2 *>(
_msrun_reader_sp.get());
if(tims2_reader != nullptr)
{
pappso::TimsDataSp tims_data =
tims2_reader->getTimsDataSPtr();
if(currentHandler->shouldStop())
{ // statistics handler was stopped : don't use collected
// statistics because it is only partial
}
else
{
setMsRunStatistics(MsRunStatistics::total_spectra, "NA");
// not the number of MS1 or MS2 but the number of scans
// and
// precursors.
// Compute from th mobillity results
setMsRunStatistics(
MsRunStatistics::total_spectra_ms1,
(unsigned int)tims_data->getTotalNumberOfPrecursors());
setMsRunStatistics(
MsRunStatistics::total_spectra_ms2,
(unsigned int)tims_data->getTotalNumberOfScans());
setMsRunStatistics(MsRunStatistics::total_spectra_ms3, 0);
setMsRunStatistics(MsRunStatistics::tic_spectra_ms1,
"NA");
setMsRunStatistics(MsRunStatistics::tic_spectra_ms2,
"NA");
setMsRunStatistics(MsRunStatistics::tic_spectra_ms3,
"NA");
}
}
}
else
{
_msrun_reader_sp.get()->readSpectrumCollection(*currentHandler);
setMsRunStatistics(MsRunStatistics::total_spectra,
(unsigned int)currentHandler->getTotalCount());
setMsRunStatistics(
......@@ -366,46 +373,6 @@ MsRun::checkMsRunStatistics(MsRunStatisticsHandler *currentHandler)
freeMsRunReaderSp();
}
void
MsRun::checkMsRunStatisticsForTdf(MsRunStatisticsHandler *currentHandler)
{
QVariant msrun_var = getMsRunStatistics(MsRunStatistics::total_spectra);
if(msrun_var.isNull())
{
try
{
QString directory =
QFileInfo(getFileName()).absoluteDir().absolutePath();
pappso::TimsData *tims_data = new pappso::TimsData(directory);
if(currentHandler->shouldStop())
{ // statistics handler was stopped : don't use collected statistics
// because it is only partial
}
else
{
setMsRunStatistics(MsRunStatistics::total_spectra, "NA");
// not the number of MS1 or MS2 but the number of scans and
// precursors.
// Compute from th mobillity results
setMsRunStatistics(
MsRunStatistics::total_spectra_ms1,
(unsigned int)tims_data->getTotalNumberOfPrecursors());
setMsRunStatistics(
MsRunStatistics::total_spectra_ms2,
(unsigned int)tims_data->getTotalNumberOfScans());
setMsRunStatistics(MsRunStatistics::total_spectra_ms3, 0);
setMsRunStatistics(MsRunStatistics::tic_spectra_ms1, "NA");
setMsRunStatistics(MsRunStatistics::tic_spectra_ms2, "NA");
setMsRunStatistics(MsRunStatistics::tic_spectra_ms3, "NA");
}
}
catch(pappso::ExceptionNotFound &error)
{
// no file found, no statistics
}
}
}
pappso::MsRunXicExtractorInterfaceSp
MsRun::getMsRunXicExtractorInterfaceSp()
{
......
......@@ -85,7 +85,6 @@ class MsRun : public pappso::MsRunId
void checkMsRunStatistics();
void checkMsRunStatistics(MsRunStatisticsHandler *currentHandler);
void checkMsRunStatisticsForTdf(MsRunStatisticsHandler *currentHandler);
pappso::MsRunXicExtractorInterfaceSp getMsRunXicExtractorInterfaceSp();
......
......@@ -153,68 +153,6 @@ MsIdListWorkerStatus::getStatus(
void
MsIdListWorkerStatus::doComputeMsNumber(
IdentificationDataSourceSp identificationDataSource)
{
if(QFileInfo(identificationDataSource.get()->getMsRunSp()->getFileName())
.completeSuffix() == "tdf")
{
doComputeMsNumberForTDF(identificationDataSource);
}
else
{
doComputeMsNumberForMzXML(identificationDataSource);
}
}
void
MsIdListWorkerStatus::changeWaitingQueue(int row [[maybe_unused]])
{
m_waitingComputing.clear();
qDebug() << m_waitingComputing.size();
}
void
MsIdListWorkerStatus::doComputeMsNumberForTDF(
IdentificationDataSourceSp identificationDataSource)
{
if(identificationDataSource->getMsRunSp()->findMsRunFile())
{
try
{
if(mpa_currentHandler == nullptr)
{
mpa_currentHandler =
new MsIdentificationTableMsRunStatisticsHandler;
identificationDataSource->getMsRunSp()
->checkMsRunStatisticsForTdf(mpa_currentHandler);
if(!mpa_currentHandler->shouldStop())
{
// if statistics computing is interrupted : don't take
// into account results because it is partial
m_identificationReady.push_back(
identificationDataSource.get());
}
delete mpa_currentHandler;
mpa_currentHandler = nullptr;
}
}
catch(pappso::PappsoException &error)
{
// error while computing
qDebug() << error.qwhat();
m_identificationError.push_back(identificationDataSource.get());
}
}
else
{
// file not found
m_identificationFileNotFound.push_back(identificationDataSource.get());
}
}
void
MsIdListWorkerStatus::doComputeMsNumberForMzXML(
IdentificationDataSourceSp identificationDataSource)
{
qDebug() << "AAAAAAAAAAAAAAAAAAAAAAAA";
pappso::MsRunReaderSPtr msrun_reader_sp =
......@@ -272,3 +210,10 @@ MsIdListWorkerStatus::doComputeMsNumberForMzXML(
m_identificationFileNotFound.push_back(identificationDataSource.get());
}
}
void
MsIdListWorkerStatus::changeWaitingQueue(int row [[maybe_unused]])
{
m_waitingComputing.clear();
qDebug() << m_waitingComputing.size();
}
......@@ -77,10 +77,6 @@ class MsIdListWorkerStatus
*/
WorkerStatus getStatus(IdentificationDataSourceSp identificationDataSource);
void doComputeMsNumber(IdentificationDataSourceSp identificationDataSource);
void
doComputeMsNumberForTDF(IdentificationDataSourceSp identificationDataSource);
void doComputeMsNumberForMzXML(
IdentificationDataSourceSp identificationDataSource);
void changeWaitingQueue(int row);
......
......@@ -153,15 +153,7 @@ SampleSheet::writeIdentificationDataSource(
{
if(msrun_sp->findMsRunFile())
{
if(QFileInfo(msrun_sp->getFileName()).completeSuffix() == "tdf")
{
msrun_sp->checkMsRunStatisticsForTdf(
new MsRunStatisticsHandler());
}
else
{
msrun_sp->checkMsRunStatistics();
}
msrun_sp->checkMsRunStatistics();
}
msrun_sp->freeMsRunReaderSp();
}
......
Supports Markdown
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