File: accessAllData.py

package info (click to toggle)
python-pymzml 0.7.6-dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 66,128 kB
  • ctags: 335
  • sloc: python: 2,428; makefile: 142; sh: 38
file content (46 lines) | stat: -rwxr-xr-x 1,169 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
accessAllData.py

Demos the usage of the spectrum.xmlTree iterator
that can be used to extract all MS:tag for a given
spectrum.

Example:


>>> example_file = get_example_file.open_example('small.pwiz.1.1.mzML')
>>> run = pymzml.run.Reader(example_file, MSn_Precision = 250e-6)
>>> spectrum = run[1]
>>> for element in spectrum.xmlTree:
...     print('-'*40)
...     print(element)
...     print(element.get('accession') )
...     print(element.tag)
...     print(element.items())

"""

from __future__ import print_function
import pymzml
import get_example_file

def main(verbose = False):
    example_file = get_example_file.open_example('small.pwiz.1.1.mzML')
    run = pymzml.run.Reader(example_file, MSn_Precision = 250e-6)
    spectrum = run[1]
    if verbose:
        print(spectrum['id'], spectrum['ms level'])
    for element in spectrum.xmlTree:
        if verbose:
            print('-'*40)
            print(element)
            print(element.get('accession') )
            print(element.tag)
            print(element.items())
    
    return True
    
if __name__ == '__main__':
    main(verbose = True)