| OpenMS 2.5.0

Public Types | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | List of all members
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:

## Public Types

typedef PeakMap | MapType
typedef MSSpectrum | SpectrumType
typedef MSChromatogram | ChromatogramType
typedef double | DatumSingleton
typedef std::vector< DatumSingleton > | Datavector
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 ()
| Default destructor. More...
CachedMzMLHandler & | operator= (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, 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, String filename) const
| Read all spectra from a dump from the disk. More...
Access and creation of the binary indices
void | createMemdumpIndex (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...
| ~ProgressLogger ()
| Destructor. More...
| ProgressLogger (const ProgressLogger &other)
| Copy constructor. More...
ProgressLogger & | operator= (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 | 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 () const
| Ends the progress display. More...
void | nextProgress () const
| increment progress by 1 (according to range begin-end) More...

## Static Public Member Functions

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...
Direct access to a single Spectrum or Chromatogram
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::BinaryDataArrayPtr > | readSpectrumFast (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::BinaryDataArrayPtr > | readChromatogramFast (std::ifstream &ifs)
| Fast access to a chromatogram. More...

## Protected Member Functions

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 Protected Member Functions

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...
Static Protected Member Functions inherited from ProgressLogger
static String | logTypeToFactoryName_ (LogType type)
| Return the name of the factory product used for this log type. More...

## Protected Attributes

std::vector< std::streampos > | spectra_index_
| Members. More...
std::vector< std::streampos > | chrom_index_
Protected Attributes inherited from ProgressLogger
LogType | type_
time_t | last_invoke_
ProgressLoggerImpl * | current_logger_

## Private Types

typedef int | IntType
typedef double | DoubleType

## Additional Inherited Members

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

typedef MSChromatogram 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

typedef MSSpectrum SpectrumType

## Constructor & Destructor Documentation

## ◆ CachedMzMLHandler()

CachedMzMLHandler | ( |  | ) |

Default constructor.

## ◆ ~CachedMzMLHandler()

~CachedMzMLHandler | ( |  | ) |

Default destructor.

## Member Function Documentation

## ◆ createMemdumpIndex()

void createMemdumpIndex | ( | 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

  chromatogram | Output chromatogram
  ifs | Input file stream (moved to the correct position)

Exceptions

  Exception::ParseError | is thrown if the chromatogram size cannot be read

## ◆ readChromatogramFast() [1/2]

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

inline static

Fast access to a chromatogram.

Parameters

  data1 | First data array (RT)
  data2 | Second data array (Intensity)

Exceptions

  Exception::ParseError | is 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

  ifs | Input file stream (moved to the correct position)

Exceptions

  Exception::ParseError | is 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
| ) |  |

inline static protected

helper method for fast reading of spectra and chromatograms

## ◆ readMemdump()

void readMemdump | ( | MapType & | exp_reading,
|  | 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

  spectrum | Output spectrum
  ifs | Input file stream (moved to the correct position)

Exceptions

  Exception::ParseError | is 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
| ) |  |

inline static

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

Parameters

  data1 | First data array (m/z)
  data2 | Second data array (Intensity)
  ms_level | Output parameter to store the MS level of the spectrum (1, 2, 3 ...)
  rt | Output parameter to store the retention time of the spectrum

Exceptions

  Exception::ParseError | is 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

  ifs | Input file stream (moved to the correct position)
  ms_level | Output parameter to store the MS level of the spectrum (1, 2, 3 ...)
  rt | Output parameter to store the retention time of the spectrum

Exceptions

  Exception::ParseError | is 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,
|  | 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.