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

`#include <mzxmloutput.h>`

## Classes

class | Translater

## Public Member Functions

| MzxmlOutput (UiMonitorInterface &monitor, QIODevice *p_output_device)
| ~MzxmlOutput ()
void | write (MsRunReader *p_msrunreader)
void | write (const MsRunReadConfig &read_config, MsRunReader *p_msrunreader)
void | close ()
void | maskMs1 (bool mask_ms1)
void | setReadAhead (bool read_ahead)

## Private Member Functions

void | writeHeader (MsRunReader *p_msrunreader)
void | writeQualifiedMassSpectrum (const QualifiedMassSpectrum &spectrum)
std::size_t | getScanNumber (const QualifiedMassSpectrum &spectrum) const
std::size_t | getPrecursorScanNumber (const QualifiedMassSpectrum &spectrum) const
std::size_t | getScanNumberFromNativeId (const QString &native_id) const

## Private Attributes

UiMonitorInterface & | m_monitor
QXmlStreamWriter * | mpa_outputStream
bool | m_isReadAhead = false
bool | m_ms1IsMasked = false

## Detailed Description

Todo:
  use msrunreader as input and writes all peaks into an mzXML output stream

Definition at line 43 of file mzxmloutput.h.

## Constructor & Destructor Documentation

## MzxmlOutput()

MzxmlOutput::MzxmlOutput | ( | UiMonitorInterface & | monitor,
|  | QIODevice * | p_output_device
| ) |  |

Default constructor

Definition at line 75 of file mzxmloutput.cpp.

: m_monitor(monitor)
{
mpa_outputStream = new QXmlStreamWriter(p_output_device);
mpa_outputStream->setAutoFormatting(true);
mpa_outputStream->writeStartDocument("1.0");
}
pappso::MzxmlOutput::m_monitor
UiMonitorInterface & m_monitor
Definition mzxmloutput.h:91
pappso::MzxmlOutput::mpa_outputStream
QXmlStreamWriter * mpa_outputStream
Definition mzxmloutput.h:92

References mpa_outputStream.

## ~MzxmlOutput()

MzxmlOutput::~MzxmlOutput | ( |  | ) |

Destructor

Definition at line 86 of file mzxmloutput.cpp.

{
close();
delete mpa_outputStream;
}
pappso::MzxmlOutput::close
void close()
Definition mzxmloutput.cpp:241

References close(), and mpa_outputStream.

## Member Function Documentation

## close()

void MzxmlOutput::close | ( |  | ) |

Definition at line 241 of file mzxmloutput.cpp.

{
mpa_outputStream->writeEndDocument();
}

References mpa_outputStream.

Referenced by ~MzxmlOutput(), and pappso::TandemWrapperRun::convertOrginalMsData2mzXmlData().

## getPrecursorScanNumber()

std::size_t MzxmlOutput::getPrecursorScanNumber | ( | const QualifiedMassSpectrum & | spectrum | ) | const

private

Definition at line 274 of file mzxmloutput.cpp.

{
std::size_t scan_number =
getScanNumberFromNativeId(spectrum.getPrecursorNativeId());
if(scan_number == std::numeric_limits<std::size_t>::max())
{
scan_number = spectrum.getPrecursorSpectrumIndex() + 1;
}
return scan_number;
}
pappso::MzxmlOutput::getScanNumberFromNativeId
std::size_t getScanNumberFromNativeId(const QString &native_id) const
Definition mzxmloutput.cpp:248
pappso::QualifiedMassSpectrum::getPrecursorNativeId
const QString & getPrecursorNativeId() const
Definition qualifiedmassspectrum.cpp:449
pappso::QualifiedMassSpectrum::getPrecursorSpectrumIndex
std::size_t getPrecursorSpectrumIndex() const
Get the scan number of the precursor ion.
Definition qualifiedmassspectrum.cpp:435

References pappso::QualifiedMassSpectrum::getPrecursorNativeId(), pappso::QualifiedMassSpectrum::getPrecursorSpectrumIndex(), and getScanNumberFromNativeId().

