def name_to_label_mapping(obonetwork):
    """
    builds name <=> label lookup dictionaries starting
    from an OBO file, including synonyms
    """
    id_to_name = {}
    name_to_id = {}
    for nodeid, data in obonetwork.nodes(data=True):
        try:
            id_to_name[nodeid] = data['name']
            name_to_id[data['name']] = nodeid
        except KeyError:
            pass
        if 'synonym' in data:
            for synonim in data['synonym']:
                name_to_id[synonim.split('"')[1]] = nodeid
    return id_to_name, name_to_id
