Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated merge of 'release_16.04' into 'release_16.07'. #5

Open
wants to merge 6 commits into
base: release_16.07
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/galaxy/tools/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def set_metadata_defaults( self, output, dataset, tool, on_text, trans, incoming
"""
if output.actions:
for action in output.actions.actions:
if action.tag == "metadata":
if action.tag == "metadata" and action.default:
metadata_new_value = fill_template( action.default, context=params ).split(",")
dataset.metadata.__setattr__(str(action.name), metadata_new_value)

Expand Down
9 changes: 9 additions & 0 deletions lib/galaxy/util/template.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
"""Entry point for the usage of Cheetah templating within Galaxy."""
from Cheetah.Template import Template


def fill_template( template_text, context=None, **kwargs ):
"""Fill a cheetah template out for specified context.

If template_text is None, an exception will be thrown, if context
is None (the default) - keyword arguments to this function will be used
as the context.
"""
if template_text is None:
raise TypeError("Template text specified as None to fill_template.")
if not context:
context = kwargs
return str( Template( source=template_text, searchList=[context] ) )
36 changes: 36 additions & 0 deletions test/functional/tools/dbkey_output_action.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<tool id="dbkey_output_action" name="dbkey_output_action" version="0.1.0">
<command>echo foo > $mapped_reads</command>
<inputs>
<param name="input" type="data" />
<param name="index" type="select" label="Using reference genome">
<options from_data_table="test_fasta_indexes">
<filter type="data_meta" ref="input" key="dbkey" column="1" />
<validator type="no_options" message="No reference genome is available for the build associated with the selected input dataset" />
</options>
</param>
</inputs>
<outputs>
<data format="txt" name="mapped_reads">
<actions>
<action type="metadata" name="dbkey">
<option type="from_data_table" name="test_fasta_indexes" column="1" offset="0">
<filter type="param_value" column="0" value="#" compare="startswith" keep="False"/>
<filter type="param_value" ref="index" column="0"/>
</option>
</action>
</actions>
</data>
</outputs>
<tests>
<test>
<param name="input" value="simple_line.txt" dbkey="hg18" />
<param name="index" value="hg18"/>
<output name="mapped_reads">
<metadata name="dbkey" value="hg18" />
<assert_contents>
<has_text text="foo" />
</assert_contents>
</output>
</test>
</tests>
</tool>
1 change: 1 addition & 0 deletions test/functional/tools/samples_tool_conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<tool file="inputs_as_json.xml" />
<tool file="dbkey_filter_input.xml" />
<tool file="dbkey_filter_multi_input.xml" />
<tool file="dbkey_output_action.xml" />
<tool file="composite_output.xml" />
<tool file="composite_output_tests.xml" />
<tool file="unicode_stream.xml" />
Expand Down