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>
33
34namespace pappso
35{
36
37/**
38 * @todo write docs
39 */
41{
42 public:
43 /**
44 * Default constructor
45 */
46 MzcborMsRunReader(MsRunIdCstSPtr &msrun_id_csp);
47
48 /**
49 * Destructor
50 */
51 virtual ~MzcborMsRunReader();
52
53
54 virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override;
55 virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override;
56
57 virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index,
58 bool want_binary_data = true) const override;
59
60 virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override;
61
62 virtual void readSpectrumCollection2(const MsRunReadConfig &config,
63 SpectrumCollectionHandlerInterface &handler) override;
64
66 newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index,
67 pappso::PrecisionPtr precision) const override;
68
71 pappso::PrecisionPtr precision) const override;
72
74 unsigned int ms_level) override;
75
76
77 virtual std::size_t spectrumListSize() const override;
78
79 virtual bool releaseDevice() override;
80
81 virtual bool acquireDevice() override;
82
83 virtual std::size_t
84 spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) override;
85
86
87 /** @brief tells if spectra can be accessed using scan numbers
88 * by default, it returns false. Only overrided functions can check if scan
89 * numbers are available in the current file
90 * if there are some Thermo native ids, this should be set to true
91 */
92 virtual bool hasScanNumbers() const override;
93
94
95 /** @brief if possible, converts a scan number into a spectrum index
96 * This is a convenient function to help transition from the old scan number
97 * (not implemented by all vendors) to more secure spectrum index (not vendor
98 * dependant).
99 * It is better to not rely on this function.
100 */
101 virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number) override;
102
103
104 const std::vector<qint64> &getSpectrumIndexPositionInFile() const;
105
106 virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const override;
107 virtual Trace getTicChromatogram() override;
108 virtual std::vector<double> getRetentionTimeLine() override;
109
110
111 /** @brief get spectrum mzML element
112 * @param spectrum_index spectrum to retrieve
113 * @param want_binary_data true to get peak list
114 * @return shared pointer on spectrum structure
115 */
116 std::shared_ptr<pappso::cbor::mzcbor::Spectrum> getMzcborSpectrumSp(std::size_t spectrum_index,
117 bool want_binary_data) const;
118
119 protected:
120 virtual void initialize() override;
121 virtual bool accept(const QString &file_name) const override;
122
123 virtual void fillMzcborSpectrum(std::size_t spectrum_index,
125 bool want_binary_data) const;
126
127 private:
130
131 protected:
132 QFileInfo m_cborFileInfo;
133 std::vector<qint64> m_spectrumIndexPositionInFile;
134 std::vector<qint64> m_spectrumTotalIonCountList;
135 std::vector<std::uint8_t> m_spectrumMsLevelList;
136 std::vector<double> m_spectrumRtList;
137 std::map<QString, std::size_t> m_nativeId2SpectrumIndexMap;
138 std::map<std::size_t, std::size_t> m_scan2SpectrumIndexMap;
139
140 QFile *mpa_mzcborFileDevice = nullptr;
141};
142} // 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
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.