Loading...
Searching...
No Matches
mzcbormsrunreader.h
Go to the documentation of this file.
/**
* \file pappsomspp/core/msrun/private/mzcbormsrunreader.h
* \date 21/11/2025
* \author Olivier Langella
* \brief MSrun file reader for mzcbor
*/
/*******************************************************************************
* Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ 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++ 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++. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#pragma once
#include <QFileInfo>
#include "pappsomspp/core/msrun/msrunreader.h"
#include "pappsomspp/core/processing/cbor/mzcbor/spectrum.h"
#include "pappsomspp/export-import-config.h"
namespace pappso
{
/**
* @todo write docs
*/
class PMSPP_LIB_DECL MzcborMsRunReader : public MsRunReader
{
public:
/**
* Default constructor
*/
MzcborMsRunReader(MsRunIdCstSPtr &msrun_id_csp);
/**
* Destructor
*/
virtual ~MzcborMsRunReader();
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override;
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override;
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index,
bool want_binary_data = true) const override;
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override;
virtual void readSpectrumCollection2(const MsRunReadConfig &config,
SpectrumCollectionHandlerInterface &handler) override;
virtual pappso::XicCoordSPtr
newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index,
pappso::PrecisionPtr precision) const override;
virtual pappso::XicCoordSPtr
newXicCoordSPtrFromQualifiedMassSpectrum(const pappso::QualifiedMassSpectrum &mass_spectrum,
pappso::PrecisionPtr precision) const override;
virtual void readSpectrumCollectionByMsLevel(SpectrumCollectionHandlerInterface &handler,
unsigned int ms_level) override;
virtual std::size_t spectrumListSize() const override;
virtual bool releaseDevice() override;
virtual bool acquireDevice() override;
virtual std::size_t
spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) override;
/** @brief tells if spectra can be accessed using scan numbers
* by default, it returns false. Only overrided functions can check if scan
* numbers are available in the current file
* if there are some Thermo native ids, this should be set to true
*/
virtual bool hasScanNumbers() const override;
/** @brief if possible, converts a scan number into a spectrum index
* This is a convenient function to help transition from the old scan number
* (not implemented by all vendors) to more secure spectrum index (not vendor
* dependant).
* It is better to not rely on this function.
*/
virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number) override;
const std::vector<qint64> &getSpectrumIndexPositionInFile() const;
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const override;
virtual Trace getTicChromatogram() override;
virtual std::vector<double> getRetentionTimeLine() override;
/** @brief get spectrum mzML element
* @param spectrum_index spectrum to retrieve
* @param want_binary_data true to get peak list
* @return shared pointer on spectrum structure
*/
std::shared_ptr<pappso::cbor::mzcbor::Spectrum> getMzcborSpectrumSp(std::size_t spectrum_index,
bool want_binary_data) const;
protected:
virtual void initialize() override;
virtual bool accept(const QString &file_name) const override;
virtual void fillMzcborSpectrum(std::size_t spectrum_index,
pappso::cbor::mzcbor::Spectrum &spectrum,
bool want_binary_data) const;
private:
void readSpectrumCollectionWithMsrunReadConfig(const MsRunReadConfig &config,
SpectrumCollectionHandlerInterface &handler);
protected:
QFileInfo m_cborFileInfo;
std::vector<qint64> m_spectrumIndexPositionInFile;
std::vector<qint64> m_spectrumTotalIonCountList;
std::vector<std::uint8_t> m_spectrumMsLevelList;
std::vector<double> m_spectrumRtList;
std::map<QString, std::size_t> m_nativeId2SpectrumIndexMap;
std::map<std::size_t, std::size_t> m_scan2SpectrumIndexMap;
QFile *mpa_mzcborFileDevice = nullptr;
};
} // namespace pappso
pappso::MsRunReadConfig
Definition msrunreadconfig.h:62
pappso::MsRunReader::MsRunReader
MsRunReader(const MsRunIdCstSPtr &ms_run_id)
Definition msrunreader.cpp:43
pappso::MzcborMsRunReader::getRetentionTimeLine
virtual std::vector< double > getRetentionTimeLine() override
retention timeline get retention times along the MSrun in seconds
Definition mzcbormsrunreader.cpp:614
pappso::MzcborMsRunReader::getSpectrumIndexPositionInFile
const std::vector< qint64 > & getSpectrumIndexPositionInFile() const
Definition mzcbormsrunreader.cpp:54
pappso::MzcborMsRunReader::newXicCoordSPtrFromSpectrumIndex
virtual pappso::XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum index
Definition mzcbormsrunreader.cpp:247
pappso::MzcborMsRunReader::m_nativeId2SpectrumIndexMap
std::map< QString, std::size_t > m_nativeId2SpectrumIndexMap
Definition mzcbormsrunreader.h:138
pappso::MzcborMsRunReader::readSpectrumCollection2
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
Definition mzcbormsrunreader.cpp:438
pappso::MzcborMsRunReader::m_spectrumTotalIonCountList
std::vector< qint64 > m_spectrumTotalIonCountList
Definition mzcbormsrunreader.h:135
pappso::MzcborMsRunReader::mpa_mzcborFileDevice
QFile * mpa_mzcborFileDevice
Definition mzcbormsrunreader.h:141
pappso::MzcborMsRunReader::m_cborFileInfo
QFileInfo m_cborFileInfo
Definition mzcbormsrunreader.h:133
pappso::MzcborMsRunReader::newXicCoordSPtrFromQualifiedMassSpectrum
virtual pappso::XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum(const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum
Definition mzcbormsrunreader.cpp:235
pappso::MzcborMsRunReader::hasScanNumbers
virtual bool hasScanNumbers() const override
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
Definition mzcbormsrunreader.cpp:152
pappso::MzcborMsRunReader::readSpectrumCollectionWithMsrunReadConfig
void readSpectrumCollectionWithMsrunReadConfig(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)
Definition mzcbormsrunreader.cpp:498
pappso::MzcborMsRunReader::getOboPsiModTermInstrumentModelName
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const override
get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: i...
Definition mzcbormsrunreader.cpp:203
pappso::MzcborMsRunReader::getTicChromatogram
virtual Trace getTicChromatogram() override
get a TIC chromatogram
Definition mzcbormsrunreader.cpp:591
pappso::MzcborMsRunReader::releaseDevice
virtual bool releaseDevice() override
release data back end device if a the data back end is released, the developper has to use acquireDev...
Definition mzcbormsrunreader.cpp:222
pappso::MzcborMsRunReader::readSpectrumCollection
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
Definition mzcbormsrunreader.cpp:395
pappso::MzcborMsRunReader::m_spectrumIndexPositionInFile
std::vector< qint64 > m_spectrumIndexPositionInFile
Definition mzcbormsrunreader.h:134
pappso::MzcborMsRunReader::spectrumStringIdentifier2SpectrumIndex
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...
Definition mzcbormsrunreader.cpp:484
pappso::MzcborMsRunReader::m_spectrumRtList
std::vector< double > m_spectrumRtList
Definition mzcbormsrunreader.h:137
pappso::MzcborMsRunReader::massSpectrumCstSPtr
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override
Definition mzcbormsrunreader.cpp:287
pappso::MzcborMsRunReader::scanNumber2SpectrumIndex
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...
Definition mzcbormsrunreader.cpp:163
pappso::MzcborMsRunReader::m_scan2SpectrumIndexMap
std::map< std::size_t, std::size_t > m_scan2SpectrumIndexMap
Definition mzcbormsrunreader.h:139
pappso::MzcborMsRunReader::getMzcborSpectrumSp
std::shared_ptr< pappso::cbor::mzcbor::Spectrum > getMzcborSpectrumSp(std::size_t spectrum_index, bool want_binary_data) const
get spectrum mzML element
Definition mzcbormsrunreader.cpp:636
pappso::MzcborMsRunReader::spectrumListSize
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
Definition mzcbormsrunreader.cpp:478
pappso::MzcborMsRunReader::MzcborMsRunReader
MzcborMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
Definition mzcbormsrunreader.cpp:40
pappso::MzcborMsRunReader::fillMzcborSpectrum
virtual void fillMzcborSpectrum(std::size_t spectrum_index, pappso::cbor::mzcbor::Spectrum &spectrum, bool want_binary_data) const
Definition mzcbormsrunreader.cpp:534
pappso::MzcborMsRunReader::readSpectrumCollectionByMsLevel
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
Definition mzcbormsrunreader.cpp:467
pappso::MzcborMsRunReader::qualifiedMassSpectrum
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
Definition mzcbormsrunreader.cpp:325
pappso::MzcborMsRunReader::massSpectrumSPtr
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override
get a MassSpectrumSPtr class given its spectrum index
Definition mzcbormsrunreader.cpp:293
pappso::MzcborMsRunReader::m_spectrumMsLevelList
std::vector< std::uint8_t > m_spectrumMsLevelList
Definition mzcbormsrunreader.h:136
pappso::MzcborMsRunReader::acquireDevice
virtual bool acquireDevice() override
acquire data back end device
Definition mzcbormsrunreader.cpp:210
pappso::MzcborMsRunReader::accept
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,...
Definition mzcbormsrunreader.cpp:194
pappso::MzcborMsRunReader::initialize
virtual void initialize() override
Definition mzcbormsrunreader.cpp:61
pappso::OboPsiModTerm
Definition obopsimodterm.h:34
pappso::QualifiedMassSpectrum
Class representing a fully specified mass spectrum.
Definition qualifiedmassspectrum.h:99
pappso::SpectrumCollectionHandlerInterface
interface to collect spectrums from the MsRunReader class
Definition spectrumcollectionhandlerinterface.h:52
pappso::Trace
A simple container of DataPoint instances.
Definition trace.h:152
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition export-import-config.h:14
msrunreader.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::MsRunIdCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition msrunid.h:46
pappso::MassSpectrumCstSPtr
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition massspectrum.h:54
pappso::PrecisionPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition massspectrum.h:53
pappso::XicCoordSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:44
spectrum.h
PSI spectrum object for mzML/mzCBOR.
pappso::cbor::mzcbor::Spectrum
Definition spectrum.h:51