Mercurial > repos > bgruening > text_processing
view unfold_column.py @ 6:60edf2f8c28f draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit b'e6ee273f75fff61d1e419283fa8088528cf59470\n'
author | bgruening |
---|---|
date | Sat, 06 May 2017 13:09:05 -0400 |
parents | 37e1eb05b1b4 |
children | f46f0e4f75c4 |
line wrap: on
line source
#!/usr/bin/env python import sys out = open(sys.argv[4], 'w+') sep = sys.argv[3] # un-sanitize Galaxy inputs if sep == 'X': sep = ';' with open(sys.argv[1]) as handle: for line in handle: cols = line.split('\t') unfolding_column = int(sys.argv[2]) - 1 column_content = cols[ unfolding_column ] for elem in column_content.split( sep ): out.write( '\t'.join( cols[:unfolding_column] + [elem] + cols[unfolding_column+1:]) ) out.close()