code: def merge_mutect(job, perchrom_rvs):
      job.fileStore.logToMaster('Running merge_mutect')
      work_dir = job.fileStore.getLocalTempDir()
      input_files = {filename: jsid for perchrom_files in perchrom_rvs.values()
                     for filename, jsid in perchrom_files.items()}
      input_files = get_files_from_filestore(job, input_files, work_dir, docker=False)
      chromosomes = [''.join(['chr', str(x)]) for x in range(1, 23) + ['X', 'Y']]
      with open('/'.join([work_dir, 'mutect_calls.vcf']), 'w') as mutvcf, \
              open('/'.join([work_dir, 'mutect_calls.out']), 'w') as mutout, \
              open('/'.join([work_dir, 'mutect_passing_calls.vcf']), 'w') as mutpassvcf:
          out_header_not_printed = True
          for chrom in chromosomes:
              with open(input_files[''.join(['mutect_', chrom, '.vcf'])], 'r') as mutfile:
                  for line in mutfile:
                      line = line.strip()
                      if line.startswith('
                          if chrom == 'chr1':
                              print(line, file=mutvcf)
                              print(line, file=mutpassvcf)
                          continue
                      else:
                          print(line, file=mutvcf)
                          line = line.split('\t')
                          if line[6] != 'REJECT':
                              print('\t'.join(line), file=mutpassvcf)
              with open(input_files[''.join(['mutect_', chrom,
                                             '.out'])], 'r') as mutfile:
                  for line in mutfile:
                      line = line.strip()
                      if line.startswith('
                          if chrom == 'chr1':
                              print(line, file=mutout)
                          continue
                      elif out_header_not_printed:
                          print(line, file=mutout)
                          out_header_not_printed = False
                      else:
                          print(line, file=mutout)
      output_file = job.fileStore.writeGlobalFile(mutpassvcf.name)
      return output_file