def _line_in_region(line, chrom, start, end):
    """Check if the region defined by the BED line falls into chrom, start, end
    """
    if start is not None:
        start = int(start)
        end = int(end)
    if line.startswith(chrom):
        parts = line.split()
        if parts[0] == chrom:
            cur_start = int(parts[1])
            cur_end = int(parts[2])
            if (start is None or
                    (cur_start >= start and cur_start <= end) or
                    (cur_end >= start and cur_end <= end)):
                return cur_start
    return None