libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
psmfilescanprocess.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/processing/cbor/psm/psmfilescanprocess.h
3 * \date 12/07/2025
4 * \author Olivier Langella
5 * \brief PSM file reader designed to parallelize scan process
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
10 *
11 * This file is part of PAPPSOms-tools.
12 *
13 * PAPPSOms-tools is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * PAPPSOms-tools is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
25 *
26 ******************************************************************************/
27
28
29#include "psmfilescanprocess.h"
31#include <QtConcurrent>
32
33
34namespace pappso
35{
36namespace cbor
37{
38namespace psm
39{
40
41PsmFileScanProcess::PsmFileScanProcess(std::size_t buffer_scan_size)
42{
43 m_bufferScanSize = buffer_scan_size;
44}
45
49
50void
52{
53 for(CborScanMapBase *cbor_scan_p : m_cborScanList)
54 {
55 delete cbor_scan_p;
56 }
57 m_cborScanList.clear();
58}
59
60
61void
63{
64 qDebug();
65 // auto& ref = elections.emplace_back("Nelson Mandela", "South Africa", 1994);
66 CborScanMapBase *scan_map_p = newCborScanMap();
67 m_cborScanList.push_back(scan_map_p);
68
69 if(!mpa_cborReader->readCborMap(*scan_map_p))
70 {
71 throw pappso::PappsoException(QObject::tr("readCborMap scan failed"));
72 }
73 // m_cborScanList.push_back(scan_map);
74 qDebug() << "scan end";
75 scanFinished(monitor);
76 qDebug();
77}
78
79void
81{
82
83 // monitor.setStatus(QObject::tr("PsmFileScanProcess::scanFinished
84 // %1").arg(m_cborScanList.size()));
86 {
87 processBufferScan(monitor);
89 }
90}
91
92void
94{
95 // qWarning() << "sampleFinished";
96 processBufferScan(monitor);
98}
99
100
101void
103{
104 // you decide how to process the list of scans
105 // monitor.setStatus(
106 // QObject::tr("PsmFileScanProcess::processBufferScan %1").arg(m_cborScanList.size()));
107 std::function<void(CborScanMapBase *)> mapProcessCborScan = [](CborScanMapBase *cbor_scan_p) {
108 cbor_scan_p->process();
109 };
110
111
112 QFuture<void> res = QtConcurrent::map<std::vector<CborScanMapBase *>::iterator>(
113 m_cborScanList.begin(), m_cborScanList.end(), mapProcessCborScan);
114 res.waitForFinished();
115 processBufferScanDone(monitor);
116
117 // monitor.setStatus(
118 // QObject::tr("PsmFileScanProcess::processBufferScan %1 done").arg(m_cborScanList.size()));
119}
120
121void
123{
124 // you decide what to do with processed scans
125}
126
127} // namespace psm
128} // namespace cbor
129} // namespace pappso
std::vector< CborScanMapBase * > m_cborScanList
void scanFinished(pappso::UiMonitorInterface &monitor) override
void readScan(pappso::UiMonitorInterface &monitor) override
void sampleFinished(pappso::UiMonitorInterface &monitor) override
virtual void processBufferScanDone(pappso::UiMonitorInterface &monitor)
PsmFileScanProcess(std::size_t buffer_scan_size)
virtual void processBufferScan(pappso::UiMonitorInterface &monitor)
virtual CborScanMapBase * newCborScanMap()=0
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39