def compute_s_id2clu(unmapped_s_ids, model, species_id2term_id, term_id2clu):
    """
    Creates a metabolite clustering based on a term clustering.
    :param unmapped_s_ids: set of ids of metabolites for which no ChEBI term was found
    :param model: libsbml.Model model of interest
    :param species_id2term_id: dict {metabolite_id: ChEBI_term_id}
    :param term_id2clu: dict {ChEBI_term_id: cluster}
    :return: dict {metabolite_id: (compartment_id, cluster)}
    """
    s_id2clu = {}
    for s_id, t_id in species_id2term_id.items():
        if t_id in term_id2clu:
            s_id2clu[s_id] = model.getSpecies(s_id).getCompartment(
                ), term_id2clu[t_id]
        else:
            s_id2clu[s_id] = model.getSpecies(s_id).getCompartment(), (t_id,)
    for s_id in unmapped_s_ids:
        if s_id in term_id2clu:
            s_id2clu[s_id] = model.getSpecies(s_id).getCompartment(
                ), term_id2clu[s_id]
    return s_id2clu
