File: extractIonChromatogram.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,548 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.2

"""
Demonstration of the extraction of a specific ion chromatogram, i.e. XIC or EIC

Example:

>>> import pymzml, get_example_file
>>> example_file = get_example_file.open_example('small.pwiz.1.1.mzML')
>>> run = pymzml.run.Reader(example_file, MS1_Precision = 20e-6, MSn_Precision = 20e-6)
>>> timeDependentIntensities = []
>>> for spectrum in run:
...     if spectrum['ms level'] == 1:
...         matchList = spectrum.hasPeak(MASS_2_FOLLOW)
...         if matchList != []:
...             for mz,I in matchList:
...                 timeDependentIntensities.append( [ spectrum['scan time'], I , mz ])
>>> for rt, i, mz in timeDependentIntensities:
...     print('{0:5.3f}\t{1:13.4f}\t{2:10}'.format( rt, i, mz ))

"""

from __future__ import print_function
import sys
import pymzml
import get_example_file

MASS_2_FOLLOW = 810.53

def main(verbose = False):
    example_file = get_example_file.open_example('small.pwiz.1.1.mzML')
    run = pymzml.run.Reader(example_file, MS1_Precision = 20e-6, MSn_Precision = 20e-6)
    timeDependentIntensities = []
    for spectrum in run:
        if spectrum['ms level'] == 1:
            matchList = spectrum.hasPeak(MASS_2_FOLLOW)
            if matchList != []:
                for mz,I in matchList:
                    timeDependentIntensities.append( [ spectrum['scan time'], I , mz ])
    print('RT   \ti   \tmz')
    for rt, i, mz in timeDependentIntensities:
        print('{0:5.3f}\t{1:13.4f}\t{2:10}'.format( rt, i, mz ))
    return

if __name__ == '__main__':
    main()