37 : m_msRunReadConfig(m_msRunReadConfig),
38 m_SpectrumCollectionHandlerInterface(m_SpectrumCollectionHandlerInterface)
49 mcsp_msRunId = msrun_id;
50 m_xmlMzMlRunId = mcsp_msRunId.get()->getRunId();
55 const std::map<QString, std::size_t> *nativeId2SpectrumIndexMap)
57 mp_nativeId2SpectrumIndexMap = nativeId2SpectrumIndexMap;
66 mpa_cborReader->enterContainer();
67 bool ms_run_to_read =
false;
69 while(getExpectedString())
71 if(m_expectedString ==
"id")
75 if((m_expectedString == m_xmlMzMlRunId) || (m_xmlMzMlRunId.isEmpty()))
77 ms_run_to_read =
true;
80 else if(m_expectedString ==
"spectrumList")
84 readSpectrumListAndLeave();
88 mpa_cborReader->next();
93 mpa_cborReader->next();
97 mpa_cborReader->leaveContainer();
103 mpa_cborReader->enterContainer();
113 const bool want_binary_data = m_msRunReadConfig.needPeakList();
119 std::size_t spectrum_list_size = 0;
123 while(getExpectedString())
126 qDebug() << m_expectedString;
127 if(m_expectedString ==
"count")
129 if(mpa_cborReader->isUnsignedInteger())
131 spectrum_list_size = mpa_cborReader->toUnsignedInteger();
132 mpa_cborReader->next();
133 qDebug() <<
"spectrum count=" << spectrum_list_size;
138 m_SpectrumCollectionHandlerInterface.spectrumListHasSize(spectrum_list_size);
140 else if(m_expectedString ==
"spectrum")
143 mpa_cborReader->enterContainer();
145 std::size_t index_count = 0;
146 while(mpa_cborReader->hasNext())
150 if(m_SpectrumCollectionHandlerInterface.shouldStop())
152 qDebug() <<
"The operation was cancelled. Breaking the loop.";
153 m_stopParsing =
true;
157 readSpectrum(index_count, want_binary_data);
161 mpa_cborReader->leaveContainer();
165 mpa_cborReader->next();
170 qDebug() <<
"Loading ended";
171 m_SpectrumCollectionHandlerInterface.loadingEnded();
173 mpa_cborReader->leaveContainer();
174 m_stopParsing =
true;
180 bool want_binary_data)
183 qDebug() << index_count <<
" " << want_binary_data;
185 cbor_spectrum.
fromCbor(*mpa_cborReader, want_binary_data);
205 if(mp_nativeId2SpectrumIndexMap !=
nullptr)
208 mp_nativeId2SpectrumIndexMap->find(cbor_spectrum.
precursorList.at(0).spectrumRef);
209 if(it != mp_nativeId2SpectrumIndexMap->end())
223 cbor_spectrum.
decodeTrace(*(mass_spectrum_sp.get()));
227 qDebug() <<
"spectrum_id.getNativeId()=" << spectrum_id.
getNativeId();
229 qDebug() <<
"mslevel=" << qualified_mass_spectrum.
getMsLevel();
231 if(m_msRunReadConfig.acceptMsLevel(qualified_mass_spectrum.
getMsLevel()))
233 if(m_msRunReadConfig.acceptRetentionTimeInSeconds(qualified_mass_spectrum.
getRtInSeconds()))
237 std::numeric_limits<std::size_t>::max())
240 QObject::tr(
"ERROR in %1 spectrum index not initialised").arg(__FUNCTION__));
242 m_SpectrumCollectionHandlerInterface.setQualifiedMassSpectrum(qualified_mass_spectrum);
335std::map<QString, pappso::cbor::mzcbor::CvParam>
338 std::map<QString, CvParam> cv_params;
339 mpa_cborReader->enterContainer();
340 while(getExpectedString())
342 qDebug() << m_expectedString;
343 if(m_expectedString ==
"cvParam")
345 cv_params = getCvParamsMap();
349 mpa_cborReader->next();
352 mpa_cborReader->leaveContainer();
void setNativeId(const QString &native_id)
std::size_t getSpectrumIndex() const
void setSpectrumIndex(std::size_t index)
const QString & getNativeId() const
Class representing a fully specified mass spectrum.
uint getMsLevel() const
Get the mass spectrum level.
void setPrecursorNativeId(const QString &native_id)
Set the scan native id of the precursor ion.
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
void setMassSpectrumId(const MassSpectrumId &iD)
Set the MassSpectrumId.
void setMsLevel(uint ms_level)
Set the mass spectrum level.
void setPrecursorSpectrumIndex(std::size_t precursor_scan_num)
Set the scan number of the precursor ion.
void setMassSpectrumSPtr(MassSpectrumSPtr massSpectrum)
Set the MassSpectrumSPtr.
void setRtInSeconds(pappso_double rt)
Set the retention time in seconds.
pappso_double getRtInSeconds() const
Get the retention time in seconds.
void setEmptyMassSpectrum(bool is_empty_mass_spectrum)
interface to collect spectrums from the MsRunReader class
void setMsRunId(const MsRunIdCstSPtr &msrun_id)
virtual ~MzcborSpectrumCollectionReader()
void readSpectrum(std::size_t index_count, bool want_binary_data)
read each spectrum in the targeted msrun (msrunId)
MzcborSpectrumCollectionReader(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)
void setNativeId2SpectrumIndexMapPtr(const std::map< QString, std::size_t > *nativeId2SpectrumIndexMap)
void readSpectrumListAndLeave()
only the spectrum list of targeted msrun, then stop parsing
std::map< QString, CvParam > readScan()
virtual void readMsrun() override
read only the targeted msrun
read mzcbor for spectrum collection handler
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
PSI spectrum object for mzML/mzCBOR.
void decodeTrace(pappso::Trace &trace)
std::vector< Precursor > precursorList
void fromCbor(CborStreamReader &reader, bool want_binary_data)
double getRtInSeconds() const
std::vector< BinaryDataArray > binaryDataArrayList
std::size_t defaultArrayLength