def filter_reads(read_list, cell_tag='CR', UMI_tag='UR', min_MAPQ=20,
    max_FLAG=255, min_LEN=30):
    """Filter reads and check read tag, e.g., cell and UMI barcodes.
    """
    idx_keep, UMIs_list, cell_list = [], [], []
    for i in range(len(read_list)):
        _read = read_list[i]
        if _read.mapq < min_MAPQ or _read.flag > max_FLAG or len(_read.
            positions) < min_LEN:
            continue
        if cell_tag is not None and _read.has_tag(cell_tag) == False:
            continue
        if UMI_tag is not None and _read.has_tag(UMI_tag) == False:
            continue
        if UMI_tag is not None:
            UMIs_list.append(_read.get_tag(UMI_tag))
        if cell_tag is not None:
            cell_list.append(_read.get_tag(cell_tag))
        idx_keep.append(i)
    RV = {}
    RV['idx_list'] = idx_keep
    RV['UMIs_list'] = UMIs_list
    RV['cell_list'] = cell_list
    return RV
