Mercurial > repos > dfornika > snippy
view snippy_core_wrapper.py @ 16:a69f73853101 draft
planemo upload for repository https://github.com/tseemann/snippy commit 93b22331ca83a82fdfbe8f2b274577e21f9bf025-dirty
author | dfornika |
---|---|
date | Tue, 22 Jan 2019 13:52:10 -0500 |
parents | bf6dbc4d4957 |
children | 412683e7a8fe |
line wrap: on
line source
#!/usr/bin/env python #-------------------------------------- # # snippy_core_wrapper.py # # This is an intermediary script between snippy-core.xml and snippy-core # It: # - Copys the supplied zipped snippy output files to the working dir # - Untars them to their datafile name # - Builds the snippy-core command # - Runs the snippy-core command # #-------------------------------------- import os import sys import argparse import subprocess from shutil import copyfile def main(): parser = argparse.ArgumentParser() parser.add_argument('-r', '--ref', help='Reference fasta', required=True) parser.add_argument('-i', '--indirs', help='Comma-separated list of input datasets') args = parser.parse_args() snippy_core_command_line = ['snippy-core', '--ref', args.ref] for input_dataset in args.indirs.split(','): base_name = os.path.basename(input_dataset) print("base_name: " + base_name) copyfile(input_dataset, base_name) subprocess.Popen(['tar', '-xf', base_name]) extracted_dirs = [f for f in os.listdir('.') if os.path.isdir(f) ] print("extracted_dirs: " + str(extracted_dirs)) for extracted_dir in extracted_dirs: snippy_core_command_line.append(extracted_dir) print(str(snippy_core_command_line)) subprocess.Popen(snippy_core_command_line).wait() if __name__ == '__main__': main()