![]() |
OpenMS
|
Random-access reader/writer for the OpenMS on-disk cache format. More...
#include <OpenMS/FORMAT/CachedMzML.h>
Constructors and Destructor | |
| MSExperiment | meta_ms_experiment_ |
| Meta data. | |
| std::ifstream | ifs_ |
| Internal filestream. | |
| std::string | filename_ |
| Name of the mzML file. | |
| std::string | filename_cached_ |
| Name of the cached mzML file. | |
| std::vector< std::streampos > | spectra_index_ |
| Indices. | |
| std::vector< std::streampos > | chrom_index_ |
| CachedmzML () | |
| Default constructor. | |
| CachedmzML (const std::string &filename) | |
Construct and load metadata + side-car index from filename in one step. | |
| CachedmzML (const CachedmzML &rhs) | |
| Copy constructor. | |
| ~CachedmzML () | |
| Destructor. | |
| MSSpectrum | getSpectrum (Size id) |
| Read one spectrum from the side-car file. | |
| MSChromatogram | getChromatogram (Size id) |
| Read one chromatogram from the side-car file. | |
| size_t | getNrSpectra () const |
| Number of spectra in the loaded experiment. | |
| size_t | getNrChromatograms () const |
| Number of chromatograms in the loaded experiment. | |
| const MSExperiment & | getMetaData () const |
Experiment-level metadata loaded from the .mzML file. | |
| static void | store (const std::string &filename, const PeakMap &map) |
Write map to disk as a cached .mzML pair. | |
| static void | load (const std::string &filename, CachedmzML &map) |
Load a cached .mzML pair into map. | |
| void | load_ (const std::string &filename) |
Random-access reader/writer for the OpenMS on-disk cache format.
Spectra and chromatograms are split across two files: an .mzML file holding the experiment-level metadata and a side-car .mzML.cached binary file holding the per-spectrum / per-chromatogram payload. After load (or constructing with a filename) the side-car's stream offsets are kept in an in-memory index, so single spectra or chromatograms can be fetched in any order from disk without scanning the full file.
| CachedmzML | ( | ) |
Default constructor.
Produces an empty instance with no associated file.
| CachedmzML | ( | const std::string & | filename | ) |
Construct and load metadata + side-car index from filename in one step.
Equivalent to default-constructing and then calling load. See load for the exact behaviour, file layout and exceptions.
| [in] | filename | Path of the .mzML metadata file; the side-car is expected next to it as filename + ".cached". |
| CachedmzML | ( | const CachedmzML & | rhs | ) |
Copy constructor.
Each instance keeps its own file handle on the .mzML.cached side-car, so the copy opens a fresh stream on the same path – the original's stream is not shared.
| [in] | rhs | Instance to copy. |
| ~CachedmzML | ( | ) |
Destructor.
Closes the open file stream on the .mzML.cached side-car.
| MSChromatogram getChromatogram | ( | Size | id | ) |
Read one chromatogram from the side-car file.
| [in] | id | Index of the chromatogram to read; must be smaller than getNrChromatograms. Out-of-range access is a programming error (checked in debug builds). |
| Exception::ParseError | when seekg on the side-car stream fails. |
|
inline |
Experiment-level metadata loaded from the .mzML file.
The returned experiment contains instrument and acquisition settings as well as the per-spectrum / per-chromatogram headers. Empty until load has been called.
| size_t getNrChromatograms | ( | ) | const |
Number of chromatograms in the loaded experiment.
| size_t getNrSpectra | ( | ) | const |
Number of spectra in the loaded experiment.
| MSSpectrum getSpectrum | ( | Size | id | ) |
Read one spectrum from the side-car file.
Seeks the cached stream to the indexed offset for id, parses the binary payload and returns the resulting MSSpectrum. The metadata for the spectrum (instrument settings, native id, ...) is taken from the in-memory experiment loaded at load time.
| [in] | id | Index of the spectrum to read; must be smaller than getNrSpectra. Out-of-range access is a programming error (checked in debug builds). |
| Exception::ParseError | when seekg on the side-car stream fails (e.g. a 32-bit-system overflow on a > 2 GB cache file). |
|
static |
Load a cached .mzML pair into map.
Reads the metadata from filename and builds the in-memory index for the side-car at filename + ".cached"; subsequent calls to getSpectrum / getChromatogram on map fetch the payload from the side-car on demand.
| [in] | filename | Path of the .mzML metadata file (the side-car is expected next to it as filename + ".cached"). |
| [out] | map | Destination instance; previous contents are replaced. |
| Exception::FileNotFound | when either file cannot be opened. |
| Exception::ParseError | when parsing the metadata or building the side-car index fails. |
|
protected |
|
static |
Write map to disk as a cached .mzML pair.
Produces two files: a binary side-car at filename + ".cached" holding the spectrum / chromatogram payload, and an .mzML file at filename holding the metadata.
| [in] | filename | Path of the metadata file (should end in .mzML); the side-car is written next to it as filename + ".cached". |
| [in] | map | Experiment to write. |
| Exception::UnableToCreateFile | when either output file cannot be created. |
|
protected |
|
protected |
Name of the mzML file.
|
protected |
Name of the cached mzML file.
|
protected |
Internal filestream.
|
protected |
Meta data.
|
protected |
Indices.