Referenced by writeQualifiedMassSpectrum().

## getScanNumber()

std::size_t MzxmlOutput::getScanNumber | ( | const QualifiedMassSpectrum & | spectrum | ) | const

private

Definition at line 262 of file mzxmloutput.cpp.

{
std::size_t scan_number =
getScanNumberFromNativeId(spectrum.getMassSpectrumId().getNativeId());
if(scan_number == std::numeric_limits<std::size_t>::max())
{
scan_number = spectrum.getMassSpectrumId().getSpectrumIndex() + 1;
}
return scan_number;
}
pappso::MassSpectrumId::getSpectrumIndex
std::size_t getSpectrumIndex() const
Definition massspectrumid.cpp:113
pappso::MassSpectrumId::getNativeId
const QString & getNativeId() const
Definition massspectrumid.cpp:99
pappso::QualifiedMassSpectrum::getMassSpectrumId
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
Definition qualifiedmassspectrum.cpp:157

References pappso::QualifiedMassSpectrum::getMassSpectrumId(), pappso::MassSpectrumId::getNativeId(), getScanNumberFromNativeId(), and pappso::MassSpectrumId::getSpectrumIndex().

Referenced by writeQualifiedMassSpectrum().

## getScanNumberFromNativeId()

std::size_t MzxmlOutput::getScanNumberFromNativeId | ( | const QString & | native_id | ) | const

private

Definition at line 248 of file mzxmloutput.cpp.

{
QStringList native_id_list = native_id.split("=");
if(native_id_list.size() < 2)
{
}
else
{
return native_id_list.back().toULong();
}
return std::numeric_limits<std::size_t>::max();
}

Referenced by getPrecursorScanNumber(), and getScanNumber().

## maskMs1()

void MzxmlOutput::maskMs1 | ( | bool | mask_ms1 | ) |

Definition at line 421 of file mzxmloutput.cpp.

{
m_ms1IsMasked = mask_ms1;
}
pappso::MzxmlOutput::m_ms1IsMasked
bool m_ms1IsMasked
Definition mzxmloutput.h:94

References m_ms1IsMasked.

Referenced by pappso::TandemWrapperRun::convertOrginalMsData2mzXmlData().

## setReadAhead()

void MzxmlOutput::setReadAhead | ( | bool | read_ahead | ) |

Definition at line 93 of file mzxmloutput.cpp.

{
m_isReadAhead = isReadAhead;
}
pappso::MzxmlOutput::m_isReadAhead
bool m_isReadAhead
Definition mzxmloutput.h:93

References m_isReadAhead.

Referenced by pappso::TandemWrapperRun::convertOrginalMsData2mzXmlData().

## write() [1/2]

void pappso::MzxmlOutput::write | ( | const MsRunReadConfig & | read_config,
|  | pappso::MsRunReader * | p_msrunreader
| ) |  |

Definition at line 118 of file mzxmloutput.cpp.

{
qDebug();
m_monitor.setTotalSteps(p_msrunreader->spectrumListSize());
writeHeader(p_msrunreader);
Translater translater(this);
translater.setReadAhead(m_isReadAhead);
translater.setNeedMsLevelPeakList(1, !m_ms1IsMasked);
// translater.setNeedMsLevelPeakList(1, false);
// translater.setNeedMsLevelPeakList(2, false);
p_msrunreader->readSpectrumCollection2(read_config, translater);
m_monitor.setTotalSteps(0);
}
pappso::MsRunReader::spectrumListSize
virtual std::size_t spectrumListSize() const =0
get the totat number of spectrum conained in the MSrun data file
pappso::MsRunReader::readSpectrumCollection2
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)=0
pappso::MzxmlOutput::writeHeader
void writeHeader(MsRunReader *p_msrunreader)
Definition mzxmloutput.cpp:138
pappso::UiMonitorInterface::setTotalSteps
virtual void setTotalSteps(std::size_t total_number_of_steps)
use it if the number of steps is known in an algorithm the total number of steps is usefull to report...
Definition uimonitorinterface.h:66

