Exemplo n.º 1
0
def postToGS(alignededges, overlaps, leftcoords, graphid):
    """Post graph to graphspace
    """

    import graphspace_interface as interface

    maxleftcoord = max([leftcoords[c] for c in leftcoords])
    minleftcoord = min([leftcoords[c] for c in leftcoords])
    for c in leftcoords:
        leftcoords[c] = int(float(leftcoords[c]-minleftcoord)\
                / float(maxleftcoord-minleftcoord)*255)
    user = '******'
    password = '******'
    group = 'SVLocalAssembly'
    outfile = graphid + '.json'

    #Graph 1 (tmp): read edges in from a file.
    #Take the first two columns of the file as the edges.

    #Make a directed graph NetworkX object.
    #A directed graph will work even if we
    #want to show an undirected graph, since
    #each edge has a "directed" attribute that
    #determines whether the edge is drawn with an
    #arrow or not.
    graph = nx.DiGraph(alignededges, directed=False)

    for n in graph.nodes():
        label = '%s' % (n)
        interface.add_node_label(graph, n, label)
        interface.add_node_wrap(graph, n, 'wrap')
        interface.add_node_color(
            graph, n, rgb_to_hex((0, leftcoords[n], 255 - leftcoords[n])))
        interface.add_node_shape(graph, n, 'ellipse')
        interface.add_node_height(graph, n, None, label)
        interface.add_node_width(graph, n, None, label)

    trueedges = [[u, v] for u, v, t in overlaps]
    for t, h in graph.edges():
        interface.add_edge_directionality(graph, t, h, False)
        if [t, h] in trueedges or [h, t] in trueedges:
            # true edges are blue
            #print 'Blue'
            interface.add_edge_color(graph, t, h, '#6666FF')
        else:
            # false edges are black
            interface.add_edge_color(graph, t, h, '#000000')
        interface.add_edge_width(graph, t, h, 2)

    metadata = {'description': 'example1', 'title': graphid, 'tags': []}
    print(graph, graphid, outfile, user, password, metadata)
    interface.postGraph(graph, graphid, outfile=outfile, user=user,\
            password=password, metadata=metadata)
    if group != None:
        interface.shareGraph(graphid,
                             user=user,
                             password=password,
                             group=group)
    return
Exemplo n.º 2
0
def postToGS(alignededges, overlaps, leftcoords, graphid):
    """Post graph to graphspace
    """

    import graphspace_interface as interface

    maxleftcoord = max([leftcoords[c] for c in leftcoords])
    minleftcoord = min([leftcoords[c] for c in leftcoords])
    for c in leftcoords:
        leftcoords[c] = int(float(leftcoords[c]-minleftcoord)\
                / float(maxleftcoord-minleftcoord)*255)
    user = '******'
    password = '******'
    group = 'SVLocalAssembly'
    outfile = graphid+'.json'

    #Graph 1 (tmp): read edges in from a file.
    #Take the first two columns of the file as the edges.

    #Make a directed graph NetworkX object.
    #A directed graph will work even if we
    #want to show an undirected graph, since
    #each edge has a "directed" attribute that
    #determines whether the edge is drawn with an
    #arrow or not.
    graph = nx.DiGraph(alignededges, directed=False)

    for n in graph.nodes():
        label = '%s' % (n)
        interface.add_node_label(graph, n, label)
        interface.add_node_wrap(graph, n, 'wrap')
        interface.add_node_color(graph, n, rgb_to_hex((0, leftcoords[n], 255-leftcoords[n])))
        interface.add_node_shape(graph, n, 'ellipse')
        interface.add_node_height(graph, n, None, label)
        interface.add_node_width(graph, n, None, label)

    trueedges = [[u, v] for u, v, t in overlaps]
    for t, h in graph.edges():
        interface.add_edge_directionality(graph, t, h, False)
        if [t, h] in trueedges or [h, t] in trueedges:
            # true edges are blue
            #print 'Blue'
            interface.add_edge_color(graph, t, h, '#6666FF')
        else:
            # false edges are black
            interface.add_edge_color(graph, t, h, '#000000')
        interface.add_edge_width(graph, t, h, 2)

    metadata = {'description': 'example1', 'title': graphid, 'tags': []}
    print(graph, graphid, outfile, user, password, metadata)
    interface.postGraph(graph, graphid, outfile=outfile, user=user,\
            password=password, metadata=metadata)
    if group != None:
        interface.shareGraph(graphid, user=user, password=password, group=group)
    return
