Mercurial > repos > devteam > emboss_5
annotate emboss_format_corrector.py @ 13:d5c3794bd246 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit ca9a6baaede679d619675e48d665748a91950115
author | iuc |
---|---|
date | Mon, 23 Apr 2018 13:04:47 -0400 |
parents | 0e2484b6829b |
children | c2228166c035 |
rev | line source |
---|---|
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
1 # EMBOSS format corrector |
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
2 import operator |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
3 |
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
4 |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
5 # Properly set file formats before job run |
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
6 def exec_before_job( app, inp_data=None, out_data=None, tool=None, param_dict=None ): |
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
7 # why isn't items an ordered list? |
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
8 items = out_data.items() |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
9 items = sorted(items, key=operator.itemgetter(0)) |
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
10 |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
11 # normal filetype correction |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
12 data_count = 1 |
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
13 for name, data in items: |
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
14 outputType = param_dict.get( 'out_format' + str(data_count), None ) |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
15 if outputType is not None: |
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
16 if outputType == 'ncbi': |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
17 outputType = "fasta" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
18 elif outputType == 'excel': |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
19 outputType = "tabular" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
20 elif outputType == 'text': |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
21 outputType = "txt" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
22 data = app.datatypes_registry.change_datatype(data, outputType) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
23 app.model.context.add( data ) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
24 app.model.context.flush() |
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
25 data_count += 1 |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
26 |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
27 # html filetype correction |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
28 data_count = 1 |
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
29 for name, data in items: |
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
30 wants_plot = param_dict.get( 'html_out' + str(data_count), None ) |
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
31 ext = "html" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
32 if wants_plot == "yes": |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
33 data = app.datatypes_registry.change_datatype(data, ext) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
34 app.model.context.add( data ) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
35 app.model.context.flush() |
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
36 data_count += 1 |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
37 |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
38 # png file correction |
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
39 data_count = 1 |
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
40 for name, data in items: |
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
41 wants_plot = param_dict.get( 'plot' + str(data_count), None ) |
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
42 ext = "png" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
43 if wants_plot == "yes": |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
44 data = app.datatypes_registry.change_datatype(data, ext) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
45 app.model.context.add( data ) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
46 app.model.context.flush() |
11
0e2484b6829b
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/emboss_5 commit b583bbeb8fc90cd4b1e987a56982e7cf4aed1a68
iuc
parents:
10
diff
changeset
|
47 data_count += 1 |