pappso::XyMsRunReader Class Reference

`#include <xymsrunreader.h>`

Inheritance diagram for pappso::XyMsRunReader:

## Public Member Functions

| XyMsRunReader (MsRunIdCstSPtr &msrun_id_csp)
virtual | ~XyMsRunReader ()
virtual MassSpectrumSPtr | massSpectrumSPtr (std::size_t spectrum_index) override
| get a MassSpectrumSPtr class given its spectrum index More...
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 More...
virtual void | readSpectrumCollection (SpectrumCollectionHandlerInterface &handler) override
| function to visit an MsRunReader and get each Spectrum in a spectrum collection handler More...
virtual pappso::XicCoordSPtr | newXicCoordSPtrFromSpectrumIndex (std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
| get a xic coordinate object from a given spectrum index More...
virtual pappso::XicCoordSPtr | newXicCoordSPtrFromQualifiedMassSpectrum (const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
| get a xic coordinate object from a given spectrum More...
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 More...
virtual std::size_t | spectrumListSize () const override
| get the totat number of spectrum conained in the MSrun data file More...
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 More...
virtual bool | acquireDevice () override
| acquire data back end device More...
Public Member Functions inherited from pappso::MsRunReader
| MsRunReader (MsRunIdCstSPtr &ms_run_id)
| MsRunReader (const MsRunReader &other)
virtual | ~MsRunReader ()
const MsRunIdCstSPtr & | getMsRunId () const
virtual std::size_t | scanNumber2SpectrumIndex (std::size_t scan_number)
| 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. More...
virtual bool | hasScanNumbers () const
| 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 More...
virtual std::vector< double > | getRetentionTimeLine ()
| retention timeline get retention times along the MSrun in seconds More...
virtual Trace | getTicChromatogram ()

## 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 More...
QualifiedMassSpectrum | qualifiedMassSpectrumFromXyMSDataFile (MassSpectrumId mass_spectrum_id) const

## Protected Attributes

QString | m_fileName
Protected Attributes inherited from pappso::MsRunReader
MsRunIdCstSPtr | mcsp_msRunId
MsRunReaderScanNumberMultiMap * | mpa_multiMapScanNumber = nullptr

## Friends

class | MsFileAccessor

## Detailed Description

Definition at line 10 of file xymsrunreader.h.

## Constructor & Destructor Documentation

## XyMsRunReader()

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

Definition at line 26 of file xymsrunreader.cpp.

: pappso::MsRunReader(msrun_id_csp)
{
// Run the initialization function that checks that the file exists!
initialize();
}
pappso::XyMsRunReader::initialize
virtual void initialize() override
Definition: xymsrunreader.cpp:36
pappso::MsRunReader
class PMSPP_LIB_DECL MsRunReader
Definition: msrunreader.h:183

References initialize().

## ~XyMsRunReader()

pappso::XyMsRunReader::~XyMsRunReader | ( |  | ) |

virtual

Definition at line 47 of file xymsrunreader.cpp.

{
}

## Member Function Documentation

## accept()

bool pappso::XyMsRunReader::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 53 of file xymsrunreader.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(file_name);
if(!file.open(QFile::ReadOnly | QFile::Text))
{
qDebug() << __FILE__ << __LINE__ << "Failed to open file" << file_name;
return false;
}
QRegularExpressionMatch regExpMatch;
QString line;
bool file_reading_failed = false;
while(!file.atEnd())
{
line = file.readLine();
++line_count;
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;
}
}
file.close();
if(!file_reading_failed && line_count >= 1)
return true;
return false;
}
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

References pappso::Utils::endOfLineRegExp, and pappso::Utils::xyMassDataFormatRegExp.

## acquireDevice()

bool pappso::XyMsRunReader::acquireDevice | ( |  | ) |

override virtual

acquire data back end device

Returns
  bool true if done

Implements pappso::MsRunReader.

Definition at line 308 of file xymsrunreader.cpp.

{
return true;
}

## initialize()

void pappso::XyMsRunReader::initialize | ( |  | ) |

override protected virtual

Implements pappso::MsRunReader.

Definition at line 36 of file xymsrunreader.cpp.

{
// qDebug();
if(!QFileInfo(mcsp_msRunId->getFileName()).exists())
throw ExceptionNotFound(QObject::tr("Xy MS file %1 not found\n")
.arg(mcsp_msRunId->getFileName()));
// qDebug();
}
pappso::MsRunReader::mcsp_msRunId
MsRunIdCstSPtr mcsp_msRunId
Definition: msrunreader.h:282

References pappso::MsRunReader::mcsp_msRunId.

Referenced by XyMsRunReader().

## massSpectrumCstSPtr()

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

override virtual

Implements pappso::MsRunReader.

Definition at line 112 of file xymsrunreader.cpp.

