annotate unfold_column.py @ 21:86755160afbf draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit c2b1677d1c94433f777c2dc28ac8eec0a99cc6a7
author bgruening
date Fri, 16 Aug 2024 10:41:54 +0000
parents f46f0e4f75c4
children
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
17
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
5 out = open(sys.argv[4], "w+")
0
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
17
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
9 if sep == "X":
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
10 sep = ";"
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
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:
17
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
14 cols = line.split("\t")
0
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
15 unfolding_column = int(sys.argv[2]) - 1
17
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
16 column_content = cols[unfolding_column]
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
17 for elem in column_content.split(sep):
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
18 out.write(
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
19 "\t".join(
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
20 cols[:unfolding_column] + [elem] + cols[unfolding_column + 1:]
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
21 )
f46f0e4f75c4 "planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 5f5d5802a961a77ceb092cbdef90d93e29717029-dirty"
bgruening
parents: 3
diff changeset
22 )
0
5314e5d6f040 Imported from capsule None
bgruening
parents:
diff changeset
23 out.close()