mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 13:50:20 +08:00
Datatypes are defined like: [galaxy:datatypes] bed = galaxy.datatypes.interval:Bed png = galaxy.datatypes.images:Image,image/png where the mime-type (default of text/plain) can be declared after the class name, as is seen with png.
45 lines
2.0 KiB
Python
45 lines
2.0 KiB
Python
#Code for direct connection to UCSC
|
|
from galaxy import datatypes
|
|
|
|
def exec_before_job( app, inp_data, out_data, param_dict, tool=None):
|
|
"""Sets the name of the data"""
|
|
outputType = param_dict.get( 'hgta_outputType', "interval" ).lower() #assume all data is interval, we will fix later if not the case
|
|
#list for converting ucsc to galaxy exts, if not in following dictionary, use provided datatype
|
|
outputType_to_ext = {'wigdata':'wig','tab':'interval','hyperlinks':'html','sequence':'fasta'}
|
|
items = out_data.items()
|
|
description = param_dict.get('hgta_regionType',"")
|
|
organism = param_dict.get('org',"unkown species")
|
|
table = param_dict.get('hgta_track',"")
|
|
if description == 'range':
|
|
try:
|
|
description = param_dict.get('position',"")
|
|
except:
|
|
description = "unkown position"
|
|
for name, data in items:
|
|
data.name = "%s on %s: %s (%s)" % (data.name, organism, table, description)
|
|
data.dbkey = param_dict.get('db', '?')
|
|
ext = outputType
|
|
try: ext = outputType_to_ext[outputType]
|
|
except: pass
|
|
if ext not in app.datatypes_registry.datatypes_by_extension: ext = 'interval'
|
|
data = app.datatypes_registry.change_datatype(data, ext)
|
|
|
|
#store ucsc parameters temporarily in output file
|
|
out = open(data.file_name,'w')
|
|
for key, value in param_dict.items():
|
|
print >> out, "%s\t%s" % (key,value)
|
|
out.close()
|
|
|
|
out_data[name] = data
|
|
|
|
def exec_after_process(app, inp_data, out_data, param_dict, tool=None, stdout=None, stderr=None):
|
|
"""Verifies the datatype after the run"""
|
|
name, data = out_data.items()[0]
|
|
if data.state == data.states.OK: data.info = data.name
|
|
|
|
if not isinstance(data.datatype, datatypes.interval.Bed) and isinstance(data.datatype, datatypes.interval.Interval):
|
|
data.set_meta()
|
|
if data.missing_meta(): data = app.datatypes_registry.change_datatype(data, 'tabular')
|
|
data.set_peek()
|
|
data.flush()
|