code: def binned_bitsets_proximity( f, chrom_col=0, start_col=1, end_col=2, strand_col=5, upstream=0, downstream=0 ):
      last_chrom = None
      last_bitset = None
      bitsets = dict()
      for line in f:
          if line.startswith("
          fields = line.split()
          strand = "+"
          if len(fields) >= strand_col + 1:
              if fields[strand_col] == "-": strand = "-"
          chrom = fields[chrom_col]
          if chrom != last_chrom:
              if chrom not in bitsets:
                  bitsets[chrom] = BinnedBitSet( MAX )
              last_chrom = chrom
              last_bitset = bitsets[chrom]
          start, end = int( fields[start_col] ), int( fields[end_col] )
          if strand == "+":
              if upstream: start = max( 0, start - upstream )
              if downstream: end = min( MAX, end + downstream )
          if strand == "-":
              if upstream: end = min( MAX, end + upstream )
              if downstream: start = max( 0, start - downstream )
          if end-start > 0:
              last_bitset.set_range( start, end-start )
      return bitsets