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();
358 precursor_ion_data.
intensity = ion.getIntensity(&is_ok);
359 precursor_ion_data.
mz = ion.getMz();
374 cbor_spectrum.
decodeTrace(*(mass_spectrum_sp.get()));
378 qDebug() <<
"spectrum id=" << cbor_spectrum.
id;
380 return qualified_mass_spectrum;
385 qDebug() <<
"Going to throw";
388 QObject::tr(
"Error reading data (qualifiedMassSpectrum) using the "
390 .arg(pappso_error.
what()));
399 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
401 std::vector<size_t> ms_levels;
402 for(std::size_t i = 1; i < 9; i++)
406 ms_levels.push_back(i);
419 qDebug() <<
"Going to throw";
422 QObject::tr(
"Error reading data (spectrum collection2) using the "
424 .arg(pappso_error.
what()));
426 catch(std::exception &error)
428 qDebug() <<
"Going to throw";
431 QObject::tr(
"Error reading data (spectrum collection) using the "
448 qDebug() <<
"Going to throw";
451 QObject::tr(
"Error reading data (spectrum collection2) using the "
453 .arg(pappso_error.
what()));
455 catch(std::exception &error)
457 qDebug() <<
"Going to throw";
460 QObject::tr(
"Error reading data (spectrum collection2) using the "
485 const QString &spectrum_identifier)
491 QObject::tr(
"spectrum identifier %1 not found").arg(spectrum_identifier));
515 mzcbor_spectrum_collection_reader.
close();
521 QObject::tr(
"ERROR in MzcborMsRunReader::readSpectrumCollectionWithMsrunReadConfig:\n%1")
522 .arg(pappso_err.
qwhat()));
536 bool want_binary_data)
const
542 QObject::tr(
"spectrum index %1 not found").arg(spectrum_index));
548 QObject::tr(
"mzCBOR file device is not ready, use acquireDevice() before access"));
564 spectrum.
fromCbor(cbor_stream_reader, want_binary_data);
571 .arg(error.
qwhat()));
575 if(spectrum.
id.isEmpty())
578 QObject::tr(
"ERROR reading spectrum %1 cbor:\nspectrum not found").arg(spectrum_index));
584 QObject::tr(
"ERROR reading spectrum %1 cbor:\nseek failed").arg(spectrum_index));
602 chromatogram.push_back(
617 std::vector<double> time_line;
635std::shared_ptr<pappso::cbor::mzcbor::Spectrum>
638 std::shared_ptr<pappso::cbor::mzcbor::Spectrum> cbor_spectrum_sp =
639 std::make_shared<pappso::cbor::mzcbor::Spectrum>();
643 return cbor_spectrum_sp;
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
std::shared_ptr< pappso::cbor::mzcbor::Spectrum > getMzcborSpectrumSp(std::size_t spectrum_index, bool want_binary_data) const
get spectrum mzML element
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
MzcborMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
virtual 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.
simple override of the raw QCborStreamReader This adds convenient functions to put CBOR data into C++...
const std::vector< qint64 > & getSpectrumIndexPositionInFile() const
virtual void readCbor(QFile *cborp, pappso::UiMonitorInterface &monitor) override
read mzCBOR file
const std::map< QString, std::size_t > & getNativeId2SpectrumIndexMap() const
const std::vector< std::vector< qint64 > > & getRunAndSpectrumTotalIonCountList() const
virtual void close()
convenient function to clean pointer before leaving
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)
read mzCBOR file
virtual void close()
convenient function to clean pointer before leaving
void setMsRunId(const MsRunIdCstSPtr &msrun_id)
void setNativeId2SpectrumIndexMapPtr(const std::map< QString, std::size_t > *nativeId2SpectrumIndexMap)
read mzcbor to build an index
MSrun file reader for mzcbor.
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
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