libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::masschroq::PrecursorParser Class Reference

#include <precursorparser.h>

Inheritance diagram for pappso::masschroq::PrecursorParser:
pappso::SpectrumCollectionHandlerInterface

Public Member Functions

 PrecursorParser (pappso::MsRunReaderCstSPtr msrun_reader)
virtual ~PrecursorParser ()
virtual void setQualifiedMassSpectrum (const pappso::QualifiedMassSpectrum &qspectrum) override
virtual bool needPeakList () const override
 tells if we need the peak list (if we want the binary data) for each spectrum
virtual bool isReadAhead () const override
 tells if we want to read ahead spectrum
const PrecursorSpgetPrecursorSPtrBySpectrumIndex (std::size_t spectrum_index) const
const PrecursorSpgetPrecursorSPtrByScanNumber (std::size_t spectrum_index) const
Public Member Functions inherited from pappso::SpectrumCollectionHandlerInterface
virtual bool needMsLevelPeakList (unsigned int ms_level) const final
 tells if we need the peak list (if we want the binary data) for each spectrum, given an MS level
virtual void setNeedMsLevelPeakList (unsigned int ms_level, bool want_peak_list) final
 tells if we need the peak list given
virtual bool shouldStop ()
virtual void loadingEnded ()
virtual void spectrumListHasSize (std::size_t size)
virtual void setReadAhead (bool is_read_ahead) final
 use threads to read a spectrum by batch of batch_size

Private Member Functions

void mapScanNumberPrecursor (std::size_t scan_num, PrecursorSp precursor)
 map precursor to its scan number as parsed in the xml file of this msrun
void mapSpectrumIndexToPrecursor (std::size_t spectrum_index, PrecursorSp precursor)
 map spectrum index to precursor new modern method to replace obsolete scan number

Private Attributes

pappso::MsRunReaderCstSPtr msp_msrunReader
std::map< std::size_t, PrecursorSpm_scanNumber2PrecursorMap
std::map< std::size_t, PrecursorSpm_spectrumIndex2PrecursorMap

Detailed Description

Todo
write docs

Definition at line 40 of file precursorparser.h.

Constructor & Destructor Documentation

◆ PrecursorParser()

pappso::masschroq::PrecursorParser::PrecursorParser ( pappso::MsRunReaderCstSPtr msrun_reader)

Definition at line 35 of file precursorparser.cpp.

36{
37 msp_msrunReader = msrun_reader;
38}
pappso::MsRunReaderCstSPtr msp_msrunReader

References msp_msrunReader.

◆ ~PrecursorParser()

pappso::masschroq::PrecursorParser::~PrecursorParser ( )
virtual

Definition at line 41 of file precursorparser.cpp.

42{
43}

Member Function Documentation

◆ getPrecursorSPtrByScanNumber()

const pappso::masschroq::PrecursorSp & pappso::masschroq::PrecursorParser::getPrecursorSPtrByScanNumber ( std::size_t spectrum_index) const

Definition at line 160 of file precursorparser.cpp.

161{
162 auto it = m_scanNumber2PrecursorMap.find(spectrum_index);
163 if(it != m_scanNumber2PrecursorMap.end())
164 {
165 }
166 else
167 {
168 throw pappso::PappsoException(QObject::tr("scan number %1 not found in %2")
169 .arg(spectrum_index)
170 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId()));
171 }
172 return it->second;
173}
std::map< std::size_t, PrecursorSp > m_scanNumber2PrecursorMap

References m_scanNumber2PrecursorMap, and msp_msrunReader.

◆ getPrecursorSPtrBySpectrumIndex()

const pappso::masschroq::PrecursorSp & pappso::masschroq::PrecursorParser::getPrecursorSPtrBySpectrumIndex ( std::size_t spectrum_index) const

Definition at line 143 of file precursorparser.cpp.

145{
146 auto it = m_spectrumIndex2PrecursorMap.find(spectrum_index);
147 if(it != m_spectrumIndex2PrecursorMap.end())
148 {
149 }
150 else
151 {
152 throw pappso::PappsoException(QObject::tr("spectrum index %1 not found in %2")
153 .arg(spectrum_index)
154 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId()));
155 }
156 return it->second;
157}
std::map< std::size_t, PrecursorSp > m_spectrumIndex2PrecursorMap

References m_spectrumIndex2PrecursorMap, and msp_msrunReader.

◆ isReadAhead()

bool pappso::masschroq::PrecursorParser::isReadAhead ( ) const
overridevirtual

tells if we want to read ahead spectrum

Reimplemented from pappso::SpectrumCollectionHandlerInterface.

Definition at line 105 of file precursorparser.cpp.

106{
107 return true;
108}

◆ mapScanNumberPrecursor()

void pappso::masschroq::PrecursorParser::mapScanNumberPrecursor ( std::size_t scan_num,
PrecursorSp precursor )
private

map precursor to its scan number as parsed in the xml file of this msrun

Definition at line 111 of file precursorparser.cpp.

113{
114
115 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
116 {
117 throw pappso::PappsoException(
118 QObject::tr("precursor.get()->getXicCoordSPtr().get() == nullptr scan_num=%1\n")
119 .arg(scan_num));
120 }
121 m_scanNumber2PrecursorMap[scan_num] = precursor;
122}

References pappso::masschroq::Precursor::getXicCoordSPtr(), and m_scanNumber2PrecursorMap.

Referenced by setQualifiedMassSpectrum().

◆ mapSpectrumIndexToPrecursor()

void pappso::masschroq::PrecursorParser::mapSpectrumIndexToPrecursor ( std::size_t spectrum_index,
PrecursorSp precursor )
private

