code: def clean_file(in_file, data, prefix="", bedprep_dir=None, simple=None):
      simple = "iconv -c -f utf-8 -t ascii | sed 's/ //g' |" if simple else ""
      if in_file:
          if not bedprep_dir:
              bedprep_dir = utils.safe_makedir(os.path.join(data["dirs"]["work"], "bedprep"))
          if prefix and os.path.basename(in_file).startswith(prefix):
              return in_file
          out_file = os.path.join(bedprep_dir, "%s%s" % (prefix, os.path.basename(in_file)))
          out_file = out_file.replace(".interval_list", ".bed")
          if out_file.endswith(".gz"):
              out_file = out_file[:-3]
          if not utils.file_uptodate(out_file, in_file):
              check_bed_contigs(in_file, data)
              check_bed_coords(in_file, data)
              with file_transaction(data, out_file) as tx_out_file:
                  bcbio_py = sys.executable
                  cat_cmd = "zcat" if in_file.endswith(".gz") else "cat"
                  sort_cmd = get_sort_cmd(os.path.dirname(tx_out_file))
                  cmd = ("{cat_cmd} {in_file} | grep -v ^track | grep -v ^browser | grep -v ^@ | "
                         "grep -v ^
                         "{bcbio_py} -c 'from bcbio.variation import bedutils; bedutils.remove_bad()' | "
                         "{sort_cmd} -k1,1 -k2,2n > {tx_out_file}")
                  do.run(cmd.format(**locals()), "Prepare cleaned BED file", data)
          vcfutils.bgzip_and_index(out_file, data.get("config", {}), remove_orig=False)
          return out_file