# Path: ob_pipelines/s3.py
# SCRATCH_DIR = os.environ.get('SCRATCH_DIR') or '/tmp'
# def csv_to_s3(df, s3_path, **kwargs):
# def create_tmp_from_key(key): 
# def path_to_bucket_and_key(path):
# def key_exists(bucket, key):
# def download_folder(bucket, prefix, folder):
# def upload_folder(folder, bucket, prefix):
# def upload_prefix(local_prefix, s3_prefix, fpath_templates):
# def download_file_or_folder(s3_path, local_path):
# def upload_file_or_folder(s3_path, local_path):
# def remove_file_or_folder(fpath):
# def swap_args(args, rm_local_outpath=False):
# def s3args(rm_local_outpath=False):
#     def s3args_decorator(f):
#         def local_fn(*args, **kwargs):
# def s3wrap():
#     def sync_and_run(*cmds):


import os
import os.path as op
import click
from subprocess import check_output
from ob_pipelines import s3
"""BWA wrapper scripts"""

SCRATCH_DIR = os.environ['SCRATCH_DIR']



@s3.s3args()
def samse_s3_enabled(threads, reference, fq, bam):
    """Run aln followed by samse and sam > bam"""
    tmp_prefix = op.join(SCRATCH_DIR, op.basename(fq))
    cmd = """
        bwa aln -t {threads} {ref} {fq} > {tmp}.sai && \

# Path: ob_pipelines/s3.py
# SCRATCH_DIR = os.environ.get('SCRATCH_DIR') or '/tmp'
# def csv_to_s3(df, s3_path, **kwargs):
# def create_tmp_from_key(key): 
# def path_to_bucket_and_key(path):
# def key_exists(bucket, key):
# def download_folder(bucket, prefix, folder):
# def upload_folder(folder, bucket, prefix):
# def upload_prefix(local_prefix, s3_prefix, fpath_templates):
# def download_file_or_folder(s3_path, local_path):
# def upload_file_or_folder(s3_path, local_path):
# def remove_file_or_folder(fpath):
# def swap_args(args, rm_local_outpath=False):
# def s3args(rm_local_outpath=False):
#     def s3args_decorator(f):
#         def local_fn(*args, **kwargs):
# def s3wrap():
#     def sync_and_run(*cmds):


# Path: ob_pipelines/apps/bwa/bwa.py
import os
import os.path as op
import click
from subprocess import check_output
from ob_pipelines import s3

"""BWA wrapper scripts"""

SCRATCH_DIR = os.environ['SCRATCH_DIR']



@s3.s3args()
def samse_s3_enabled(threads, reference, fq, bam):
    """Run aln followed by samse and sam > bam"""
    tmp_prefix = op.join(SCRATCH_DIR, op.basename(fq))
    cmd = """
        bwa aln -t {threads} {ref} {fq} > {tmp}.sai && \

        bwa samse {ref} {tmp}.sai {fq} > {tmp}.sam && \