-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
137 lines (118 loc) · 3.93 KB
/
app.py
File metadata and controls
137 lines (118 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# import csv
# import dash
# import dash_cytoscape as cyto
# # import dash_html_components as html
# from dash import html
# from dash.dependencies import Input, Output, State
# # import dash_core_components as dcc
# from dash import dcc
# app = dash.Dash(__name__)
# styles = {
# 'pre': {
# 'border': 'thin lightgrey solid',
# 'overflowX': 'scroll'
# }
# }
# edge_list = []
# node_list = []
# with open('reaction_map.csv', newline='') as csvfile:
# reader = csv.DictReader(csvfile)
# for row in reader:
# # print(row)
# node_list.append(row['\ufeffSource'])
# if row['End'] not in node_list:
# node_list.append(row['End'])
# source_target_label = tuple(
# (row['\ufeffSource'], row['End'], row['Label']))
# edge_list.append(source_target_label)
# nodes = [
# {
# 'data': {'id': label, 'label': label}
# }
# for label in (
# node_list
# )
# ]
# edges = [
# {'data': {'id': source+'--'+target+'--'+label, 'source': source,
# 'target': target, 'label': label}}
# for source, target, label in (
# edge_list
# )
# ]
# elements = nodes + edges
# default_stylesheet = [
# {
# 'selector': 'node',
# 'style': {
# 'width': 'data(size)',
# 'height': 'data(size)',
# 'content': 'data(label)',
# 'font-size': '10px',
# 'color': 'black',
# 'background-color': 'data(color)'
# }
# },
# {
# 'selector': 'edge',
# 'style': {
# 'curve-style': 'bezier',
# 'width': '2px',
# 'label': 'data(label)',
# 'font-size': '10px',
# 'font-opacity': 1,
# 'target-arrow-color': 'black',
# 'target-arrow-shape': 'triangle',
# 'line-color': 'green'
# }
# },
# {
# 'selector': ':selected',
# 'style': {
# 'border-color': 'black',
# 'border-opacity': '1',
# 'border-width': '0.075px'
# }
# }
# ]
# cyto.load_extra_layouts()
# app.layout = html.Div(
# children=[
# cyto.Cytoscape(
# id='cytoscape-event-callbacks-2',
# layout={'name': 'cola', 'nodeSpacing': 70},
# style={'width': '100vw', 'height': '100vh'},
# stylesheet=default_stylesheet,
# elements=elements,
# # mouseoverEdgeData=edges
# ),
# html.P(id='cytoscape-tapNodeData-output'),
# html.P(id='cytoscape-tapEdgeData-output'),
# html.P(id='cytoscape-mouseoverNodeData-output'),
# html.P(id='cytoscape-mouseoverEdgeData-output')
# ],
# )
# @app.callback(Output('cytoscape-tapNodeData-output', 'children'),
# Input('cytoscape-event-callbacks-2', 'tapNodeData'))
# def displayTapNodeData(data):
# if data:
# return "You recently clicked/tapped the city: " + data['label']
# @app.callback(Output('cytoscape-tapEdgeData-output', 'children'),
# Input('cytoscape-event-callbacks-2', 'tapEdgeData'))
# def displayTapEdgeData(data):
# if data:
# return "You recently clicked/tapped the edge between " + \
# data['source'].upper() + " and " + data['target'].upper()
# @app.callback(Output('cytoscape-mouseoverNodeData-output', 'children'),
# Input('cytoscape-event-callbacks-2', 'mouseoverNodeData'))
# def displayTapNodeData(data):
# if data:
# return "You recently hovered over the city: " + data['label']
# @app.callback(Output('cytoscape-mouseoverEdgeData-output', 'children'),
# Input('cytoscape-event-callbacks-2', 'mouseoverEdgeData'))
# def displayTapEdgeData(data):
# if data:
# return "You recently hovered over the edge between " + \
# data['source'].upper() + " and " + data['target'].upper()
# if __name__ == '__main__':
# app.run_server(debug=True)