CORS(app)

ONTOLOGY_FILE = __dirname + "/../mi.owl"
ROOT_ID = "MI:0001"

onto = Ontology(ONTOLOGY_FILE)


def constructTree(root_id, seeds):
    tree = onto.constructTreeFromRoot(root_id)
    pruned = tree.prune(seeds).toDict()

    return pruned


root_tree = onto.constructTreeFromRoot(ROOT_ID)


def getLabelOf(id):
    node = root_tree.findInTree(id)

    if node:
        return node.label
    else:
        return None


term_cache = {}
"""
Respond a JSON containing the MI ontology name of the given MI ids.
@expecting HTTP POST; Content-Type: application/json; Body: { "term" [:listofIDs] }