OpenMS
Loading...
Searching...
No Matches
SpectrumAccessOpenMSInMemory Class Reference

OpenSwath::ISpectrumAccess implementation that holds the complete spectrum / chromatogram payload in memory. More...

#include <OpenMS/ANALYSIS/OPENSWATH/DATAACCESS/SpectrumAccessOpenMSInMemory.h>

Inheritance diagram for SpectrumAccessOpenMSInMemory:
[legend]
Collaboration diagram for SpectrumAccessOpenMSInMemory:
[legend]

Public Types

typedef OpenMS::PeakMap MSExperimentType
 
typedef OpenMS::MSSpectrum MSSpectrumType
 
typedef OpenMS::MSChromatogram MSChromatogramType
 

Public Member Functions

 SpectrumAccessOpenMSInMemory (OpenSwath::ISpectrumAccess &origin)
 Construct by reading every spectrum and chromatogram from origin into memory.
 
 ~SpectrumAccessOpenMSInMemory () override
 Destructor.
 
 SpectrumAccessOpenMSInMemory (const SpectrumAccessOpenMSInMemory &rhs)
 Copy constructor (light copy).
 
std::shared_ptr< OpenSwath::ISpectrumAccesslightClone () const override
 Return a clone of this accessor as a new OpenSwath::ISpectrumAccess.
 
OpenSwath::SpectrumPtr getSpectrumById (int id) override
 Look up one spectrum by index.
 
OpenSwath::SpectrumMeta getSpectrumMetaById (int id) const override
 Look up one spectrum's metadata by index.
 
std::vector< std::size_t > getSpectraByRT (double RT, double deltaRT) const override
 Indices of cached spectra whose RT lies in [RT - deltaRT, RT + deltaRT].
 
size_t getNrSpectra () const override
 Number of spectra cached in memory.
 
OpenSwath::ChromatogramPtr getChromatogramById (int id) override
 Look up one chromatogram by index.
 
size_t getNrChromatograms () const override
 Number of chromatograms cached in memory.
 
std::string getChromatogramNativeID (int id) const override
 Native id of one cached chromatogram.
 
- Public Member Functions inherited from ISpectrumAccess
virtual ~ISpectrumAccess ()
 Destructor.
 
SpectrumPtr getSpectrumById (int id, double drift_start, double drift_end)
 Return pointer to a spectrum at the given id, the spectrum will be filtered by drift time.
 
SpectrumSequence getMultipleSpectra (double RT, int nr_spectra_to_fetch)
 
SpectrumSequence getMultipleSpectra (double RT, int nr_spectra_to_fetch, double drift_start, double drift_end)
 

Private Attributes

std::vector< OpenSwath::SpectrumPtrspectra_
 Spectrum payloads captured at construction; shared with light clones.
 
std::vector< OpenSwath::SpectrumMetaspectra_meta_
 Parallel metadata cache (native id, RT, MS level) keyed on the same index.
 
std::vector< OpenSwath::ChromatogramPtrchromatograms_
 Chromatogram payloads captured at construction; shared with light clones.
 
std::vector< std::string > chromatogram_ids_
 Parallel chromatogram native-id cache keyed on the same index.
 

Additional Inherited Members

- Static Public Member Functions inherited from ISpectrumAccess
static SpectrumPtr filterByDrift (const SpectrumPtr &input, double drift_start, double drift_end)
 filters a spectrum by drift time, spectrum pointer returned is a copy
 

Detailed Description

OpenSwath::ISpectrumAccess implementation that holds the complete spectrum / chromatogram payload in memory.

Constructed from any other OpenSwath::ISpectrumAccess (file-backed, on-disk cached, etc.); every spectrum and chromatogram is read through the source's interface during construction and cached locally, so subsequent accesses do not touch the disk again. The view exposes exactly the same data as the source. After construction the source is no longer referenced.

fillData(data_access); // assume data_access now points at some data
OpenSwath::ISpectrumAccess * in_memory_data_access = new SpectrumAccessOpenMSInMemory(*data_access);
OpenSwath::ISpectrumAccess implementation that holds the complete spectrum / chromatogram payload in ...
Definition SpectrumAccessOpenMSInMemory.h:47
The interface of a mass spectrometry experiment.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:30

After this snippet, data_access still serves the original data (its backing store is opaque to the caller), while in_memory_data_access serves the same data with the guarantee that it is held in memory and not re-read from disk.

