diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emboss_format_corrector.py	Fri Aug 12 19:17:10 2016 -0400
@@ -0,0 +1,50 @@
+#EMBOSS format corrector
+
+import operator
+
+#Properly set file formats before job run
+def exec_before_job( app, inp_data=None, out_data=None, tool=None, param_dict=None ):
+    #why isn't items an ordered list?
+    items = out_data.items()
+    #lets sort it ourselves....
+    items = sorted(items, key=operator.itemgetter(0))
+    #items is now sorted...
+    
+    #normal filetype correction
+    data_count=1
+    for name, data in items:
+        outputType = param_dict.get( 'out_format'+str(data_count), None )
+        #print "data_count",data_count, "name", name, "outputType", outputType
+        if outputType !=None:
+            if outputType == 'ncbi':
+                outputType = "fasta"
+            elif outputType == 'excel':
+                outputType = "tabular"
+            elif outputType == 'text':
+                outputType = "txt"
+            data = app.datatypes_registry.change_datatype(data, outputType)
+            app.model.context.add( data )
+            app.model.context.flush()
+        data_count+=1
+    
+    #html filetype correction
+    data_count=1
+    for name, data in items:
+        wants_plot = param_dict.get( 'html_out'+str(data_count), None )
+        ext = "html"
+        if wants_plot == "yes":
+            data = app.datatypes_registry.change_datatype(data, ext)
+            app.model.context.add( data )
+            app.model.context.flush()
+        data_count+=1
+    
+    #png file correction
+    data_count=1
+    for name, data in items:
+        wants_plot = param_dict.get( 'plot'+str(data_count), None )
+        ext = "png"
+        if wants_plot == "yes":
+            data = app.datatypes_registry.change_datatype(data, ext)
+            app.model.context.add( data )
+            app.model.context.flush()
+        data_count+=1