main.py
def build_graph(data):
    '''
    builds a networkX graph from a response of the elasticsearch Ghraph API
    :param data:
    :return:
    '''
    if data and data['vertices']:
        '''build graph'''
        G = nx.Graph()
        node_names = {}
        node_class = []
        node_classes = []
        gene_nodes = []
        for i, vertex in enumerate(data['vertices']):
            G.add_node(i,
                       term=vertex['term'],
                       weight=vertex['weight'],
                       flat_weight=1.
                       )
            if vertex['term'].lower() in gene_names:
                gene_nodes.append(i)
            node_names[i] = vertex['term']
            if vertex['field'] not in node_classes:
                node_classes.append(vertex['field'])
            node_class.append(node_classes.index(vertex['field']))

        edge_sizes = []
        for i, edge in enumerate(data['connections']):
            G.add_edge(edge['source'],
                       edge['target'],
                       # weight=edge['weight'],
                       flat_weight=1.,
                       doc_count=edge['doc_count'])
            edge_sizes.append(edge['doc_count'])

        return G

    builds a networkX graph from a response of the elasticsearch Ghraph API
    :param data:
    :return:
    
builds a networkX graph from a response of the elasticsearch Ghraph API
builds a networkX graph from a response of the elasticsearch Ghraph API
def build_graph(data):
    if data and data['vertices']:
        G = nx.Graph()
        node_names = {}
        node_class = []
        node_classes = []
        gene_nodes = []
        for i, vertex in enumerate(data['vertices']):
            G.add_node(i,
                       term=vertex['term'],
                       weight=vertex['weight'],
                       flat_weight=1.
                       )
            if vertex['term'].lower() in gene_names:
                gene_nodes.append(i)
            node_names[i] = vertex['term']
            if vertex['field'] not in node_classes:
                node_classes.append(vertex['field'])
            node_class.append(node_classes.index(vertex['field']))
        edge_sizes = []
        for i, edge in enumerate(data['connections']):
            G.add_edge(edge['source'],
                       edge['target'],
                       flat_weight=1.,
                       doc_count=edge['doc_count'])
            edge_sizes.append(edge['doc_count'])
        return G
def build_graph ( data ) : if data and data [ 'vertices' ] : '''build graph''' G = nx . Graph ( ) node_names = { } node_class = [ ] node_classes = [ ] gene_nodes = [ ] for i , vertex in enumerate ( data [ 'vertices' ] ) : G . add_node ( i , term = vertex [ 'term' ] , weight = vertex [ 'weight' ] , flat_weight = 1. ) if vertex [ 'term' ] . lower ( ) in gene_names : gene_nodes . append ( i ) node_names [ i ] = vertex [ 'term' ] if vertex [ 'field' ] not in node_classes : node_classes . append ( vertex [ 'field' ] ) node_class . append ( node_classes . index ( vertex [ 'field' ] ) ) edge_sizes = [ ] for i , edge in enumerate ( data [ 'connections' ] ) : G . add_edge ( edge [ 'source' ] , edge [ 'target' ] , flat_weight = 1. , doc_count = edge [ 'doc_count' ] ) edge_sizes . append ( edge [ 'doc_count' ] ) return G
builds a networkX graph from a response of the elasticsearch Ghraph API
builds a networkX graph from a response of the elasticsearch Ghraph API
'''
    builds a networkX graph from a response of the elasticsearch Ghraph API
    :param data:
    :return:
    ''' '''build graph''' # weight=edge['weight'],
None
data
None