Files
galaxy/test/functional/tools/column_param.xml
T
Matthias Bernt 2395e6579b column_parameter: use column_names metadata if present
makes column_parameter work for all datatypes setting column_names
and still fallback to try to take the first line (tab separated)

fixes: https://github.com/galaxyproject/galaxy/issues/17468
2024-02-15 16:08:46 +01:00

73 lines
2.6 KiB
XML

<tool id="column_param" name="Column Param" version="1.0.0">
<command><![CDATA[
cut
-f '$col'
#if $input1.is_of_type('csv')
-d','
#end if
'$input1' > '$output1' &&
echo "col $col" > '$output2' &&
echo "col_names $col_names" >> '$output2'
]]></command>
<inputs>
<param name="input1" type="data" format="tabular,csv" label="Input 1" />
<param name="col" type="data_column" 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>
<!-- test csv input -->
<test>
<param name="input1" value="1.csv" ftype="csv"/>
<param name="col" value="1" />
<param name="col_names" value="c1: Transaction_date" />
<output name="output1">
<assert_contents>
<has_line line="1/2/09 6:17" />
</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>