Tanguyvans commited on
Commit
76919d3
1 Parent(s): 3cfdd19

added graph

Browse files
Files changed (1) hide show
  1. app.py +60 -0
app.py CHANGED
@@ -191,3 +191,63 @@ with st.container():
191
  for i in range(0, len(tabs)):
192
  with tabs[i]:
193
  render_tab(trials[i])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  for i in range(0, len(tabs)):
192
  with tabs[i]:
193
  render_tab(trials[i])
194
+
195
+
196
+ from utils import get_all_diseases_name, get_most_similar_diseases_from_uri, get_uri_from_name
197
+
198
+ username = 'demo'
199
+ password = 'demo'
200
+ hostname = os.getenv('IRIS_HOSTNAME', 'localhost')
201
+ port = '1972'
202
+ namespace = 'USER'
203
+ CONNECTION_STRING = f"iris://{username}:{password}@{hostname}:{port}/{namespace}"
204
+ engine = create_engine(CONNECTION_STRING)
205
+
206
+ chosen_disease_name = st.selectbox(
207
+ "Choose a disease",
208
+ get_all_diseases_name(engine))
209
+
210
+ st.write("You selected:", chosen_disease_name)
211
+ chosen_disease_uri = get_uri_from_name(engine, chosen_disease_name)
212
+
213
+ nodes = []
214
+ edges = []
215
+
216
+
217
+ nodes.append( Node(id=chosen_disease_uri,
218
+ label=chosen_disease_name,
219
+ size=25,
220
+ shape="circular")
221
+ )
222
+
223
+ similar_diseases = get_most_similar_diseases_from_uri(engine, chosen_disease_uri, threshold=0.6)
224
+ print(similar_diseases)
225
+ for uri, name, weight in similar_diseases:
226
+ nodes.append( Node(id=uri,
227
+ label=name,
228
+ size=25,
229
+ shape="circular")
230
+ )
231
+
232
+ print(True if float(weight) > 0.7 else False)
233
+ edges.append( Edge(source=chosen_disease_uri,
234
+ target=uri,
235
+ color="red" if float(weight) > 0.7 else "blue",
236
+ weight=float(weight)**10,
237
+ type="CURVE_SMOOTH"
238
+ # type="STRAIGHT"
239
+ )
240
+ )
241
+
242
+ config = Config(width=750,
243
+ height=950,
244
+ directed=False,
245
+ physics=True,
246
+ hierarchical=False,
247
+ collapsible=False,
248
+ # **kwargs
249
+ )
250
+
251
+ return_value = agraph(nodes=nodes,
252
+ edges=edges,
253
+ config=config)