Member Typedef Documentation

◆ MSChromatogramType

◆ MSExperimentType

◆ MSSpectrumType

Constructor & Destructor Documentation

◆ SpectrumAccessOpenMSInMemory() [1/2]

Construct by reading every spectrum and chromatogram from origin into memory.

After construction the accessor exposes the same spectra and chromatograms as origin, served entirely from memory; origin itself is no longer referenced.

Parameters
[in]originSource accessor; read once during construction and not retained.

◆ ~SpectrumAccessOpenMSInMemory()

Destructor.

◆ SpectrumAccessOpenMSInMemory() [2/2]

Copy constructor (light copy).

The copy shares the underlying spectrum / chromatogram payloads with rhs; only the per-element handles are duplicated. No data is re-read from the original source.

Parameters
[in]rhsSource accessor to copy.

Member Function Documentation

◆ getChromatogramById()

OpenSwath::ChromatogramPtr getChromatogramById ( int  id)
overridevirtual

Look up one chromatogram by index.

Parameters
[in]idChromatogram index in [0, getNrChromatograms()). Out-of-range access is a programming error (checked in debug builds).
Returns
Cached ChromatogramPtr for the requested chromatogram.

Implements ISpectrumAccess.

◆ getChromatogramNativeID()

std::string getChromatogramNativeID ( int  id) const
overridevirtual

Native id of one cached chromatogram.

Parameters
[in]idChromatogram index in [0, getNrChromatograms()). Out-of-range access is a programming error (checked in debug builds).
Returns
Native-id string captured at construction time.

Implements ISpectrumAccess.

◆ getNrChromatograms()

size_t getNrChromatograms ( ) const
overridevirtual

Number of chromatograms cached in memory.

Implements ISpectrumAccess.

◆ getNrSpectra()

size_t getNrSpectra ( ) const
overridevirtual

Number of spectra cached in memory.

Implements ISpectrumAccess.

◆ getSpectraByRT()

std::vector< std::size_t > getSpectraByRT ( double  RT,
double  deltaRT 
) const
overridevirtual

Indices of cached spectra whose RT lies in [RT - deltaRT, RT + deltaRT].

Relies on the cached metadata being sorted by RT (inherited from the source); the lookup is logarithmic in the number of spectra.

Parameters
[in]RTCentre of the RT window.
[in]deltaRTHalf-width of the RT window. Must be non-negative; a negative value is a programming error (checked in debug builds).
Returns
Indices into the in-memory view of spectra whose RT falls in the window.

Implements ISpectrumAccess.

◆ getSpectrumById()

OpenSwath::SpectrumPtr getSpectrumById ( int  id)
overridevirtual

Look up one spectrum by index.

Parameters
[in]idSpectrum index in [0, getNrSpectra()). Out-of-range access is a programming error (checked in debug builds).
Returns
Cached SpectrumPtr for the requested spectrum.

Implements ISpectrumAccess.

◆ getSpectrumMetaById()

OpenSwath::SpectrumMeta getSpectrumMetaById ( int  id) const
overridevirtual

Look up one spectrum's metadata by index.

Parameters
[in]idSpectrum index in [0, getNrSpectra()). Out-of-range access is a programming error (checked in debug builds).
Returns
Cached SpectrumMeta for the requested spectrum.

Implements ISpectrumAccess.

◆ lightClone()

std::shared_ptr< OpenSwath::ISpectrumAccess > lightClone ( ) const
overridevirtual

Return a clone of this accessor as a new OpenSwath::ISpectrumAccess.

The clone shares this accessor's spectrum / chromatogram payloads, so it is cheap to create and safe to hand to another thread without re-reading the source.

Returns
Shared pointer to the cloned accessor.

Implements ISpectrumAccess.

Member Data Documentation

◆ chromatogram_ids_

std::vector< std::string > chromatogram_ids_
private

Parallel chromatogram native-id cache keyed on the same index.

◆ chromatograms_

std::vector< OpenSwath::ChromatogramPtr > chromatograms_
private

Chromatogram payloads captured at construction; shared with light clones.

◆ spectra_

std::vector< OpenSwath::SpectrumPtr > spectra_
private

Spectrum payloads captured at construction; shared with light clones.

◆ spectra_meta_

std::vector< OpenSwath::SpectrumMeta > spectra_meta_
private

Parallel metadata cache (native id, RT, MS level) keyed on the same index.