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