import string


def get_longid(donor, cell, GTEx_ID):
    """Constructs a long ID {donor}_{cell}_{GTEx_ID}, ensuring that it uses
    only sensible characters."""
    assert '_' not in donor,\
        f"Donor should not contain the delimiter '_': {donor}"
    assert '_' not in donor, \
        f"Cell should not contain the delimiter '_': {cell}"
    assert '_' not in donor, \
        f"GTEx_ID should not contain the delimiter '_': {GTEx_ID}"
    full = f"{donor}_{cell}_{GTEx_ID}"

    valid_chars = f"-_.(){string.ascii_letters}{string.digits}"
    sanitised = ''.join(c for c in full if c in valid_chars)
    return sanitised