References pappso::MsRunReader::readSpectrumCollection2(), pappso::SpectrumCollectionHandlerInterface::setNeedMsLevelPeakList(), pappso::SpectrumCollectionHandlerInterface::setReadAhead(), and pappso::MsRunReader::spectrumListSize().

## write() [2/2]

void MzxmlOutput::write | ( | MsRunReader * | p_msrunreader | ) |

Definition at line 98 of file mzxmloutput.cpp.

{
qDebug();
m_monitor.setTotalSteps(p_msrunreader->spectrumListSize());
writeHeader(p_msrunreader);
Translater translater(this);
translater.setReadAhead(m_isReadAhead);
translater.setNeedMsLevelPeakList(1, !m_ms1IsMasked);
// translater.setNeedMsLevelPeakList(1, false);
// translater.setNeedMsLevelPeakList(2, false);
p_msrunreader->readSpectrumCollection(translater);
m_monitor.setTotalSteps(0);
qDebug();
}
pappso::MsRunReader::readSpectrumCollection
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler

References m_isReadAhead, m_monitor, m_ms1IsMasked, pappso::MsRunReader::readSpectrumCollection(), pappso::SpectrumCollectionHandlerInterface::setNeedMsLevelPeakList(), pappso::SpectrumCollectionHandlerInterface::setReadAhead(), pappso::UiMonitorInterface::setTotalSteps(), pappso::MsRunReader::spectrumListSize(), and writeHeader().

Referenced by pappso::TandemWrapperRun::convertOrginalMsData2mzXmlData().

## writeHeader()

void MzxmlOutput::writeHeader | ( | MsRunReader * | p_msrunreader | ) |

private

Definition at line 138 of file mzxmloutput.cpp.

