Mercurial > repos > stevecassidy > ziptools
annotate 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 |
rev | line source |
---|---|
0
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
1 from __future__ import print_function |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
2 import argparse |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
3 from zipfile import ZipFile |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
4 |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
5 def parser(): |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
6 parser = argparse.ArgumentParser(description="Find matching segments in a TextGrid") |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
7 parser.add_argument('--dataset', required=True, action="store", type=str, help="TextGrid files (comma separated)") |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
8 parser.add_argument('--identifier', required=True, action="store", type=str, help="Dataset identifiers (comma separated)") |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
9 parser.add_argument('--output', required=True, action="store", type=str, help="Path to output file") |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
10 return parser.parse_args() |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
11 |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
12 |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
13 def main(): |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
14 args = parser() |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
15 |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
16 datasets = args.dataset.split(',') |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
17 identifiers = args.identifier.split(',') |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
18 assert len(datasets) == len(identifiers), "number of datasets must match number of identifiers" |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
19 |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
20 pairs = zip(datasets, identifiers) |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
21 |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
22 with ZipFile(args.output, 'w') as zipfile: |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
23 for dataset, identifier in pairs: |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
24 zipfile.write(dataset, identifier) |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
25 |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
26 |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
27 if __name__ == '__main__': |
fe887de9b4b5
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
stevecassidy
parents:
diff
changeset
|
28 main() |