Mercurial > repos > dfornika > snippy
comparison snippy_core_wrapper.py @ 20:3bbfe41787af draft
planemo upload commit bf653fc1bf39312caf070843fbde7b2570330917-dirty
| author | dfornika |
|---|---|
| date | Fri, 08 Mar 2019 20:46:56 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 19:8a6b951f6ec2 | 20:3bbfe41787af |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 # -------------------------------------- | |
| 4 # | |
| 5 # snippy_core_wrapper.py | |
| 6 # | |
| 7 # This is an intermediary script between snippy-core.xml and snippy-core | |
| 8 # It: | |
| 9 # - Copys the supplied zipped snippy output files to the working dir | |
| 10 # - Untars them to their datafile name | |
| 11 # - Builds the snippy-core command | |
| 12 # - Runs the snippy-core command | |
| 13 # | |
| 14 # -------------------------------------- | |
| 15 | |
| 16 import argparse | |
| 17 import os | |
| 18 import subprocess | |
| 19 from shutil import copyfile | |
| 20 | |
| 21 | |
| 22 def main(): | |
| 23 | |
| 24 parser = argparse.ArgumentParser() | |
| 25 parser.add_argument('-r', '--ref', help='Reference fasta', required=True) | |
| 26 parser.add_argument('-i', '--indirs', help='Comma-separated list of input datasets') | |
| 27 args = parser.parse_args() | |
| 28 | |
| 29 snippy_core_command_line = ['snippy-core', '--ref', args.ref] | |
| 30 | |
| 31 for input_dataset in args.indirs.split(','): | |
| 32 base_name = os.path.basename(input_dataset) | |
| 33 copyfile(input_dataset, base_name) | |
| 34 subprocess.Popen(['tar', '-xf', base_name]).wait() | |
| 35 | |
| 36 extracted_dirs = [f for f in os.listdir('.') if os.path.isdir(f) ] | |
| 37 for extracted_dir in extracted_dirs: | |
| 38 snippy_core_command_line.append(extracted_dir) | |
| 39 | |
| 40 subprocess.Popen(snippy_core_command_line).wait() | |
| 41 | |
| 42 | |
| 43 if __name__ == '__main__': | |
| 44 main() |