{
mpa_outputStream->writeNamespace("http://www.w3.org/2001/XMLSchema-instance",
"xsi");
// xmlns="http://sashimi.sourceforge.net/schema_revision/mzXML_2.0"
// xsi:schemaLocation="http://sashimi.sourceforge.net/schema_revision/mzXML_2.0
// http://sashimi.sourceforge.net/schema_revision/mzXML_2.0/mzXML_idx_2.0.xsd"
/*
114 writer.setPrefix("xsi", xmlnsxsi);
115 writer.setDefaultNamespace(namespaceURI);
mpa_outputStream->writeStartElement("mzXML");
117 writer.writeNamespace("xsi", xmlnsxsi);
118 writer.writeDefaultNamespace(namespaceURI);
119
120 writer.writeAttribute(xmlnsxsi, "schemaLocation",
xsischemaLocation); 121 */
mpa_outputStream->writeStartElement("mzXML");
mpa_outputStream->writeAttribute(
"xmlns", "http://sashimi.sourceforge.net/schema_revision/mzXML_3.2");
mpa_outputStream->writeAttribute(
"xsi:schemaLocation",
"http://sashimi.sourceforge.net/schema_revision/mzXML_3.2 "
"http://sashimi.sourceforge.net/schema_revision/mzXML_3.2/"
"mzXML_idx_3.2.xsd");
mpa_outputStream->writeStartElement("msRun");
mpa_outputStream->writeAttribute(
"scanCount", QString("%1").arg(p_msrunreader->spectrumListSize()));
//<msRun scanCount="16576" startTime="PT0.292553S" endTime="PT3000.34S">
// writer.writeAttribute("scanCount",
// ms_run.getSpectrumCount(this.controller).toString());
/*
* # < parentFile fileName = #
* "file://SEQUEST1/raw/vidal/20060411_VIDAL_JEAN_1_PEPCR1_42140.RAW" #
* fileType = "RAWData" fileSha1 = #
* "23c1620d4ad3f4f0103b0141b7caec1e8b7eebf5" / >
*/
mpa_outputStream->writeStartElement("parentFile");
mpa_outputStream->writeAttribute("fileName",
p_msrunreader->getMsRunId()->getFileName());
mpa_outputStream->writeAttribute("fileType", "RAWData");
mpa_outputStream->writeEndElement();
/*
144
145 MsInstrumentList instrument_list =
ms_run.getMsInstruments(controller); 146 for (MsInstrument
instrument : instrument_list) { 147 this.write(instrument); 148 }
*/
mpa_outputStream->writeStartElement("msInstrument");
mpa_outputStream->writeAttribute("msInstrumentID", "1");
//<msManufacturer category="msManufacturer" value="Thermo Scientific"/>
mpa_outputStream->writeStartElement("msManufacturer");
mpa_outputStream->writeAttribute("category", "msManufacturer");
mpa_outputStream->writeAttribute("value", "unknown");
mpa_outputStream->writeEndElement();
//<msModel category="msModel" value="Q Exactive"/>
// <msIonisation category="msIonisation" value="nanoelectrospray"/>
// <msMassAnalyzer category="msMassAnalyzer" value="quadrupole"/>
// <msDetector category="msDetector" value="inductive detector"/>
// <software type="acquisition" name="Xcalibur"
// version="2.1-152001/2.1.0.1520"/>
mpa_outputStream->writeEndElement();
/*
149
150 // #< dataProcessing centroided ="1" >
151 // my $ref_data_processings =
$ms_run_description->dataProcessing(); 152 MsDataProcessingList
dataProcList = ms_run.getMsDataProcessings(controller); 153 for
(MsDataProcessing msDataProc : dataProcList) { 154 this.write(msDataProc); 155 }
*/
mpa_outputStream->writeStartElement("dataProcessing");
//<dataProcessing centroided="1">
mpa_outputStream->writeAttribute("centroided", "1");
// <software type="conversion" name="ProteoWizard" version="3.0.3706"/>
mpa_outputStream->writeStartElement("software");
mpa_outputStream->writeAttribute("type", "conversion");
mpa_outputStream->writeAttribute("name", PAPPSOMSPP_NAME);
mpa_outputStream->writeAttribute("version", PAPPSOMSPP_VERSION);
mpa_outputStream->writeEndElement();
//<processingOperation name="Conversion to mzML"/>
mpa_outputStream->writeStartElement("processingOperation");
mpa_outputStream->writeAttribute("name", "Conversion to mzXML");
//<software type="processing" name="ProteoWizard" version="3.0.3706"/>
mpa_outputStream->writeStartElement("software");
mpa_outputStream->writeAttribute("type", "processing");
mpa_outputStream->writeAttribute("name", PAPPSOMSPP_NAME);
mpa_outputStream->writeAttribute("version", PAPPSOMSPP_VERSION);
mpa_outputStream->writeEndElement();
//<comment>Thermo/Xcalibur peak picking</comment>
mpa_outputStream->writeStartElement("comment");
mpa_outputStream->writeCharacters("pappso::MzxmlOutput");
mpa_outputStream->writeEndElement();
//</dataProcessing>
mpa_outputStream->writeEndElement();
mpa_outputStream->writeEndElement();
// Peaks
}
pappso::MsRunReader::getMsRunId
const MsRunIdCstSPtr & getMsRunId() const
Definition msrunreader.cpp:57

References pappso::MsRunReader::getMsRunId(), mpa_outputStream, and pappso::MsRunReader::spectrumListSize().

Referenced by write().

## writeQualifiedMassSpectrum()

void MzxmlOutput::writeQualifiedMassSpectrum | ( | const QualifiedMassSpectrum & | spectrum | ) |

private

Definition at line 287 of file mzxmloutput.cpp.

