def compute_cell_index(species_list, cell_barcodes):
    """Produces a cell index dictionary that is keyed on barcode and links cell barcodes to per-species indices
    """
    cell_index = {}
    for species in species_list:
        bc_list = cell_barcodes.get(species, {}).keys()
        bc_list.sort()
        for index, barcode in enumerate(bc_list):
            label = "{species}_cell_{index}".format(**locals())
            if barcode not in cell_index:
                cell_index[barcode] = label
            else:
                cell_index[barcode] = "_".join([cell_index[barcode], label])
    return cell_index