original_docstring: Parses a (gzip/bzip2 compressed) BED file, and yields a sequence of BED records.
      Comments and empty lines are skipped. If the number of columns in the bed record is
      less than the specified ('min_columns'), a BEDError is raised. If a dictionary of
      {contig: length} is supplied then contigs/coordinates are validated.
      
docstring: Parses a (gzip/bzip2 compressed) BED file, and yields a sequence of BED records.
  Comments and empty lines are skipped. If the number of columns in the bed record is
  less than the specified ('min_columns'), a BEDError is raised. If a dictionary of
  {contig: length} is supplied then contigs/coordinates are validated.
docstring_tokens: Parses a ( gzip / bzip2 compressed ) BED file and yields a sequence of BED records . Comments and empty lines are skipped . If the number of columns in the bed record is less than the specified ( ' min_columns ' ) a BEDError is raised . If a dictionary of { contig : length } is supplied then contigs / coordinates are validated .
code: def read_bed_file(filename: str, contigs: Mapping[str, int] = {}):
      """Parses a (gzip/bzip2 compressed) BED file, and yields a sequence of BED records.
      Comments and empty lines are skipped. If the number of columns in the bed record is
      less than the specified ('min_columns'), a BEDError is raised. If a dictionary of
      {contig: length} is supplied then contigs/coordinates are validated.
      """
      with open_rt(filename) as handle:
          for (line_num, line) in enumerate(handle, start=1):
              line = line.strip()
              if not line or line.startswith("#"):
                  continue
  
              try:
                  bed = BEDRecord.parse(line)
                  if contigs:
                      contig_len = contigs.get(bed.contig)
                      if contig_len is None:
                          raise ValueError(f"unknown contig {bed.contig}")
                      elif bed.end > contig_len:
                          raise BEDError("coordinates outside contig")
              except Exception as error:
                  raise BEDError(f"{filename}:{line_num}: {error}") from error
  
              yield bed
code_tokens: def read_bed_file ( filename : str , contigs : Mapping [ str , int ] = { } ) : with open_rt ( filename ) as handle : for ( line_num , line ) in enumerate ( handle , start = 1 ) : line = line . strip ( ) if not line or line . startswith ( "#" ) : continue try : bed = BEDRecord . parse ( line ) if contigs : contig_len = contigs . get ( bed . contig ) if contig_len is None : raise ValueError ( f"unknown contig {bed.contig}" ) elif bed . end > contig_len : raise BEDError ( "coordinates outside contig" ) except Exception as error : raise BEDError ( f"{filename}:{line_num}: {error}" ) from error yield bed
short_docstring: Parses a (gzip/bzip2 compressed) BED file, and yields a sequence of BED records.
short_docstring_tokens: Parses a ( gzip / bzip2 compressed ) BED file and yields a sequence of BED records .
comment: """Parses a (gzip/bzip2 compressed) BED file, and yields a sequence of BED records.
      Comments and empty lines are skipped. If the number of columns in the bed record is
      less than the specified ('min_columns'), a BEDError is raised. If a dictionary of
      {contig: length} is supplied then contigs/coordinates are validated.
      """