Loading...
Searching...
No Matches
mzcborreaderbase.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/processing/cbor/mzcbor/mzcborreaderbase.cpp
* \date 19/11/2025
* \author Olivier Langella
* \brief read mzcbor stream or file
*/
/*******************************************************************************
* Copyright (c) 2025 Olivier Langella <Olivier.Langella@universite-paris-saclay.fr>.
*
* This file is part of PAPPSOms-tools.
*
* PAPPSOms-tools 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-tools 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-tools. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "mzcborreaderbase.h"
#include "cvparam.h"
pappso::cbor::mzcbor::MzcborReaderBase::MzcborReaderBase()
{
}
pappso::cbor::mzcbor::MzcborReaderBase::~MzcborReaderBase()
{
}
void
pappso::cbor::mzcbor::MzcborReaderBase::close()
{
}
void
pappso::cbor::mzcbor::MzcborReaderBase::readCbor(QFile *cborp, pappso::UiMonitorInterface &monitor)
{
qDebug();
initCborReader(cborp);
qDebug();
if(mpa_cborReader->isMap())
{
readRoot(monitor);
}
qDebug();
}
void
pappso::cbor::mzcbor::MzcborReaderBase::readCbor(QIODevice *cborp,
pappso::UiMonitorInterface &monitor)
{
qDebug();
initCborReader(cborp);
qDebug();
if(mpa_cborReader->isMap())
{
readRoot(monitor);
}
qDebug();
}
void
pappso::cbor::mzcbor::MzcborReaderBase::readRoot(pappso::UiMonitorInterface &monitor
[[maybe_unused]])
{
qDebug();
mpa_cborReader->enterContainer();
while(getExpectedString())
{
if(m_expectedString == "mzCBOR")
{
m_isMzcbor = true;
mpa_cborReader->next();
}
else if(m_expectedString == "mzML")
{
m_isMzcbor = true;
qDebug() << m_expectedString;
mpa_cborReader->next();
while(getExpectedString())
{
qDebug() << m_expectedString;
if(m_expectedString == "run")
{
readMsrun();
}
else if(m_expectedString == "referenceableParamGroupList")
{
readReferenceableParamGroupList();
}
else
{
mpa_cborReader->next();
}
if(m_stopParsing)
break;
}
}
}
mpa_cborReader->leaveContainer();
}
bool
pappso::cbor::mzcbor::MzcborReaderBase::isMzcbor() const
{
return m_isMzcbor;
}
const QStringList &
pappso::cbor::mzcbor::MzcborReaderBase::getMsrunIdList() const
{
return m_msrunIdList;
}
void
pappso::cbor::mzcbor::MzcborReaderBase::readReferenceableParamGroupList()
{
mpa_cborReader->enterContainer();
while(getExpectedString())
{
if(m_expectedString == "referenceableParamGroup")
{
mpa_cborReader->next();
/*
mpa_cborReader->enterContainer();
while(getExpectedString())
{
if(m_expectedString == "cvParam")
{
std::map<QString, pappso::cbor::mzcbor::CvParam> cvParamMap =
CvParam::getCvParamsMapFromCbor(*mpa_cborReader);
}
else
{
mpa_cborReader->next();
}
}
mpa_cborReader->leaveContainer();*/
}
else
{
mpa_cborReader->next();
}
}
mpa_cborReader->leaveContainer();
}
void
pappso::cbor::mzcbor::MzcborReaderBase::readMsrun()
{
mpa_cborReader->enterContainer();
while(getExpectedString())
{
if(m_expectedString == "id")
{
getExpectedString();
m_msrunIdList << m_expectedString;
}
else
{
mpa_cborReader->next();
}
}
mpa_cborReader->leaveContainer();
}
std::map<QString, pappso::cbor::mzcbor::CvParam>
pappso::cbor::mzcbor::MzcborReaderBase::getCvParamsMap()
{
qDebug();
std::map<QString, CvParam> accession_values;
mpa_cborReader->enterContainer(); // start array
while(mpa_cborReader->hasNext())
{
CvParam cv_param;
cv_param.fromCbor(*mpa_cborReader);
accession_values.insert({cv_param.accession, cv_param});
}
mpa_cborReader->leaveContainer(); // end array
return accession_values;
}
pappso::UiMonitorInterface
Definition uimonitorinterface.h:50
pappso::cbor::CborStreamReaderInterface::m_expectedString
QString m_expectedString
Definition cborstreamreaderinterface.h:69
pappso::cbor::CborStreamReaderInterface::initCborReader
void initCborReader(QFile *pcborfile)
Definition cborstreamreaderinterface.cpp:80
pappso::cbor::CborStreamReaderInterface::getExpectedString
bool getExpectedString()
Definition cborstreamreaderinterface.cpp:54
pappso::cbor::CborStreamReaderInterface::mpa_cborReader
CborStreamReader * mpa_cborReader
Definition cborstreamreaderinterface.h:68
pappso::cbor::mzcbor::MzcborReaderBase::m_msrunIdList
QStringList m_msrunIdList
Definition mzcborreaderbase.h:94
pappso::cbor::mzcbor::MzcborReaderBase::MzcborReaderBase
MzcborReaderBase()
Definition mzcborreaderbase.cpp:31
pappso::cbor::mzcbor::MzcborReaderBase::m_isMzcbor
bool m_isMzcbor
Definition mzcborreaderbase.h:93
pappso::cbor::mzcbor::MzcborReaderBase::readReferenceableParamGroupList
virtual void readReferenceableParamGroupList()
Definition mzcborreaderbase.cpp:133
pappso::cbor::mzcbor::MzcborReaderBase::readCbor
virtual void readCbor(QFile *cborp, pappso::UiMonitorInterface &monitor)
read mzCBOR file
Definition mzcborreaderbase.cpp:45
pappso::cbor::mzcbor::MzcborReaderBase::readMsrun
virtual void readMsrun()
Definition mzcborreaderbase.cpp:169
pappso::cbor::mzcbor::MzcborReaderBase::isMzcbor
bool isMzcbor() const
Definition mzcborreaderbase.cpp:120
pappso::cbor::mzcbor::MzcborReaderBase::readRoot
void readRoot(pappso::UiMonitorInterface &monitor)
Definition mzcborreaderbase.cpp:75
pappso::cbor::mzcbor::MzcborReaderBase::m_stopParsing
bool m_stopParsing
Definition mzcborreaderbase.h:90
pappso::cbor::mzcbor::MzcborReaderBase::close
virtual void close()
convenient function to clean pointer before leaving
Definition mzcborreaderbase.cpp:40
pappso::cbor::mzcbor::MzcborReaderBase::getCvParamsMap
std::map< QString, CvParam > getCvParamsMap()
read the array containing cvParams to give accessions and values
Definition mzcborreaderbase.cpp:190
pappso::cbor::mzcbor::MzcborReaderBase::getMsrunIdList
const QStringList & getMsrunIdList() const
Definition mzcborreaderbase.cpp:126
pappso::cbor::mzcbor::MzcborReaderBase::~MzcborReaderBase
virtual ~MzcborReaderBase()
Definition mzcborreaderbase.cpp:35
cvparam.h
PSI cvParam object for mzML/mzCBOR.
mzcborreaderbase.h
read mzcbor stream or file
pappso::cbor::mzcbor::CvParam
Definition cvparam.h:47
pappso::cbor::mzcbor::CvParam::fromCbor
void fromCbor(CborStreamReader &reader)
Definition cvparam.cpp:36
pappso::cbor::mzcbor::CvParam::accession
QString accession
Definition cvparam.h:74