| OpenMS 2.5.0

Public Member Functions | Protected Attributes | Private Types | List of all members
MSDataSqlConsumer Class Reference

A data consumer that inserts MS data into a SQLite database. More...

`#include <OpenMS/FORMAT/DATAACCESS/MSDataSqlConsumer.h>`

Inheritance diagram for MSDataSqlConsumer:

## Public Member Functions

| MSDataSqlConsumer (String filename, int buffer_size=500, bool full_meta=true, bool lossy_compression=false, double linear_mass_acc=1e-4)
| Constructor. More...
| ~MSDataSqlConsumer () override
| Destructor. More...
void | flush ()
| Flushes the data for good. More...
void | consumeSpectrum (SpectrumType &s) override
| Write a spectrum to the output file. More...
void | consumeChromatogram (ChromatogramType &c) override
| Write a chromatogram to the output file. More...
void | setExpectedSize (Size, Size) override
| Set expected size of spectra and chromatograms to be consumed. More...
void | setExperimentalSettings (const ExperimentalSettings &) override
| Set experimental settings (meta-data) of the data to be consumed. More...
Public Member Functions inherited from IMSDataConsumer
virtual | ~IMSDataConsumer ()

## Protected Attributes

String | filename_
OpenMS::Internal::MzMLSqliteHandler * | handler_
size_t | flush_after_
bool | full_meta_
std::vector< SpectrumType > | spectra_
std::vector< ChromatogramType > | chromatograms_
MSExperiment | peak_meta_

## Private Types

typedef MSExperiment | MapType
typedef MapType::SpectrumType | SpectrumType
typedef MapType::ChromatogramType | ChromatogramType

## Additional Inherited Members

Public Types inherited from IMSDataConsumer
typedef MSSpectrum | SpectrumType
typedef MSChromatogram | ChromatogramType

## Detailed Description

A data consumer that inserts MS data into a SQLite database.

Consumes spectra and chromatograms and inserts them into an file-based SQL database using SQLite. As SQLite is highly inefficient when inserting one spectrum/chromatogram at a time, the consumer collects the data in an internal buffer and then flushes them all together to disk.

It uses MzMLSqliteHandler internally to write batches of data to disk.

## Member Typedef Documentation

## ◆ ChromatogramType

typedef MapType::ChromatogramType ChromatogramType

private

## ◆ MapType

typedef MSExperiment MapType

private

## ◆ SpectrumType

typedef MapType::SpectrumType SpectrumType

private

## Constructor & Destructor Documentation

## ◆ MSDataSqlConsumer()

MSDataSqlConsumer | ( | String | filename,
|  | int | buffer_size = `500`,
|  | bool | full_meta = `true`,
|  | bool | lossy_compression = `false`,
|  | double | linear_mass_acc = `1e-4`
| ) |  |

Constructor.

Opens the SQLite file and writes the tables.

Parameters

  filename | The filename of the SQLite database
  buffer_size | How large the internal buffer size should be (defaults to 500 spectra / chromatograms)
  full_meta | Whether to write the full meta-data in the SQLite header
  lossy_compression | Whether to use lossy compression (numpress)
  linear_mass_acc | Desired mass accuracy for RT or m/z space (absolute value)

## ◆ ~MSDataSqlConsumer()

~MSDataSqlConsumer | ( |  | ) |

override

Destructor.

Flushes the data for good.

## Member Function Documentation

## ◆ consumeChromatogram()

void consumeChromatogram | ( | ChromatogramType & | c | ) |

override virtual

Write a chromatogram to the output file.

Implements IMSDataConsumer.

## ◆ consumeSpectrum()

void consumeSpectrum | ( | SpectrumType & | s | ) |

override virtual

Write a spectrum to the output file.

Implements IMSDataConsumer.

## ◆ flush()

void flush | ( |  | ) |

Flushes the data for good.

After calling this function, no more data is held in the buffer but the class is still able to receive new data.

## ◆ setExpectedSize()

void setExpectedSize | ( | Size | expectedSpectra,
|  | Size | expectedChromatograms
| ) |  |

override virtual

Set expected size of spectra and chromatograms to be consumed.

Some implementations might care about the number of spectra and chromatograms to be consumed and need to be informed about this (usually before consuming starts).

Note
  Calling this method is optional but good practice.

Parameters

  expectedSpectra | Number of spectra expected
  expectedChromatograms | Number of chromatograms expected

Implements IMSDataConsumer.

## ◆ setExperimentalSettings()

void setExperimentalSettings | ( | const ExperimentalSettings & | exp | ) |

override virtual

Set experimental settings (meta-data) of the data to be consumed.

Some implementations might need to know about the meta-data (or the context) of the spectra and chromatograms to be consumed. This method allows them learn this.

Note
  Calling this method is optional but good practice.

Parameters

  exp | Experimental settings meta data for the data to be consumed

Implements IMSDataConsumer.

## Member Data Documentation

## ◆ chromatograms_

std::vector<ChromatogramType> chromatograms_

protected

## ◆ filename_

String filename_

protected

## ◆ flush_after_

size_t flush_after_

protected

## ◆ full_meta_

bool full_meta_

protected

## ◆ handler_

OpenMS::Internal::MzMLSqliteHandler* handler_

protected

## ◆ peak_meta_

MSExperiment peak_meta_

protected

## ◆ spectra_

std::vector<SpectrumType> spectra_

protected