libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
mzcbormsrunreader.h
Go to the documentation of this file.
1/**
2 * \file pappsomspp/msrun/private/timsmsrunreader.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
32
33namespace pappso
34{
35
36/**
37 * @todo write docs
38 */
40{
41 public:
42 /**
43 * Default constructor
44 */
45 MzcborMsRunReader(MsRunIdCstSPtr &msrun_id_csp);
46
47 /**
48 * Destructor
49 */
50 virtual ~MzcborMsRunReader();
51
52
53 virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override;
54 virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override;
55
56 virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index,
57 bool want_binary_data = true) const override;
58
59 virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override;
60
61 virtual void readSpectrumCollection2(const MsRunReadConfig &config,
62 SpectrumCollectionHandlerInterface &handler) override;
63
65 newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index,
66 pappso::PrecisionPtr precision) const override;
67
70 pappso::PrecisionPtr precision) const override;
71
73 unsigned int ms_level) override;
74
75
76 virtual std::size_t spectrumListSize() const override;
77
78 virtual bool releaseDevice() override;
79
80 virtual bool acquireDevice() override;
81
82 virtual std::size_t
83 spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) override;
84
85
86 /** @brief tells if spectra can be accessed using scan numbers
87 * by default, it returns false. Only overrided functions can check if scan
88 * numbers are available in the current file
89 * if there are some Thermo native ids, this should be set to true
90 */
91 virtual bool hasScanNumbers() const override;
92
93
94 /** @brief if possible, converts a scan number into a spectrum index
95 * This is a convenient function to help transition from the old scan number
96 * (not implemented by all vendors) to more secure spectrum index (not vendor
97 * dependant).
98 * It is better to not rely on this function.
99 */
100 virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number) override;
101
102
103 const std::vector<qint64> &getSpectrumIndexPositionInFile() const;
104
105 virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const override;
106 virtual Trace getTicChromatogram() override;
107 virtual std::vector<double> getRetentionTimeLine() override;
108
109 protected:
110 virtual void initialize() override;
111 virtual bool accept(const QString &file_name) const override;
112
113 private:
116
117 void fillMzcborSpectrum(std::size_t spectrum_index,
119 bool want_binary_data) const;
120
121 private:
122 QFileInfo m_cborFileInfo;
123 std::vector<qint64> m_spectrumIndexPositionInFile;
124 std::vector<qint64> m_spectrumTotalIonCountList;
125 std::vector<std::uint8_t> m_spectrumMsLevelList;
126 std::vector<double> m_spectrumRtList;
127 std::map<QString, std::size_t> m_nativeId2SpectrumIndexMap;
128 std::map<std::size_t, std::size_t> m_scan2SpectrumIndexMap;
129
130 QFile *mpa_mzcborFileDevice = nullptr;
131};
132} // 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
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
MzcborMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
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:148
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.