53const std::vector<qint64> &
74 QFileInfo mzcbor_index_fileinfo(str_index_file.append(
".idx"));
75 if(mzcbor_index_fileinfo.exists())
77 qDebug() <<
"mzcbor_index_fileinfo.exists()";
78 QFile mzcbor_index_file(mzcbor_index_fileinfo.absoluteFilePath());
79 mzcbor_index_file.open(QIODevice::ReadOnly);
82 index_reader.
readCbor(&mzcbor_index_file);
84 mzcbor_index_file.close();
87 std::vector<QString> run_id_list = index_reader.
getRunIdList();
88 if(run_id_list.size() > 0)
90 std::size_t run_position = 0;
91 if(run_id_list.size() > 1)
93 std::size_t i_run = 0;
94 for(
const QString &run_id : run_id_list)
125 mzcbor_build_index_reader.
close();
152 QStringList native_id_list = index_pair.first.split(
"=");
153 if(native_id_list.size() < 2)
158 std::size_t scan_number = native_id_list.back().toULong();
160 std::pair<std::size_t, std::size_t>(scan_number, index_pair.second));
181 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
189 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
195 if(mpa_mzcborFileDevice ==
nullptr)
197 mpa_mzcborFileDevice =
new QFile(m_cborFileInfo.absoluteFilePath());
198 mpa_mzcborFileDevice->open(QIODevice::ReadOnly);
207 if(mpa_mzcborFileDevice !=
nullptr)
209 mpa_mzcborFileDevice->close();
210 delete mpa_mzcborFileDevice;
211 mpa_mzcborFileDevice =
nullptr;
236 fillMzcborSpectrum(spectrum_index, cbor_spectrum,
false);
248 for(
auto &ion : precursor.selectedIonList)
250 xic_coord.get()->mzRange =
MzRange(ion.getMz(), precision);
257 QObject::tr(
"precursor m/z not found for this spectrum index %1").arg(spectrum_index));
263 QObject::tr(
"no precursor found for this spectrum index %1").arg(spectrum_index));
272 return massSpectrumSPtr(spectrum_index);
284 fillMzcborSpectrum(spectrum_index, cbor_spectrum,
true);
287 mass_spectrum_sp = std::make_shared<MassSpectrum>();
288 cbor_spectrum.
decodeTrace(*(mass_spectrum_sp.get()));
293 QObject::tr(
"cbor_spectrum.binaryDataArrayList.size() != 2"));
298 qDebug() <<
"Going to throw";
302 .arg(pappso_error.
what()));
304 return mass_spectrum_sp;
309 bool want_binary_data)
const
316 fillMzcborSpectrum(spectrum_index, cbor_spectrum, want_binary_data);
317 qDebug() << cbor_spectrum.
index;
332 m_nativeId2SpectrumIndexMap.at(cbor_spectrum.
precursorList.at(0).spectrumRef));
336 for(
auto &ion : precursor.selectedIonList)
339 precursor_ion_data.
charge = ion.getChargeState();
340 precursor_ion_data.
intensity = ion.getIntensity();
341 precursor_ion_data.
mz = ion.getMz();
353 cbor_spectrum.
decodeTrace(*(mass_spectrum_sp.get()));
357 qDebug() <<
"spectrum id=" << cbor_spectrum.
id;
359 return qualified_mass_spectrum;
364 qDebug() <<
"Going to throw";
367 QObject::tr(
"Error reading data (qualifiedMassSpectrum) using the "
369 .arg(pappso_error.
what()));
378 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
380 std::vector<size_t> ms_levels;
381 for(std::size_t i = 1; i < 9; i++)
385 ms_levels.push_back(i);
394 readSpectrumCollectionWithMsrunReadConfig(config, handler);
398 qDebug() <<
"Going to throw";
401 QObject::tr(
"Error reading data (spectrum collection2) using the "
403 .arg(pappso_error.
what()));
405 catch(std::exception &error)
407 qDebug() <<
"Going to throw";
410 QObject::tr(
"Error reading data (spectrum collection) using the "
423 readSpectrumCollectionWithMsrunReadConfig(config, handler);
427 qDebug() <<
"Going to throw";
430 QObject::tr(
"Error reading data (spectrum collection2) using the "
432 .arg(pappso_error.
what()));
434 catch(std::exception &error)
436 qDebug() <<
"Going to throw";
439 QObject::tr(
"Error reading data (spectrum collection2) using the "
453 readSpectrumCollection2(config, handler);
459 return m_spectrumIndexPositionInFile.size();
464 const QString &spectrum_identifier)
466 auto it = m_nativeId2SpectrumIndexMap.find(spectrum_identifier);
467 if(it == m_nativeId2SpectrumIndexMap.end())
470 QObject::tr(
"spectrum identifier %1 not found").arg(spectrum_identifier));
494 mzcbor_spectrum_collection_reader.
close();
500 QObject::tr(
"ERROR in MzcborMsRunReader::readSpectrumCollectionWithMsrunReadConfig:\n%1")
501 .arg(pappso_err.
qwhat()));
515 bool want_binary_data)
const
521 QObject::tr(
"spectrum index %1 not found").arg(spectrum_index));
527 QObject::tr(
"mzCBOR file device is not ready, use acquireDevice() before access"));
540 spectrum.
fromCbor(cbor_stream_reader, want_binary_data);
void setNativeId(const QString &native_id)
void setSpectrumIndex(std::size_t index)
void setNeedPeakList(bool need_peak_list)
void setMsLevels(std::vector< std::size_t > ms_levels)
base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory
MsRunIdCstSPtr mcsp_msRunId
const MsRunIdCstSPtr & getMsRunId() const
const std::vector< qint64 > & getSpectrumIndexPositionInFile() const
virtual pappso::XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum index
std::map< QString, std::size_t > m_nativeId2SpectrumIndexMap
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler) override
QFile * mpa_mzcborFileDevice
virtual pappso::XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum(const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum
virtual bool hasScanNumbers() const override
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
void readSpectrumCollectionWithMsrunReadConfig(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const override
get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: i...
virtual bool releaseDevice() override
release data back end device if a the data back end is released, the developper has to use acquireDev...
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
std::vector< qint64 > m_spectrumIndexPositionInFile
virtual std::size_t spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) override
if possible, get the spectrum index given a string identifier throw a not found exception if spectrum...
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override
virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number) override
if possible, converts a scan number into a spectrum index This is a convenient function to help trans...
std::map< std::size_t, std::size_t > m_scan2SpectrumIndexMap
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
MzcborMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
void fillMzcborSpectrum(std::size_t spectrum_index, pappso::cbor::mzcbor::Spectrum &spectrum, bool want_binary_data) const
virtual void readSpectrumCollectionByMsLevel(SpectrumCollectionHandlerInterface &handler, unsigned int ms_level) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override
get a MassSpectrumSPtr class given its spectrum index
virtual ~MzcborMsRunReader()
virtual bool acquireDevice() override
acquire data back end device
virtual bool accept(const QString &file_name) const override
tells if the reader is able to handle this file must be implemented by private MS run reader,...
virtual void initialize() override
const char * what() const noexcept override
virtual const QString & qwhat() const
Class representing a fully specified mass spectrum.
void setPrecursorNativeId(const QString &native_id)
Set the scan native id of the precursor ion.
void appendPrecursorIonData(const PrecursorIonData &precursor_ion_data)
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.
pappso_double getPrecursorMz(bool *ok=nullptr) const
get precursor mz
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
virtual bool needPeakList() const =0
tells if we need the peak list (if we want the binary data) for each spectrum
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
const std::vector< qint64 > & getSpectrumIndexPositionInFile() const
virtual void readCbor(QFile *cborp, pappso::UiMonitorInterface &monitor) override
const std::map< QString, std::size_t > & getNativeId2SpectrumIndexMap() const
const std::vector< std::vector< qint64 > > & getRunAndSpectrumOffsetList() const
const std::vector< std::vector< QString > > & getRunAndSpectrumIdList() const
const std::vector< QString > & getRunIdList() const
virtual void readCbor(QFile *cborp)
virtual void readCbor(QFile *cborp, pappso::UiMonitorInterface &monitor)
void setMsRunId(const MsRunIdCstSPtr &msrun_id)
void setNativeId2SpectrumIndexMapPtr(const std::map< QString, std::size_t > *nativeId2SpectrumIndexMap)
read mzcbor to build an index
read mzcbor for spectrum collection handler
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
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