def computeAncestors(graph, nodes):
    '''build dictionary with node ancestors in graph.'''

    iteration, total = 0, len(nodes)

    E.info("computing ancestral information for %i nodes" % len(nodes))

    ancestors = {}
    for node in nodes:
        a = getAncestors(graph, node)
        # only take nodes with annotations
        a = set([x for x in a if x in nodes])
        # add self
        # a.add( node )
        ancestors[node] = a
        iteration += 1
        if iteration % 500 == 0:
            E.debug("total = %i (%5.2f%%)" %
                    (iteration, 100.0 * iteration / total))
    return ancestors
dataset/ETHPy150Open CGATOxford/cgat/scripts/revigo.py/computeAncestors/original