Mercurial > repos > bgruening > text_processing
comparison unfold_column.py @ 3:37e1eb05b1b4 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
| author | bgruening |
|---|---|
| date | Fri, 26 Feb 2016 12:22:19 -0500 |
| parents | 5314e5d6f040 |
| children | f46f0e4f75c4 |
comparison
equal
deleted
inserted
replaced
| 2:616efa22d193 | 3:37e1eb05b1b4 |
|---|---|
| 2 | 2 |
| 3 import sys | 3 import sys |
| 4 | 4 |
| 5 out = open(sys.argv[4], 'w+') | 5 out = open(sys.argv[4], 'w+') |
| 6 | 6 |
| 7 sep = sys.argv[3] | |
| 8 # un-sanitize Galaxy inputs | |
| 9 if sep == 'X': | |
| 10 sep = ';' | |
| 11 | |
| 7 with open(sys.argv[1]) as handle: | 12 with open(sys.argv[1]) as handle: |
| 8 for line in handle: | 13 for line in handle: |
| 9 cols = line.split('\t') | 14 cols = line.split('\t') |
| 10 unfolding_column = int(sys.argv[2]) - 1 | 15 unfolding_column = int(sys.argv[2]) - 1 |
| 11 column_content = cols[ unfolding_column ] | 16 column_content = cols[ unfolding_column ] |
| 12 for elem in column_content.split( sys.argv[3] ): | 17 for elem in column_content.split( sep ): |
| 13 out.write( '\t'.join( cols[:unfolding_column] + [elem] + cols[unfolding_column+1:]) ) | 18 out.write( '\t'.join( cols[:unfolding_column] + [elem] + cols[unfolding_column+1:]) ) |
| 14 out.close() | 19 out.close() |