{
return qualifiedMassSpectrum(spectrum_index).getMassSpectrumCstSPtr();
}
pappso::QualifiedMassSpectrum::getMassSpectrumCstSPtr
MassSpectrumCstSPtr getMassSpectrumCstSPtr() const
Get the MassSpectrumCstSPtr.
Definition: qualifiedmassspectrum.cpp:141
pappso::XyMsRunReader::qualifiedMassSpectrum
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
Definition: xymsrunreader.cpp:215

References pappso::QualifiedMassSpectrum::getMassSpectrumCstSPtr(), and qualifiedMassSpectrum().

## massSpectrumSPtr()

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

override virtual

get a MassSpectrumSPtr class given its spectrum index

Implements pappso::MsRunReader.

Definition at line 105 of file xymsrunreader.cpp.

{
return qualifiedMassSpectrum(spectrum_index).getMassSpectrumSPtr();
}
pappso::QualifiedMassSpectrum::getMassSpectrumSPtr
MassSpectrumSPtr getMassSpectrumSPtr() const
Get the MassSpectrumSPtr.
Definition: qualifiedmassspectrum.cpp:133

References pappso::QualifiedMassSpectrum::getMassSpectrumSPtr(), and qualifiedMassSpectrum().

## newXicCoordSPtrFromQualifiedMassSpectrum()

XicCoordSPtr pappso::XyMsRunReader::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 326 of file xymsrunreader.cpp.

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

## newXicCoordSPtrFromSpectrumIndex()

XicCoordSPtr pappso::XyMsRunReader::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 314 of file xymsrunreader.cpp.

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

## qualifiedMassSpectrum()

QualifiedMassSpectrum pappso::XyMsRunReader::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 215 of file xymsrunreader.cpp.

{
// qDebug();
// In reality there is only one mass spectrum in the file, so we do not use
// spectrum_index, but use 0 instead.
MassSpectrumId massSpectrumId(mcsp_msRunId, 0);
QualifiedMassSpectrum qualified_mass_spectrum =
qualifiedMassSpectrumFromXyMSDataFile(massSpectrumId);
// qDebug() << "qualified mass spectrum has size:"
//<< qualified_mass_spectrum.getMassSpectrumSPtr()->size();
// We also do not abide by the want_binary_data parameter because in this XY
// mass spec data file loading process we actually want the data.
if(!want_binary_data)
{
// qualified_mass_spectrum.setMassSpectrumSPtr(nullptr);
}
return qualified_mass_spectrum;
}
pappso::XyMsRunReader::qualifiedMassSpectrumFromXyMSDataFile
QualifiedMassSpectrum qualifiedMassSpectrumFromXyMSDataFile(MassSpectrumId mass_spectrum_id) const
Definition: xymsrunreader.cpp:119

References pappso::MsRunReader::mcsp_msRunId, and qualifiedMassSpectrumFromXyMSDataFile().

Referenced by massSpectrumCstSPtr(), and massSpectrumSPtr().

## qualifiedMassSpectrumFromXyMSDataFile()

QualifiedMassSpectrum pappso::XyMsRunReader::qualifiedMassSpectrumFromXyMSDataFile | ( | MassSpectrumId | mass_spectrum_id | ) | const

protected

Definition at line 119 of file xymsrunreader.cpp.

{
// qDebug();
// This is a file that contains a single spectrum. Just iterate in the various
// lines and convert them to DataPoint objects that are fed to the mass
// spectrum.
QualifiedMassSpectrum qualified_mass_spectrum(mass_spectrum_id);
// Set manually data that are necessary for the correct use of this mass
// spectrum in the MS data set tree node.
qualified_mass_spectrum.setMsLevel(1);
qualified_mass_spectrum.setRtInSeconds(0);
MassSpectrum mass_spectrum;
QFile file(mcsp_msRunId->getFileName());
if(!file.exists())
{
// qDebug() << "File" << mcsp_msRunId->getFileName() << "does not exist.";
return qualified_mass_spectrum;
}
if(!file.open(QFile::ReadOnly | QFile::Text))
{
// qDebug() << "Failed to open file" << mcsp_msRunId->getFileName();
return qualified_mass_spectrum;
}
QRegularExpressionMatch regExpMatch;
QString line;
while(!file.atEnd())
{
line = file.readLine();
if(line.startsWith('#') || line.isEmpty() ||
Utils::endOfLineRegExp.match(line).hasMatch())
continue;
if(Utils::xyMassDataFormatRegExp.match(line).hasMatch())
{
pappso_double x = -1;
pappso_double y = -1;
QRegularExpressionMatch regExpMatch =
Utils::xyMassDataFormatRegExp.match(line);
if(!regExpMatch.hasMatch())
throw ExceptionNotPossible(
QObject::tr("Failed to create data point with line %1.\n")
.arg(line));
bool ok = false;
x = regExpMatch.captured(1).toDouble(&ok);
if(!ok)
throw ExceptionNotPossible(
QObject::tr("Failed to create data point with line %1.\n")
.arg(line));
// Note that group 2 is the separator group.
y = regExpMatch.captured(3).toDouble(&ok);
if(!ok)
throw ExceptionNotPossible(
QObject::tr("Failed to create data point with line %1.\n")
.arg(line));
DataPoint data_point(x, y);
mass_spectrum.emplace_back(x, y);
}
}
file.close();
MassSpectrumSPtr spectrum_sp = mass_spectrum.makeMassSpectrumSPtr();
qualified_mass_spectrum.setMassSpectrumSPtr(spectrum_sp);
// qDebug() << "the qualified mass spectrum has size:"
//<< qualified_mass_spectrum.getMassSpectrumSPtr()->size();
return qualified_mass_spectrum;
}
pappso::PeptideIonCter::y
@ y
pappso::PeptideIonCter::x
@ x
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:48
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54

