Mercurial > repos > dfornika > snippy
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/snippy_core_wrapper.py Fri Mar 08 20:46:56 2019 -0500 @@ -0,0 +1,44 @@ +#!/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 argparse +import os +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) + copyfile(input_dataset, base_name) + subprocess.Popen(['tar', '-xf', base_name]).wait() + + extracted_dirs = [f for f in os.listdir('.') if os.path.isdir(f) ] + for extracted_dir in extracted_dirs: + snippy_core_command_line.append(extracted_dir) + + subprocess.Popen(snippy_core_command_line).wait() + + +if __name__ == '__main__': + main()