40 : m_msRunReadConfig(m_msRunReadConfig),
41 m_SpectrumCollectionHandlerInterface(m_SpectrumCollectionHandlerInterface)
52 mcsp_msRunId = msrun_id;
53 m_xmlMzMlRunId = mcsp_msRunId.get()->getRunId();
58 const std::map<QString, std::size_t> *nativeId2SpectrumIndexMap)
60 mp_nativeId2SpectrumIndexMap = nativeId2SpectrumIndexMap;
69 mpa_cborReader->enterContainer();
70 bool ms_run_to_read =
false;
72 while(getExpectedString())
74 if(m_expectedString ==
"id")
78 if((m_expectedString == m_xmlMzMlRunId) || (m_xmlMzMlRunId.isEmpty()))
80 ms_run_to_read =
true;
83 else if(m_expectedString ==
"spectrumList")
87 readSpectrumListAndLeave();
91 mpa_cborReader->next();
96 mpa_cborReader->next();
100 mpa_cborReader->leaveContainer();
106 mpa_cborReader->enterContainer();
116 const bool want_binary_data = m_msRunReadConfig.needPeakList();
122 std::size_t spectrum_list_size = 0;
126 while(getExpectedString())
129 qDebug() << m_expectedString;
130 if(m_expectedString ==
"count")
132 if(mpa_cborReader->isUnsignedInteger())
134 spectrum_list_size = mpa_cborReader->toUnsignedInteger();
135 mpa_cborReader->next();
136 qDebug() <<
"spectrum count=" << spectrum_list_size;
141 m_SpectrumCollectionHandlerInterface.spectrumListHasSize(spectrum_list_size);
143 else if(m_expectedString ==
"spectrum")
146 mpa_cborReader->enterContainer();
148 std::size_t index_count = 0;
149 while(mpa_cborReader->hasNext())
153 if(m_SpectrumCollectionHandlerInterface.shouldStop())
155 qDebug() <<
"The operation was cancelled. Breaking the loop.";
156 m_stopParsing =
true;
160 readSpectrum(index_count, want_binary_data);
164 mpa_cborReader->leaveContainer();
168 mpa_cborReader->next();
173 qDebug() <<
"Loading ended";
174 m_SpectrumCollectionHandlerInterface.loadingEnded();
176 mpa_cborReader->leaveContainer();
177 m_stopParsing =
true;
183 bool want_binary_data)
186 qDebug() << index_count <<
" " << want_binary_data;
190 cbor_spectrum.
fromCbor(*mpa_cborReader, want_binary_data);
213 if(mp_nativeId2SpectrumIndexMap !=
nullptr)
216 mp_nativeId2SpectrumIndexMap->find(cbor_spectrum.
precursorList.at(0).spectrumRef);
217 if(it != mp_nativeId2SpectrumIndexMap->end())
234 precursor.isolationWindow.getTargetMz());
237 auto it = precursor.isolationWindow.cvParamMap.find(
"MS:1000828");
239 if(it == precursor.isolationWindow.cvParamMap.end())
242 "isolation window lower offset MS:1000828 not found in cvParam map"));
246 it->second.valueDouble);
249 it = precursor.isolationWindow.cvParamMap.find(
"MS:1000829");
251 if(it == precursor.isolationWindow.cvParamMap.end())
254 "isolation window upper offset MS:1000829 not found in cvParam map"));
259 it->second.valueDouble);
271 ion_data.
mz = precursor.isolationWindow.getTargetMz();
272 for(
auto &selected_ion : precursor.selectedIonList)
274 ion_data.
charge = selected_ion.getChargeState();
277 ion_data.
intensity = selected_ion.getIntensity(&is_ok);
278 ion_data.
mz = selected_ion.getMz();
296 cbor_spectrum.
decodeTrace(*(mass_spectrum_sp.get()));
302 qDebug() <<
"spectrum_id.getNativeId()=" << spectrum_id.
getNativeId();
304 qDebug() <<
"mslevel=" << qualified_mass_spectrum.
getMsLevel();
306 if(m_msRunReadConfig.acceptMsLevel(qualified_mass_spectrum.
getMsLevel()))
308 if(m_msRunReadConfig.acceptRetentionTimeInSeconds(
313 std::numeric_limits<std::size_t>::max())
316 QObject::tr(
"ERROR in %1 spectrum index not initialised").arg(__FUNCTION__));
318 m_SpectrumCollectionHandlerInterface.setQualifiedMassSpectrum(
319 qualified_mass_spectrum);
411 QObject::tr(
"ERROR reading spectrum index %1 :\%2").arg(index_count).arg(error.
qwhat()));
415std::map<QString, pappso::cbor::mzcbor::CvParam>
418 std::map<QString, CvParam> cv_params;
419 mpa_cborReader->enterContainer();
420 while(getExpectedString())
422 qDebug() << m_expectedString;
423 if(m_expectedString ==
"cvParam")
425 cv_params = getCvParamsMap();
429 mpa_cborReader->next();
432 mpa_cborReader->leaveContainer();
void setNativeId(const QString &native_id)
std::size_t getSpectrumIndex() const
void setSpectrumIndex(std::size_t index)
const QString & getNativeId() const
virtual const QString & qwhat() 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.
void appendPrecursorIonData(const PrecursorIonData &precursor_ion_data)
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 setParameterValue(QualifiedMassSpectrumParameter parameter, const QVariant &value)
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
@ IsolationWindowTargetMz
Isolation m/z value isolation window target m/z (thomson)
@ IsolationWindowUpperOffset
isolation window upper offset (thomson)
@ IsolationWindowLowerOffset
isolation window lower offset (thomson)
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
PSI spectrum object for mzML/mzCBOR.
std::vector< Precursor > precursorList
void fromCbor(CborStreamReader &reader, bool want_binary_data)
fill the structure reading data from a CBOR stream
double getRtInSeconds() const
void decodeTrace(pappso::Trace &trace) const
std::vector< BinaryDataArray > binaryDataArrayList
std::size_t defaultArrayLength