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

`#include <pwizmsfilereader.h>`

Inheritance diagram for pappso::PwizMsFileReader:

## Public Member Functions

| PwizMsFileReader (const QString &file_name)
virtual | ~PwizMsFileReader ()
virtual MsDataFormat | getFileFormat () override
virtual std::vector< MsRunIdCstSPtr > | getMsRunIds (const QString &run_prefix) override

## Private Member Functions

virtual std::size_t | initialize ()
Private Member Functions inherited from pappso::MsFileReader
| MsFileReader (const QString &file_name)
virtual | ~MsFileReader ()

## Private Attributes

std::vector< pwiz::msdata::MSDataPtr > | m_msDataPtrVector
Private Attributes inherited from pappso::MsFileReader
QString | m_fileName
MsDataFormat | m_fileFormat = MsDataFormat::unknown

## Detailed Description

Definition at line 17 of file pwizmsfilereader.h.

## Constructor & Destructor Documentation

## PwizMsFileReader()

pappso::PwizMsFileReader::PwizMsFileReader | ( | const QString & | file_name | ) |

Definition at line 28 of file pwizmsfilereader.cpp.

: MsFileReader{file_name}
{
}
pappso::MsFileReader::MsFileReader
MsFileReader(const QString &file_name)
Definition msfilereader.cpp:19

## ~PwizMsFileReader()

pappso::PwizMsFileReader::~PwizMsFileReader | ( |  | ) |

virtual

Definition at line 34 of file pwizmsfilereader.cpp.

{
}

## Member Function Documentation

## getFileFormat()

MsDataFormat pappso::PwizMsFileReader::getFileFormat | ( |  | ) |

override virtual

Implements pappso::MsFileReader.

Definition at line 164 of file pwizmsfilereader.cpp.

{
// std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << " () "
// << std::setprecision(15) << "m_fileFormat: " << (int)m_fileFormat
// << std::endl;
return m_fileFormat;
}
pappso::MsFileReader::m_fileFormat
MsDataFormat m_fileFormat
Definition msfilereader.h:17

References pappso::MsFileReader::m_fileFormat.

Referenced by pappso::MsFileAccessor::getMsRunIds().

## getMsRunIds()

std::vector< MsRunIdCstSPtr > pappso::PwizMsFileReader::getMsRunIds | ( | const QString & | run_prefix | ) |

override virtual

Implements pappso::MsFileReader.

Definition at line 175 of file pwizmsfilereader.cpp.

{
std::vector<MsRunIdCstSPtr> ms_run_ids;
if(!initialize())
return ms_run_ids;
std::size_t iter = 0;
for(const pwiz::msdata::MSDataPtr & ms_data_ptr : m_msDataPtrVector)
{
MsRunId ms_run_id(m_fileName, QString::fromStdString(ms_data_ptr->run.id));
// 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 :
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:
if(ms_data_ptr->run.samplePtr != nullptr)
{
ms_run_id.setSampleName(
QString::fromStdString(ms_data_ptr->run.samplePtr->name));
}
// qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
//<< "Current ms_run_id:" << ms_run_id.toString();
// Finally make a shared pointer out of it and append it to the vector.
ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
++iter;
}
return ms_run_ids;
}
pappso::MsFileReader::m_fileName
QString m_fileName
Definition msfilereader.h:16
pappso::PwizMsFileReader::m_msDataPtrVector
std::vector< pwiz::msdata::MSDataPtr > m_msDataPtrVector
Definition pwizmsfilereader.h:20
pappso::PwizMsFileReader::initialize
virtual std::size_t initialize()
Definition pwizmsfilereader.cpp:40
pappso::Utils::getLexicalOrderedString
static const QString getLexicalOrderedString(unsigned int num)
Definition utils.cpp:74

References pappso::Utils::getLexicalOrderedString(), initialize(), pappso::MsFileReader::m_fileFormat, pappso::MsFileReader::m_fileName, m_msDataPtrVector, pappso::MsRunId::setMsDataFormat(), pappso::MsRunId::setSampleName(), and pappso::MsRunId::setXmlId().

Referenced by pappso::MsFileAccessor::getMsRunIds().

## initialize()

std::size_t pappso::PwizMsFileReader::initialize | ( |  | ) |

private virtual

Definition at line 40 of file pwizmsfilereader.cpp.

