Mercurial > repos > stevecassidy > ziptools
changeset 0:fe887de9b4b5 draft
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
author | stevecassidy |
---|---|
date | Thu, 16 Nov 2017 06:19:53 -0500 |
parents | |
children | 278da6e5ab11 |
files | zipcollection.py zipcollection.xml |
diffstat | 2 files changed, 59 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zipcollection.py Thu Nov 16 06:19:53 2017 -0500 @@ -0,0 +1,28 @@ +from __future__ import print_function +import argparse +from zipfile import ZipFile + +def parser(): + parser = argparse.ArgumentParser(description="Find matching segments in a TextGrid") + parser.add_argument('--dataset', required=True, action="store", type=str, help="TextGrid files (comma separated)") + parser.add_argument('--identifier', required=True, action="store", type=str, help="Dataset identifiers (comma separated)") + parser.add_argument('--output', required=True, action="store", type=str, help="Path to output file") + return parser.parse_args() + + +def main(): + args = parser() + + datasets = args.dataset.split(',') + identifiers = args.identifier.split(',') + assert len(datasets) == len(identifiers), "number of datasets must match number of identifiers" + + pairs = zip(datasets, identifiers) + + with ZipFile(args.output, 'w') as zipfile: + for dataset, identifier in pairs: + zipfile.write(dataset, identifier) + + +if __name__ == '__main__': + main()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zipcollection.xml Thu Nov 16 06:19:53 2017 -0500 @@ -0,0 +1,31 @@ +<tool id="zipcollection" name="Create a Zip file" version="0.01"> + <description>from one or more datasets</description> + + <command interpreter="python"> + zipcollection.py --dataset "${",".join(map(str, $dataset))}" --identifier "${",".join(map(str, [t.element_identifier + "." + t.extension for t in $dataset]))}" --output $output + </command> + + <inputs> + <param name="dataset" format="data" type="data" + multiple="true" label="DataSets" help="Datasets to include in zip"/> + <param name="job_name" type="text" size="25" + label="Name of output zip file" value="dataset"/> + </inputs> + + <outputs> + <data format="zip" name="output" label="$job_name" /> + </outputs> + + <tests> + <!-- can't compare zip file as it changes based on time the test is run + <test> + <param name="dataset" value="textgrids/1_1308_2_22_020-ch6-speaker16.TextGrid_TextGrid"/> + <param name="job_name" value="test.zip"/> + <output name="output" ftype="zip"/> + </test> + --> + </tests> + + <help>Creates a zip file from a dataset or dataset collection</help> + +</tool>