comparison unfold_column.py @ 17:f46f0e4f75c4 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
author bgruening
date Tue, 22 Jun 2021 16:06:48 +0000
parents 37e1eb05b1b4
children
comparison
equal deleted inserted replaced
16:ddf54b12c295 17:f46f0e4f75c4
1 #!/usr/bin/env python 1 #!/usr/bin/env python
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] 7 sep = sys.argv[3]
8 # un-sanitize Galaxy inputs 8 # un-sanitize Galaxy inputs
9 if sep == 'X': 9 if sep == "X":
10 sep = ';' 10 sep = ";"
11 11
12 with open(sys.argv[1]) as handle: 12 with open(sys.argv[1]) as handle:
13 for line in handle: 13 for line in handle:
14 cols = line.split('\t') 14 cols = line.split("\t")
15 unfolding_column = int(sys.argv[2]) - 1 15 unfolding_column = int(sys.argv[2]) - 1
16 column_content = cols[ unfolding_column ] 16 column_content = cols[unfolding_column]
17 for elem in column_content.split( sep ): 17 for elem in column_content.split(sep):
18 out.write( '\t'.join( cols[:unfolding_column] + [elem] + cols[unfolding_column+1:]) ) 18 out.write(
19 "\t".join(
20 cols[:unfolding_column] + [elem] + cols[unfolding_column + 1:]
21 )
22 )
19 out.close() 23 out.close()