{
qDebug();
mpa_outputStream->writeStartElement("scan");
/*
<scan num="1"
scanType="Full"
centroided="1"
msLevel="1"
peaksCount="1552"
polarity="+"
retentionTime="PT0.292553S"
lowMz="400.153411865234"
highMz="1013.123352050781"
basePeakMz="445.12003"
basePeakIntensity="2.0422125e06"
totIonCurrent="1.737798e07">*/
mpa_outputStream->writeAttribute("num",
QString("%1").arg(getScanNumber(spectrum)));
mpa_outputStream->writeAttribute("centroided", QString("1"));
mpa_outputStream->writeAttribute("msLevel",
QString("%1").arg(spectrum.getMsLevel()));
if(spectrum.getMassSpectrumCstSPtr().get() == nullptr)
{
mpa_outputStream->writeAttribute("peaksCount", "0");
}
else
{
mpa_outputStream->writeAttribute("peaksCount",
QString("%1").arg(spectrum.size()));
if(spectrum.size() > 0)
{
mpa_outputStream->writeAttribute(
"lowMz",
QString::number(
spectrum.getMassSpectrumCstSPtr().get()->front().x, 'f', 12));
mpa_outputStream->writeAttribute(
"highMz",
QString::number(
spectrum.getMassSpectrumCstSPtr().get()->back().x, 'f', 12));
// mpa_outputStream->writeAttribute("highMz",
// QString::number(spectrum.getMassSpectrumCstSPtr().get()->back().x,
// 'f', 10)); basePeakMz="245.1271988"
// basePeakIntensity="5810.7739"
// totIonCurrent="57803.815999999999">
}
}
mpa_outputStream->writeAttribute("polarity", "+");
mpa_outputStream->writeAttribute(
"retentionTime",
QString("PT%1S").arg(QString::number(spectrum.getRtInSeconds(), 'f', 2)));
if(spectrum.getMsLevel() > 1)
{
//<precursorMz precursorScanNum="16574"
// precursorIntensity="58403.04296875" precursorCharge="2"
////activationMethod="HCD">994.690619901808</precursorMz>
mpa_outputStream->writeStartElement("precursorMz");
mpa_outputStream->writeAttribute(
"precursorScanNum",
QString("%1").arg(getPrecursorScanNumber(spectrum)));
bool ok;
double precursor_intensity = spectrum.getPrecursorIntensity(&ok);
if(ok)
{
mpa_outputStream->writeAttribute(
"precursorIntensity", QString::number(precursor_intensity, 'f', 4));
}
uint charge = spectrum.getPrecursorCharge(&ok);
if(ok)
{
mpa_outputStream->writeAttribute("precursorCharge",
QString("%1").arg(charge));
}
double precursor_mz = spectrum.getPrecursorMz(&ok);
if(ok)
{
mpa_outputStream->writeCharacters(
QString::number(precursor_mz, 'f', 12));
}
mpa_outputStream->writeEndElement();
}
/*<peaks compressionType="none"
compressedLen="0"
precision="64"
byteOrder="network"
contentType="m/z-int"></peaks>*/
mpa_outputStream->writeStartElement("peaks");
mpa_outputStream->writeAttribute("compressionType", "none");
mpa_outputStream->writeAttribute("compressedLen", "0");
mpa_outputStream->writeAttribute("precision", "64");
mpa_outputStream->writeAttribute("byteOrder", "network");
mpa_outputStream->writeAttribute("contentType", "m/z-int");
if((spectrum.getMassSpectrumCstSPtr().get() != nullptr) &&
(!spectrum.isEmptyMassSpectrum()))
{
QByteArray byte_array;
if(QSysInfo::ByteOrder == QSysInfo::LittleEndian)
{
for(const DataPoint &peak :
*(spectrum.getMassSpectrumCstSPtr().get()))
{
double swap = change_endian(peak.x);
byte_array.append((char *)&swap, 8);
swap = change_endian(peak.y);
byte_array.append((char *)&swap, 8);
}
}
else
{
for(const DataPoint &peak :
*(spectrum.getMassSpectrumCstSPtr().get()))
{
byte_array.append((char *)&peak.x, 8);
byte_array.append((char *)&peak.y, 8);
}
}
mpa_outputStream->writeCharacters(byte_array.toBase64());
}
mpa_outputStream->writeEndElement();
// scan
mpa_outputStream->writeEndElement();
qDebug();
}
pappso::MzxmlOutput::getScanNumber
std::size_t getScanNumber(const QualifiedMassSpectrum &spectrum) const
Definition mzxmloutput.cpp:262
pappso::MzxmlOutput::getPrecursorScanNumber
std::size_t getPrecursorScanNumber(const QualifiedMassSpectrum &spectrum) const
Definition mzxmloutput.cpp:274
pappso::QualifiedMassSpectrum::getMsLevel
uint getMsLevel() const
Get the mass spectrum level.
Definition qualifiedmassspectrum.cpp:192
pappso::QualifiedMassSpectrum::getMassSpectrumCstSPtr
MassSpectrumCstSPtr getMassSpectrumCstSPtr() const
Get the MassSpectrumCstSPtr.
Definition qualifiedmassspectrum.cpp:141
pappso::QualifiedMassSpectrum::getPrecursorCharge
uint getPrecursorCharge(bool *ok=nullptr) const
get precursor charge
Definition qualifiedmassspectrum.cpp:344
pappso::QualifiedMassSpectrum::getPrecursorIntensity
pappso_double getPrecursorIntensity(bool *ok=nullptr) const
get precursor intensity
Definition qualifiedmassspectrum.cpp:408
pappso::QualifiedMassSpectrum::isEmptyMassSpectrum
bool isEmptyMassSpectrum() const
Definition qualifiedmassspectrum.cpp:176
pappso::QualifiedMassSpectrum::getPrecursorMz
pappso_double getPrecursorMz(bool *ok=nullptr) const
get precursor mz
Definition qualifiedmassspectrum.cpp:243
pappso::QualifiedMassSpectrum::size
std::size_t size() const
Definition qualifiedmassspectrum.cpp:518
pappso::QualifiedMassSpectrum::getRtInSeconds
pappso_double getRtInSeconds() const
Get the retention time in seconds.
Definition qualifiedmassspectrum.cpp:208
change_endian
T change_endian(T in)
Definition mzxmloutput.cpp:43
pappso::uint
unsigned int uint
Definition types.h:57
pappso::DataPoint
Definition datapoint.h:22

