code: def _combine_variants(in_vcfs, out_file, ref_file, config):
      in_vcfs.sort()
      wrote_header = False
      with open(out_file, "w") as out_handle:
          for in_vcf in (x[-1] for x in in_vcfs):
              with open(in_vcf) as in_handle:
                  header = list(itertools.takewhile(lambda x: x.startswith("
                                                    in_handle))
                  if not header[0].startswith("
                      raise ValueError("Unexpected VCF file: %s" % in_vcf)
                  for line in in_handle:
                      if not wrote_header:
                          wrote_header = True
                          out_handle.write("".join(header))
                      out_handle.write(line)
          if not wrote_header:
              out_handle.write("".join(header))
      return out_file