Proposal to add a "format_source" attribute to the ToolConfig output data element
I would like to propose adding a "format_source" attribute to the tool_config output data element. This would be a backward compatible change. It is analogous to the "metadata_source" attribute. Motivation: It is often convenient to have an output dataset inherit the format of an input dataset. The format="input" convention only works in the limited case when the 'last' input dataset is the single format one wants to reference. Using an explicit attribute "format_source" to pair an output dataset format to an input dataset format allows for multiple use and is not order dependent. While the "change_format" element can do also accomplish this, it requires more code. A "format_source" attribute is simpler and cleaner. Example: <inputs> <param name="fasta_in" type="data" format="fasta,align" optional="true" label="fasta - Fasta Sequences"/> <param name="qfile_in" type="data" format="qual,qual454,qualsolexa,qualillumina,qualsolid" optional="true" label="qfile - Fasta Quality"/> </inputs> <outputs> <!-- Using format_source --> <data format_source="fasta_in" metadata_source="fasta_in" name="fasta_out" label="${tool.name} on ${on_string}: pick.${fasta_in.datatype.file_ext}"> <filter>fasta_in != None</filter> </data> <!-- Using change_format to accomplish the the inheritance --> <data format="qual" name="qfile_out" label="${tool.name} on ${on_string}: pick.${fasta_in.datatype.file_ext}"> <filter>qfile_in != None</filter> <change_format> <when input="${qfile_in.datatype.file_ext}" value="qual454" format="qual454" /> <when input="${qfile_in.datatype.file_ext}" value="qualsolexa" format="qualsolexa" /> <when input="${qfile_in.datatype.file_ext}" value="qualillumina" format="qualillumina" /> <when input="${qfile_in.datatype.file_ext}" value="qualsolid" format="qualsolid" /> </change_format> </data> <outputs> Code changes: $ hg diff lib/galaxy/tools/__init__.py diff -r 36c27bfbb7a8 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py Tue Feb 08 15:21:19 2011 -0500 +++ b/lib/galaxy/tools/__init__.py Tue Feb 08 15:06:12 2011 -0600 @@ -249,10 +249,11 @@ (format, metadata_source, parent) """ - def __init__( self, name, format=None, metadata_source=None, + def __init__( self, name, format=None, format_source=None, metadata_source=None, parent=None, label=None, filters = None, actions = None ): self.name = name self.format = format + self.format_source = format_source self.metadata_source = metadata_source self.parent = parent self.label = label @@ -558,6 +559,7 @@ for data_elem in out_elem.findall("data"): output = ToolOutput( data_elem.get("name") ) output.format = data_elem.get("format", "data") + output.format_source = data_elem.get("format_source", "") output.change_format = data_elem.findall("change_format") output.metadata_source = data_elem.get("metadata_source", "") output.parent = data_elem.get("parent", None) $ hg diff lib/galaxy/tools/actions/__init__.py diff -r 36c27bfbb7a8 lib/galaxy/tools/actions/__init__.py --- a/lib/galaxy/tools/actions/__init__.py Tue Feb 08 15:21:19 2011 -0500 +++ b/lib/galaxy/tools/actions/__init__.py Tue Feb 08 15:39:21 2011 -0600 @@ -244,6 +244,11 @@ ext = output.format if ext == "input": ext = input_ext + if output.format_source != None and output.format_source in inp_data: + try: + ext = inp_data[output.format_source].ext + except Exception, e: + pass #process change_format tags if output.change_format: if params is None: And the hardest part would be the documentation change to: https://bitbucket.org/galaxy/galaxy-central/wiki/ToolConfigSyntax
participants (1)
-
Jim Johnson