code: def get_hla_choice(h, hlas, normal_bam, tumor_bam):
      
      def get_counts(bam_file):
          counts = {}
          for line in subprocess.check_output(["samtools", "idxstats", bam_file]).split("\n"):
              if line.startswith(h):
                  name, _, count, _ = line.split()
                  counts[name] = int(count)
          return counts
      tcounts = get_counts(tumor_bam)
      ncounts = get_counts(normal_bam)
      check_hlas = [x for x in hlas if x.startswith(h) and tcounts.get(x, 0) > 0 and ncounts.get(x, 0) > 0]
      cur_hlas = sorted(check_hlas, key=lambda x: ncounts[x], reverse=True)
      #print(cur_hlas[0], tcounts.get(cur_hlas[0]), ncounts.get(cur_hlas[0]))
      return cur_hlas[0]
docs: Retrieve matching HLA with best read support in both tumor and normal