# HG changeset patch # User devteam # Date 1591194135 0 # Node ID 26d0d9bdbafc1133e6facddab80edcb10f67782f # Parent 11de536c87b174e6b5b2cd99027f9b5b9e8f96c5 "planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/merge_cols commit dc2e3b631f515e905d5645baa4fb49df8e8cc0d5" diff -r 11de536c87b1 -r 26d0d9bdbafc mergeCols.py --- a/mergeCols.py Mon Nov 09 11:45:18 2015 -0500 +++ b/mergeCols.py Wed Jun 03 14:22:15 2020 +0000 @@ -1,37 +1,36 @@ -import sys, re +import sys -def stop_err( msg ): - sys.stderr.write( msg ) - sys.exit() def __main__(): try: - infile = open ( sys.argv[1], 'r') - outfile = open ( sys.argv[2], 'w') - except: - stop_err( 'Cannot open or create a file\n' ) - - if len( sys.argv ) < 4: - stop_err( 'No columns to merge' ) + infile = open(sys.argv[1], 'r') + outfile = open(sys.argv[2], 'w') + except Exception: + sys.exit('Cannot open or create a file\n') + + if len(sys.argv) < 4: + sys.exit('No columns to merge\n') else: - cols = sys.argv[3:] + cols = sys.argv[3:] skipped_lines = 0 for line in infile: - line = line.rstrip( '\r\n' ) - if line and not line.startswith( '#' ): - fields = line.split( '\t' ) + line = line.rstrip('\r\n') + if line and not line.startswith('#'): + fields = line.split('\t') line += '\t' for col in cols: try: - line += fields[ int( col ) -1 ] - except: + line += fields[int(col) - 1] + except Exception: skipped_lines += 1 - - print >>outfile, line - + + print(line, file=outfile) + if skipped_lines > 0: - print 'Skipped %d invalid lines' % skipped_lines - -if __name__ == "__main__" : __main__() \ No newline at end of file + print('Skipped %d invalid lines' % skipped_lines) + + +if __name__ == "__main__": + __main__() diff -r 11de536c87b1 -r 26d0d9bdbafc mergeCols.xml --- a/mergeCols.xml Mon Nov 09 11:45:18 2015 -0500 +++ b/mergeCols.xml Wed Jun 03 14:22:15 2020 +0000 @@ -1,5 +1,8 @@ - + together + + python + mergeCols.py "${input1}"