OpenMS
CachedMzMLHandler Class Reference

An class that uses on-disk caching to read and write spectra and chromatograms. More...

#include <OpenMS/FORMAT/HANDLERS/CachedMzMLHandler.h>

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

Public Types

typedef PeakMap MapType
 
typedef MSSpectrum SpectrumType
 
typedef MSChromatogram ChromatogramType
 
typedef double DatumSingleton
 
typedef std::vector< DatumSingletonDatavector
 
- Public Types inherited from ProgressLogger
enum  LogType { CMD , GUI , NONE }
 Possible log types. More...
 

Public Member Functions

Constructors and Destructor
 CachedMzMLHandler ()
 Default constructor. More...
 
 ~CachedMzMLHandler () override
 Default destructor. More...
 
CachedMzMLHandleroperator= (const CachedMzMLHandler &rhs)
 Assignment operator. More...
 
Read / Write a complete mass spectrometric experiment (or its meta data)
void writeMemdump (const MapType &exp, const String &out) const
 Write complete spectra as a dump to the disk. More...
 
void writeMetadata (MapType exp, const String &out_meta, bool addCacheMetaValue=false)
 Write only the meta data of an MSExperiment. More...
 
void writeMetadata_x (const MapType &exp, const String &out_meta, bool addCacheMetaValue=false)
 Write only the meta data of an MSExperiment. More...
 
void readMemdump (MapType &exp_reading, const String &filename) const
 Read all spectra from a dump from the disk. More...
 
Access and creation of the binary indices
void createMemdumpIndex (const String &filename)
 Create an index on the location of all the spectra and chromatograms. More...
 
const std::vector< std::streampos > & getSpectraIndex () const
 Access to a constant copy of the binary spectra index. More...
 
const std::vector< std::streampos > & getChromatogramIndex () const
 Access to a constant copy of the binary chromatogram index. More...
 
- Public Member Functions inherited from ProgressLogger
 ProgressLogger ()
 Constructor. More...
 
virtual ~ProgressLogger ()
 Destructor. More...
 
 ProgressLogger (const ProgressLogger &other)
 Copy constructor. More...
 
ProgressLoggeroperator= (const ProgressLogger &other)
 Assignment Operator. More...
 
void setLogType (LogType type) const
 Sets the progress log that should be used. The default type is NONE! More...
 
LogType getLogType () const
 Returns the type of progress log being used. More...
 
void setLogger (ProgressLoggerImpl *logger)
 Sets the logger to be used for progress logging. More...
 
void startProgress (SignedSize begin, SignedSize end, const String &label) const
 Initializes the progress display. More...
 
void setProgress (SignedSize value) const
 Sets the current progress. More...
 
void endProgress (UInt64 bytes_processed=0) const
 
void nextProgress () const
 increment progress by 1 (according to range begin-end) More...
 

Private Types

typedef int IntType
 
typedef double DoubleType
 

Direct access to a single Spectrum or Chromatogram

std::vector< std::streampos > spectra_index_
 Members. More...
 
std::vector< std::streampos > chrom_index_
 
static void readSpectrumFast (OpenSwath::BinaryDataArrayPtr &data1, OpenSwath::BinaryDataArrayPtr &data2, std::ifstream &ifs, int &ms_level, double &rt)
 fast access to a spectrum (a direct copy of the data into the provided arrays) More...
 
static std::vector< OpenSwath::BinaryDataArrayPtrreadSpectrumFast (std::ifstream &ifs, int &ms_level, double &rt)
 Fast access to a spectrum. More...
 
static void readChromatogramFast (OpenSwath::BinaryDataArrayPtr &data1, OpenSwath::BinaryDataArrayPtr &data2, std::ifstream &ifs)
 Fast access to a chromatogram. More...
 
static std::vector< OpenSwath::BinaryDataArrayPtrreadChromatogramFast (std::ifstream &ifs)
 Fast access to a chromatogram. More...
 
static void readSpectrum (SpectrumType &spectrum, std::ifstream &ifs)
 Read a single spectrum directly into an OpenMS MSSpectrum (assuming file is already at the correct position) More...
 
static void readChromatogram (ChromatogramType &chromatogram, std::ifstream &ifs)
 Read a single chromatogram directly into an OpenMS MSChromatogram (assuming file is already at the correct position) More...
 
void writeSpectrum_ (const SpectrumType &spectrum, std::ofstream &ofs) const
 write a single spectrum to filestream More...
 
void writeChromatogram_ (const ChromatogramType &chromatogram, std::ofstream &ofs) const
 write a single chromatogram to filestream More...
 
static void readDataFast_ (std::ifstream &ifs, std::vector< OpenSwath::BinaryDataArrayPtr > &data, const Size &data_size, const Size &nr_float_arrays)
 helper method for fast reading of spectra and chromatograms More...
 

Additional Inherited Members

- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImplcurrent_logger_
 
- Static Protected Attributes inherited from ProgressLogger
static int recursion_depth_
 

Detailed Description

An class that uses on-disk caching to read and write spectra and chromatograms.

This class provides functions to read and write spectra and chromatograms to disk using a time-efficient format. Reading the data items from disk can be very fast and done in random order (once the in-memory index is built for the file).

Member Typedef Documentation

◆ ChromatogramType

◆ Datavector

typedef std::vector<DatumSingleton> Datavector

◆ DatumSingleton

