code: def _prepare_calls(result_file, out_dir, data):
      
      sample = dd.get_sample_name(data)
      out_file = os.path.join(out_dir, "%s-optitype.csv" % (sample))
      if not utils.file_uptodate(out_file, result_file):
          hla_truth = bwakit.get_hla_truthset(data)
          with file_transaction(data, out_file) as tx_out_file:
              with open(tx_out_file, "w") as out_handle:
                  writer = csv.writer(out_handle)
                  allele_info = _parse_result_file(result_file)
                  if len(allele_info) == 1:
                      writer.writerow(["sample", "locus", "alleles", "expected", "validates"])
                  else:
                      writer.writerow(["sample", "local", "index", "alleles", "score"])
                  for j, (alleles, score) in enumerate(allele_info):
                      for hla_locus, call_alleles in alleles:
                          truth_alleles = tz.get_in([sample, hla_locus], hla_truth, [])
                          if len(allele_info) == 1:
                              writer.writerow([sample, hla_locus,
                                               ";".join(call_alleles), ";".join(truth_alleles),
                                               bwakit.matches_truth(call_alleles, truth_alleles, data)])
                          else:
                              writer.writerow([sample, hla_locus, j, ";".join(call_alleles), score])
      return out_file
docs: Write summary file of results of HLA typing by allele.