code: def get_ref_bedtool(ref_file, config, chrom=None):
      
      broad_runner = broad.runner_from_path("picard", config)
      ref_dict = broad_runner.run_fn("picard_index_ref", ref_file)
      ref_lines = []
      with pysam.Samfile(ref_dict, "r") as ref_sam:
          for sq in ref_sam.header["SQ"]:
              if not chrom or sq["SN"] == chrom:
                  ref_lines.append("%s\t%s\t%s" % (sq["SN"], 0, sq["LN"]))
      return pybedtools.BedTool("\n".join(ref_lines), from_string=True)
docs: Retrieve a pybedtool BedTool object with reference sizes from input reference.