Mercurial > repos > devteam > emboss_5
annotate emboss_format_corrector.py @ 10:9b98d3d903c6 draft
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
author | devteam |
---|---|
date | Fri, 12 Aug 2016 19:17:10 -0400 |
parents | |
children | 0e2484b6829b |
rev | line source |
---|---|
10
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
1 #EMBOSS format corrector |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
2 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
3 import operator |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
4 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
5 #Properly set file formats before job run |
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 ): |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
7 #why isn't items an ordered list? |
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 #lets sort it ourselves.... |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
10 items = sorted(items, key=operator.itemgetter(0)) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
11 #items is now sorted... |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
12 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
13 #normal filetype correction |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
14 data_count=1 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
15 for name, data in items: |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
16 outputType = param_dict.get( 'out_format'+str(data_count), None ) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
17 #print "data_count",data_count, "name", name, "outputType", outputType |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
18 if outputType !=None: |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
19 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
|
20 outputType = "fasta" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
21 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
|
22 outputType = "tabular" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
23 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
|
24 outputType = "txt" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
25 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
|
26 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
|
27 app.model.context.flush() |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
28 data_count+=1 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
29 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
30 #html filetype correction |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
31 data_count=1 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
32 for name, data in items: |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
33 wants_plot = param_dict.get( 'html_out'+str(data_count), None ) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
34 ext = "html" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 app.model.context.flush() |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
39 data_count+=1 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
40 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
41 #png file correction |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
42 data_count=1 |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
43 for name, data in items: |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
44 wants_plot = param_dict.get( 'plot'+str(data_count), None ) |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
45 ext = "png" |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 app.model.context.flush() |
9b98d3d903c6
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/emboss_5 commit fc158bfe5f5927dc199321a2cf43310373cbc8ba
devteam
parents:
diff
changeset
|
50 data_count+=1 |