Mercurial > repos > devteam > basecoverage
comparison gops_basecoverage.py @ 6:4d584cf5ced5 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
author | devteam |
---|---|
date | Mon, 13 Jun 2022 16:26:51 +0000 |
parents | 37652c34b3bf |
children |
comparison
equal
deleted
inserted
replaced
5:37652c34b3bf | 6:4d584cf5ced5 |
---|---|
6 -1, --cols1=N,N,N,N: Columns for start, end, strand in first file | 6 -1, --cols1=N,N,N,N: Columns for start, end, strand in first file |
7 """ | 7 """ |
8 from __future__ import print_function | 8 from __future__ import print_function |
9 | 9 |
10 import fileinput | 10 import fileinput |
11 import sys | |
12 | 11 |
13 from bx.cookbook import doc_optparse | 12 from bx.cookbook import doc_optparse |
14 from bx.intervals.io import NiceReaderWrapper | 13 from bx.intervals.io import NiceReaderWrapper |
15 from bx.intervals.operations.base_coverage import base_coverage | 14 from bx.intervals.operations.base_coverage import base_coverage |
16 from bx.tabular.io import ParseError | 15 from bx.tabular.io import ParseError |
17 from galaxy.tools.util.galaxyops import fail, parse_cols_arg, skipped | 16 from galaxy.tools.util.galaxyops import fail, parse_cols_arg, skipped |
18 | 17 |
19 assert sys.version_info[:2] >= ( 2, 4 ) | |
20 | |
21 | 18 |
22 def main(): | 19 def main(): |
23 options, args = doc_optparse.parse( __doc__ ) | 20 options, args = doc_optparse.parse(__doc__) |
24 try: | 21 try: |
25 chr_col_1, start_col_1, end_col_1, strand_col_1 = parse_cols_arg( options.cols1 ) | 22 chr_col_1, start_col_1, end_col_1, strand_col_1 = parse_cols_arg(options.cols1) |
26 in_fname, out_fname = args | 23 in_fname, out_fname = args |
27 except: | 24 except Exception: |
28 doc_optparse.exception() | 25 doc_optparse.exception() |
29 | 26 |
30 g1 = NiceReaderWrapper( fileinput.FileInput( in_fname ), | 27 g1 = NiceReaderWrapper( |
31 chrom_col=chr_col_1, | 28 fileinput.FileInput(in_fname), |
32 start_col=start_col_1, | 29 chrom_col=chr_col_1, |
33 end_col=end_col_1, | 30 start_col=start_col_1, |
34 strand_col=strand_col_1, | 31 end_col=end_col_1, |
35 fix_strand=True ) | 32 strand_col=strand_col_1, |
33 fix_strand=True | |
34 ) | |
36 | 35 |
37 try: | 36 try: |
38 bases = base_coverage(g1) | 37 bases = base_coverage(g1) |
39 except ParseError as exc: | 38 except ParseError as exc: |
40 fail( "Invalid file format: %s" % str( exc ) ) | 39 fail("Invalid file format: %s" % str(exc)) |
41 out_file = open( out_fname, "w" ) | 40 out_file = open(out_fname, "w") |
42 out_file.write( "%s\n" % str( bases ) ) | 41 out_file.write("%s\n" % str(bases)) |
43 out_file.close() | 42 out_file.close() |
44 if g1.skipped > 0: | 43 if g1.skipped > 0: |
45 print(skipped( g1, filedesc="" )) | 44 print(skipped(g1, filedesc="")) |
46 | 45 |
47 | 46 |
48 if __name__ == "__main__": | 47 if __name__ == "__main__": |
49 main() | 48 main() |