Loading...
Searching...
No Matches
psmfilescanprocess.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/processing/cbor/psm/psmfilescanprocess.h
* \date 12/07/2025
* \author Olivier Langella
* \brief PSM file reader designed to parallelize scan process
*/
/*******************************************************************************
* Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
*
* This file is part of PAPPSOms-tools.
*
* PAPPSOms-tools 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.
*
* PAPPSOms-tools 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 PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "psmfilescanprocess.h"
#include "pappsomspp/core/pappsoexception.h"
#include <QtConcurrent>
namespace pappso
{
namespace cbor
{
namespace psm
{
PsmFileScanProcess::PsmFileScanProcess(std::size_t buffer_scan_size)
{
m_bufferScanSize = buffer_scan_size;
}
PsmFileScanProcess::~PsmFileScanProcess()
{
}
void
PsmFileScanProcess::clearScanBuffer()
{
for(CborScanMapBase *cbor_scan_p : m_cborScanList)
{
delete cbor_scan_p;
}
m_cborScanList.clear();
}
void
PsmFileScanProcess::readScan(pappso::UiMonitorInterface &monitor)
{
qDebug();
// auto& ref = elections.emplace_back("Nelson Mandela", "South Africa", 1994);
CborScanMapBase *scan_map_p = newCborScanMap();
m_cborScanList.push_back(scan_map_p);
if(!mpa_cborReader->readCborMap(*scan_map_p))
{
throw pappso::PappsoException(QObject::tr("readCborMap scan failed"));
}
// m_cborScanList.push_back(scan_map);
qDebug() << "scan end";
scanFinished(monitor);
qDebug();
}
void
PsmFileScanProcess::scanFinished(pappso::UiMonitorInterface &monitor)
{
// monitor.setStatus(QObject::tr("PsmFileScanProcess::scanFinished
// %1").arg(m_cborScanList.size()));
if(m_cborScanList.size() > m_bufferScanSize)
{
processBufferScan(monitor);
clearScanBuffer();
}
}
void
PsmFileScanProcess::sampleFinished(pappso::UiMonitorInterface &monitor)
{
// qWarning() << "sampleFinished";
processBufferScan(monitor);
clearScanBuffer();
}
void
PsmFileScanProcess::processBufferScan(pappso::UiMonitorInterface &monitor)
{
// you decide how to process the list of scans
// monitor.setStatus(
// QObject::tr("PsmFileScanProcess::processBufferScan %1").arg(m_cborScanList.size()));
std::function<void(CborScanMapBase *)> mapProcessCborScan = [](CborScanMapBase *cbor_scan_p) {
cbor_scan_p->process();
};
QFuture<void> res = QtConcurrent::map<std::vector<CborScanMapBase *>::iterator>(
m_cborScanList.begin(), m_cborScanList.end(), mapProcessCborScan);
res.waitForFinished();
processBufferScanDone(monitor);
// monitor.setStatus(
// QObject::tr("PsmFileScanProcess::processBufferScan %1 done").arg(m_cborScanList.size()));
}
void
PsmFileScanProcess::processBufferScanDone(pappso::UiMonitorInterface &monitor [[maybe_unused]])
{
// you decide what to do with processed scans
}
} // namespace psm
} // namespace cbor
} // namespace pappso
pappso::PappsoException
Definition pappsoexception.h:41
pappso::UiMonitorInterface
Definition uimonitorinterface.h:50
pappso::cbor::CborStreamReaderInterface::mpa_cborReader
CborStreamReader * mpa_cborReader
Definition cborstreamreaderinterface.h:68
pappso::cbor::psm::PsmFileScanProcess::m_cborScanList
std::vector< CborScanMapBase * > m_cborScanList
Definition psmfilescanprocess.h:74
pappso::cbor::psm::PsmFileScanProcess::scanFinished
void scanFinished(pappso::UiMonitorInterface &monitor) override
Definition psmfilescanprocess.cpp:80
pappso::cbor::psm::PsmFileScanProcess::m_bufferScanSize
std::size_t m_bufferScanSize
Definition psmfilescanprocess.h:73
pappso::cbor::psm::PsmFileScanProcess::CborScanMapBase
friend CborScanMapBase
Definition psmfilescanprocess.h:49
pappso::cbor::psm::PsmFileScanProcess::readScan
void readScan(pappso::UiMonitorInterface &monitor) override
Definition psmfilescanprocess.cpp:62
pappso::cbor::psm::PsmFileScanProcess::sampleFinished
void sampleFinished(pappso::UiMonitorInterface &monitor) override
Definition psmfilescanprocess.cpp:93
pappso::cbor::psm::PsmFileScanProcess::~PsmFileScanProcess
virtual ~PsmFileScanProcess()
Definition psmfilescanprocess.cpp:46
pappso::cbor::psm::PsmFileScanProcess::processBufferScanDone
virtual void processBufferScanDone(pappso::UiMonitorInterface &monitor)
Definition psmfilescanprocess.cpp:122
pappso::cbor::psm::PsmFileScanProcess::PsmFileScanProcess
PsmFileScanProcess(std::size_t buffer_scan_size)
Definition psmfilescanprocess.cpp:41
pappso::cbor::psm::PsmFileScanProcess::processBufferScan
virtual void processBufferScan(pappso::UiMonitorInterface &monitor)
Definition psmfilescanprocess.cpp:102
pappso::cbor::psm::PsmFileScanProcess::clearScanBuffer
void clearScanBuffer()
Definition psmfilescanprocess.cpp:51
pappso::cbor::psm::PsmFileScanProcess::newCborScanMap
virtual CborScanMapBase * newCborScanMap()=0
pappso::cbor::psm
Definition cborscanmapbase.h:40
pappso::cbor
Definition cborstreamreader.cpp:35
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappsoexception.h
psmfilescanprocess.h