def get_bcl2fastq_read_type_map(read_info, sample_index_read=None, dual_indexed=False, ignore_dual_index=False):
    """
    Get a mapping between ReadInfo read name (R1,I1,I2,R2) and bcl2fastq
    output file naming (R1/R2/R3/R4/I1)

    The guarantee here is that the 10X sample index will always be on I1,
    if generated.  If dual-indexing is specified, the secondary index will
    be on I2.  Upstream pipestances can expect read1 to be in R1, sample
    indexes to be on I1, and read2 to be on R2.

    :param read_info: The ReadInfo block from RunInfo.xml
    :param sample_index_read: The ReadInfo read (I1, I2) to use as the sample index
    :param ignore_dual_index: Whether the dual index was ignored (and thus not sequenced)
    """
    #read_names = [r["read_name"] for r in read_info]
    read_map = {}
    reads_counted = 0
    for idx, r in enumerate(read_info):
        read_name = r["read_name"]
        if read_name == sample_index_read:
            read_map[read_name] = 'I1'
        elif ignore_dual_index and r["index_read"]:
            # we didn't read this index -- see make_bases_mask_val
            continue
        elif dual_indexed and r["index_read"]:
            read_map[read_name] = 'I2'
        else:
            reads_counted += 1
            read_map[read_name] = 'R%d' % reads_counted
    return read_map