dalexanderch commited on
Commit
b7d6d94
1 Parent(s): 555d33d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -10,6 +10,7 @@ from glycowork.motif.graph import glycan_to_nxGraph
10
  import networkx as nx
11
  import matplotlib.pyplot as plt
12
  from networkx.drawing.nx_agraph import write_dot
 
13
  # import pygraphviz as pgv
14
 
15
 
@@ -40,10 +41,12 @@ model3 = torch.load("model3.pt", map_location=torch.device('cpu'))
40
 
41
  def fn(glycan, model):
42
  # Draw graph
43
- # graph = glycan_to_nxGraph(glycan)
44
- # node_labels = nx.get_node_attributes(graph, 'string_labels')
45
- # labels = {i:node_labels[i] for i in range(len(graph.nodes))}
46
- # graph = nx.relabel_nodes(graph, labels)
 
 
47
  # write_dot(graph, "graph.dot")
48
  # graph=pgv.AGraph("graph.dot")
49
  # graph.layout(prog='dot')
 
10
  import networkx as nx
11
  import matplotlib.pyplot as plt
12
  from networkx.drawing.nx_agraph import write_dot
13
+ import pydot
14
  # import pygraphviz as pgv
15
 
16
 
 
41
 
42
  def fn(glycan, model):
43
  # Draw graph
44
+ graph = glycan_to_nxGraph(glycan)
45
+ node_labels = nx.get_node_attributes(graph, 'string_labels')
46
+ labels = {i:node_labels[i] for i in range(len(graph.nodes))}
47
+ graph = nx.relabel_nodes(graph, labels)
48
+ graph = nx.drawing.nx_pydot.to_pydot(graph)
49
+ graph.write_png("graph.png")
50
  # write_dot(graph, "graph.dot")
51
  # graph=pgv.AGraph("graph.dot")
52
  # graph.layout(prog='dot')