3.1. Main reader interface

The class Reader has been designed to selectively extract data from a mzML file and to expose the data as a python object. Necessary information are read in and stored in a fast accessible format. The reader itself is an iterator, thus looping over all spectra follows the classical pythonian syntax. Additionally one can random access spectra by their nativeID if the file if not truncated by a conversion Program.

The class Writer is still in development.

class pymzml.run.Reader(path, MS_precisions=None, obo_version=None, **kwargs)[source]

Initialize Reader object for a given mzML file.

Parameters:

path (str) – path to the mzml file to parse.

Keyword Arguments:
 
  • MS_precisions (dict) – measured precisions for the different MS levels. e.g.:

    {
        1: 1e-6,
        2: 5e-6
    }
    
  • obo_version (str, optional) – obo version number as string. If not specified the version will be extracted from the mzML file

__getitem__(identifier)[source]

Access spectrum with native id ‘identifier’

Parameters:identifier (str or int) – last number in the id tag of the spectrum element
Returns:spectrum – spectrum class with native id ‘identifier’
Return type:Spectrum
get_chromatogram_count()[source]

Number of chromatograms in file.

Returns:chromatogram count – Number of chromatograms in file.
Return type:int
get_spectrum_count()[source]

Number of spectra in file.

Returns:spectrum count – Number of spectra in file.
Return type:int