| 1 |
.. code-block:: python |
| 2 |
|
| 3 |
#!/usr/bin/env python |
| 4 |
import sys |
| 5 |
import pymzml |
| 6 |
|
| 7 |
|
| 8 |
def main(mzml_file): |
| 9 |
""" |
| 10 |
Basic example script to access basic run info of an mzML file. Requires a |
| 11 |
mzML file as first command line argument. |
| 12 |
|
| 13 |
usage: |
| 14 |
|
| 15 |
./access_run_info.py <path_to_mzml_file> |
| 16 |
|
| 17 |
>>> run.info = |
| 18 |
{ |
| 19 |
'encoding': 'utf-8', |
| 20 |
'file_name': '/Users/joe/Dev/pymzml_2.0/tests/data/BSA1.mzML.gz', |
| 21 |
'file_object': <pymzml.file_interface.FileInterface object at 0x1039a3f28>, |
| 22 |
'obo_version': '1.1.0', |
| 23 |
'offset_dict': None, |
| 24 |
'run_id': 'ru_0', |
| 25 |
'spectrum_count': 1684, |
| 26 |
'start_time': '2009-08-09T22:32:31' |
| 27 |
} |
| 28 |
|
| 29 |
""" |
| 30 |
run = pymzml.run.Reader(mzml_file) |
| 31 |
print( |
| 32 |
""" |
| 33 |
Summary for mzML file: |
| 34 |
{file_name} |
| 35 |
Run was measured on {start_time} using obo version {obo_version} |
| 36 |
File contains {spectrum_count} spectra |
| 37 |
""".format( |
| 38 |
**run.info |
| 39 |
) |
| 40 |
) |
| 41 |
|
| 42 |
|
| 43 |
if __name__ == "__main__": |
| 44 |
if len(sys.argv) < 2: |
| 45 |
print(main.__doc__) |
| 46 |
exit() |
| 47 |
mzml_file = sys.argv[1] |
| 48 |
main(mzml_file) |