comparison gops_concat.py @ 3:32e1c8dac438 draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/concat commit cae3e05d02e60f595bb8b6d77a84f030e9bd1689
author devteam
date Thu, 22 Jun 2017 18:40:46 -0400
parents d491589307e7
children
comparison
equal deleted inserted replaced
2:d491589307e7 3:32e1c8dac438
10 usage: %prog in_file_1 in_file_2 out_file 10 usage: %prog in_file_1 in_file_2 out_file
11 -1, --cols1=N,N,N,N: Columns for chrom, start, end, strand in first file 11 -1, --cols1=N,N,N,N: Columns for chrom, start, end, strand in first file
12 -2, --cols2=N,N,N,N: Columns for chrom, start, end, strand in second file 12 -2, --cols2=N,N,N,N: Columns for chrom, start, end, strand in second file
13 -s, --sameformat: All files are precisely the same format. 13 -s, --sameformat: All files are precisely the same format.
14 """ 14 """
15 from __future__ import print_function
15 16
16 import fileinput 17 import fileinput
17 import sys 18 import sys
19
20 from bx.cookbook import doc_optparse
18 from bx.intervals.io import GenomicInterval, NiceReaderWrapper 21 from bx.intervals.io import GenomicInterval, NiceReaderWrapper
19 from bx.intervals.operations.concat import concat 22 from bx.intervals.operations.concat import concat
20 from bx.cookbook import doc_optparse
21 from bx.tabular.io import ParseError 23 from bx.tabular.io import ParseError
22 from galaxy.tools.util.galaxyops import fail, parse_cols_arg, skipped 24 from galaxy.tools.util.galaxyops import fail, parse_cols_arg, skipped
23 25
24 assert sys.version_info[:2] >= ( 2, 4 ) 26 assert sys.version_info[:2] >= ( 2, 4 )
25 27
57 for line in concat( [g1, g2], sameformat=sameformat ): 59 for line in concat( [g1, g2], sameformat=sameformat ):
58 if type( line ) is GenomicInterval: 60 if type( line ) is GenomicInterval:
59 out_file.write( "%s\n" % "\t".join( line.fields ) ) 61 out_file.write( "%s\n" % "\t".join( line.fields ) )
60 else: 62 else:
61 out_file.write( "%s\n" % line ) 63 out_file.write( "%s\n" % line )
62 except ParseError, exc: 64 except ParseError as exc:
63 out_file.close() 65 out_file.close()
64 fail( "Invalid file format: %s" % str( exc ) ) 66 fail( "Invalid file format: %s" % str( exc ) )
65 67
66 out_file.close() 68 out_file.close()
67 69
68 if g1.skipped > 0: 70 if g1.skipped > 0:
69 print skipped( g1, filedesc=" of 1st dataset" ) 71 print(skipped( g1, filedesc=" of 1st dataset" ))
70 if g2.skipped > 0: 72 if g2.skipped > 0:
71 print skipped( g2, filedesc=" of 2nd dataset" ) 73 print(skipped( g2, filedesc=" of 2nd dataset" ))
74
72 75
73 if __name__ == "__main__": 76 if __name__ == "__main__":
74 main() 77 main()