code: def split_vcf(in_file, ref_file, config, out_dir=None):
      
      if out_dir is None:
          out_dir = os.path.join(os.path.dirname(in_file), "split")
      out_files = []
      with open(ref.fasta_idx(ref_file, config)) as in_handle:
          for line in in_handle:
              chrom, size = line.split()[:2]
              out_file = os.path.join(out_dir,
                                      os.path.basename(replace_suffix(append_stem(in_file, "-%s" % chrom), ".vcf")))
              subset_vcf(in_file, (chrom, 0, size), out_file, config)
              out_files.append(out_file)
      return out_files
docs: Split a VCF file into separate files by chromosome.