References change_endian(), pappso::QualifiedMassSpectrum::getMassSpectrumCstSPtr(), pappso::QualifiedMassSpectrum::getMsLevel(), pappso::QualifiedMassSpectrum::getPrecursorCharge(), pappso::QualifiedMassSpectrum::getPrecursorIntensity(), pappso::QualifiedMassSpectrum::getPrecursorMz(), getPrecursorScanNumber(), pappso::QualifiedMassSpectrum::getRtInSeconds(), getScanNumber(), pappso::QualifiedMassSpectrum::isEmptyMassSpectrum(), mpa_outputStream, and pappso::QualifiedMassSpectrum::size().

## Member Data Documentation

## m_isReadAhead

bool pappso::MzxmlOutput::m_isReadAhead = false

private

Definition at line 93 of file mzxmloutput.h.

Referenced by setReadAhead(), and write().

## m_monitor

UiMonitorInterface& pappso::MzxmlOutput::m_monitor

private

Definition at line 91 of file mzxmloutput.h.

Referenced by write().

## m_ms1IsMasked

bool pappso::MzxmlOutput::m_ms1IsMasked = false

private

Definition at line 94 of file mzxmloutput.h.

Referenced by maskMs1(), and write().

## mpa_outputStream

QXmlStreamWriter* pappso::MzxmlOutput::mpa_outputStream

private

Definition at line 92 of file mzxmloutput.h.

Referenced by MzxmlOutput(), ~MzxmlOutput(), close(), writeHeader(), and writeQualifiedMassSpectrum().

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

- pappsomspp/msrun/output/mzxmloutput.h
- pappsomspp/msrun/output/mzxmloutput.cpp