Mercurial > repos > dfornika > snippy
view snippy_core_wrapper.py @ 7:ab3026667cdc draft
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
author | dfornika |
---|---|
date | Mon, 21 Jan 2019 18:17:52 -0500 |
parents | b9eacd069df6 |
children | c441153cb4c2 |
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', nargs='+') args = parser.parse_args() snippy_core_command_line = ['snippy-core', '--ref', args.ref] for indir in args.indirs.split(): base_name = os.path.basename(indir) sys.stderr.write(indir + '\n') copyfile(indir, base_name) sys.stderr.write('\n'.join([indir, base_name]) + '\n') subprocess.run(['tar', '-xf', base_name]) extracted_dirs = [f.path for f in os.scandir() if f.is_dir() ] for extracted_dir in extracted_dirs: snippy_core_command_line.append(extracted_dir) print(snippy_core_command_line) subprocess.run(snippy_core_command_line) if __name__ == '__main__': main()