/tools/emboss_5/emboss_format_corrector.py

https://bitbucket.org/cistrome/cistrome-harvard/ · Python · 53 lines · 36 code · 5 blank · 12 comment · 9 complexity · 04460cb400af133c4c7248106669b5b7 MD5 · raw file

  1. #EMBOSS format corrector
  2. import operator
  3. #from galaxy import datatypes
  4. #Properly set file formats after job run
  5. def exec_after_process( app, inp_data, out_data, param_dict,tool, stdout, stderr):
  6. #Properly set file formats before job run
  7. #def exec_before_job(trans, inp_data, out_data, param_dict,tool):
  8. #why isn't items an ordered list?
  9. items = out_data.items()
  10. #lets sort it ourselves....
  11. items = sorted(items, key=operator.itemgetter(0))
  12. #items is now sorted...
  13. #normal filetype correction
  14. data_count=1
  15. for name, data in items:
  16. outputType = param_dict.get( 'out_format'+str(data_count), None )
  17. #print "data_count",data_count, "name", name, "outputType", outputType
  18. if outputType !=None:
  19. if outputType == 'ncbi':
  20. outputType = "fasta"
  21. elif outputType == 'excel':
  22. outputType = "tabular"
  23. elif outputType == 'text':
  24. outputType = "txt"
  25. data = app.datatypes_registry.change_datatype(data, outputType)
  26. app.model.context.add( data )
  27. app.model.context.flush()
  28. data_count+=1
  29. #html filetype correction
  30. data_count=1
  31. for name, data in items:
  32. wants_plot = param_dict.get( 'html_out'+str(data_count), None )
  33. ext = "html"
  34. if wants_plot == "yes":
  35. data = app.datatypes_registry.change_datatype(data, ext)
  36. app.model.context.add( data )
  37. app.model.context.flush()
  38. data_count+=1
  39. #png file correction
  40. data_count=1
  41. for name, data in items:
  42. wants_plot = param_dict.get( 'plot'+str(data_count), None )
  43. ext = "png"
  44. if wants_plot == "yes":
  45. data = app.datatypes_registry.change_datatype(data, ext)
  46. app.model.context.add( data )
  47. app.model.context.flush()
  48. data_count+=1