File: gzip_mzml.inc

package info (click to toggle)
python-pymzml 2.5.2%2Brepack1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 27,792 kB
  • sloc: python: 6,495; pascal: 341; makefile: 233; sh: 30
file content (31 lines) | stat: -rwxr-xr-x 739 bytes parent folder | download | duplicates (3)
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
.. code-block:: python

	#!/usr/bin/env python3.4
	
	import sys
	import os
	from pymzml.utils.utils import index_gzip
	from pymzml.run import Reader
	
	
	def main(mzml_path, out_path):
	    """
	    Create and indexed gzip mzML file from a plain mzML.
	
	    Usage: python3 gzip_mzml.py <path/to/mzml> <path/to/output>
	    """
	    with open(mzml_path) as fin:
	        fin.seek(0, 2)
	        max_offset_len = fin.tell()
	        max_spec_no = Reader(mzml_path).get_spectrum_count() + 10
	
	    index_gzip(
	        mzml_path, out_path, max_idx=max_spec_no, idx_len=len(str(max_offset_len))
	    )
	
	
	if __name__ == "__main__":
	    if len(sys.argv) > 2:
	        main(sys.argv[1], sys.argv[2])
	    else:
	        print(main.__doc__)