mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Allow dbkey filtering of multiple input targets.
Fixes #388. Includes a test case.
This commit is contained in:
@@ -127,9 +127,26 @@ class DataMetaFilter( Filter ):
|
||||
return file_value == dataset_value
|
||||
assert self.ref_name in other_values or ( trans is not None and trans.workflow_building_mode), "Required dependency '%s' not found in incoming values" % self.ref_name
|
||||
ref = other_values.get( self.ref_name, None )
|
||||
if not isinstance( ref, self.dynamic_option.tool_param.tool.app.model.HistoryDatasetAssociation ) and not isinstance( ref, galaxy.tools.wrappers.DatasetFilenameWrapper ):
|
||||
is_data = isinstance( ref, galaxy.tools.wrappers.DatasetFilenameWrapper )
|
||||
is_data_list = isinstance( ref, galaxy.tools.wrappers.DatasetListWrapper ) or isinstance( ref, list )
|
||||
is_data_or_data_list = is_data or is_data_list
|
||||
if not isinstance( ref, self.dynamic_option.tool_param.tool.app.model.HistoryDatasetAssociation ) and not is_data_or_data_list:
|
||||
return [] # not a valid dataset
|
||||
meta_value = ref.metadata.get( self.key, None )
|
||||
|
||||
if is_data_list:
|
||||
meta_value = None
|
||||
for single_ref in ref:
|
||||
this_meta_value = single_ref.metadata.get( self.key, None )
|
||||
if this_meta_value == meta_value:
|
||||
continue
|
||||
elif meta_value is None:
|
||||
meta_value = this_meta_value
|
||||
else:
|
||||
# Different values with mismatching metadata, return []
|
||||
return []
|
||||
else:
|
||||
meta_value = ref.metadata.get( self.key, None )
|
||||
|
||||
if meta_value is None: # assert meta_value is not None, "Required metadata value '%s' not found in referenced dataset" % self.key
|
||||
return [ ( disp_name, basic.UnvalidatedValue( optval ), selected ) for disp_name, optval, selected in options ]
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<tool id="dbkey_filter_multi_input" name="dbkey_filter_multi_input" version="0.1.0">
|
||||
<description>Filter select on dbkey of multiple inputs</description>
|
||||
<command><![CDATA[
|
||||
#for $input in $inputs#
|
||||
cat $input >> $output;
|
||||
#end for#
|
||||
]]>
|
||||
</command>
|
||||
<inputs>
|
||||
<param format="txt" name="inputs" type="data" label="Inputs" multiple="true" help="" />
|
||||
<param name="index" type="select" label="Using reference genome">
|
||||
<options from_data_table="test_fasta_indexes">
|
||||
<filter type="data_meta" ref="inputs" 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="output" />
|
||||
</outputs>
|
||||
|
||||
<tests>
|
||||
<!-- can choose a dbkey if it matches input -->
|
||||
<test>
|
||||
<param name="inputs" value="simple_line.txt,simple_line.txt" dbkey="hg19" />
|
||||
<param name="index" value="hg19" />
|
||||
<output name="output" file="simple_line_x2.txt"/>
|
||||
</test>
|
||||
</tests>
|
||||
|
||||
<help>
|
||||
</help>
|
||||
</tool>
|
||||
@@ -17,6 +17,7 @@
|
||||
<tool file="multi_output_configured.xml" />
|
||||
<tool file="multi_output_assign_primary.xml" />
|
||||
<tool file="dbkey_filter_input.xml" />
|
||||
<tool file="dbkey_filter_multi_input.xml" />
|
||||
<tool file="composite_output.xml" />
|
||||
<tool file="metadata.xml" />
|
||||
<tool file="metadata_bam.xml" />
|
||||
|
||||
Reference in New Issue
Block a user