pappso::XyMsFileReader Class Reference

`#include <xymsfilereader.h>`

Inheritance diagram for pappso::XyMsFileReader:

## Public Member Functions

| XyMsFileReader (const QString &file_name)
virtual | ~XyMsFileReader ()
virtual MzFormat | getFileFormat () override
virtual std::vector< MsRunIdCstSPtr > | getMsRunIds (const QString &run_prefix) override
MsRunReader * | selectMsRunReader (const QString &file_name) const

## Private Member Functions

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

## Additional Inherited Members

Private Attributes inherited from pappso::MsFileReader
QString | m_fileName
MzFormat | m_fileFormat = MzFormat::unknown

## Detailed Description

Definition at line 16 of file xymsfilereader.h.

## Constructor & Destructor Documentation

## XyMsFileReader()

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

Definition at line 28 of file xymsfilereader.cpp.

: MsFileReader{file_name}
{
initialize();
}
pappso::MsFileReader::MsFileReader
MsFileReader(const QString &file_name)
Definition: msfilereader.cpp:19
pappso::XyMsFileReader::initialize
virtual std::size_t initialize()
Definition: xymsfilereader.cpp:41

References initialize().

## ~XyMsFileReader()

pappso::XyMsFileReader::~XyMsFileReader | ( |  | ) |

virtual

Definition at line 35 of file xymsfilereader.cpp.

{
}

## Member Function Documentation

## getFileFormat()

MzFormat pappso::XyMsFileReader::getFileFormat | ( |  | ) |

override virtual

Implements pappso::MsFileReader.

Definition at line 99 of file xymsfilereader.cpp.

{
return m_fileFormat;
}
pappso::MsFileReader::m_fileFormat
MzFormat m_fileFormat
Definition: msfilereader.h:18

References pappso::MsFileReader::m_fileFormat.

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

## getMsRunIds()

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

override virtual

Implements pappso::MsFileReader.

Definition at line 106 of file xymsfilereader.cpp.

{
std::vector<MsRunIdCstSPtr> ms_run_ids;
if(!initialize())
return ms_run_ids;
// Finally create the MsRunId with the file name.
MsRunId ms_run_id(m_fileName);
ms_run_id.setMzFormat(m_fileFormat);
// We need to set the unambiguous xmlId string.
ms_run_id.setXmlId(
QString("%1%2").arg(run_prefix).arg(Utils::getLexicalOrderedString(0)));
// Craft a meaningful sample name because otherwise all the files loaded from
// text files will have the same sample name and it will be difficult to
// differentiate them.
// Orig version:
// ms_run_id.setRunId("Single spectrum");
// Now the sample name is nothing but the file name without the path.
QFileInfo file_info(m_fileName);
// qDebug() << "file name:" << m_fileName;
QString sample_name = file_info.fileName();
// qDebug() << "sample name:" << sample_name;
ms_run_id.setRunId(sample_name);
// Now set the sample name to the run id:
ms_run_id.setSampleName(ms_run_id.getRunId());
// Now set the sample name to the run id:
ms_run_id.setSampleName(ms_run_id.getRunId());
// 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));
return ms_run_ids;
}
pappso::MsFileReader::m_fileName
QString m_fileName
Definition: msfilereader.h:17
pappso::Utils::getLexicalOrderedString
static const QString getLexicalOrderedString(unsigned int num)
Definition: utils.cpp:52

References pappso::Utils::getLexicalOrderedString(), pappso::MsRunId::getRunId(), initialize(), pappso::MsFileReader::m_fileFormat, pappso::MsFileReader::m_fileName, pappso::MsRunId::setMzFormat(), pappso::MsRunId::setRunId(), pappso::MsRunId::setSampleName(), and pappso::MsRunId::setXmlId().

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

## initialize()

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

private virtual

Definition at line 41 of file xymsfilereader.cpp.

{
// Here we just test all the lines of the file to check that they comply with
// the xy format.
std::size_t line_count = 0;
QFile file(m_fileName);
if(!file.open(QFile::ReadOnly | QFile::Text))
{
qDebug() << "Failed to open file" << m_fileName;
return 0;
}
QRegularExpressionMatch regExpMatch;
QString line;
bool file_reading_failed = false;
while(!file.atEnd())
{
line = file.readLine();
++line_count;
// We only read a given number of lines from the file, that would be
// enough to check if that file has the right syntax or not.
// if(linesRead >= 2000)
// return true;
if(line.startsWith('#') || line.isEmpty() ||
Utils::endOfLineRegExp.match(line).hasMatch())
continue;
// qDebug() << __FILE__ << __LINE__ << "Current xy format line:" << line;
if(Utils::xyMassDataFormatRegExp.match(line).hasMatch())
continue;
else
{
file_reading_failed = true;
break;
}
}
if(!file_reading_failed && line_count >= 1)
m_fileFormat = MzFormat::xy;
else
m_fileFormat = MzFormat::unknown;
qDebug() << "m_fileFormat: " << static_cast<int>(m_fileFormat);
return line_count;
}
pappso::Utils::xyMassDataFormatRegExp
static QRegularExpression xyMassDataFormatRegExp
Definition: utils.h:53
pappso::Utils::endOfLineRegExp
static QRegularExpression endOfLineRegExp
Regular expression that tracks the end of line in text files.
Definition: utils.h:62
pappso::MzFormat::xy
@ xy
(x,y) format
pappso::MzFormat::unknown
@ unknown
unknown format

References pappso::Utils::endOfLineRegExp, pappso::MsFileReader::m_fileFormat, pappso::MsFileReader::m_fileName, pappso::unknown, pappso::xy, and pappso::Utils::xyMassDataFormatRegExp.

Referenced by XyMsFileReader(), and getMsRunIds().

## selectMsRunReader()

MsRunReader* pappso::XyMsFileReader::selectMsRunReader | ( | const QString & | file_name | ) | const

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

- pappsomspp/msfile/xymsfilereader.h
- pappsomspp/msfile/xymsfilereader.cpp