| 1 |
.. code-block:: python |
| 2 |
|
| 3 |
#!/usr/bin/env python3.4 |
| 4 |
|
| 5 |
import sys |
| 6 |
import os |
| 7 |
from pymzml.utils.utils import index_gzip |
| 8 |
from pymzml.run import Reader |
| 9 |
|
| 10 |
|
| 11 |
def main(mzml_path): |
| 12 |
""" |
| 13 |
Create and indexed gzip mzML file from a plain mzML. |
| 14 |
|
| 15 |
Usage: python3 gzip_mzml.py <path/to/mzml> <path/to/output> |
| 16 |
""" |
| 17 |
with open(mzml_path) as fin: |
| 18 |
fin.seek(0,2) |
| 19 |
max_offset_len = fin.tell() |
| 20 |
max_spec_no = Reader(mzml_path).get_spectrum_count() + 10 |
| 21 |
|
| 22 |
out_path = '{0}.gz'.format(mzml_path) |
| 23 |
index_gzip( |
| 24 |
mzml_path, |
| 25 |
out_path, |
| 26 |
max_idx = max_spec_no, |
| 27 |
idx_len = len(str(max_offset_len)) |
| 28 |
) |
| 29 |
print('Wrote file {0}'.format(out_path)) |
| 30 |
|
| 31 |
if __name__ == '__main__': |
| 32 |
if len(sys.argv) > 1: |
| 33 |
main( |
| 34 |
sys.argv[1], |
| 35 |
) |
| 36 |
else: |
| 37 |
print(main.__doc__) |