Mercurial > repos > bgruening > text_processing
annotate unfold_column.py @ 13:0a8c6b61f0f4 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:01 -0400 |
parents | 37e1eb05b1b4 |
children | f46f0e4f75c4 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
2 | |
3 import sys | |
4 | |
5 out = open(sys.argv[4], 'w+') | |
6 | |
3
37e1eb05b1b4
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
0
diff
changeset
|
7 sep = sys.argv[3] |
37e1eb05b1b4
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
0
diff
changeset
|
8 # un-sanitize Galaxy inputs |
37e1eb05b1b4
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
0
diff
changeset
|
9 if sep == 'X': |
37e1eb05b1b4
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
0
diff
changeset
|
10 sep = ';' |
37e1eb05b1b4
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
0
diff
changeset
|
11 |
0 | 12 with open(sys.argv[1]) as handle: |
13 for line in handle: | |
14 cols = line.split('\t') | |
15 unfolding_column = int(sys.argv[2]) - 1 | |
16 column_content = cols[ unfolding_column ] | |
3
37e1eb05b1b4
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 10052765d6b712cf7d38356af4251fcc38a339b6-dirty
bgruening
parents:
0
diff
changeset
|
17 for elem in column_content.split( sep ): |
0 | 18 out.write( '\t'.join( cols[:unfolding_column] + [elem] + cols[unfolding_column+1:]) ) |
19 out.close() |