Mercurial > repos > stevecassidy > ziptools
diff zipcollection.py @ 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 |
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()