| 1 |
.. code-block:: python |
| 2 |
|
| 3 |
#!/usr/bin/env python |
| 4 |
# -*- coding: utf-8 -*- |
| 5 |
|
| 6 |
|
| 7 |
import pymzml |
| 8 |
import get_example_file |
| 9 |
|
| 10 |
|
| 11 |
def main(): |
| 12 |
""" |
| 13 |
Accessing positive or negative polarity of scan using obo 1.1.0 |
| 14 |
|
| 15 |
usage: |
| 16 |
|
| 17 |
./polarity.py |
| 18 |
|
| 19 |
""" |
| 20 |
example_file = get_example_file.open_example("small.pwiz.1.1.mzML") |
| 21 |
run = pymzml.run.Reader(example_file, obo_version="1.1.0") |
| 22 |
for spec in run: |
| 23 |
negative_polarity = spec["negative scan"] |
| 24 |
if negative_polarity is None: |
| 25 |
negative_polarity = False |
| 26 |
if negative_polarity == "": |
| 27 |
negative_polarity = True |
| 28 |
positive_polarity = spec["positive scan"] |
| 29 |
if positive_polarity is None: |
| 30 |
positive_polarity = False |
| 31 |
if positive_polarity == "": |
| 32 |
positive_polarity = True |
| 33 |
else: |
| 34 |
positive_polarity = False |
| 35 |
print( |
| 36 |
"Polarity negative {0} - Polarity positive {1}".format( |
| 37 |
negative_polarity, positive_polarity |
| 38 |
) |
| 39 |
) |
| 40 |
exit(1) |
| 41 |
|
| 42 |
return |
| 43 |
|
| 44 |
|
| 45 |
if __name__ == "__main__": |
| 46 |
main() |