def check_dangling_end(read, dangling_sequences):
    """
    given a pysam read object, this function
    checks if a forward read starts with
    the dangling sequence or if a reverse
    read ends with the dangling sequence.
    """
    ds = dangling_sequences
    if 'pat_forw' not in ds or 'pat_rev' not in ds:
        return False
    if not read.is_reverse and read.seq.upper().startswith(ds['pat_forw']):
        return True
    if read.is_reverse and read.seq.upper().endswith(ds['pat_rev']):
        return True
    return False
