Mercurial > repos > nml > csvtk_collapse
diff collapse.xml @ 0:7ff05a1ffdd7 draft default tip
"planemo upload for repository https://github.com/shenwei356/csvtk commit 3a97e1b79bf0c6cdd37d5c8fb497b85531a563ab"
author | nml |
---|---|
date | Tue, 19 May 2020 17:18:56 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/collapse.xml Tue May 19 17:18:56 2020 -0400 @@ -0,0 +1,193 @@ +<tool id="csvtk_collapse" name="csvtk-collapse" version="@VERSION@+@GALAXY_VERSION@"> + <description> one field with selected fields as keys</description> + <macros> + <import>macros.xml</import> + </macros> + <expand macro="requirements" /> + <expand macro="version_cmd" /> + <command detect_errors="exit_code"><![CDATA[ + +################### +## Start Command ## +################### + +csvtk collapse --num-cpus "\${GALAXY_SLOTS:-1}" + + ## Add additional flags as specified ## + ####################################### + $ignore_case + $global_param.illegal_rows + $global_param.empty_rows + $global_param.header + $global_param.lazy_quotes + + ## Set Tabular input/output flag if input is tabular ## + ####################################################### + #if $in_1.is_of_type("tabular"): + -t -T + #end if + + ## Set Input ## + ############### + '$in_1' + + ## Specify fields for collapse ## + ################################# + -F -f '$column_text.in_text' + + ## other ## + ########### + -v '$value_column.in_text' + -s '$separator' + + ## To output ## + ############### + > collapsed + + ]]></command> + <inputs> + <expand macro="singular_input" /> + <expand macro="fields_input" /> + <conditional name="value_column" > + <param type="select" name="select" label="Select value column to collapse based on" argument="-v"> + <option value="string">Column Name</option> + <option value="column">Column Number</option> + </param> + <when value="column"> + <param type="data_column" name="in_text" + data_ref="in_1" + multiple="false" + label="Input column number" + help="Select column to collapse on" + /> + </when> + <when value="string"> + <param type="text" name="in_text" + optional="false" + label="Input column name" + help="Specify column name or number (ex. 1 for first column) to collapse on"> + <expand macro="text_sanitizer" /> + </param> + </when> + </conditional> + <param name="separator" type="text" value="; " argument="-s" + optional="false" + label="Separator string" + help="Input string of characters that will separate collapsed columns. The ' character is not allowed"> + <expand macro="text_sanitizer" /> + </param> + <expand macro="ignore_case" /> + <expand macro="global_parameters" /> + </inputs> + <outputs> + <data format_source="in_1" name="collapse" from_work_dir="collapsed" label="${in_1.name} with ${value_column.in_text} collapsed by ${column_text.in_text}" /> + </outputs> + <tests> + <test> + <param name="in_1" value="blood_type.tsv" /> + <conditional name="column_text"> + <param name="select" value="string" /> + <param name="in_text" value="2" /> + </conditional> + <conditional name="value_column"> + <param name="select" value="string" /> + <param name="in_text" value="1" /> + </conditional> + <param name="separator" value="; " /> + <output name="collapse" file="collapsed.tsv" ftype="tabular" /> + </test> + <test> + <param name="in_1" value="illegal.csv" /> + <conditional name="column_text"> + <param name="select" value="string" /> + <param name="in_text" value="4" /> + </conditional> + <conditional name="value_column"> + <param name="select" value="string" /> + <param name="in_text" value="1" /> + </conditional> + <param name="separator" value="; " /> + <section name="global_param"> + <param name="illegal_rows" value="true" /> + </section> + <output name="collapse" file="illegal_collapse.csv" /> + </test> + </tests> + <help><![CDATA[ + +Csvtk - Collapse Help +--------------------- + +Info +#### + +Csvtk collapse combines one field with selected fields as keys for what to combine + +.. class:: warningmark + + Single quotes are not allowed in text inputs! + +@HELP_INPUT_DATA@ + + +Usage +##### + +To run csvtk-collapse, all you need is a valid (as defined above) CSV or TSV file with a column you want to use +to collapse on based on any number of key column(s). + +**Example collapse with one key column** + +Input table: + ++--------+--------+----------+ +| Name | Colour | Food | ++========+========+==========+ +| Eric | Blue | Apples | ++--------+--------+----------+ +| Darian | Blue | Pancakes | ++--------+--------+----------+ +| Daniel | Red | Apples | ++--------+--------+----------+ +| Emily | Blue | Apples | ++--------+--------+----------+ + +Now if you wanted to find out who has the same favourite colour, you would specify the key column as "Colour" (-F -f) +and the value column as "Name" (-v) to generate the following table: + ++--------+---------------------+ +| Colour | Name | ++========+=====================+ +| Red | Daniel | ++--------+---------------------+ +| Blue | Eric; Darian; Emily | ++--------+---------------------+ + +-------- + +**Example collapse with two key columns** + +Same input table, now our key columns are "Colour" and "Food" which could be input as "2,3" (-F -f) +and the same value column which would generate the following table: + ++--------+----------+-------------+ +| Colour | Food | Name | ++========+==========+=============+ +| Blue | Pancakes | Darian | ++--------+----------+-------------+ +| Red | Apples | Daniel | ++--------+----------+-------------+ +| Blue | Apples | Eric; Emily | ++--------+----------+-------------+ + +---- + +@HELP_COLUMNS@ + + +@HELP_END_STATEMENT@ + + + ]]></help> + <expand macro="citations" /> +</tool> \ No newline at end of file