code: def subset_variant_regions(variant_regions, region, out_file, items=None, do_merge=True, data=None):
      
      if region is None:
          return variant_regions
      elif variant_regions is None:
          return region
      elif not isinstance(region, (list, tuple)) and region.find(":") > 0:
          raise ValueError("Partial chromosome regions not supported")
      else:
          merge_text = "-unmerged" if not do_merge else ""
          subset_file = "{0}".format(utils.splitext_plus(out_file)[0])
          subset_file += "%s-regions.bed" % (merge_text)
          if not os.path.exists(subset_file):
              data = items[0] if items else data
              with file_transaction(data, subset_file) as tx_subset_file:
                  if isinstance(region, (list, tuple)):
                      _subset_bed_by_region(variant_regions, tx_subset_file, to_multiregion(region),
                                            dd.get_ref_file(data), do_merge=do_merge)
                  else:
                      _rewrite_bed_with_chrom(variant_regions, tx_subset_file, region)
          if os.path.getsize(subset_file) == 0:
              return region
          else:
              return subset_file
docs: Return BED file subset by a specified chromosome region.
  
      variant_regions is a BED file, region is a chromosome name or tuple
      of (name, start, end) for a genomic region.