libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
mzcbormsrunreader.h
Go to the documentation of this file.
1/**
2 * \file pappsomspp/core/msrun/private/mzcbormsrunreader.h
3 * \date 21/11/2025
4 * \author Olivier Langella
5 * \brief MSrun file reader for mzcbor
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
10 *
11 * This file is part of the PAPPSOms++ library.
12 *
13 * PAPPSOms++ 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++ 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++. If not, see <http://www.gnu.org/licenses/>.
25 *
26 ******************************************************************************/
27
28#pragma once
29
30#include <QFileInfo>
34
35namespace pappso
36{
37
38/**
39 * @todo write docs
40 */
42{
43 public:
44 /**
45 * Default constructor
46 */
47 MzcborMsRunReader(MsRunIdCstSPtr &msrun_id_csp);
48
49 /**
50 * Destructor
51 */
52 virtual ~MzcborMsRunReader();
53
54
55 virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override;
56 virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override;
57
58 virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index,
59 bool want_binary_data = true) const override;
60
61 virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override;
62
63 virtual void readSpectrumCollection2(const MsRunReadConfig &config,
64 SpectrumCollectionHandlerInterface &handler) override;
65
67 newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index,
68 pappso::PrecisionPtr precision) const override;
69
72 pappso::PrecisionPtr precision) const override;
73
75 unsigned int ms_level) override;
76
77
78 virtual std::size_t spectrumListSize() const override;
79
80 virtual bool releaseDevice() override;
81
82 virtual bool acquireDevice() override;
83
84 virtual std::size_t
85 spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) override;
86
87
88 /** @brief tells if spectra can be accessed using scan numbers
89 * by default, it returns false. Only overrided functions can check if scan
90 * numbers are available in the current file
91 * if there are some Thermo native ids, this should be set to true
92 */
93 virtual bool hasScanNumbers() const override;
94
95
96 /** @brief if possible, converts a scan number into a spectrum index
97 * This is a convenient function to help transition from the old scan number
98 * (not implemented by all vendors) to more secure spectrum index (not vendor
99 * dependant).
100 * It is better to not rely on this function.
101 */
102 virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number) override;
103
104
105 const std::vector<qint64> &getSpectrumIndexPositionInFile() const;
106
107 virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const override;
108 virtual Trace getTicChromatogram() override;
109 virtual std::vector<double> getRetentionTimeLine() override;
110
111
112 /** @brief get spectrum mzML element
113 * @param spectrum_index spectrum to retrieve
114 * @param want_binary_data true to get peak list
115 * @return shared pointer on spectrum structure
116 */
117 std::shared_ptr<pappso::cbor::mzcbor::Spectrum> getMzcborSpectrumSp(std::size_t spectrum_index,
118 bool want_binary_data) const;
119
120 protected:
121 virtual void initialize() override;
122 virtual bool accept(const QString &file_name) const override;
123
124 virtual void fillMzcborSpectrum(std::size_t spectrum_index,
126 bool want_binary_data) const;
127
128 private:
131
132 protected:
133 QFileInfo m_cborFileInfo;
134 std::vector<qint64> m_spectrumIndexPositionInFile;
135 std::vector<qint64> m_spectrumTotalIonCountList;
136 std::vector<std::uint8_t> m_spectrumMsLevelList;
137 std::vector<double> m_spectrumRtList;
138 std::map<QString, std::size_t> m_nativeId2SpectrumIndexMap;
139 std::map<std::size_t, std::size_t> m_scan2SpectrumIndexMap;
140
141 QFile *mpa_mzcborFileDevice = nullptr;
142};
143} // namespace pappso
MsRunReader(const MsRunIdCstSPtr &ms_run_id)
virtual std::vector< double > getRetentionTimeLine() override
retention timeline get retention times along the MSrun in seconds
const std::vector< qint64 > & getSpectrumIndexPositionInFile() const
virtual pappso::XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum index
std::map< QString, std::size_t > m_nativeId2SpectrumIndexMap
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
std::vector< qint64 > m_spectrumTotalIonCountList
virtual pappso::XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum(const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum
virtual bool hasScanNumbers() const override
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
void readSpectrumCollectionWithMsrunReadConfig(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const override
get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: i...
virtual Trace getTicChromatogram() override
get a TIC chromatogram
virtual bool releaseDevice() override
release data back end device if a the data back end is released, the developper has to use acquireDev...
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
std::vector< qint64 > m_spectrumIndexPositionInFile
virtual std::size_t spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) override
if possible, get the spectrum index given a string identifier throw a not found exception if spectrum...
std::vector< double > m_spectrumRtList
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override
virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number) override
if possible, converts a scan number into a spectrum index This is a convenient function to help trans...
std::map< std::size_t, std::size_t > m_scan2SpectrumIndexMap
std::shared_ptr< pappso::cbor::mzcbor::Spectrum > getMzcborSpectrumSp(std::size_t spectrum_index, bool want_binary_data) const
get spectrum mzML element
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
MzcborMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
virtual void fillMzcborSpectrum(std::size_t spectrum_index, pappso::cbor::mzcbor::Spectrum &spectrum, bool want_binary_data) const
virtual void readSpectrumCollectionByMsLevel(SpectrumCollectionHandlerInterface &handler, unsigned int ms_level) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override
get a MassSpectrumSPtr class given its spectrum index
std::vector< std::uint8_t > m_spectrumMsLevelList
virtual bool acquireDevice() override
acquire data back end device
virtual bool accept(const QString &file_name) const override
tells if the reader is able to handle this file must be implemented by private MS run reader,...
virtual void initialize() override
Class representing a fully specified mass spectrum.
interface to collect spectrums from the MsRunReader class
A simple container of DataPoint instances.
Definition trace.h:152
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition msrunid.h:46
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:44
PSI spectrum object for mzML/mzCBOR.