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)
142 mzcbor_build_index_reader.
close();
169 QStringList native_id_list = index_pair.first.split(
"=");
170 if(native_id_list.size() < 2)
175 std::size_t scan_number = native_id_list.back().toULong();
177 std::pair<std::size_t, std::size_t>(scan_number, index_pair.second));
198 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
206 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
265 for(
auto &ion : precursor.selectedIonList)
274 QObject::tr(
"precursor m/z not found for this spectrum index %1").arg(spectrum_index));
280 QObject::tr(
"no precursor found for this spectrum index %1").arg(spectrum_index));
304 mass_spectrum_sp = std::make_shared<MassSpectrum>();
305 cbor_spectrum.
decodeTrace(*(mass_spectrum_sp.get()));
310 QObject::tr(
"cbor_spectrum.binaryDataArrayList.size() != 2"));
315 qDebug() <<
"Going to throw";
319 .arg(pappso_error.
what()));
321 return mass_spectrum_sp;
326 bool want_binary_data)
const
334 qDebug() << cbor_spectrum.
index;
353 for(
auto &ion : precursor.selectedIonList)
356 precursor_ion_data.
charge = ion.getChargeState();
357 precursor_ion_data.
intensity = ion.getIntensity();
358 precursor_ion_data.
mz = ion.getMz();
370 cbor_spectrum.
decodeTrace(*(mass_spectrum_sp.get()));
374 qDebug() <<
"spectrum id=" << cbor_spectrum.
id;
376 return qualified_mass_spectrum;
381 qDebug() <<
"Going to throw";
384 QObject::tr(
"Error reading data (qualifiedMassSpectrum) using the "
386 .arg(pappso_error.
what()));
395 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
397 std::vector<size_t> ms_levels;
398 for(std::size_t i = 1; i < 9; i++)
402 ms_levels.push_back(i);
415 qDebug() <<
"Going to throw";
418 QObject::tr(
"Error reading data (spectrum collection2) using the "
420 .arg(pappso_error.
what()));
422 catch(std::exception &error)
424 qDebug() <<
"Going to throw";
427 QObject::tr(
"Error reading data (spectrum collection) using the "
444 qDebug() <<
"Going to throw";
447 QObject::tr(
"Error reading data (spectrum collection2) using the "
449 .arg(pappso_error.
what()));
451 catch(std::exception &error)
453 qDebug() <<
"Going to throw";
456 QObject::tr(
"Error reading data (spectrum collection2) using the "
481 const QString &spectrum_identifier)
487 QObject::tr(
"spectrum identifier %1 not found").arg(spectrum_identifier));
511 mzcbor_spectrum_collection_reader.
close();
517 QObject::tr(
"ERROR in MzcborMsRunReader::readSpectrumCollectionWithMsrunReadConfig:\n%1")
518 .arg(pappso_err.
qwhat()));
532 bool want_binary_data)
const
538 QObject::tr(
"spectrum index %1 not found").arg(spectrum_index));
544 QObject::tr(
"mzCBOR file device is not ready, use acquireDevice() before access"));
560 spectrum.
fromCbor(cbor_stream_reader, want_binary_data);
567 .arg(error.
qwhat()));
571 if(spectrum.
id.isEmpty())
574 QObject::tr(
"ERROR reading spectrum %1 cbor:\nspectrum not found").arg(spectrum_index));
580 QObject::tr(
"ERROR reading spectrum %1 cbor:\nseek failed").arg(spectrum_index));
598 chromatogram.push_back(
613 std::vector<double> time_line;
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)
MsRunIdCstSPtr mcsp_msRunId
MsRunReader(const MsRunIdCstSPtr &ms_run_id)
virtual std::vector< double > getRetentionTimeLine()
retention timeline get retention times along the MSrun in seconds
virtual Trace getTicChromatogram()
get a TIC chromatogram
const MsRunIdCstSPtr & getMsRunId() const
virtual std::vector< double > getRetentionTimeLine() override
retention timeline get retention times along the MSrun in seconds
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
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
std::vector< qint64 > m_spectrumTotalIonCountList
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 Trace getTicChromatogram() override
get a TIC chromatogram
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...
std::vector< double > m_spectrumRtList
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()
std::vector< std::uint8_t > m_spectrumMsLevelList
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
A simple container of DataPoint instances.
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 > > & getRunAndSpectrumTotalIonCountList() const
const std::vector< std::vector< std::uint8_t > > & getRunAndSpectrumMsLevelList() const
const std::vector< std::vector< qint64 > > & getRunAndSpectrumOffsetList() const
const std::vector< std::vector< QString > > & getRunAndSpectrumIdList() const
const std::vector< QString > & getRunIdList() const
const std::vector< std::vector< double > > & getRunAndSpectrumRtList() 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
const PrecisionBase * PrecisionPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
double rtTarget
the targeted retention time to extract around intended in seconds, and related to one msrun....
MzRange mzRange
the mass to extract
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