def addBarcodesToIdentifier(read, UMI, cell):
    """extract the identifier from a read and append the UMI and
    cell barcode before the first space"""
    read_id = read.identifier.split(' ')
    if cell == '':
        read_id[0] = read_id[0] + '_' + UMI
    else:
        read_id[0] = read_id[0] + '_' + cell + '_' + UMI
    identifier = ' '.join(read_id)
    return identifier
