def parse_bed_to_bin(filename, bin_size, bin_dict, input_dir):
    """ parse the bed files into bin """
    infile = open(input_dir + filename, 'r')
    num = 0
    for line in infile:
        num += 1
        if num % 10000000 == 0:
            print('{0:,} lines processed in {1}'.format(num, filename))
        chr, start, end, col3, col4, strand = line.strip().split()
        pos = int(start)
        try:
            bin_dict[chr][int(pos / bin_size)] += 1
        except (IndexError, KeyError) as e:
            pass
    return bin_dict