map spectrum index to precursor new modern method to replace obsolete scan number

Definition at line 125 of file precursorparser.cpp.

127{
128
129 qDebug() << " spectrum_index=" << spectrum_index;
130
131 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
132 {
133 throw pappso::PappsoException(
134 QObject::tr("precursor.get()->getXicCoordSPtr().get() == nullptr \n")
135 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId())
136 .arg(spectrum_index));
137 }
138 m_spectrumIndex2PrecursorMap[spectrum_index] = precursor;
139 qDebug() << " spectrum_index=" << spectrum_index;
140}

References pappso::masschroq::Precursor::getXicCoordSPtr(), m_spectrumIndex2PrecursorMap, and msp_msrunReader.

Referenced by setQualifiedMassSpectrum().

◆ needPeakList()

bool pappso::masschroq::PrecursorParser::needPeakList ( ) const
overridevirtual

tells if we need the peak list (if we want the binary data) for each spectrum

Implements pappso::SpectrumCollectionHandlerInterface.

Definition at line 46 of file precursorparser.cpp.

47{
48 return false;
49}

◆ setQualifiedMassSpectrum()

void pappso::masschroq::PrecursorParser::setQualifiedMassSpectrum ( const pappso::QualifiedMassSpectrum & qspectrum)
overridevirtual

adding this new precursor to the msrun's hash map of scan_num -> precursor

Implements pappso::SpectrumCollectionHandlerInterface.

Definition at line 51 of file precursorparser.cpp.

53{
54
55 if(qspectrum.getMsLevel() > 1)
56 {
57
58 pappso::masschroq::PrecursorSp precursor = std::make_shared<pappso::masschroq::Precursor>(
59 qspectrum.getPrecursorSpectrumIndex(),
60 qspectrum.getPrecursorMz(),
61 qspectrum.getPrecursorIntensity(),
62 msp_msrunReader.get()->newXicCoordSPtrFromQualifiedMassSpectrum(
64
65
66 qDebug() << " native_id=" << qspectrum.getMassSpectrumId().getNativeId()
67 << " scan idx=" << qspectrum.getMassSpectrumId().getSpectrumIndex()
68 << " precursor_idx=" << qspectrum.getPrecursorSpectrumIndex()
69 << " precursor.get()->getXicCoordSPtr().get()->toString="
70 << precursor.get()->getXicCoordSPtr().get()->toString();
71 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
72 {
73 throw pappso::PappsoException(QObject::tr("precursor.get()->getXicCoordSPtr().get() == "
74 "nullptr\nindex=%1 %2 %3 %4")
75 .arg(qspectrum.getMassSpectrumId().getNativeId())
76 .arg(__FILE__)
77 .arg(__FUNCTION__)
78 .arg(__LINE__));
79 }
80 /// adding this new precursor to the msrun's hash map of scan_num ->
81 /// precursor
82 qDebug();
83 if(qspectrum.getMassSpectrumId().getNativeId().contains("scan="))
84 {
85 qDebug();
87 qspectrum.getMassSpectrumId().getNativeId()),
88 precursor);
90 qDebug();
91 }
92 else
93 {
94 qDebug();
96
98 qDebug();
99 }
100 qDebug();
101 }
102}
std::size_t getSpectrumIndex() const
const QString & getNativeId() const
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
uint getMsLevel() const
Get the mass spectrum level.
pappso_double getPrecursorIntensity(bool *ok=nullptr) const
get precursor intensity
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
pappso_double getPrecursorMz(bool *ok=nullptr) const
get precursor mz
std::size_t getPrecursorSpectrumIndex() const
Get the scan number of the precursor ion.
static std::size_t extractScanNumberFromMzmlNativeId(const QString &spectrum_native_id)
Definition utils.cpp:285
void mapSpectrumIndexToPrecursor(std::size_t spectrum_index, PrecursorSp precursor)
map spectrum index to precursor new modern method to replace obsolete scan number
void mapScanNumberPrecursor(std::size_t scan_num, PrecursorSp precursor)
map precursor to its scan number as parsed in the xml file of this msrun
std::shared_ptr< Precursor > PrecursorSp
Definition precursor.h:39

References pappso::Utils::extractScanNumberFromMzmlNativeId(), pappso::QualifiedMassSpectrum::getMassSpectrumId(), pappso::QualifiedMassSpectrum::getMsLevel(), pappso::MassSpectrumId::getNativeId(), pappso::PrecisionFactory::getPpmInstance(), pappso::QualifiedMassSpectrum::getPrecursorIntensity(), pappso::QualifiedMassSpectrum::getPrecursorMz(), pappso::QualifiedMassSpectrum::getPrecursorSpectrumIndex(), pappso::MassSpectrumId::getSpectrumIndex(), pappso::masschroq::Precursor::getXicCoordSPtr(), mapScanNumberPrecursor(), mapSpectrumIndexToPrecursor(), and msp_msrunReader.

Member Data Documentation

◆ m_scanNumber2PrecursorMap

std::map<std::size_t, PrecursorSp> pappso::masschroq::PrecursorParser::m_scanNumber2PrecursorMap
private

Definition at line 73 of file precursorparser.h.

Referenced by getPrecursorSPtrByScanNumber(), and mapScanNumberPrecursor().

◆ m_spectrumIndex2PrecursorMap

std::map<std::size_t, PrecursorSp> pappso::masschroq::PrecursorParser::m_spectrumIndex2PrecursorMap
private

◆ msp_msrunReader

pappso::MsRunReaderCstSPtr pappso::masschroq::PrecursorParser::msp_msrunReader
private

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