{
pwiz::msdata::DefaultReaderList defaultReaderList;
std::string readerName;
try
{
qDebug() << m_fileName;
readerName = defaultReaderList.identify(m_fileName.toStdString());
}
catch(std::runtime_error &error)
{
qDebug() << error.what() << " " << typeid(error).name();
throw PappsoException(
QObject::tr(
"libpwiz ERROR reading MS data file %1 "
"(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
.arg(m_fileName)
.arg(error.what())
.arg(__FILE__)
.arg(__LINE__));
}
catch(std::exception &error)
{
qDebug() << error.what() << " " << typeid(error).name();
throw PappsoException(
QObject::tr(
"libpwiz ERROR reading MS data file %1 "
"(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
.arg(m_fileName)
.arg(error.what())
.arg(__FILE__)
.arg(__LINE__));
}
if(readerName.empty())
{
qDebug() << "Failed to identify the file.";
return 0;
}
// Now convert the string to MsDataFormat.
if(readerName == "mzML")
m_fileFormat = MsDataFormat::mzML;
else if(readerName == "mzXML")
m_fileFormat = MsDataFormat::mzXML;
else if(readerName == "Mascot Generic")
m_fileFormat = MsDataFormat::MGF;
else if(readerName == "MZ5")
m_fileFormat = MsDataFormat::mz5;
else if(readerName == "MSn")
m_fileFormat = MsDataFormat::msn;
else if(readerName == "ABSciex WIFF")
m_fileFormat = MsDataFormat::abSciexWiff;
else if(readerName == "ABSciex T2D")
m_fileFormat = MsDataFormat::abSciexT2D;
else if(readerName == "Agilent MassHunter")
m_fileFormat = MsDataFormat::agilentMassHunter;
else if(readerName == "Thermo RAW")
m_fileFormat = MsDataFormat::thermoRaw;
else if(readerName == "Water RAW")
m_fileFormat = MsDataFormat::watersRaw;
else if(readerName == "Bruker FID")
m_fileFormat = MsDataFormat::brukerFid;
else if(readerName == "Bruker YEP")
m_fileFormat = MsDataFormat::brukerYep;
else if(readerName == "Bruker BAF")
m_fileFormat = MsDataFormat::brukerBaf;
else
{
m_fileFormat = MsDataFormat::unknown;
return 0;
}
// std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << " () "
// << std::setprecision(15) << "m_fileFormat: " << (int)m_fileFormat
// << std::endl;
// At this point we know pwiz could be able to read the file. Actually fill-in
// the MSDataPtr vector!
try
{
defaultReaderList.read(Utils::toUtf8StandardString(m_fileName),
m_msDataPtrVector);
}
catch(std::runtime_error &error)
{
qDebug() << error.what() << " " << typeid(error).name();
throw PappsoException(
QObject::tr(
"libpwiz ERROR reading MS data file %1 "
"(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
.arg(m_fileName)
.arg(error.what())
.arg(__FILE__)
.arg(__LINE__));
}
catch(std::exception &error)
{
qDebug() << error.what() << " " << typeid(error).name();
throw PappsoException(
QObject::tr(
"libpwiz ERROR reading MS data file %1 "
"(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
.arg(m_fileName)
.arg(error.what())
.arg(__FILE__)
.arg(__LINE__));
}
// qDebug() << "The number of runs is:" << m_msDataPtrVector.size()
//<< "The reader type is:" << QString::fromStdString(readerName)
//<< "The number of spectra in first run is:"
//<< m_msDataPtrVector.at(0)->run.spectrumListPtr->size();
return m_msDataPtrVector.size();
}
pappso::Utils::toUtf8StandardString
static std::string toUtf8StandardString(const QString &text)
Definition utils.cpp:165
pappso::MsDataFormat::msn
@ msn
pappso::MsDataFormat::agilentMassHunter
@ agilentMassHunter
pappso::MsDataFormat::abSciexT2D
@ abSciexT2D
pappso::MsDataFormat::mzXML
@ mzXML
mzXML
pappso::MsDataFormat::watersRaw
@ watersRaw
pappso::MsDataFormat::mz5
@ mz5
pappso::MsDataFormat::brukerBaf
@ brukerBaf
pappso::MsDataFormat::mzML
@ mzML
mzML
pappso::MsDataFormat::abSciexWiff
@ abSciexWiff
pappso::MsDataFormat::brukerFid
@ brukerFid
pappso::MsDataFormat::unknown
@ unknown
unknown format
pappso::MsDataFormat::MGF
@ MGF
Mascot format.
pappso::MsDataFormat::thermoRaw
@ thermoRaw
pappso::MsDataFormat::brukerYep
@ brukerYep

References pappso::abSciexT2D, pappso::abSciexWiff, pappso::agilentMassHunter, pappso::brukerBaf, pappso::brukerFid, pappso::brukerYep, pappso::MsFileReader::m_fileFormat, pappso::MsFileReader::m_fileName, m_msDataPtrVector, pappso::MGF, pappso::msn, pappso::mz5, pappso::mzML, pappso::mzXML, pappso::thermoRaw, pappso::Utils::toUtf8StandardString(), pappso::unknown, and pappso::watersRaw.

Referenced by getMsRunIds().

## Member Data Documentation

## m_msDataPtrVector

std::vector<pwiz::msdata::MSDataPtr> pappso::PwizMsFileReader::m_msDataPtrVector

private

Definition at line 20 of file pwizmsfilereader.h.

Referenced by getMsRunIds(), and initialize().

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

- pappsomspp/msfile/pwizmsfilereader.h
- pappsomspp/msfile/pwizmsfilereader.cpp