view STACKS_clone_filter.py @ 0:42e64fbf4609 draft

planemo upload commit 60a090d1dc89c2eb383feeb35cd6078b9130e0e5-dirty
author tiagoantao
date Tue, 02 Feb 2016 21:15:50 -0500
parents
children 1a5ebb16aaea
line wrap: on
line source

#!/usr/bin/python
# -*- coding: utf-8 -*-

import shutil
import subprocess
import argparse


def __main__():
    parser = argparse.ArgumentParser()
    parser.add_argument('-f', type=str)
    parser.add_argument('-fwd', type=str)
    parser.add_argument('-rev', type=str)

    #parser.add_argument('-k', action='store_true')

    options = parser.parse_args()

    # create the working dir
    os.mkdir('job_outputs')
    os.chdir('job_outputs')

    # STACKS_archive
    # check if zipped files are into the tab
    extract_compress_files(options.P, os.getcwd())

    # create the populations command input line
    cmd_line=['clone_filter']
    if options.f is not None:
        cmd_line.extend(['-f', options.f])
    else:
        cmd_line.extend(['-1', options.fwd])
        cmd_line.extend(['-2', options.rev])

    print "[CMD]:"+' '.join(cmd_line)
    subprocess.call(cmd_line)

    # postprocesses
    clean_files = glob.glob('*.fq')
    if options.f is not None:
        shutil.copy(clean_files[0], 'clean.fq')
    else:
        shutil.copy(clean_files[0], 'fwd.fq')
        shutil.copy(clean_files[1], 'rev.fq')


if __name__ == '__main__':
    __main__()