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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
1 #!/usr/bin/env python
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
2
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
3 import sys
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
4
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
5 out = open(sys.argv[4], 'w+')
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
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
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
12 with open(sys.argv[1]) as handle:
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
13 for line in handle:
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
14 cols = line.split('\t')
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
15 unfolding_column = int(sys.argv[2]) - 1
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
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
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
18 out.write( '\t'.join( cols[:unfolding_column] + [elem] + cols[unfolding_column+1:]) )
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
19 out.close()