code: def add_contig_to_header(line, ref_file):
      
      if line.startswith("##fileformat=VCF"):
          out = [line]
          for region in ref.file_contigs(ref_file):
              out.append("##contig=<ID=%s,length=%s>" % (region.name, region.size))
          return "\n".join(out)
      else:
          return line
docs: Streaming target to add contigs to a VCF file header.