comparison gops_join.py @ 4:a10f49d9218a draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/join commit cae3e05d02e60f595bb8b6d77a84f030e9bd1689
author devteam
date Thu, 22 Jun 2017 18:52:36 -0400
parents ffbd1de29c28
children
comparison
equal deleted inserted replaced
3:ffbd1de29c28 4:a10f49d9218a
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 -2, --cols2=N,N,N,N: Columns for start, end, strand in second file 7 -2, --cols2=N,N,N,N: Columns for start, end, strand in second file
8 -m, --mincols=N: Require this much overlap (default 1bp) 8 -m, --mincols=N: Require this much overlap (default 1bp)
9 -f, --fill=N: none, right, left, both 9 -f, --fill=N: none, right, left, both
10 """ 10 """
11 from __future__ import print_function
12
11 import fileinput 13 import fileinput
12 import sys 14 import sys
15
16 from bx.cookbook import doc_optparse
13 from bx.intervals.io import NiceReaderWrapper 17 from bx.intervals.io import NiceReaderWrapper
14 from bx.intervals.operations.join import join 18 from bx.intervals.operations.join import join
15 from bx.cookbook import doc_optparse
16 from bx.tabular.io import ParseError 19 from bx.tabular.io import ParseError
17 from galaxy.tools.util.galaxyops import fail, parse_cols_arg, skipped 20 from galaxy.tools.util.galaxyops import fail, parse_cols_arg, skipped
18 21
19 assert sys.version_info[:2] >= ( 2, 4 ) 22 assert sys.version_info[:2] >= ( 2, 4 )
20 23
59 for outfields in join(g1, g2, mincols=mincols, rightfill=rightfill, leftfill=leftfill): 62 for outfields in join(g1, g2, mincols=mincols, rightfill=rightfill, leftfill=leftfill):
60 if type( outfields ) is list: 63 if type( outfields ) is list:
61 out_file.write( "%s\n" % "\t".join( outfields ) ) 64 out_file.write( "%s\n" % "\t".join( outfields ) )
62 else: 65 else:
63 out_file.write( "%s\n" % outfields ) 66 out_file.write( "%s\n" % outfields )
64 except ParseError, exc: 67 except ParseError as exc:
65 out_file.close() 68 out_file.close()
66 fail( "Invalid file format: %s" % str( exc ) ) 69 fail( "Invalid file format: %s" % str( exc ) )
67 except MemoryError: 70 except MemoryError:
68 out_file.close() 71 out_file.close()
69 fail( "Input datasets were too large to complete the join operation." ) 72 fail( "Input datasets were too large to complete the join operation." )
70 73
71 out_file.close() 74 out_file.close()
72 75
73 if g1.skipped > 0: 76 if g1.skipped > 0:
74 print skipped( g1, filedesc=" of 1st dataset" ) 77 print(skipped( g1, filedesc=" of 1st dataset" ))
75 if g2.skipped > 0: 78 if g2.skipped > 0:
76 print skipped( g2, filedesc=" of 2nd dataset" ) 79 print(skipped( g2, filedesc=" of 2nd dataset" ))
80
77 81
78 if __name__ == "__main__": 82 if __name__ == "__main__":
79 main() 83 main()