def run_indel_realignment(job, intervals, bam, bai, ref, ref_dict, fai, g1k, mills, unsafe=False):
inputs = {'<STR_LIT>': ref,<EOL>'<STR_LIT>': fai,<EOL>'<STR_LIT>': ref_dict,<EOL>'<STR_LIT>': bam,<EOL>'<STR_LIT>': bai,<EOL>'<STR_LIT>': intervals,<EOL>'<STR_LIT>': g1k,<EOL>'<STR_LIT>': mills}<EOL>work_dir = job.fileStore.getLocalTempDir()<EOL>for name, file_store_id in inputs.iteritems():<EOL><INDENT>job.fileStore.readGlobalFile(file_store_id, os.path.join(work_dir, name))<EOL><DEDENT>parameters = ['<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', str(<NUM_LIT>),  <EOL>'<STR_LIT>', str(<NUM_LIT>),  <EOL>'<STR_LIT>', '<STR_LIT>']<EOL>if unsafe:<EOL><INDENT>parameters.extend(['<STR_LIT>', '<STR_LIT>'])<EOL><DEDENT>docker_parameters = ['<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT:none>',<EOL>'<STR_LIT>', '<STR_LIT>'.format(job.memory),<EOL>'<STR_LIT>', '<STR_LIT>'.format(work_dir)]<EOL>start_time = time.time()<EOL>dockerCall(job=job, tool='<STR_LIT>',<EOL>workDir=work_dir,<EOL>parameters=parameters,<EOL>dockerParameters=docker_parameters)<EOL>end_time = time.time()<EOL>_log_runtime(job, start_time, end_time, "<STR_LIT>")<EOL>indel_bam = job.fileStore.writeGlobalFile(os.path.join(work_dir, '<STR_LIT>'))<EOL>indel_bai = job.fileStore.writeGlobalFile(os.path.join(work_dir, '<STR_LIT>'))<EOL>return indel_bam, indel_bai<EOL>
Realigns BAM file at realignment target intervals

:param JobFunctionWrappingJob job: passed automatically by Toil
:param str intervals: FileStoreID for INDEL realignment intervals file
:param str bam: FileStoreID for BAM file
:param str bai: FileStoreID for BAM index file
:param str ref: FileStoreID for reference genome fasta file
:param str ref_dict: FileStoreID for reference sequence dictionary file
:param str fai: FileStoreID for reference fasta index file
:param str g1k: FileStoreID for 1000 Genomes VCF file
:param str mills: FileStoreID for Mills VCF file
:param bool unsafe: If True, runs GATK in UNSAFE mode: "-U ALLOW_SEQ_DICT_INCOMPATIBILITY"
:return: FileStoreIDs for realigned BAM and BAI files
:rtype: tuple(str, str)