Mercurial > repos > devteam > merge
comparison gops_merge.py @ 5:dfbbc0291b36 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/merge commit cae3e05d02e60f595bb8b6d77a84f030e9bd1689
author | devteam |
---|---|
date | Thu, 22 Jun 2017 18:51:08 -0400 |
parents | b9c97d3233bb |
children |
comparison
equal
deleted
inserted
replaced
4:a2f62c0c0537 | 5:dfbbc0291b36 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 """ | 2 """ |
3 Merge overlaping regions. | 3 Merge overlapping regions. |
4 | 4 |
5 usage: %prog in_file out_file | 5 usage: %prog in_file out_file |
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 -m, --mincols=N: Require this much overlap (default 1bp) | 7 -m, --mincols=N: Require this much overlap (default 1bp) |
8 -3, --threecol: Output 3 column bed | 8 -3, --threecol: Output 3 column bed |
9 """ | 9 """ |
10 from __future__ import print_function | |
11 | |
10 import fileinput | 12 import fileinput |
11 import sys | 13 import sys |
14 | |
15 from bx.cookbook import doc_optparse | |
12 from bx.intervals.io import GenomicInterval, NiceReaderWrapper | 16 from bx.intervals.io import GenomicInterval, NiceReaderWrapper |
13 from bx.intervals.operations.merge import merge | 17 from bx.intervals.operations.merge import merge |
14 from bx.cookbook import doc_optparse | |
15 from bx.tabular.io import ParseError | 18 from bx.tabular.io import ParseError |
16 from galaxy.tools.util.galaxyops import fail, parse_cols_arg, skipped | 19 from galaxy.tools.util.galaxyops import fail, parse_cols_arg, skipped |
17 | 20 |
18 assert sys.version_info[:2] >= ( 2, 4 ) | 21 assert sys.version_info[:2] >= ( 2, 4 ) |
19 | 22 |
53 out_file.write( "%s\n" % "\t".join( line.fields ) ) | 56 out_file.write( "%s\n" % "\t".join( line.fields ) ) |
54 elif type( line ) is list: | 57 elif type( line ) is list: |
55 out_file.write( "%s\n" % "\t".join( line ) ) | 58 out_file.write( "%s\n" % "\t".join( line ) ) |
56 else: | 59 else: |
57 out_file.write( "%s\n" % line ) | 60 out_file.write( "%s\n" % line ) |
58 except ParseError, exc: | 61 except ParseError as exc: |
59 out_file.close() | 62 out_file.close() |
60 fail( "Invalid file format: %s" % str( exc ) ) | 63 fail( "Invalid file format: %s" % str( exc ) ) |
61 | 64 |
62 out_file.close() | 65 out_file.close() |
63 | 66 |
64 if g1.skipped > 0: | 67 if g1.skipped > 0: |
65 print skipped( g1, filedesc=" of 1st dataset" ) | 68 print(skipped( g1, filedesc=" of 1st dataset" )) |
69 | |
66 | 70 |
67 if __name__ == "__main__": | 71 if __name__ == "__main__": |
68 main() | 72 main() |