54const std::vector<qint64> &
75 QFileInfo mzcbor_index_fileinfo(str_index_file.append(
".idx"));
76 if(mzcbor_index_fileinfo.exists())
78 qDebug() <<
"mzcbor_index_fileinfo.exists()";
79 QFile mzcbor_index_file(mzcbor_index_fileinfo.absoluteFilePath());
80 mzcbor_index_file.open(QIODevice::ReadOnly);
83 index_reader.
readCbor(&mzcbor_index_file);
85 mzcbor_index_file.close();
88 std::vector<QString> run_id_list = index_reader.
getRunIdList();
89 if(run_id_list.size() > 0)
91 std::size_t run_position = 0;
92 if(run_id_list.size() > 1)
94 std::size_t i_run = 0;
95 for(
const QString &run_id : run_id_list)
143 mzcbor_build_index_reader.
close();
170 QStringList native_id_list = index_pair.first.split(
"=");
171 if(native_id_list.size() < 2)
176 std::size_t scan_number = native_id_list.back().toULong();
178 std::pair<std::size_t, std::size_t>(scan_number, index_pair.second));
199 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
207 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
266 for(
auto &ion : precursor.selectedIonList)
275 QObject::tr(
"precursor m/z not found for this spectrum index %1").arg(spectrum_index));
281 QObject::tr(
"no precursor found for this spectrum index %1").arg(spectrum_index));
305 mass_spectrum_sp = std::make_shared<MassSpectrum>();
306 cbor_spectrum.
decodeTrace(*(mass_spectrum_sp.get()));
311 QObject::tr(
"cbor_spectrum.binaryDataArrayList.size() != 2"));
316 qDebug() <<
"Going to throw";
320 .arg(pappso_error.
what()));
322 return mass_spectrum_sp;
327 bool want_binary_data)
const
335 qDebug() << cbor_spectrum.
index;
365 precursor.isolationWindow.getTargetMz());
368 auto it = precursor.isolationWindow.cvParamMap.find(
"MS:1000828");
370 if(it == precursor.isolationWindow.cvParamMap.end())
373 "isolation window lower offset MS:1000828 not found in cvParam map"));
377 it->second.valueDouble);
380 it = precursor.isolationWindow.cvParamMap.find(
"MS:1000829");
382 if(it == precursor.isolationWindow.cvParamMap.end())
385 "isolation window upper offset MS:1000829 not found in cvParam map"));
390 it->second.valueDouble);
401 for(
auto &ion : precursor.selectedIonList)
404 precursor_ion_data.
charge = ion.getChargeState();
406 precursor_ion_data.
intensity = ion.getIntensity(&is_ok);
407 precursor_ion_data.
mz = ion.getMz();
422 cbor_spectrum.
decodeTrace(*(mass_spectrum_sp.get()));
426 qDebug() <<
"spectrum id=" << cbor_spectrum.
id;
428 return qualified_mass_spectrum;
433 qDebug() <<
"Going to throw";
436 QObject::tr(
"Error reading data (qualifiedMassSpectrum) using the "
438 .arg(pappso_error.
what()));
447 QObject::tr(
"%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
449 std::vector<size_t> ms_levels;
450 for(std::size_t i = 1; i < 9; i++)
454 ms_levels.push_back(i);
467 qDebug() <<
"Going to throw";
470 QObject::tr(
"Error reading data (spectrum collection2) using the "
472 .arg(pappso_error.
what()));
474 catch(std::exception &error)
476 qDebug() <<
"Going to throw";
479 QObject::tr(
"Error reading data (spectrum collection) using the "
496 qDebug() <<
"Going to throw";
499 QObject::tr(
"Error reading data (spectrum collection2) using the "
501 .arg(pappso_error.
what()));
503 catch(std::exception &error)
505 qDebug() <<
"Going to throw";
508 QObject::tr(
"Error reading data (spectrum collection2) using the "
533 const QString &spectrum_identifier)
539 QObject::tr(
"spectrum identifier %1 not found").arg(spectrum_identifier));
563 mzcbor_spectrum_collection_reader.
close();
569 QObject::tr(
"ERROR in MzcborMsRunReader::readSpectrumCollectionWithMsrunReadConfig:\n%1")
570 .arg(pappso_err.
qwhat()));
584 bool want_binary_data)
const
590 QObject::tr(
"spectrum index %1 not found").arg(spectrum_index));
596 QObject::tr(
"mzCBOR file device is not ready, use acquireDevice() before access"));
612 spectrum.
fromCbor(cbor_stream_reader, want_binary_data);
619 .arg(error.
qwhat()));
623 if(spectrum.
id.isEmpty())
626 QObject::tr(
"ERROR reading spectrum %1 cbor:\nspectrum not found").arg(spectrum_index));
632 QObject::tr(
"ERROR reading spectrum %1 cbor:\nseek failed").arg(spectrum_index));
650 chromatogram.push_back(
665 std::vector<double> time_line;
683std::shared_ptr<pappso::cbor::mzcbor::Spectrum>
686 std::shared_ptr<pappso::cbor::mzcbor::Spectrum> cbor_spectrum_sp =
687 std::make_shared<pappso::cbor::mzcbor::Spectrum>();
691 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 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
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
@ IsolationWindowTargetMz
Isolation m/z value isolation window target m/z (thomson).
@ IsolationWindowUpperOffset
isolation window upper offset (thomson)
@ IsolationWindowLowerOffset
isolation window lower offset (thomson)
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