-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_app_test.py
84 lines (70 loc) · 2.78 KB
/
streamlit_app_test.py
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
import streamlit as st
import os
import re
# Define a function to display the network visualization
def network_page():
st.title('Glyco Interactome Network')
# Add your existing code for the network visualization here
st.sidebar.title('Choose your favorite Graph')
path = 'data/html/'
graph_set = set()
for filename in os.listdir(path):
if filename.endswith(".html"):
graph_set.add(filename.replace('.html', ''))
option = st.sidebar.selectbox('Select graph', (graph_set))
HtmlFile = open(path + option + '.html', 'r', encoding='utf-8')
source_code = HtmlFile.read()
st.components.v1.html(source_code, height=800, width=1000)
# Define a function to display the Figure section
def figure_page():
st.sidebar.title("Figure")
st.title('Boxplot')
# Add your existing code for the network visualization here
# st.sidebar.title('Choose your favorite Graph')
path = 'data/html/'
graph_set = set()
for filename in os.listdir(path):
if filename.endswith(".html"):
graph_set.add(filename.replace('.html', ''))
option = st.sidebar.selectbox('Select graph', (graph_set))
HtmlFile = open(path + option + '.html', 'r', encoding='utf-8')
source_code = HtmlFile.read()
figure = st.empty()
# get the row from source_code that contains "edges = new vis.DataSet"
edges_row = [row for row in source_code.splitlines() if "edges = new vis.DataSet" in row][0]
title_occurrences = re.findall(r'"title": "([^"]+)"', edges_row)
clicked_edge = st.sidebar.selectbox("Select an Interactome:", title_occurrences)
if clicked_edge:
edge_name = clicked_edge
figure_filename = os.path.join('data/boxplot/', edge_name + ".png") # Adjust the filename as needed
# set size of the figure
figure.image(figure_filename, use_column_width=True, caption=f"Abundance for Edge: {edge_name}",width=200)
# Define a function to display the Home page content
def home_page():
st.title('Home')
st.write('This is the home page content.')
# Define a function to display the Contact page content
def contact_page():
st.title('Contact Us')
st.write("You can reach out to us at contact@example.com")
# Define the main app layout
def main():
st.set_page_config(
page_title="Myco Interactome Network",
page_icon="🌐",
layout="wide",
)
# Navigation
st.sidebar.title("Navigation")
selection = st.sidebar.radio("Go to", ["Home", "Network", "Interactome", "Contact"])
# Page Display
if selection == "Home":
home_page()
elif selection == "Network":
network_page()
elif selection == "Interactome":
figure_page()
elif selection == "Contact":
contact_page()
if __name__ == "__main__":
main()