Mercurial > repos > devteam > merge_cols
changeset 1:26d0d9bdbafc draft
"planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/merge_cols commit dc2e3b631f515e905d5645baa4fb49df8e8cc0d5"
author | devteam |
---|---|
date | Wed, 03 Jun 2020 14:22:15 +0000 |
parents | 11de536c87b1 |
children | 4576d639d805 |
files | mergeCols.py mergeCols.xml |
diffstat | 2 files changed, 26 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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__()
--- 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 @@ -<tool id="mergeCols1" name="Merge Columns" version="1.0.1"> +<tool id="mergeCols1" name="Merge Columns" version="1.0.2"> <description>together</description> + <requirements> + <requirement type="package" version="3.7">python</requirement> + </requirements> <command interpreter="python"> mergeCols.py "${input1}"