def set_id(bibtex_entry, ID):
    """Given a (string) BibTeX entry, replace its identifier with @ID.
    """
    first_bracket = bibtex_entry.index("{") + 1
    first_comma = bibtex_entry.index(",")
    return bibtex_entry[:first_bracket] + ID + bibtex_entry[first_comma:]