Mercurial > repos > bgruening > text_processing
view unfold_column.py @ 20:1aa30b2c73c9 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 4f79443517baf378fbfe1f81be361d97f2938601
author | bgruening |
---|---|
date | Wed, 03 Apr 2019 13:56:43 -0400 |
parents | c78b1767db2b |
children | 5fef6d08de83 |
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()