Mercurial > repos > imgteam > unzip
diff unzip.xml @ 2:57f0914ddb7b draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tools/unzip/ commit a8d89b9ebc13951944dcec84323464692837bba7
author | imgteam |
---|---|
date | Fri, 14 Apr 2023 19:02:41 +0000 |
parents | 38eec75fbe9b |
children |
line wrap: on
line diff
--- a/unzip.xml Fri Aug 02 07:21:01 2019 -0400 +++ b/unzip.xml Fri Apr 14 19:02:41 2023 +0000 @@ -1,88 +1,125 @@ -<tool id="unzip" name="Unzip" version="0.2"> - <description>Unzip file</description> - <requirements> - <requirement type="package">unzip</requirement> - <requirement type="package">tar</requirement> - </requirements> - <command> - <![CDATA[ +<tool id="unzip" name="Unzip" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@"> + <description>Unzip a file</description> + <macros> + <token name="@TOOL_VERSION@">6.0</token> + <token name="@VERSION_SUFFIX@">0</token> + <token name="@PROFILE@">22.01</token> + </macros> + <requirements> + <requirement type="package" version="@TOOL_VERSION@">unzip</requirement> + <requirement type="package" version="1.34">tar</requirement> + </requirements> + <command> + <![CDATA[ mkdir ./out && #if $input_file.is_of_type("zip"): - unzip - #if $extract_options['extract_all'] == 'False' - -p "$input_file" "$extract_options['pathtofile']" > out.data - #else - "$input_file" -d out/ - #end if + unzip + #if $extract_options['extract_all'] == 'False' + -p '$input_file' '$extract_options["pathtofile"]' > out.data + #else + '$input_file' -d out/ + #end if #end if #if $input_file.is_of_type("tar"): - tar - #if $extract_options['extract_all'] == 'False' - xfO "$input_file" "$extract_options['pathtofile']" > out.data - #else - -xf "$input_file" -C ./out/ - #end if + tar + #if $extract_options['extract_all'] == 'False' + xfO '$input_file' '$extract_options["pathtofile"]' > out.data + #else + -xf '$input_file' -C ./out/ + #end if #end if - ]]> - </command> - <inputs> - <param label="input_file" name="input_file" type="data" format="zip,tar"/> - <conditional name="extract_options"> - <param label="Extract single file" name="extract_all" type="select"> - <option selected="True" value="True">All files</option> - <option value="False">Single file</option> - </param> - <when value="True"></when> - <when value="False"> - <param name="pathtofile" type="text" value="" label="Filepath"> - <validator type="expression" message="No two dots (..) allowed">'..' not in value</validator> - <validator type="expression" message="No comma (,) allowed">',' not in value</validator> - <validator type="expression" message="No asterisk (*) allowed">'*' not in value</validator> - <validator type="expression" message="No leading slash (/) allowed">str(value)[0] != '/'</validator> - </param> - </when> - </conditional> - </inputs> - <outputs> - <data auto_format="true" name="unzipped_single" from_work_dir="out.data"> - <filter>extract_options['extract_all'] == 'False'</filter> + && + + ## Flatten any potential directory structure, e.g. + ## out/sub1/subsub2/fileA.ext -> out/sub1_subsub2_fileA.ext + find out -type f | cut -d '/' -f 2- | grep '/' | xargs -I % sh -c "mv out/% out/\\$(echo % | tr / _)" + ]]> + </command> + <inputs> + <param label="input_file" name="input_file" type="data" format="zip,tar"/> + <conditional name="extract_options"> + <param label="Extract single file" name="extract_all" type="select"> + <option selected="True" value="True">All files</option> + <option value="False">Single file</option> + </param> + <when value="True"></when> + <when value="False"> + <param name="pathtofile" type="text" value="" label="Filepath"> + <validator type="expression" message="No two dots (..) allowed">'..' not in value</validator> + <validator type="expression" message="No comma (,) allowed">',' not in value</validator> + <validator type="expression" message="No asterisk (*) allowed">'*' not in value</validator> + <validator type="expression" message="No leading slash (/) allowed">str(value)[0] != '/'</validator> + </param> + </when> + </conditional> + </inputs> + <outputs> + <data auto_format="true" name="unzipped_single" from_work_dir="out.data" label="${tool.name} on ${on_string}"> + <filter>extract_options['extract_all'] == 'False'</filter> </data> - <collection name="unzipped" type="list" label="${tool.name} on ${on_string}"> - <discover_datasets pattern="__designation_and_ext__" directory="out" visible="false" format="auto" /> - <filter>extract_options['extract_all'] == 'True'</filter> + <collection name="unzipped" type="list" label="${tool.name} on ${on_string} all files as collection"> + <discover_datasets directory="out" pattern="(?P<designation>.+?)(\.(?P<ext>[^\._]+))?$" visible="false" format="auto"/> + <!-- pattern=__designation_and_ext__ = (?P<designation>.*)\.(?P<ext>[^\._]+)? would discard files without extensions --> + <filter>extract_options['extract_all'] == 'True'</filter> </collection> - </outputs> - <tests> - <test> + </outputs> + <tests> + <test expect_num_outputs="1"> <param name="input_file" value="input.zip" ftype="zip"/> <param name="extract_all" value="False"/> <param name="pathtofile" value="input.png"/> - <output name="unzipped_single" file="input.png" ftype="png" compare="sim_size" /> + <output name="unzipped_single" file="input.png" ftype="png" compare="sim_size"/> </test> - <test> + <test expect_num_outputs="1"> <param name="input_file" value="input.zip" ftype="zip"/> <param name="extract_all" value="True"/> - <output_collection name="unzipped" type="list"> + <output_collection name="unzipped" type="list" count="2"> <element name="input" file="input.png" ftype="png" compare="sim_size"/> <element name="res" file="res.tiff" ftype="tiff" compare="sim_size"/> </output_collection> </test> - <test> + <!-- Binary files without file extension --> + <test expect_num_outputs="1"> + <param name="input_file" value="input_binary.zip" ftype="zip"/> + <param name="extract_all" value="True"/> + <output_collection name="unzipped" type="list" count="2"> + <element name="yelp" file="yelp" compare="sim_size"/> + <element name="yes" file="yes" compare="sim_size"/> + </output_collection> + </test> + <!-- Compressed object with subfolders, each containing files --> + <test expect_num_outputs="1"> + <param name="input_file" value="subfolders.zip" ftype="zip"/> + <param name="extract_all" value="True"/> + <output_collection name="unzipped" type="list" count="4"> + <element name="binaries_yelp" file="yelp" compare="sim_size"/> + <element name="binaries_yes" file="yes" compare="sim_size"/> + <element name="images_input" file="input.png" ftype="png" compare="sim_size"/> + <element name="images_res" file="res.tiff" ftype="tiff" compare="sim_size"/> + </output_collection> + </test> + <test expect_num_outputs="1"> + <param name="input_file" value="input.tar" ftype="tar"/> + <param name="extract_all" value="False"/> + <param name="pathtofile" value="input.png"/> + <output name="unzipped_single" file="input.png" ftype="png" compare="sim_size"/> + </test> + <test expect_num_outputs="1"> <param name="input_file" value="input.tar" ftype="tar"/> <param name="extract_all" value="True"/> - <output_collection name="unzipped" type="list"> + <output_collection name="unzipped" type="list" count="2"> <element name="input" file="input.png" ftype="png" compare="sim_size"/> <element name="res" file="res.tiff" ftype="tiff" compare="sim_size"/> </output_collection> </test> - </tests> - <help> - **What it does** - - Unzip folder to collection. - </help> - <citations> - <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> - </citations> + </tests> + <help> + **What it does** + + Unzip a folder containing file(s) of various types. If multiple files are asked to be retained, the output will be a collection containing all files within the zip or tar archive. + </help> + <citations> + <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> + </citations> </tool>