import re


def trim_id(id, prefix):
    """Remove insignificant characters from the feature ID

    If we know the species in a downstream context, in an ID like
    "ENSMUSG00000102628", we can infer everything except the "102628".

    So we trim the ID to only those significant characters, which yields
    a smaller gene cache file that is faster to transfer.
    """
    insignificant = re.search(prefix + r"0+", id).group()
    slim_id = id.replace(insignificant, "")
    return slim_id