annotate emboss_format_corrector.py @ 1:40774082f93e draft default tip

"planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit 1a6cdd455506ca8013a089fdb64b75fb39d34856"
author brinkmanlab
date Tue, 25 Jan 2022 04:02:42 +0000
parents de3a45e9ccce
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
1 # EMBOSS format corrector
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
2 import operator
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
3
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
4
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
5 # Properly set file formats before job run
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
6 def exec_before_job(app, inp_data=None, out_data=None, tool=None, param_dict=None):
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
7 # why isn't items an ordered list?
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
8 items = out_data.items()
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
9 items = sorted(items, key=operator.itemgetter(0))
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
10
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
11 # normal filetype correction
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
12 data_count = 1
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
13 for name, data in items:
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
14 outputType = param_dict.get('out_format' + str(data_count), None)
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
15 if outputType is not None:
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
16 if outputType == 'ncbi':
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
17 outputType = "fasta"
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
18 elif outputType == 'excel':
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
19 outputType = "tabular"
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
20 elif outputType == 'text':
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
21 outputType = "txt"
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
22 data = app.datatypes_registry.change_datatype(data, outputType)
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
23 app.model.context.add(data)
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
24 app.model.context.flush()
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
25 data_count += 1
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
26
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
27 # html filetype correction
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
28 data_count = 1
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
29 for name, data in items:
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
30 wants_plot = param_dict.get('html_out' + str(data_count), None)
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
31 ext = "html"
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
32 if wants_plot == "yes":
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
33 data = app.datatypes_registry.change_datatype(data, ext)
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
34 app.model.context.add(data)
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
35 app.model.context.flush()
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
36 data_count += 1
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
37
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
38 # png file correction
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
39 data_count = 1
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
40 for name, data in items:
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
41 wants_plot = param_dict.get('plot' + str(data_count), None)
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
42 ext = "png"
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
43 if wants_plot == "yes":
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
44 data = app.datatypes_registry.change_datatype(data, ext)
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
45 app.model.context.add(data)
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
46 app.model.context.flush()
de3a45e9ccce "planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/emboss commit eaefd81cf7afec08ffc570ac53d6718d62743a99"
brinkmanlab
parents:
diff changeset
47 data_count += 1