Loading...
Searching...
No Matches
mzcbormsfilereader.cpp
Go to the documentation of this file.
#include "mzcbormsfilereader.h"
#include "pappsomspp/core/processing/uimonitor/uimonitorvoid.h"
#include "pappsomspp/core/utils.h"
#include <QFileInfo>
namespace pappso
{
MzcborMsFileReader::MzcborMsFileReader(const QString &file_name) : MsFileReader{file_name}
{
m_fileFormat = pappso::Enums::MsDataFormat::unknown;
initialize();
}
MzcborMsFileReader::~MzcborMsFileReader()
{
}
Enums::MsDataFormat
MzcborMsFileReader::getFileFormat()
{
// std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << " () "
// << std::setprecision(15) << "m_fileFormat: " << (int)m_fileFormat
// << std::endl;
return m_fileFormat;
}
std::size_t
pappso::MzcborMsFileReader::initialize()
{
pappso::UiMonitorVoid monitor;
QString str_index_file = m_fileName;
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);
m_mzcborIndexReader.readCbor(&mzcbor_index_file);
if(m_mzcborIndexReader.isMzcborIndex())
{
m_fileFormat = pappso::Enums::MsDataFormat::mzcbor;
}
m_mzcborIndexReader.close();
mzcbor_index_file.close();
qDebug() << m_mzcborIndexReader.getRunIdList().size();
return m_mzcborIndexReader.getRunIdList().size();
}
else
{
qDebug();
QFile mzcbor_file(m_fileName);
mzcbor_file.open(QIODevice::ReadOnly);
m_mzcborReaderBase.readCbor(&mzcbor_file, monitor);
if(m_mzcborReaderBase.isMzcbor())
{
m_fileFormat = pappso::Enums::MsDataFormat::mzcbor;
}
m_mzcborReaderBase.close();
mzcbor_file.close();
qDebug() << m_mzcborReaderBase.getMsrunIdList().join(" ");
return m_mzcborReaderBase.getMsrunIdList().size();
}
}
std::vector<MsRunIdCstSPtr>
MzcborMsFileReader::getMsRunIds(const QString &run_prefix)
{
std::vector<MsRunIdCstSPtr> ms_run_ids;
if(m_fileFormat == pappso::Enums::MsDataFormat::mzcbor)
{
if(m_mzcborIndexReader.getRunIdList().size() > 0)
{
qDebug();
std::size_t iter = 0;
for(auto &msrun_id_str : m_mzcborIndexReader.getRunIdList())
{
MsRunId ms_run_id(m_fileName, msrun_id_str);
// Set the MS data format as determined in initialize().
ms_run_id.setMsDataFormat(m_fileFormat);
// We need to set the unambiguous xmlId string.
ms_run_id.setXmlId(
QString("%1%2").arg(run_prefix).arg(Utils::getLexicalOrderedString(iter)));
// Now set the sample name to the run id : we can not do that, this is not the use
// sample name ms_run_id.setSampleName(QString::fromStdString(ms_data_ptr->run.id));
// And if it is possible, the real sample name because this one is for the
// end user to recognize his sample:
ms_run_id.setSampleName(msrun_id_str);
ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
iter++;
}
}
else
{
std::size_t iter = 0;
for(auto &msrun_id_str : m_mzcborReaderBase.getMsrunIdList())
{
MsRunId ms_run_id(m_fileName, msrun_id_str);
// Set the MS data format as determined in initialize().
ms_run_id.setMsDataFormat(m_fileFormat);
// We need to set the unambiguous xmlId string.
ms_run_id.setXmlId(
QString("%1%2").arg(run_prefix).arg(Utils::getLexicalOrderedString(iter)));
// Now set the sample name to the run id : we can not do that, this is not the use
// sample name ms_run_id.setSampleName(QString::fromStdString(ms_data_ptr->run.id));
// And if it is possible, the real sample name because this one is for the
// end user to recognize his sample:
ms_run_id.setSampleName(msrun_id_str);
ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
iter++;
}
}
}
return ms_run_ids;
}
} // namespace pappso
pappso::MsFileReader::MsFileReader
MsFileReader(const QString &file_name)
Definition msfilereader.cpp:19
pappso::MsFileReader::m_fileFormat
Enums::MsDataFormat m_fileFormat
Definition msfilereader.h:17
pappso::MsFileReader::m_fileName
QString m_fileName
Definition msfilereader.h:16
pappso::MsRunId
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition msrunid.h:54
pappso::MsRunId::setMsDataFormat
void setMsDataFormat(Enums::MsDataFormat format)
Definition msrunid.cpp:168
pappso::MsRunId::setXmlId
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition msrunid.cpp:147
pappso::MsRunId::setSampleName
void setSampleName(const QString &name)
set a sample name for this MsRunId
Definition msrunid.cpp:77
pappso::MzcborMsFileReader::m_mzcborIndexReader
pappso::cbor::mzcbor::MzcborIndexReader m_mzcborIndexReader
Definition mzcbormsfilereader.h:39
pappso::MzcborMsFileReader::~MzcborMsFileReader
virtual ~MzcborMsFileReader()
Definition mzcbormsfilereader.cpp:19
pappso::MzcborMsFileReader::getMsRunIds
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
Definition mzcbormsfilereader.cpp:81
pappso::MzcborMsFileReader::getFileFormat
virtual Enums::MsDataFormat getFileFormat() override
Definition mzcbormsfilereader.cpp:25
pappso::MzcborMsFileReader::m_mzcborReaderBase
pappso::cbor::mzcbor::MzcborReaderBase m_mzcborReaderBase
Definition mzcbormsfilereader.h:38
pappso::MzcborMsFileReader::MzcborMsFileReader
MzcborMsFileReader(const QString &file_name)
Definition mzcbormsfilereader.cpp:12
pappso::MzcborMsFileReader::initialize
virtual std::size_t initialize()
Definition mzcbormsfilereader.cpp:35
pappso::UiMonitorVoid
Definition uimonitorvoid.h:42
pappso::Utils::getLexicalOrderedString
static const QString getLexicalOrderedString(unsigned int num)
Definition utils.cpp:72
mzcbormsfilereader.h
pappso::Enums::MsDataFormat
MsDataFormat
Definition types.h:148
pappso::Enums::MsDataFormat::mzcbor
@ mzcbor
Definition types.h:167
pappso::Enums::MsDataFormat::unknown
@ unknown
unknown format
Definition types.h:149
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
uimonitorvoid.h
utils.h