def runExample1(edgefile,user,password,group,graphid,outfile):
    #Graph 1 (tmp): read edges in from a file.
    #Take the first two columns of the file as the edges.
    edges = []
    with open(edgefile) as fin:
        for line in fin:
            if line[0] == '#': # skip comments
                continue
            row = line.strip().split()
            edges.append((row[0],row[1]))

    #Make a directed graph NetworkX object.
    #A directed graph will work even if we 
    #want to show an undirected graph, since
    #each edge has a "directed" attribute that
    #determines whether the edge is drawn with an
    #arrow or not.
    G = nx.DiGraph(edges,directed=True)

    for n in G.nodes():
        label= 'node\n%s' % (n)
        interface.add_node_label(G,n,label)
        interface.add_node_wrap(G,n,'wrap')
        interface.add_node_color(G,n,'#ACFA58')
        interface.add_node_shape(G,n,'rectangle')
        interface.add_node_height(G,n,None,label)
        interface.add_node_width(G,n,None,label)

    for t,h in G.edges():
        interface.add_edge_directionality(G,t,h,True)
        interface.add_edge_color(G,t,h,'#000000')
        interface.add_edge_width(G,t,h,2)

    metadata = {'description':'example1','title':'Example 1 Graph','tags':[]}
    print G,graphid,outfile,user,password,metadata
    interface.postGraph(G,graphid,outfile=outfile,user=user,password=password,metadata=metadata)
    if group != None:
        interface.shareGraph(graphid,user=user,password=password,group=group)
    return
Exemplo n.º 4
0
            continue
        row = line.strip().split()
        edges.append((row[0],row[1]))

#Make a directed graph NetworkX object.
#A directed graph will work even if we 
#want to show an undirected graph, since
#each edge has a "directed" attribute that
#determines whether the edge is drawn with an
#arrow or not.
G = nx.DiGraph(edges,directed=True)

for n in G.nodes():
    label= 'node\n%s' % (n)
    interface.add_node_label(G,n,label)
    interface.add_node_wrap(G,n,'wrap')
    interface.add_node_color(G,n,'#ACFA58')
    interface.add_node_shape(G,n,'rectangle')
    interface.add_node_height(G,n,None,label)
    interface.add_node_width(G,n,None,label)

for t,h in G.edges():
    interface.add_edge_directionality(G,t,h,True)
    interface.add_edge_color(G,t,h,'#000000')
    interface.add_edge_width(G,t,h,2)

#Divit's Note: We should have a JSON validator at this step
#Divit: We should.  I want to talk to Murali about possibly enhancing the validator.

interface.postGraph(G,graphid,outfile=outfile,user=user,password=password)
if group != None:
Exemplo n.º 5
0
            continue
        row = line.strip().split()
        edges.append((row[0], row[1]))

#Make a directed graph NetworkX object.
#A directed graph will work even if we
#want to show an undirected graph, since
#each edge has a "directed" attribute that
#determines whether the edge is drawn with an
#arrow or not.
G = nx.DiGraph(edges, directed=True)

for n in G.nodes():
    label = 'node\n%s' % (n)
    interface.add_node_label(G, n, label)
    interface.add_node_wrap(G, n, 'wrap')
    interface.add_node_color(G, n, '#ACFA58')
    interface.add_node_shape(G, n, 'rectangle')
    interface.add_node_height(G, n, None, label)
    interface.add_node_width(G, n, None, label)

for t, h in G.edges():
    interface.add_edge_directionality(G, t, h, True)
    interface.add_edge_color(G, t, h, '#000000')
    interface.add_edge_width(G, t, h, 2)

#Divit's Note: We should have a JSON validator at this step
#Divit: We should.  I want to talk to Murali about possibly enhancing the validator.

interface.postGraph(G, graphid, outfile=outfile, user=user, password=password)
if group != None: