OpenMS
Loading...
Searching...
No Matches
IMSExperimentRandomAccess Class Referenceabstract

Random access to the spectra and chromatograms of an MS run that stays on disk. More...

#include <OpenMS/KERNEL/IMSExperimentRandomAccess.h>

Inheritance diagram for IMSExperimentRandomAccess:
OnDiscMSExperiment

Public Member Functions

virtual ~IMSExperimentRandomAccess ()
 
virtual Size getNrSpectra () const =0
 Number of spectra.
 
virtual Size getNrChromatograms () const =0
 Number of chromatograms.
 
Size size () const
 Alias for getNrSpectra()
 
bool empty () const
 True if there are no spectra.
 
virtual MSSpectrum getSpectrum (Size index)=0
 The spectrum with index index, including peaks and metadata.
 
virtual MSSpectrum getSpectrumMetadata (Size index)=0
 The spectrum with index index without peaks and data arrays.
 
virtual MSSpectrum getSpectrumPeaks (Size index)
 Peaks and data arrays of spectrum index; other metadata may be missing.
 
virtual double getSpectrumRT (Size index) const =0
 Retention time (in seconds) of spectrum index, from the index.
 
virtual UInt getSpectrumMSLevel (Size index) const =0
 MS level of spectrum index, from the index.
 
virtual bool isSortedByRT () const =0
 True if the spectra are sorted by ascending retention time.
 
virtual Size findFirstRT (double rt) const
 Index of the first spectrum with retention time >= rt.
 
virtual MSChromatogram getChromatogram (Size index)=0
 The chromatogram with index index.
 
virtual std::shared_ptr< const ExperimentalSettings > getExperimentalSettings () const =0
 Run-level metadata (instrument, source files, sample, ...)
 
virtual std::unique_ptr< IMSExperimentRandomAccess > clone () const =0
 A new instance on the same data with its own file handle (for another thread).
 

Protected Member Functions

 IMSExperimentRandomAccess ()=default
 
 IMSExperimentRandomAccess (const IMSExperimentRandomAccess &)=default
 
IMSExperimentRandomAccess & operator= (const IMSExperimentRandomAccess &)=default
 

Detailed Description

Random access to the spectra and chromatograms of an MS run that stays on disk.

Backends keep a small index in memory (e.g. retention time and MS level of every spectrum) and decode spectra on request. Implemented by OnDiscMSExperiment (indexed mzML) and OnDiscThermoRawExperiment (Thermo RAW); further formats (e.g. Bruker TDF, imzML) can be added the same way. Algorithms that only need random access, such as the OpenSWATH adapter SpectrumAccessOnDisc, are written against this interface.

Note
An instance is not thread-safe, as it typically holds one file handle. Give each thread its own clone(); clones share the immutable index.

Constructor & Destructor Documentation

◆ ~IMSExperimentRandomAccess()

virtual ~IMSExperimentRandomAccess ( )
virtual

◆ IMSExperimentRandomAccess() [1/2]

IMSExperimentRandomAccess ( )
protecteddefault

◆ IMSExperimentRandomAccess() [2/2]

IMSExperimentRandomAccess ( const IMSExperimentRandomAccess &  )
protecteddefault

Member Function Documentation

◆ clone()

virtual std::unique_ptr< IMSExperimentRandomAccess > clone ( ) const
pure virtual

A new instance on the same data with its own file handle (for another thread).

Cheap: the index is shared, not copied.

Implemented in OnDiscMSExperiment.

◆ empty()

bool empty ( ) const
inline

True if there are no spectra.

◆ findFirstRT()

virtual Size findFirstRT ( double  rt) const
virtual

Index of the first spectrum with retention time >= rt.

Binary search if the spectra are sorted by retention time, linear search otherwise.

Parameters
[in]rtRetention time in seconds
Returns
the index, or getNrSpectra() if there is no such spectrum

◆ getChromatogram()

virtual MSChromatogram getChromatogram ( Size  index)
pure virtual

The chromatogram with index index.

Parameters
[in]indexChromatogram index (0 <= index < getNrChromatograms())

Implemented in OnDiscMSExperiment.

◆ getExperimentalSettings()

virtual std::shared_ptr< const ExperimentalSettings > getExperimentalSettings ( ) const
pure virtual

Run-level metadata (instrument, source files, sample, ...)

Implemented in OnDiscMSExperiment.

◆ getNrChromatograms()

virtual Size getNrChromatograms ( ) const
pure virtual

Number of chromatograms.

Implemented in OnDiscMSExperiment.

◆ getNrSpectra()

virtual Size getNrSpectra ( ) const
pure virtual

Number of spectra.

Implemented in OnDiscMSExperiment.

◆ getSpectrum()

virtual MSSpectrum getSpectrum ( Size  index)
pure virtual

The spectrum with index index, including peaks and metadata.

Parameters
[in]indexSpectrum index (0 <= index < getNrSpectra())
Exceptions
Exception::IndexOverflowif index is out of range (backend dependent)

Implemented in OnDiscMSExperiment.

◆ getSpectrumMetadata()

virtual MSSpectrum getSpectrumMetadata ( Size  index)
pure virtual

The spectrum with index index without peaks and data arrays.

Parameters
[in]indexSpectrum index (0 <= index < getNrSpectra())

Implemented in OnDiscMSExperiment.

◆ getSpectrumMSLevel()

virtual UInt getSpectrumMSLevel ( Size  index) const
pure virtual

MS level of spectrum index, from the index.

Implemented in OnDiscMSExperiment.

◆ getSpectrumPeaks()

virtual MSSpectrum getSpectrumPeaks ( Size  index)
virtual

Peaks and data arrays of spectrum index; other metadata may be missing.

Backends can skip decoding metadata that consumers of peak data alone (e.g. OpenSWATH) do not need. The default returns getSpectrum().

Parameters
[in]indexSpectrum index (0 <= index < getNrSpectra())

◆ getSpectrumRT()

virtual double getSpectrumRT ( Size  index) const
pure virtual

Retention time (in seconds) of spectrum index, from the index.

Implemented in OnDiscMSExperiment.

◆ isSortedByRT()

virtual bool isSortedByRT ( ) const
pure virtual

True if the spectra are sorted by ascending retention time.

Implemented in OnDiscMSExperiment.

◆ operator=()

IMSExperimentRandomAccess & operator= ( const IMSExperimentRandomAccess &  )
protecteddefault

◆ size()

Size size ( ) const
inline

Alias for getNrSpectra()