esmraldi.imzmlparsermmapped¶
Module Contents¶
Classes¶
Parser for imzML 1.1.0 files (see specification here: |
- class esmraldi.imzmlparsermmapped.ImzMLParserMMapped(filename, parse_lib=None, ibd_file=INFER_IBD_FROM_IMZML, include_spectra_metadata=None)¶
Bases:
pyimzml.ImzMLParser.ImzMLParserParser for imzML 1.1.0 files (see specification here: http://imzml.org/download/imzml/specifications_imzML1.1.0_RC1.pdf).
Iteratively reads the .imzML file into memory while pruning the per-spectrum metadata (everything in <spectrumList> elements) during initialization. Returns a spectrum upon calling getspectrum(i). The binary file is read in every call of getspectrum(i). Use enumerate(parser.coordinates) to get all coordinates with their respective index. Coordinates are always 3-dimensional. If the third spatial dimension is not present in the data, it will be set to zero.
pyimzML has limited support for the metadata embedded in the imzML file. For some general metadata, you can use the parser’s
ìmzmldictattribute. You can find the exact list of supported metadata in the documentation of the__readimzmlmetamethod.- __exit__(exc_t, exc_v, trace)¶
- get_spectrum_as_string(index)¶
Reads m/z array and intensity array of the spectrum at specified location from the binary file as a byte string. The string can be unpacked by the struct module. To get the arrays as numbers, use getspectrum
- Parameters
index – Index of the desired spectrum in the .imzML file
- Return type
Tuple[str, str]
Output:
- mz_string:
string where each character represents a byte of the mz array of the spectrum
- intensity_string:
string where each character represents a byte of the intensity array of the spectrum