Mercurial > repos > devteam > merge_cols
changeset 2:dd40b1e9eebe 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 10:22:39 -0400 |
parents | f2aac0c5c60d |
children | ae7843d06f8f |
files | mergeCols.py mergeCols.xml |
diffstat | 2 files changed, 26 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/mergeCols.py Mon Apr 01 15:13:57 2013 -0400 +++ b/mergeCols.py Wed Jun 03 10:22:39 2020 -0400 @@ -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 Apr 01 15:13:57 2013 -0400 +++ b/mergeCols.xml Wed Jun 03 10:22:39 2020 -0400 @@ -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}"