typedef double DatumSingleton

◆ DoubleType

typedef double DoubleType
private

◆ IntType

typedef int IntType
private

◆ MapType

typedef PeakMap MapType

◆ SpectrumType

Constructor & Destructor Documentation

◆ CachedMzMLHandler()

Default constructor.

◆ ~CachedMzMLHandler()

~CachedMzMLHandler ( )
override

Default destructor.

Member Function Documentation

◆ createMemdumpIndex()

void createMemdumpIndex ( const String filename)

Create an index on the location of all the spectra and chromatograms.

◆ getChromatogramIndex()

const std::vector<std::streampos>& getChromatogramIndex ( ) const

Access to a constant copy of the binary chromatogram index.

◆ getSpectraIndex()

const std::vector<std::streampos>& getSpectraIndex ( ) const

Access to a constant copy of the binary spectra index.

◆ operator=()

CachedMzMLHandler& operator= ( const CachedMzMLHandler rhs)

Assignment operator.

◆ readChromatogram()

static void readChromatogram ( ChromatogramType chromatogram,
std::ifstream &  ifs 
)
static

Read a single chromatogram directly into an OpenMS MSChromatogram (assuming file is already at the correct position)

Parameters
chromatogramOutput chromatogram
ifsInput file stream (moved to the correct position)
Exceptions
Exception::ParseErroris thrown if the chromatogram size cannot be read

◆ readChromatogramFast() [1/2]

static void readChromatogramFast ( OpenSwath::BinaryDataArrayPtr data1,
OpenSwath::BinaryDataArrayPtr data2,
std::ifstream &  ifs 
)
inlinestatic

Fast access to a chromatogram.

Parameters
data1First data array (RT)
data2Second data array (Intensity)
ifsInput file stream (moved to the correct position)
Exceptions
Exception::ParseErroris thrown if the chromatogram size cannot be read

◆ readChromatogramFast() [2/2]

static std::vector<OpenSwath::BinaryDataArrayPtr> readChromatogramFast ( std::ifstream &  ifs)
static

Fast access to a chromatogram.

Parameters
ifsInput file stream (moved to the correct position)
Exceptions
Exception::ParseErroris thrown if the chromatogram size cannot be read

◆ readDataFast_()

static void readDataFast_ ( std::ifstream &  ifs,
std::vector< OpenSwath::BinaryDataArrayPtr > &  data,
const Size data_size,
const Size nr_float_arrays 
)
inlinestaticprotected

helper method for fast reading of spectra and chromatograms

◆ readMemdump()

void readMemdump ( MapType exp_reading,
const String filename 
) const

Read all spectra from a dump from the disk.

◆ readSpectrum()

static void readSpectrum ( SpectrumType spectrum,
std::ifstream &  ifs 
)
static

Read a single spectrum directly into an OpenMS MSSpectrum (assuming file is already at the correct position)

Parameters
spectrumOutput spectrum
ifsInput file stream (moved to the correct position)
Exceptions
Exception::ParseErroris thrown if the chromatogram size cannot be read

◆ readSpectrumFast() [1/2]

static void readSpectrumFast ( OpenSwath::BinaryDataArrayPtr data1,
OpenSwath::BinaryDataArrayPtr data2,
std::ifstream &  ifs,
int &  ms_level,
double &  rt 
)
inlinestatic

fast access to a spectrum (a direct copy of the data into the provided arrays)

Parameters
[out]data1First data array (m/z)
[out]data2Second data array (Intensity)
ifsInput file stream (moved to the correct position)
[out]ms_levelOutput parameter to store the MS level of the spectrum (1, 2, 3 ...)
[out]rtOutput parameter to store the retention time of the spectrum
Exceptions
Exception::ParseErroris thrown if the spectrum cannot be read

◆ readSpectrumFast() [2/2]

static std::vector<OpenSwath::BinaryDataArrayPtr> readSpectrumFast ( std::ifstream &  ifs,
int &  ms_level,
double &  rt 
)
static

Fast access to a spectrum.

Parameters
ifsInput file stream (moved to the correct position)
ms_levelOutput parameter to store the MS level of the spectrum (1, 2, 3 ...)
rtOutput parameter to store the retention time of the spectrum
Exceptions
Exception::ParseErroris thrown if the spectrum cannot be read

◆ writeChromatogram_()

void writeChromatogram_ ( const ChromatogramType chromatogram,
std::ofstream &  ofs 
) const
protected

write a single chromatogram to filestream

◆ writeMemdump()

void writeMemdump ( const MapType exp,
const String out 
) const

Write complete spectra as a dump to the disk.

◆ writeMetadata()

void writeMetadata ( MapType  exp,
const String out_meta,
bool  addCacheMetaValue = false 
)

Write only the meta data of an MSExperiment.

Referenced by CachedSwathFileConsumer::ensureMapsAreFilled_().

◆ writeMetadata_x()

void writeMetadata_x ( const MapType exp,
const String out_meta,
bool  addCacheMetaValue = false 
)

Write only the meta data of an MSExperiment.

◆ writeSpectrum_()

void writeSpectrum_ ( const SpectrumType spectrum,
std::ofstream &  ofs 
) const
protected

write a single spectrum to filestream

Member Data Documentation

◆ chrom_index_

std::vector<std::streampos> chrom_index_
protected

◆ spectra_index_

std::vector<std::streampos> spectra_index_
protected

Members.