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 168 of file precursorparser.cpp.

170{
171 auto it = m_scanNumber2PrecursorMap.find(spectrum_index);
172 if(it != m_scanNumber2PrecursorMap.end())
173 {
174 }
175 else
176 {
177 throw pappso::PappsoException(
178 QObject::tr("scan number %1 not found in %2")
179 .arg(spectrum_index)
180 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId()));
181 }
182 return it->second;
183}
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 150 of file precursorparser.cpp.

152{
153 auto it = m_spectrumIndex2PrecursorMap.find(spectrum_index);
154 if(it != m_spectrumIndex2PrecursorMap.end())
155 {
156 }
157 else
158 {
159 throw pappso::PappsoException(
160 QObject::tr("spectrum index %1 not found in %2")
161 .arg(spectrum_index)
162 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId()));
163 }
164 return it->second;
165}
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 111 of file precursorparser.cpp.

112{
113 return true;
114}

◆ 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 117 of file precursorparser.cpp.

119{
120
121 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
122 {
123 throw pappso::PappsoException(
124 QObject::tr(
125 "precursor.get()->getXicCoordSPtr().get() == nullptr scan_num=%1\n")
126 .arg(scan_num));
127 }
128 m_scanNumber2PrecursorMap[scan_num] = precursor;
129}

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 132 of file precursorparser.cpp.

134{
135
136 qDebug() << " spectrum_index=" << spectrum_index;
137
138 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
139 {
140 throw pappso::PappsoException(
141 QObject::tr("precursor.get()->getXicCoordSPtr().get() == nullptr \n")
142 .arg(msp_msrunReader.get()->getMsRunId()->getXmlId())
143 .arg(spectrum_index));
144 }
145 m_spectrumIndex2PrecursorMap[spectrum_index] = precursor;
146 qDebug() << " spectrum_index=" << spectrum_index;
147}

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="
68 << qspectrum.getMassSpectrumId().getSpectrumIndex()
69 << " precursor_idx=" << qspectrum.getPrecursorSpectrumIndex()
70 << " precursor.get()->getXicCoordSPtr().get()->toString="
71 << precursor.get()->getXicCoordSPtr().get()->toString();
72 if(precursor.get()->getXicCoordSPtr().get() == nullptr)
73 {
74 throw pappso::PappsoException(
75 QObject::tr("precursor.get()->getXicCoordSPtr().get() == "
76 "nullptr\nindex=%1 %2 %3 %4")
77 .arg(qspectrum.getMassSpectrumId().getNativeId())
78 .arg(__FILE__)
79 .arg(__FUNCTION__)
80 .arg(__LINE__));
81 }
82 /// adding this new precursor to the msrun's hash map of scan_num ->
83 /// precursor
84 qDebug();
85 if(qspectrum.getMassSpectrumId().getNativeId().contains("scan="))
86 {
87 qDebug();
90 qspectrum.getMassSpectrumId().getNativeId()),
91 precursor);
93 qspectrum.getMassSpectrumId().getSpectrumIndex(), precursor);
94 qDebug();
95 }
96 else
97 {
98 qDebug();
100 qspectrum.getMassSpectrumId().getSpectrumIndex(), precursor);
101
103 qspectrum.getMassSpectrumId().getSpectrumIndex(), precursor);
104 qDebug();
105 }
106 qDebug();
107 }
108}
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:258
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: