Merge pull request #11514 from kxk302/csv_columns

Handle the case where column list is a comma-separated string
This commit is contained in:
John Chilton
2021-03-04 09:41:30 -05:00
committed by GitHub
4 changed files with 97 additions and 3 deletions
+6 -3
View File
@@ -1361,9 +1361,12 @@ class ColumnListParameter(SelectToolParameter):
legal_values = self.get_column_list(trans, other_values)
value = other_values.get(self.name)
if value is not None and value not in legal_values and self.is_file_empty(trans, other_values):
value = value if isinstance(value, list) else [value]
legal_values.extend(value)
if value is not None:
# There are cases where 'value' is a string of comma separated values. This ensures
# that it is converted into a list, with extra whitespace around items removed.
value = util.listify(value, do_strip=True)
if not set(value).issubset(set(legal_values)) and self.is_file_empty(trans, other_values):
legal_values.extend(value)
return set(legal_values)
+40
View File
@@ -1193,6 +1193,46 @@ steps:
invocation_id = self.__invoke_workflow(history_id, workflow_id, inputs)
self.wait_for_invocation_and_jobs(history_id, workflow_id, invocation_id)
@skip_without_tool('column_param')
def test_empty_file_data_column_specified(self):
# Regression test for https://github.com/galaxyproject/galaxy/pull/10981
with self.dataset_populator.test_history() as history_id:
self._run_jobs("""class: GalaxyWorkflow
steps:
empty_output:
tool_id: empty_output
outputs:
out_file1:
change_datatype: tabular
column_param:
tool_id: column_param
in:
input1: empty_output/out_file1
state:
col: 2
col_names: 'B'
""", history_id=history_id)
@skip_without_tool('column_param_list')
def test_comma_separated_columns(self):
# Regression test for https://github.com/galaxyproject/galaxy/pull/10981
with self.dataset_populator.test_history() as history_id:
self._run_jobs("""class: GalaxyWorkflow
steps:
empty_output:
tool_id: empty_output
outputs:
out_file1:
change_datatype: tabular
column_param_list:
tool_id: column_param_list
in:
input1: empty_output/out_file1
state:
col: '2,3'
col_names: 'B'
""", history_id=history_id)
@skip_without_tool("mapper")
@skip_without_tool("pileup")
def test_workflow_metadata_validation_0(self):
@@ -0,0 +1,50 @@
<tool id="column_param_list" name="Column Param List" version="1.0.0">
<command><![CDATA[
cut -f '$col' '$input1' > '$output1' &&
echo "col $col" > '$output2' &&
echo "col_names $col_names" >> '$output2'
]]></command>
<inputs>
<param name="input1" type="data" format="tabular" label="Input 1" />
<param name="col" type="data_column" multiple="true" value="1" data_ref="input1" label="Column to Use" />
<param name="col_names" type="data_column" data_ref="input1" use_header_names="true" label="Column to Use" />
</inputs>
<outputs>
<data name="output1" format="tabular" />
<data name="output2" format="txt" />
</outputs>
<tests>
<test>
<param name="input1" value="2.tabular" />
<param name="col" value="2" />
<param name="col_names" value="2" />
<output name="output1">
<assert_contents>
<has_line line="68" />
</assert_contents>
</output>
<output name="output2">
<assert_contents>
<has_line line="col 2" />
<has_line line="col_names 2" />
</assert_contents>
</output>
</test>
<!-- test if non tabular data also creates entries by using the default
value (which is the 1st column, but empty if filling the options fails) -->
<test>
<param name="input1" value="1.bed" />
<output name="output1">
<assert_contents>
<has_line line="chr1" />
</assert_contents>
</output>
<output name="output2">
<assert_contents>
<has_line line="col 1" />
<has_line line="col_names 1" />
</assert_contents>
</output>
</test>
</tests>
</tool>
@@ -114,6 +114,7 @@
<tool file="param_text_option.xml" />
<tool file="column_param.xml" />
<tool file="column_param_configfile.xml" />
<tool file="column_param_list.xml" />
<tool file="column_multi_param.xml" />
<tool file="hidden_param.xml" />
<tool file="special_params.xml" />