References pappso::Utils::endOfLineRegExp, pappso::MassSpectrum::makeMassSpectrumSPtr(), pappso::MsRunReader::mcsp_msRunId, pappso::QualifiedMassSpectrum::setMassSpectrumSPtr(), pappso::QualifiedMassSpectrum::setMsLevel(), pappso::QualifiedMassSpectrum::setRtInSeconds(), pappso::x, pappso::Utils::xyMassDataFormatRegExp, and pappso::y.

Referenced by qualifiedMassSpectrum(), readSpectrumCollection(), and readSpectrumCollectionByMsLevel().

## readSpectrumCollection()

void pappso::XyMsRunReader::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 243 of file xymsrunreader.cpp.

{
// qDebug();
// In reality there is only one mass spectrum in the file.
MassSpectrumId massSpectrumId(mcsp_msRunId, 0 /* spectrum index*/);
QualifiedMassSpectrum qualified_mass_spectrum =
qualifiedMassSpectrumFromXyMSDataFile(massSpectrumId);
// qDebug() << "qualified mass spectrum has size:"
//<< qualified_mass_spectrum.getMassSpectrumSPtr()->size();
// The handler will receive the index of the mass spectrum in the
// current run via the mass spectrum id member datum.
handler.setQualifiedMassSpectrum(qualified_mass_spectrum);
// qDebug() << "Loading ended";
handler.loadingEnded();
}

References pappso::SpectrumCollectionHandlerInterface::loadingEnded(), pappso::MsRunReader::mcsp_msRunId, qualifiedMassSpectrumFromXyMSDataFile(), and pappso::SpectrumCollectionHandlerInterface::setQualifiedMassSpectrum().

## readSpectrumCollectionByMsLevel()

void pappso::XyMsRunReader::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 268 of file xymsrunreader.cpp.

{
// qDebug();
// In reality there is only one mass spectrum in the file.
MassSpectrumId massSpectrumId(mcsp_msRunId, 0 /* spectrum index*/);
QualifiedMassSpectrum qualified_mass_spectrum =
qualifiedMassSpectrumFromXyMSDataFile(massSpectrumId);
// qDebug() << "qualified mass spectrum has size:"
//<< qualified_mass_spectrum.getMassSpectrumSPtr()->size();
// The handler will receive the index of the mass spectrum in the
// current run via the mass spectrum id member datum.
if(qualified_mass_spectrum.getMsLevel() == ms_level)
{
handler.setQualifiedMassSpectrum(qualified_mass_spectrum);
}
// qDebug() << "Loading ended";
handler.loadingEnded();
}

References pappso::QualifiedMassSpectrum::getMsLevel(), pappso::SpectrumCollectionHandlerInterface::loadingEnded(), pappso::MsRunReader::mcsp_msRunId, qualifiedMassSpectrumFromXyMSDataFile(), and pappso::SpectrumCollectionHandlerInterface::setQualifiedMassSpectrum().

## releaseDevice()

bool pappso::XyMsRunReader::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 302 of file xymsrunreader.cpp.

{
return true;
}

## spectrumListSize()

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

override virtual

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

Implements pappso::MsRunReader.

Definition at line 296 of file xymsrunreader.cpp.

{
return 1;
}

## Friends And Related Function Documentation

## MsFileAccessor

friend class MsFileAccessor

friend

Definition at line 12 of file xymsrunreader.h.

## Member Data Documentation

## m_fileName

QString pappso::XyMsRunReader::m_fileName

protected

Definition at line 50 of file xymsrunreader.h.

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

- pappsomspp/msrun/xymsrunreader.h
- pappsomspp/msrun/xymsrunreader.cpp