def run_mutect_perchrom(job, tumor_bam, normal_bam, univ_options, mutect_options, chrom):
    """
    Run MuTect call on a single chromosome in the input bams.

    :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq
    :param dict normal_bam: Dict of bam and bai for normal DNA-Seq
    :param dict univ_options: Dict of universal options used by almost all tools
    :param dict mutect_options: Options specific to MuTect
    :param str chrom: Chromosome to process
    :return: fsID for the chromsome vcf
    :rtype: toil.fileStore.FileID
    """
    work_dir = os.getcwd()
    input_files = {
        'tumor.bam': tumor_bam['tumor_dna_fix_pg_sorted.bam'],
        'tumor.bam.bai': tumor_bam['tumor_dna_fix_pg_sorted.bam.bai'],
        'normal.bam': normal_bam['normal_dna_fix_pg_sorted.bam'],
        'normal.bam.bai': normal_bam['normal_dna_fix_pg_sorted.bam.bai'],
        'genome.fa.tar.gz': mutect_options['genome_fasta'],
        'genome.fa.fai.tar.gz': mutect_options['genome_fai'],
        'genome.dict.tar.gz': mutect_options['genome_dict'],
        'cosmic.vcf.tar.gz': mutect_options['cosmic_vcf'],
        'cosmic.vcf.idx.tar.gz': mutect_options['cosmic_idx'],
        'dbsnp.vcf.gz': mutect_options['dbsnp_vcf'],
        'dbsnp.vcf.idx.tar.gz': mutect_options['dbsnp_idx']}
    input_files = get_files_from_filestore(job, input_files, work_dir, docker=False)
    # dbsnp.vcf should be bgzipped, but all others should be tar.gz'd
    input_files['dbsnp.vcf'] = gunzip(input_files['dbsnp.vcf.gz'])
    for key in ('genome.fa', 'genome.fa.fai', 'genome.dict', 'cosmic.vcf', 'cosmic.vcf.idx',
                'dbsnp.vcf.idx'):
        input_files[key] = untargz(input_files[key + '.tar.gz'], work_dir)
    input_files = {key: docker_path(path) for key, path in input_files.items()}

    mutout = ''.join([work_dir, '/', chrom, '.out'])
    mutvcf = ''.join([work_dir, '/', chrom, '.vcf'])
    parameters = ['-R', input_files['genome.fa'],
                  '--cosmic', input_files['cosmic.vcf'],
                  '--dbsnp', input_files['dbsnp.vcf'],
                  '--input_file:normal', input_files['normal.bam'],
                  '--input_file:tumor', input_files['tumor.bam'],
                  # '--tumor_lod', str(10),
                  # '--initial_tumor_lod', str(4.0),
                  '-L', chrom,
                  '--out', docker_path(mutout),
                  '--vcf', docker_path(mutvcf)
                  ]
    java_xmx = mutect_options['java_Xmx'] if mutect_options['java_Xmx'] \
        else univ_options['java_Xmx']
    docker_call(tool='mutect', tool_parameters=parameters, work_dir=work_dir,
                dockerhub=univ_options['dockerhub'], java_xmx=java_xmx,
                tool_version=mutect_options['version'])
    output_file = job.fileStore.writeGlobalFile(mutvcf)
    export_results(job, output_file, mutvcf, univ_options, subfolder='mutations/mutect')
    job.fileStore.logToMaster('Ran MuTect on %s:%s successfully' % (univ_options['patient'], chrom))
    return output_file
def run_mutect_perchrom ( job , tumor_bam , normal_bam , univ_options , mutect_options , chrom ) : work_dir = os . getcwd ( ) input_files = { 'tumor.bam' : tumor_bam [ 'tumor_dna_fix_pg_sorted.bam' ] , 'tumor.bam.bai' : tumor_bam [ 'tumor_dna_fix_pg_sorted.bam.bai' ] , 'normal.bam' : normal_bam [ 'normal_dna_fix_pg_sorted.bam' ] , 'normal.bam.bai' : normal_bam [ 'normal_dna_fix_pg_sorted.bam.bai' ] , 'genome.fa.tar.gz' : mutect_options [ 'genome_fasta' ] , 'genome.fa.fai.tar.gz' : mutect_options [ 'genome_fai' ] , 'genome.dict.tar.gz' : mutect_options [ 'genome_dict' ] , 'cosmic.vcf.tar.gz' : mutect_options [ 'cosmic_vcf' ] , 'cosmic.vcf.idx.tar.gz' : mutect_options [ 'cosmic_idx' ] , 'dbsnp.vcf.gz' : mutect_options [ 'dbsnp_vcf' ] , 'dbsnp.vcf.idx.tar.gz' : mutect_options [ 'dbsnp_idx' ] } input_files = get_files_from_filestore ( job , input_files , work_dir , docker = False ) input_files [ 'dbsnp.vcf' ] = gunzip ( input_files [ 'dbsnp.vcf.gz' ] ) for key in ( 'genome.fa' , 'genome.fa.fai' , 'genome.dict' , 'cosmic.vcf' , 'cosmic.vcf.idx' , 'dbsnp.vcf.idx' ) : input_files [ key ] = untargz ( input_files [ key + '.tar.gz' ] , work_dir ) input_files = { key : docker_path ( path ) for key , path in input_files . items ( ) } mutout = '' . join ( [ work_dir , '/' , chrom , '.out' ] ) mutvcf = '' . join ( [ work_dir , '/' , chrom , '.vcf' ] ) parameters = [ '-R' , input_files [ 'genome.fa' ] , '--cosmic' , input_files [ 'cosmic.vcf' ] , '--dbsnp' , input_files [ 'dbsnp.vcf' ] , '--input_file:normal' , input_files [ 'normal.bam' ] , '--input_file:tumor' , input_files [ 'tumor.bam' ] , '-L' , chrom , '--out' , docker_path ( mutout ) , '--vcf' , docker_path ( mutvcf ) ] java_xmx = mutect_options [ 'java_Xmx' ] if mutect_options [ 'java_Xmx' ] else univ_options [ 'java_Xmx' ] docker_call ( tool = 'mutect' , tool_parameters = parameters , work_dir = work_dir , dockerhub = univ_options [ 'dockerhub' ] , java_xmx = java_xmx , tool_version = mutect_options [ 'version' ] ) output_file = job . fileStore . writeGlobalFile ( mutvcf ) export_results ( job , output_file , mutvcf , univ_options , subfolder = 'mutations/mutect' ) job . fileStore . logToMaster ( 'Ran MuTect on %s:%s successfully' % ( univ_options [ 'patient' ] , chrom ) ) return output_file
Run MuTect call on a single chromosome in the input bams.

    :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq
    :param dict normal_bam: Dict of bam and bai for normal DNA-Seq
    :param dict univ_options: Dict of universal options used by almost all tools
    :param dict mutect_options: Options specific to MuTect
    :param str chrom: Chromosome to process
    :return: fsID for the chromsome vcf
    :rtype: toil.fileStore.FileID