import re


def trim_trailing_rna_type(rna_type, description):
    """
    Some descriptions like the ones from RefSeq (URS0000ABD871/9606) and some
    from flybase (URS0000002CB3/7227) end with their RNA type. This isn't
    really all that useful as we display the RNA type anyway. So  this
    out along with ', ' that tends to go along with those.
    """

    if "predicted gene" in description:
        return description

    trailing = [rna_type]
    if rna_type == "lncRNA" or "antisense" in rna_type:
        trailing.append("long non-coding RNA")

    if rna_type == "telomerase_RNA":
        trailing.append("telomerase RNA")

    for value in trailing:
        pattern = r"[, ]*%s$" % value
        description = re.sub(pattern, "", description, re.IGNORECASE)
    return description