def has_enough_by_background_and_foreground(
    alignment, foreground_list, min_foreground=2, min_background=2
):
    """
    Return the alignment if it has at least min_foreground and min_background 
    sequences
    """
    alignment_ids = {sequence.id.split("@")[0]: sequence.id for sequence in alignment}
    n_foreground = len(set(foreground_list) & set(alignment_ids.keys()))
    n_background = len(set(alignment_ids.keys()) - set(foreground_list))
    if n_foreground >= min_foreground and n_background >= min_background:
        return True
    return False