Loading...
Searching...
No Matches
pappso::MzcborMsRunReader Class Reference

`#include <mzcbormsrunreader.h>`

Inheritance diagram for pappso::MzcborMsRunReader:

## Public Member Functions

| MzcborMsRunReader (MsRunIdCstSPtr &msrun_id_csp)
virtual | ~MzcborMsRunReader ()
virtual MassSpectrumSPtr | massSpectrumSPtr (std::size_t spectrum_index) override
| get a MassSpectrumSPtr class given its spectrum index
virtual MassSpectrumCstSPtr | massSpectrumCstSPtr (std::size_t spectrum_index) override
virtual QualifiedMassSpectrum | qualifiedMassSpectrum (std::size_t spectrum_index, bool want_binary_data=true) const override
| get a QualifiedMassSpectrum class given its scan number
virtual void | readSpectrumCollection (SpectrumCollectionHandlerInterface &handler) override
| function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
virtual void | readSpectrumCollection2 (const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler) override
| function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
virtual pappso::XicCoordSPtr | newXicCoordSPtrFromSpectrumIndex (std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
| get a xic coordinate object from a given spectrum index
virtual pappso::XicCoordSPtr | newXicCoordSPtrFromQualifiedMassSpectrum (const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
| get a xic coordinate object from a given spectrum
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 std::size_t | spectrumListSize () const override
| get the totat number of spectrum conained in the MSrun data file
virtual bool | releaseDevice () override
| release data back end device if a the data back end is released, the developper has to use acquireDevice before using the msrunreader object
virtual bool | acquireDevice () override
| acquire data back end device
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 identifier is not found
virtual bool | hasScanNumbers () const override
| 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 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 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.
const std::vector< qint64 > & | getSpectrumIndexPositionInFile () const
virtual const OboPsiModTerm | getOboPsiModTermInstrumentModelName () const override
| get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: instrument model def: "Instrument model name not including the vendor's name." [PSI:MS] relationship: part_of MS:1000463 ! instrument
virtual Trace | getTicChromatogram () override
| get a TIC chromatogram
virtual std::vector< double > | getRetentionTimeLine () override
| retention timeline get retention times along the MSrun in seconds
std::shared_ptr< pappso::cbor::mzcbor::Spectrum > | getMzcborSpectrumSp (std::size_t spectrum_index, bool want_binary_data) const
| get spectrum mzML element
Public Member Functions inherited from pappso::MsRunReader
| MsRunReader (const MsRunIdCstSPtr &ms_run_id)
| MsRunReader (const MsRunReader &other)
virtual | ~MsRunReader ()
const MsRunIdCstSPtr & | getMsRunId () const
void | setMonoThread (bool is_mono_thread)
| set only one is_mono_thread to true
bool | isMonoThread () const

## Protected Member Functions

virtual void | initialize () override
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, specific of one or more file format
virtual void | fillMzcborSpectrum (std::size_t spectrum_index, pappso::cbor::mzcbor::Spectrum &spectrum, bool want_binary_data) const

## Protected Attributes

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
Protected Attributes inherited from pappso::MsRunReader
MsRunIdCstSPtr | mcsp_msRunId
MsRunReaderScanNumberMultiMap * | mpa_multiMapScanNumber = nullptr

## Private Member Functions

void | readSpectrumCollectionWithMsrunReadConfig (const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)

## Detailed Description

Todo
  write docs

Definition at line 41 of file mzcbormsrunreader.h.

## Constructor & Destructor Documentation

## MzcborMsRunReader()

pappso::MzcborMsRunReader::MzcborMsRunReader | ( | MsRunIdCstSPtr & | msrun_id_csp | ) |

Default constructor

Definition at line 40 of file mzcbormsrunreader.cpp.

: pappso::MsRunReader(msrun_id_csp)
{
initialize();
qDebug();
}
pappso::MzcborMsRunReader::initialize
virtual void initialize() override
Definition mzcbormsrunreader.cpp:61
pappso::MsRunReader
class PMSPP_LIB_DECL MsRunReader
Definition msrunreader.h:56

References pappso::MsRunReader::MsRunReader(), and initialize().

## ~MzcborMsRunReader()

pappso::MzcborMsRunReader::~MzcborMsRunReader | ( |  | ) |

virtual

Destructor

Definition at line 47 of file mzcbormsrunreader.cpp.

{
releaseDevice();
}
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

References releaseDevice().

## Member Function Documentation

## accept()

bool pappso::MzcborMsRunReader::accept | ( | const QString & | file_name | ) | const

override protected virtual

tells if the reader is able to handle this file must be implemented by private MS run reader, specific of one or more file format

Implements pappso::MsRunReader.

Definition at line 194 of file mzcbormsrunreader.cpp.

{
throw pappso::ExceptionNotImplemented(
QObject::tr("%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
}

## acquireDevice()

bool pappso::MzcborMsRunReader::acquireDevice | ( |  | ) |

override virtual

acquire data back end device

Returns
  bool true if done

Implements pappso::MsRunReader.

Definition at line 210 of file mzcbormsrunreader.cpp.

{
if(mpa_mzcborFileDevice == nullptr)
{
mpa_mzcborFileDevice = new QFile(m_cborFileInfo.absoluteFilePath());
mpa_mzcborFileDevice->open(QIODevice::ReadOnly);
}
return true;
}
pappso::MzcborMsRunReader::mpa_mzcborFileDevice
QFile * mpa_mzcborFileDevice
Definition mzcbormsrunreader.h:141
pappso::MzcborMsRunReader::m_cborFileInfo
QFileInfo m_cborFileInfo
Definition mzcbormsrunreader.h:133

References m_cborFileInfo, and mpa_mzcborFileDevice.

Referenced by initialize(), massSpectrumSPtr(), and readSpectrumCollectionWithMsrunReadConfig().

## fillMzcborSpectrum()

void pappso::MzcborMsRunReader::fillMzcborSpectrum | ( | std::size_t | spectrum_index,
|  | pappso::cbor::mzcbor::Spectrum & | spectrum,
|  | bool | want_binary_data ) const

protected virtual

Definition at line 534 of file mzcbormsrunreader.cpp.

{
if(spectrum_index >= m_spectrumIndexPositionInFile.size())
{
throw pappso::ExceptionNotFound(
QObject::tr("spectrum index %1 not found").arg(spectrum_index));
}
if(mpa_mzcborFileDevice == nullptr)
{
throw pappso::PappsoException(
QObject::tr("mzCBOR file device is not ready, use acquireDevice() before access"));
}
qDebug() << spectrum_index << " " << m_spectrumIndexPositionInFile[spectrum_index];
// qDebug() << spectrum_index << " " << m_spectrumIndexPositionInFile[spectrum_index-1];
if(mpa_mzcborFileDevice->seek(m_spectrumIndexPositionInFile[spectrum_index]))
{
pappso::cbor::CborStreamReader cbor_stream_reader(mpa_mzcborFileDevice);
cbor_stream_reader.setDevice(mpa_mzcborFileDevice);
try
{
spectrum.fromCbor(cbor_stream_reader, want_binary_data);
}
catch(const pappso::PappsoException &error)
{
throw pappso::PappsoException(QObject::tr("ERROR reading spectrum %1 cbor:\n%2")
.arg(spectrum_index)
.arg(error.qwhat()));
}
// cbor_stream_reader.leaveContainer();
if(spectrum.id.isEmpty())
{
throw pappso::PappsoException(
QObject::tr("ERROR reading spectrum %1 cbor:\nspectrum not found").arg(spectrum_index));
}
}
else
{
throw pappso::PappsoException(
QObject::tr("ERROR reading spectrum %1 cbor:\nseek failed").arg(spectrum_index));
}
// mzcbor_file.close();
}
pappso::MzcborMsRunReader::m_spectrumIndexPositionInFile
std::vector< qint64 > m_spectrumIndexPositionInFile
Definition mzcbormsrunreader.h:134
pappso::PappsoException::qwhat
virtual const QString & qwhat() const
Definition pappsoexception.h:66
pappso::cbor::mzcbor::Spectrum::id
QString id
Definition spectrum.h:80
pappso::cbor::mzcbor::Spectrum::fromCbor
void fromCbor(CborStreamReader &reader, bool want_binary_data)
fill the structure reading data from a CBOR stream
Definition spectrum.cpp:43

References pappso::cbor::mzcbor::Spectrum::fromCbor(), pappso::cbor::mzcbor::Spectrum::id, m_spectrumIndexPositionInFile, mpa_mzcborFileDevice, and pappso::PappsoException::qwhat().

Referenced by getMzcborSpectrumSp(), massSpectrumSPtr(), newXicCoordSPtrFromSpectrumIndex(), and qualifiedMassSpectrum().

## getMzcborSpectrumSp()

std::shared_ptr< pappso::cbor::mzcbor::Spectrum > pappso::MzcborMsRunReader::getMzcborSpectrumSp | ( | std::size_t | spectrum_index,
|  | bool | want_binary_data ) const

get spectrum mzML element

Parameters

  spectrum_index | spectrum to retrieve
  want_binary_data | true to get peak list

Returns
  shared pointer on spectrum structure

Definition at line 636 of file mzcbormsrunreader.cpp.

{
std::shared_ptr<pappso::cbor::mzcbor::Spectrum> cbor_spectrum_sp =
std::make_shared<pappso::cbor::mzcbor::Spectrum>();
fillMzcborSpectrum(spectrum_index, *cbor_spectrum_sp, want_binary_data);
return cbor_spectrum_sp;
}
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

References fillMzcborSpectrum().

## getOboPsiModTermInstrumentModelName()

const OboPsiModTerm pappso::MzcborMsRunReader::getOboPsiModTermInstrumentModelName | ( |  | ) | const

override virtual

get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: instrument model def: "Instrument model name not including the vendor's name." [PSI:MS] relationship: part_of MS:1000463 ! instrument

Reimplemented from pappso::MsRunReader.

Definition at line 203 of file mzcbormsrunreader.cpp.

{
throw pappso::ExceptionNotImplemented(
QObject::tr("%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
}

## getRetentionTimeLine()

std::vector< double > pappso::MzcborMsRunReader::getRetentionTimeLine | ( |  | ) |

override virtual

retention timeline get retention times along the MSrun in seconds

Returns
  vector of retention times (seconds)

Reimplemented from pappso::MsRunReader.

Definition at line 614 of file mzcbormsrunreader.cpp.

{
qDebug();
std::vector<double> time_line;
if((m_spectrumRtList.size() > 0) && (m_spectrumMsLevelList.size() == m_spectrumRtList.size()))
{
for(std::size_t i = 0; i < m_spectrumRtList.size(); i++)
{
if(m_spectrumMsLevelList.at(i) == 1)
{
time_line.push_back(m_spectrumRtList.at(i));
}
}
}
else
{
return MsRunReader::getRetentionTimeLine();
}
return time_line;
}
pappso::MsRunReader::getRetentionTimeLine
virtual std::vector< double > getRetentionTimeLine()
retention timeline get retention times along the MSrun in seconds
Definition msrunreader.cpp:126
pappso::MzcborMsRunReader::m_spectrumRtList
std::vector< double > m_spectrumRtList
Definition mzcbormsrunreader.h:137
pappso::MzcborMsRunReader::m_spectrumMsLevelList
std::vector< std::uint8_t > m_spectrumMsLevelList
Definition mzcbormsrunreader.h:136

References pappso::MsRunReader::getRetentionTimeLine(), m_spectrumMsLevelList, and m_spectrumRtList.

## getSpectrumIndexPositionInFile()

const std::vector< qint64 > & pappso::MzcborMsRunReader::getSpectrumIndexPositionInFile | ( |  | ) | const

Definition at line 54 of file mzcbormsrunreader.cpp.

{
return m_spectrumIndexPositionInFile;
}

References m_spectrumIndexPositionInFile.

## getTicChromatogram()

Trace pappso::MzcborMsRunReader::getTicChromatogram | ( |  | ) |

override virtual

get a TIC chromatogram

for each retention time, computes the sum of all intensities. For IM-MS, combines the mobility spectra

Note that, formally, a TIC chromatogram is computed only for MS1 spectra.

Returns
  a trace (x=rt, y=intensities)

Reimplemented from pappso::MsRunReader.

Definition at line 591 of file mzcbormsrunreader.cpp.

{
qDebug() << m_spectrumMsLevelList.size() << " " << m_spectrumTotalIonCountList.size();
Trace chromatogram;
if((m_spectrumTotalIonCountList.size() > 0) &&
(m_spectrumMsLevelList.size() == m_spectrumTotalIonCountList.size()))
{
for(std::size_t i = 0; i < m_spectrumTotalIonCountList.size(); i++)
{
if(m_spectrumMsLevelList.at(i) == 1)
{
chromatogram.push_back(
{m_spectrumRtList.at(i), (double)m_spectrumTotalIonCountList.at(i)});
}
}
}
else
{
return MsRunReader::getTicChromatogram();
}
return chromatogram;
}
pappso::MsRunReader::getTicChromatogram
virtual Trace getTicChromatogram()
get a TIC chromatogram
Definition msrunreader.cpp:159
pappso::MzcborMsRunReader::m_spectrumTotalIonCountList
std::vector< qint64 > m_spectrumTotalIonCountList
Definition mzcbormsrunreader.h:135

References pappso::MsRunReader::getTicChromatogram(), m_spectrumMsLevelList, m_spectrumRtList, and m_spectrumTotalIonCountList.

## hasScanNumbers()

bool pappso::MzcborMsRunReader::hasScanNumbers | ( |  | ) | const

override virtual

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

Reimplemented from pappso::MsRunReader.

Definition at line 152 of file mzcbormsrunreader.cpp.

{
if(m_nativeId2SpectrumIndexMap.size() > 0)
{
if(m_nativeId2SpectrumIndexMap.begin()->first.contains("scan="))
return true;
}
return false;
}
pappso::MzcborMsRunReader::m_nativeId2SpectrumIndexMap
std::map< QString, std::size_t > m_nativeId2SpectrumIndexMap
Definition mzcbormsrunreader.h:138

References m_nativeId2SpectrumIndexMap.

## initialize()

void pappso::MzcborMsRunReader::initialize | ( |  | ) |

override protected virtual

Implements pappso::MsRunReader.

Definition at line 61 of file mzcbormsrunreader.cpp.

{
qDebug();
m_cborFileInfo.setFile(mcsp_msRunId->getFileName());
if(!m_cborFileInfo.exists())
throw ExceptionNotFound(m_cborFileInfo.absoluteFilePath());
// build the index
acquireDevice();
QString str_index_file = m_cborFileInfo.absoluteFilePath();
QFileInfo mzcbor_index_fileinfo(str_index_file.append(".idx"));
if(mzcbor_index_fileinfo.exists())
{
qDebug() << "mzcbor_index_fileinfo.exists()";
QFile mzcbor_index_file(mzcbor_index_fileinfo.absoluteFilePath());
mzcbor_index_file.open(QIODevice::ReadOnly);
pappso::cbor::mzcbor::MzcborIndexReader index_reader;
index_reader.readCbor(&mzcbor_index_file);
index_reader.close();
mzcbor_index_file.close();
qDebug();
std::vector<QString> run_id_list = index_reader.getRunIdList();
if(run_id_list.size() > 0)
{
std::size_t run_position = 0;
if(run_id_list.size() > 1)
{
std::size_t i_run = 0;
for(const QString &run_id : run_id_list)
{
if(run_id == getMsRunId().get()->getRunId())
{
run_position = i_run;
}
i_run++;
}
}
m_spectrumIndexPositionInFile =
index_reader.getRunAndSpectrumOffsetList().at(run_position);
if(index_reader.getRunAndSpectrumTotalIonCountList().size() > run_position)
{
m_spectrumTotalIonCountList =
index_reader.getRunAndSpectrumTotalIonCountList().at(run_position);
}
if(index_reader.getRunAndSpectrumMsLevelList().size() > run_position)
{
m_spectrumMsLevelList = index_reader.getRunAndSpectrumMsLevelList().at(run_position);
}
if(index_reader.getRunAndSpectrumRtList().size() > run_position)
{
m_spectrumRtList = index_reader.getRunAndSpectrumRtList().at(run_position);
}
// qFatal() << m_spectrumTotalIonCountList.size();
std::size_t i = 0;
for(const QString &native_id : index_reader.getRunAndSpectrumIdList().at(run_position))
{
m_nativeId2SpectrumIndexMap.insert({native_id, i});
i++;
}
}
}
if(m_spectrumIndexPositionInFile.size() == 0)
{
pappso::UiMonitorVoid monitor;
pappso::cbor::mzcbor::MzcborBuildIndexReader mzcbor_build_index_reader(getMsRunId());
mzcbor_build_index_reader.readCbor(mpa_mzcborFileDevice, monitor);
qDebug();
mzcbor_build_index_reader.close();
// releaseDevice();
qDebug();
m_spectrumIndexPositionInFile = mzcbor_build_index_reader.getSpectrumIndexPositionInFile();
m_nativeId2SpectrumIndexMap = mzcbor_build_index_reader.getNativeId2SpectrumIndexMap();
}
}
pappso::MsRunReader::mcsp_msRunId
MsRunIdCstSPtr mcsp_msRunId
Definition msrunreader.h:194
pappso::MsRunReader::getMsRunId
const MsRunIdCstSPtr & getMsRunId() const
Definition msrunreader.cpp:55
pappso::MzcborMsRunReader::acquireDevice
virtual bool acquireDevice() override
acquire data back end device
Definition mzcbormsrunreader.cpp:210
pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumTotalIonCountList
const std::vector< std::vector< qint64 > > & getRunAndSpectrumTotalIonCountList() const
Definition mzcborindexreader.cpp:174
pappso::cbor::mzcbor::MzcborIndexReader::close
virtual void close()
convenient function to clean pointer before leaving
Definition mzcborindexreader.cpp:41
pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumMsLevelList
const std::vector< std::vector< std::uint8_t > > & getRunAndSpectrumMsLevelList() const
Definition mzcborindexreader.cpp:186
pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumOffsetList
const std::vector< std::vector< qint64 > > & getRunAndSpectrumOffsetList() const
Definition mzcborindexreader.cpp:162
pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumIdList
const std::vector< std::vector< QString > > & getRunAndSpectrumIdList() const
Definition mzcborindexreader.cpp:168
pappso::cbor::mzcbor::MzcborIndexReader::getRunIdList
const std::vector< QString > & getRunIdList() const
Definition mzcborindexreader.cpp:155
pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumRtList
const std::vector< std::vector< double > > & getRunAndSpectrumRtList() const
Definition mzcborindexreader.cpp:180
pappso::cbor::mzcbor::MzcborIndexReader::readCbor
virtual void readCbor(QFile *cborp)
Definition mzcborindexreader.cpp:46

References acquireDevice(), pappso::cbor::mzcbor::MzcborIndexReader::close(), pappso::cbor::mzcbor::MzcborReaderBase::close(), pappso::MsRunReader::getMsRunId(), pappso::cbor::mzcbor::MzcborBuildIndexReader::getNativeId2SpectrumIndexMap(), pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumIdList(), pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumMsLevelList(), pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumOffsetList(), pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumRtList(), pappso::cbor::mzcbor::MzcborIndexReader::getRunAndSpectrumTotalIonCountList(), pappso::cbor::mzcbor::MzcborIndexReader::getRunIdList(), pappso::cbor::mzcbor::MzcborBuildIndexReader::getSpectrumIndexPositionInFile(), m_cborFileInfo, m_nativeId2SpectrumIndexMap, m_spectrumIndexPositionInFile, m_spectrumMsLevelList, m_spectrumRtList, m_spectrumTotalIonCountList, pappso::MsRunReader::mcsp_msRunId, mpa_mzcborFileDevice, pappso::cbor::mzcbor::MzcborBuildIndexReader::readCbor(), and pappso::cbor::mzcbor::MzcborIndexReader::readCbor().

Referenced by MzcborMsRunReader().

## massSpectrumCstSPtr()

MassSpectrumCstSPtr pappso::MzcborMsRunReader::massSpectrumCstSPtr | ( | std::size_t | spectrum_index | ) |

override virtual

Implements pappso::MsRunReader.

Definition at line 287 of file mzcbormsrunreader.cpp.

{
return massSpectrumSPtr(spectrum_index);
}
pappso::MzcborMsRunReader::massSpectrumSPtr
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override
get a MassSpectrumSPtr class given its spectrum index
Definition mzcbormsrunreader.cpp:293

References massSpectrumSPtr().

## massSpectrumSPtr()

MassSpectrumSPtr pappso::MzcborMsRunReader::massSpectrumSPtr | ( | std::size_t | spectrum_index | ) |

override virtual

get a MassSpectrumSPtr class given its spectrum index

Implements pappso::MsRunReader.

Definition at line 293 of file mzcbormsrunreader.cpp.

{
MassSpectrumSPtr mass_spectrum_sp;
try
{
acquireDevice();
pappso::cbor::mzcbor::Spectrum cbor_spectrum;
fillMzcborSpectrum(spectrum_index, cbor_spectrum, true);
if(cbor_spectrum.binaryDataArrayList.size() == 2)
{
mass_spectrum_sp = std::make_shared<MassSpectrum>();
cbor_spectrum.decodeTrace(*(mass_spectrum_sp.get()));
}
else
{
throw pappso::PappsoException(
QObject::tr("cbor_spectrum.binaryDataArrayList.size() != 2"));
}
}
catch(const pappso::PappsoException &pappso_error)
{
qDebug() << "Going to throw";
throw pappso::PappsoException(QObject::tr("Error reading data (massSpectrumSPtr) using the "
"mzcbor reader: %1")
.arg(pappso_error.what()));
}
return mass_spectrum_sp;
}
pappso::PappsoException::what
const char * what() const noexcept override
Definition pappsoexception.h:72
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition massspectrum.h:53
pappso::cbor::mzcbor::Spectrum::decodeTrace
void decodeTrace(pappso::Trace &trace) const
Definition spectrum.cpp:356
pappso::cbor::mzcbor::Spectrum::binaryDataArrayList
std::vector< BinaryDataArray > binaryDataArrayList
Definition spectrum.h:90

References acquireDevice(), pappso::cbor::mzcbor::Spectrum::binaryDataArrayList, pappso::cbor::mzcbor::Spectrum::decodeTrace(), fillMzcborSpectrum(), and pappso::PappsoException::what().

Referenced by massSpectrumCstSPtr().

## newXicCoordSPtrFromQualifiedMassSpectrum()

pappso::XicCoordSPtr pappso::MzcborMsRunReader::newXicCoordSPtrFromQualifiedMassSpectrum | ( | const pappso::QualifiedMassSpectrum & | mass_spectrum,
|  | pappso::PrecisionPtr | precision ) const

override virtual

get a xic coordinate object from a given spectrum

Implements pappso::MsRunReader.

Definition at line 235 of file mzcbormsrunreader.cpp.

{
XicCoordSPtr xic_coord = std::make_shared<XicCoord>();
xic_coord.get()->rtTarget = mass_spectrum.getRtInSeconds();
xic_coord.get()->mzRange = MzRange(mass_spectrum.getPrecursorMz(), precision);
return xic_coord;
}
pappso::QualifiedMassSpectrum::getPrecursorMz
pappso_double getPrecursorMz(bool *ok=nullptr) const
get precursor mz
Definition qualifiedmassspectrum.cpp:240
pappso::QualifiedMassSpectrum::getRtInSeconds
pappso_double getRtInSeconds() const
Get the retention time in seconds.
Definition qualifiedmassspectrum.cpp:205
pappso::XicCoordSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:44

References pappso::QualifiedMassSpectrum::getPrecursorMz(), pappso::QualifiedMassSpectrum::getRtInSeconds(), pappso::XicCoord::mzRange, and pappso::XicCoord::rtTarget.

## newXicCoordSPtrFromSpectrumIndex()

pappso::XicCoordSPtr pappso::MzcborMsRunReader::newXicCoordSPtrFromSpectrumIndex | ( | std::size_t | spectrum_index,
|  | pappso::PrecisionPtr | precision ) const

override virtual

get a xic coordinate object from a given spectrum index

Implements pappso::MsRunReader.

Definition at line 247 of file mzcbormsrunreader.cpp.

{
pappso::cbor::mzcbor::Spectrum cbor_spectrum;
fillMzcborSpectrum(spectrum_index, cbor_spectrum, false);
XicCoordSPtr xic_coord = std::make_shared<XicCoord>();
xic_coord.get()->rtTarget = cbor_spectrum.getRtInSeconds();
bool get_mz = false;
if(cbor_spectrum.precursorList.size() > 0)
{
for(auto &precursor : cbor_spectrum.precursorList)
{
for(auto &ion : precursor.selectedIonList)
{
xic_coord.get()->mzRange = MzRange(ion.getMz(), precision);
get_mz = true;
}
}
if(!get_mz)
{
throw pappso::ExceptionNotFound(
QObject::tr("precursor m/z not found for this spectrum index %1").arg(spectrum_index));
}
}
else
{
throw pappso::ExceptionNotFound(
QObject::tr("no precursor found for this spectrum index %1").arg(spectrum_index));
}
return xic_coord;
}
pappso::cbor::mzcbor::Spectrum::precursorList
std::vector< Precursor > precursorList
Definition spectrum.h:89
pappso::cbor::mzcbor::Spectrum::getRtInSeconds
double getRtInSeconds() const
Definition spectrum.cpp:342

References fillMzcborSpectrum(), pappso::cbor::mzcbor::Spectrum::getRtInSeconds(), pappso::XicCoord::mzRange, pappso::cbor::mzcbor::Spectrum::precursorList, and pappso::XicCoord::rtTarget.

## qualifiedMassSpectrum()

QualifiedMassSpectrum pappso::MzcborMsRunReader::qualifiedMassSpectrum | ( | std::size_t | spectrum_index,
|  | bool | want_binary_data = true ) const

override virtual

get a QualifiedMassSpectrum class given its scan number

Implements pappso::MsRunReader.

Definition at line 325 of file mzcbormsrunreader.cpp.

{
qDebug();
try
{
pappso::cbor::mzcbor::Spectrum cbor_spectrum;
fillMzcborSpectrum(spectrum_index, cbor_spectrum, want_binary_data);
qDebug() << cbor_spectrum.index;
QualifiedMassSpectrum qualified_mass_spectrum;
MassSpectrumId spectrum_id(mcsp_msRunId, spectrum_index);
spectrum_id.setNativeId(cbor_spectrum.id);
spectrum_id.setSpectrumIndex(cbor_spectrum.index);
qualified_mass_spectrum.setMassSpectrumId(spectrum_id);
qualified_mass_spectrum.setRtInSeconds(cbor_spectrum.getRtInSeconds());
if(cbor_spectrum.precursorList.size() > 0)
{
qualified_mass_spectrum.setPrecursorNativeId(
cbor_spectrum.precursorList.at(0).spectrumRef);
qualified_mass_spectrum.setPrecursorSpectrumIndex(
m_nativeId2SpectrumIndexMap.at(cbor_spectrum.precursorList.at(0).spectrumRef));
for(auto &precursor : cbor_spectrum.precursorList)
{
for(auto &ion : precursor.selectedIonList)
{
PrecursorIonData precursor_ion_data;
precursor_ion_data.charge = ion.getChargeState();
bool is_ok;
precursor_ion_data.intensity = ion.getIntensity(&is_ok);
precursor_ion_data.mz = ion.getMz();
qualified_mass_spectrum.appendPrecursorIonData(precursor_ion_data);
}
}
}
qDebug();
qualified_mass_spectrum.setMsLevel(cbor_spectrum.getMsLevel());
qDebug();
qualified_mass_spectrum.setEmptyMassSpectrum(!cbor_spectrum.defaultArrayLength);
if(cbor_spectrum.binaryDataArrayList.size() == 2)
{
MassSpectrumSPtr mass_spectrum_sp = std::make_shared<MassSpectrum>();
cbor_spectrum.decodeTrace(*(mass_spectrum_sp.get()));
qualified_mass_spectrum.setMassSpectrumSPtr(mass_spectrum_sp);
}
qDebug() << "spectrum id=" << cbor_spectrum.id;
return qualified_mass_spectrum;
}
catch(const pappso::PappsoException &pappso_error)
{
qDebug() << "Going to throw";
throw pappso::PappsoException(
QObject::tr("Error reading data (qualifiedMassSpectrum) using the "
"mzcbor reader: %1")
.arg(pappso_error.what()));
}
}
pappso::cbor::mzcbor::Spectrum::getMsLevel
uint getMsLevel() const
Definition spectrum.cpp:328
pappso::cbor::mzcbor::Spectrum::index
std::size_t index
Definition spectrum.h:81
pappso::cbor::mzcbor::Spectrum::defaultArrayLength
std::size_t defaultArrayLength
Definition spectrum.h:82

References pappso::QualifiedMassSpectrum::appendPrecursorIonData(), pappso::cbor::mzcbor::Spectrum::binaryDataArrayList, pappso::PrecursorIonData::charge, pappso::cbor::mzcbor::Spectrum::decodeTrace(), pappso::cbor::mzcbor::Spectrum::defaultArrayLength, fillMzcborSpectrum(), pappso::cbor::mzcbor::Spectrum::getMsLevel(), pappso::cbor::mzcbor::Spectrum::getRtInSeconds(), pappso::cbor::mzcbor::Spectrum::id, pappso::cbor::mzcbor::Spectrum::index, pappso::PrecursorIonData::intensity, m_nativeId2SpectrumIndexMap, pappso::MsRunReader::mcsp_msRunId, pappso::PrecursorIonData::mz, pappso::cbor::mzcbor::Spectrum::precursorList, pappso::QualifiedMassSpectrum::setEmptyMassSpectrum(), pappso::QualifiedMassSpectrum::setMassSpectrumId(), pappso::QualifiedMassSpectrum::setMassSpectrumSPtr(), pappso::QualifiedMassSpectrum::setMsLevel(), pappso::MassSpectrumId::setNativeId(), pappso::QualifiedMassSpectrum::setPrecursorNativeId(), pappso::QualifiedMassSpectrum::setPrecursorSpectrumIndex(), pappso::QualifiedMassSpectrum::setRtInSeconds(), pappso::MassSpectrumId::setSpectrumIndex(), and pappso::PappsoException::what().

## readSpectrumCollection()

void pappso::MzcborMsRunReader::readSpectrumCollection | ( | SpectrumCollectionHandlerInterface & | handler | ) |

override virtual

function to visit an MsRunReader and get each Spectrum in a spectrum collection handler

Implements pappso::MsRunReader.

Definition at line 395 of file mzcbormsrunreader.cpp.

{
throw pappso::ExceptionNotImplemented(
QObject::tr("%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
MsRunReadConfig config;
std::vector<size_t> ms_levels;
for(std::size_t i = 1; i < 9; i++)
{
if(handler.needMsLevelPeakList(i))
{
ms_levels.push_back(i);
}
}
config.setMsLevels(ms_levels);
config.setNeedPeakList(handler.needPeakList());
// readSpectrumCollectionByMsLevel(reader_timeline, 1);
try
{
readSpectrumCollectionWithMsrunReadConfig(config, handler);
}
catch(const pappso::PappsoException &pappso_error)
{
qDebug() << "Going to throw";
throw pappso::PappsoException(
QObject::tr("Error reading data (spectrum collection2) using the "
"mzcbor reader: %1")
.arg(pappso_error.what()));
}
catch(std::exception &error)
{
qDebug() << "Going to throw";
throw pappso::PappsoException(
QObject::tr("Error reading data (spectrum collection) using the "
"mzcbor reader: %1")
.arg(error.what()));
}
}
pappso::MzcborMsRunReader::readSpectrumCollectionWithMsrunReadConfig
void readSpectrumCollectionWithMsrunReadConfig(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)
Definition mzcbormsrunreader.cpp:498

References pappso::SpectrumCollectionHandlerInterface::needMsLevelPeakList(), pappso::SpectrumCollectionHandlerInterface::needPeakList(), readSpectrumCollectionWithMsrunReadConfig(), pappso::MsRunReadConfig::setMsLevels(), pappso::MsRunReadConfig::setNeedPeakList(), and pappso::PappsoException::what().

## readSpectrumCollection2()

void pappso::MzcborMsRunReader::readSpectrumCollection2 | ( | const MsRunReadConfig & | config,
|  | SpectrumCollectionHandlerInterface & | handler )

override virtual

function to visit an MsRunReader and get each Spectrum in a spectrum collection handler

Implements pappso::MsRunReader.

Definition at line 438 of file mzcbormsrunreader.cpp.

{
qDebug();
try
{
readSpectrumCollectionWithMsrunReadConfig(config, handler);
}
catch(const pappso::PappsoException &pappso_error)
{
qDebug() << "Going to throw";
throw pappso::PappsoException(
QObject::tr("Error reading data (spectrum collection2) using the "
"mzcbor reader: %1")
.arg(pappso_error.what()));
}
catch(std::exception &error)
{
qDebug() << "Going to throw";
throw pappso::PappsoException(
QObject::tr("Error reading data (spectrum collection2) using the "
"mzcbor reader: %1")
.arg(error.what()));
}
}

References readSpectrumCollectionWithMsrunReadConfig(), and pappso::PappsoException::what().

Referenced by readSpectrumCollectionByMsLevel().

## readSpectrumCollectionByMsLevel()

void pappso::MzcborMsRunReader::readSpectrumCollectionByMsLevel | ( | SpectrumCollectionHandlerInterface & | handler,
|  | unsigned int | ms_level )

override virtual

function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels

Implements pappso::MsRunReader.

Definition at line 467 of file mzcbormsrunreader.cpp.

{
MsRunReadConfig config;
config.setMsLevels({ms_level});
config.setNeedPeakList(handler.needPeakList());
// readSpectrumCollectionByMsLevel(reader_timeline, 1);
readSpectrumCollection2(config, handler);
}
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

References pappso::SpectrumCollectionHandlerInterface::needPeakList(), readSpectrumCollection2(), pappso::MsRunReadConfig::setMsLevels(), and pappso::MsRunReadConfig::setNeedPeakList().

## readSpectrumCollectionWithMsrunReadConfig()

void pappso::MzcborMsRunReader::readSpectrumCollectionWithMsrunReadConfig | ( | const MsRunReadConfig & | config,
|  | SpectrumCollectionHandlerInterface & | handler )

private

Definition at line 498 of file mzcbormsrunreader.cpp.

{
// acquireDevice();
try
{
acquireDevice();
pappso::UiMonitorVoid monitor;
pappso::cbor::mzcbor::MzcborSpectrumCollectionReader mzcbor_spectrum_collection_reader(
config, handler);
mzcbor_spectrum_collection_reader.setMsRunId(getMsRunId());
mzcbor_spectrum_collection_reader.setNativeId2SpectrumIndexMapPtr(
&m_nativeId2SpectrumIndexMap);
mzcbor_spectrum_collection_reader.readCbor(mpa_mzcborFileDevice, monitor);
qDebug();
mzcbor_spectrum_collection_reader.close();
qDebug();
}
catch(const pappso::PappsoException &pappso_err)
{
throw pappso::PappsoException(
QObject::tr("ERROR in MzcborMsRunReader::readSpectrumCollectionWithMsrunReadConfig:\n%1")
.arg(pappso_err.qwhat()));
}
// End of
// for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
// Now let the loading handler know that the loading of the data has ended.
// The handler might need this "signal" to perform additional tasks or to
// cleanup cruft.
}

References acquireDevice(), pappso::cbor::mzcbor::MzcborReaderBase::close(), pappso::MsRunReader::getMsRunId(), m_nativeId2SpectrumIndexMap, mpa_mzcborFileDevice, pappso::PappsoException::qwhat(), pappso::cbor::mzcbor::MzcborReaderBase::readCbor(), pappso::cbor::mzcbor::MzcborSpectrumCollectionReader::setMsRunId(), and pappso::cbor::mzcbor::MzcborSpectrumCollectionReader::setNativeId2SpectrumIndexMapPtr().

Referenced by readSpectrumCollection(), and readSpectrumCollection2().

## releaseDevice()

bool pappso::MzcborMsRunReader::releaseDevice | ( |  | ) |

override virtual

release data back end device if a the data back end is released, the developper has to use acquireDevice before using the msrunreader object

Returns
  bool true if done

Implements pappso::MsRunReader.

Definition at line 222 of file mzcbormsrunreader.cpp.

{
if(mpa_mzcborFileDevice != nullptr)
{
mpa_mzcborFileDevice->close();
delete mpa_mzcborFileDevice;
mpa_mzcborFileDevice = nullptr;
}
return true;
}

References mpa_mzcborFileDevice.

Referenced by ~MzcborMsRunReader().

## scanNumber2SpectrumIndex()

std::size_t pappso::MzcborMsRunReader::scanNumber2SpectrumIndex | ( | std::size_t | scan_number | ) |

override virtual

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.

Reimplemented from pappso::MsRunReader.

Definition at line 163 of file mzcbormsrunreader.cpp.

{
if(m_scan2SpectrumIndexMap.size() == 0)
{
for(auto &index_pair : m_nativeId2SpectrumIndexMap)
{
QStringList native_id_list = index_pair.first.split("=");
if(native_id_list.size() < 2)
{
}
else
{
std::size_t scan_number = native_id_list.back().toULong();
m_scan2SpectrumIndexMap.insert(
std::pair<std::size_t, std::size_t>(scan_number, index_pair.second));
}
}
}
auto it = m_scan2SpectrumIndexMap.find(scan_number);
if(it == m_scan2SpectrumIndexMap.end())
{
throw ExceptionNotFound(QObject::tr("error reading file %1 : scan %2 not found")
.arg(mcsp_msRunId.get()->getFileName())
.arg(scan_number));
}
return it->second;
}
pappso::MzcborMsRunReader::m_scan2SpectrumIndexMap
std::map< std::size_t, std::size_t > m_scan2SpectrumIndexMap
Definition mzcbormsrunreader.h:139

References m_nativeId2SpectrumIndexMap, m_scan2SpectrumIndexMap, and pappso::MsRunReader::mcsp_msRunId.

## spectrumListSize()

std::size_t pappso::MzcborMsRunReader::spectrumListSize | ( |  | ) | const

override virtual

get the totat number of spectrum conained in the MSrun data file

Implements pappso::MsRunReader.

Definition at line 478 of file mzcbormsrunreader.cpp.

{
return m_spectrumIndexPositionInFile.size();
}

References m_spectrumIndexPositionInFile.

## spectrumStringIdentifier2SpectrumIndex()

std::size_t pappso::MzcborMsRunReader::spectrumStringIdentifier2SpectrumIndex | ( | const QString & | spectrum_identifier | ) |

override virtual

if possible, get the spectrum index given a string identifier throw a not found exception if spectrum identifier is not found

Parameters

  spectrum_identifier | string identifier of a specific spectrum

Returns
  the spectrum index

Implements pappso::MsRunReader.

Definition at line 484 of file mzcbormsrunreader.cpp.

{
auto it = m_nativeId2SpectrumIndexMap.find(spectrum_identifier);
if(it == m_nativeId2SpectrumIndexMap.end())
{
throw pappso::ExceptionNotFound(
QObject::tr("spectrum identifier %1 not found").arg(spectrum_identifier));
}
return it->second;
}

References m_nativeId2SpectrumIndexMap.

## Member Data Documentation

## m_cborFileInfo

QFileInfo pappso::MzcborMsRunReader::m_cborFileInfo

protected

Definition at line 133 of file mzcbormsrunreader.h.

Referenced by acquireDevice(), and initialize().

## m_nativeId2SpectrumIndexMap

std::map<QString, std::size_t> pappso::MzcborMsRunReader::m_nativeId2SpectrumIndexMap

protected

Definition at line 138 of file mzcbormsrunreader.h.

Referenced by hasScanNumbers(), initialize(), qualifiedMassSpectrum(), readSpectrumCollectionWithMsrunReadConfig(), scanNumber2SpectrumIndex(), and spectrumStringIdentifier2SpectrumIndex().

## m_scan2SpectrumIndexMap

std::map<std::size_t, std::size_t> pappso::MzcborMsRunReader::m_scan2SpectrumIndexMap

protected

Definition at line 139 of file mzcbormsrunreader.h.

Referenced by scanNumber2SpectrumIndex().

## m_spectrumIndexPositionInFile

std::vector<qint64> pappso::MzcborMsRunReader::m_spectrumIndexPositionInFile

protected

Definition at line 134 of file mzcbormsrunreader.h.

Referenced by fillMzcborSpectrum(), getSpectrumIndexPositionInFile(), initialize(), and spectrumListSize().

## m_spectrumMsLevelList

std::vector<std::uint8_t> pappso::MzcborMsRunReader::m_spectrumMsLevelList

protected

Definition at line 136 of file mzcbormsrunreader.h.

Referenced by getRetentionTimeLine(), getTicChromatogram(), and initialize().

## m_spectrumRtList

std::vector<double> pappso::MzcborMsRunReader::m_spectrumRtList

protected

Definition at line 137 of file mzcbormsrunreader.h.

Referenced by getRetentionTimeLine(), getTicChromatogram(), and initialize().

## m_spectrumTotalIonCountList

std::vector<qint64> pappso::MzcborMsRunReader::m_spectrumTotalIonCountList

protected

Definition at line 135 of file mzcbormsrunreader.h.

Referenced by getTicChromatogram(), and initialize().

## mpa_mzcborFileDevice

QFile* pappso::MzcborMsRunReader::mpa_mzcborFileDevice = nullptr

protected

Definition at line 141 of file mzcbormsrunreader.h.

Referenced by acquireDevice(), fillMzcborSpectrum(), initialize(), readSpectrumCollectionWithMsrunReadConfig(), and releaseDevice().

The documentation for this class was generated from the following files:

- pappsomspp/core/msrun/private/mzcbormsrunreader.h
- pappsomspp/core/msrun/private/mzcbormsrunreader.cpp