| 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, out_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 |
index_gzip( |
| 23 |
mzml_path, out_path, max_idx=max_spec_no, idx_len=len(str(max_offset_len)) |
| 24 |
) |
| 25 |
|
| 26 |
|
| 27 |
if __name__ == "__main__": |
| 28 |
if len(sys.argv) > 2: |
| 29 |
main(sys.argv[1], sys.argv[2]) |
| 30 |
else: |
| 31 |
print(main.__doc__) |