Spaces:
Sleeping
Sleeping
Layout
Browse files- app.py +39 -22
- assets/style.css +150 -0
app.py
CHANGED
|
@@ -5,23 +5,6 @@ import logging
|
|
| 5 |
logging.basicConfig(level=logging.INFO)
|
| 6 |
logger = logging.getLogger(__name__)
|
| 7 |
|
| 8 |
-
# Set Page Config
|
| 9 |
-
st.set_page_config(
|
| 10 |
-
page_title="spMetaTME Atlas",
|
| 11 |
-
page_icon=":material/hub:",
|
| 12 |
-
layout="centered",
|
| 13 |
-
initial_sidebar_state="expanded",
|
| 14 |
-
)
|
| 15 |
-
|
| 16 |
-
# Import UI Components and Pages
|
| 17 |
-
from src.ui.components.header import render_header, load_css
|
| 18 |
-
from src.ui.components.footer import render_footer
|
| 19 |
-
|
| 20 |
-
from src.ui.pages.overview import show_overview
|
| 21 |
-
from src.ui.pages.visualization import show_visualization
|
| 22 |
-
from src.ui.pages.preprocessing import show_preprocessing
|
| 23 |
-
from src.ui.pages.flux_analysis import show_flux_analysis
|
| 24 |
-
|
| 25 |
def init_session_state():
|
| 26 |
"""Initialise global session state."""
|
| 27 |
if "adata" not in st.session_state:
|
|
@@ -76,19 +59,53 @@ def render_sidebar_dev():
|
|
| 76 |
st.success("Loaded Breast Cancer Block A (HF local cache)")
|
| 77 |
st.rerun()
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
def main():
|
| 80 |
load_css()
|
| 81 |
init_session_state()
|
| 82 |
-
# render_sidebar_dev()
|
| 83 |
|
| 84 |
-
#
|
| 85 |
if st.session_state.metabolic_adata is not None:
|
| 86 |
-
|
| 87 |
elif st.session_state.adata is not None:
|
| 88 |
if st.session_state.preprocessing_done:
|
| 89 |
-
|
| 90 |
else:
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
else:
|
| 93 |
render_header()
|
| 94 |
show_overview()
|
|
|
|
| 5 |
logging.basicConfig(level=logging.INFO)
|
| 6 |
logger = logging.getLogger(__name__)
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def init_session_state():
|
| 9 |
"""Initialise global session state."""
|
| 10 |
if "adata" not in st.session_state:
|
|
|
|
| 59 |
st.success("Loaded Breast Cancer Block A (HF local cache)")
|
| 60 |
st.rerun()
|
| 61 |
|
| 62 |
+
# Import UI Components and Pages (after session state init)
|
| 63 |
+
from src.ui.components.header import render_header, load_css
|
| 64 |
+
from src.ui.components.footer import render_footer
|
| 65 |
+
|
| 66 |
+
from src.ui.pages.overview import show_overview
|
| 67 |
+
from src.ui.pages.visualization import show_visualization
|
| 68 |
+
from src.ui.pages.preprocessing import show_preprocessing
|
| 69 |
+
from src.ui.pages.flux_analysis import show_flux_analysis
|
| 70 |
+
|
| 71 |
def main():
|
| 72 |
load_css()
|
| 73 |
init_session_state()
|
|
|
|
| 74 |
|
| 75 |
+
# Determine which page will be shown
|
| 76 |
if st.session_state.metabolic_adata is not None:
|
| 77 |
+
current_page = "visualization"
|
| 78 |
elif st.session_state.adata is not None:
|
| 79 |
if st.session_state.preprocessing_done:
|
| 80 |
+
current_page = "flux_analysis"
|
| 81 |
else:
|
| 82 |
+
current_page = "preprocessing"
|
| 83 |
+
else:
|
| 84 |
+
current_page = "overview"
|
| 85 |
+
|
| 86 |
+
# Set page layout based on current page
|
| 87 |
+
if current_page == "overview":
|
| 88 |
+
layout = "centered" # Full width for home page
|
| 89 |
+
else:
|
| 90 |
+
layout = "wide" # Wide layout for other pages (85% width via CSS)
|
| 91 |
+
|
| 92 |
+
# Configure page with appropriate layout
|
| 93 |
+
st.set_page_config(
|
| 94 |
+
page_title="spMetaTME Atlas",
|
| 95 |
+
page_icon=":material/hub:",
|
| 96 |
+
layout=layout,
|
| 97 |
+
initial_sidebar_state="expanded",
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
# render_sidebar_dev()
|
| 101 |
+
|
| 102 |
+
# Render the appropriate page
|
| 103 |
+
if current_page == "visualization":
|
| 104 |
+
show_visualization()
|
| 105 |
+
elif current_page == "preprocessing":
|
| 106 |
+
show_preprocessing()
|
| 107 |
+
elif current_page == "flux_analysis":
|
| 108 |
+
show_flux_analysis()
|
| 109 |
else:
|
| 110 |
render_header()
|
| 111 |
show_overview()
|
assets/style.css
CHANGED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Main container styling */
|
| 2 |
+
* {
|
| 3 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
:root {
|
| 7 |
+
--primary-red: #d32f2f;
|
| 8 |
+
/* Strong Material Red */
|
| 9 |
+
--light-red: #ffebee;
|
| 10 |
+
--hover-red: #ffcdd2;
|
| 11 |
+
--dark-red: #b71c1c;
|
| 12 |
+
--text-color: #333333;
|
| 13 |
+
--border-color: #e0e0e0;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
.main {
|
| 17 |
+
background-color: #fffafb;
|
| 18 |
+
/* Very light red tint */
|
| 19 |
+
padding: 1rem;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/* Main Header */
|
| 23 |
+
.main-header {
|
| 24 |
+
font-size: 2.5rem;
|
| 25 |
+
color: var(--primary-red);
|
| 26 |
+
margin-bottom: 1.5rem;
|
| 27 |
+
font-weight: 700;
|
| 28 |
+
letter-spacing: -0.5px;
|
| 29 |
+
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/* Section Headers */
|
| 33 |
+
.section-header {
|
| 34 |
+
font-size: 1.8rem;
|
| 35 |
+
color: var(--primary-red);
|
| 36 |
+
margin-top: 1rem;
|
| 37 |
+
margin-bottom: 1.5rem;
|
| 38 |
+
font-weight: 600;
|
| 39 |
+
border-bottom: 3px solid var(--primary-red);
|
| 40 |
+
padding-bottom: 0.5rem;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/* Info Boxes with Material Design Shadow */
|
| 44 |
+
.info-box {
|
| 45 |
+
background: linear-gradient(135deg, var(--light-red) 0%, #fffde7 100%);
|
| 46 |
+
padding: 1.5rem;
|
| 47 |
+
border-radius: 8px;
|
| 48 |
+
margin: 1rem 0;
|
| 49 |
+
border-left: 4px solid var(--primary-red);
|
| 50 |
+
box-shadow: 0 2px 8px rgba(211, 47, 47, 0.1);
|
| 51 |
+
transition: all 0.3s ease;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.info-box:hover {
|
| 55 |
+
box-shadow: 0 4px 16px rgba(211, 47, 47, 0.2);
|
| 56 |
+
transform: translateY(-2px);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/* Success Boxes */
|
| 60 |
+
.success-box {
|
| 61 |
+
background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
|
| 62 |
+
padding: 1.5rem;
|
| 63 |
+
border-radius: 8px;
|
| 64 |
+
margin: 1rem 0;
|
| 65 |
+
border-left: 4px solid #2e7d32;
|
| 66 |
+
box-shadow: 0 2px 8px rgba(46, 125, 50, 0.1);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/* Card Styling for Material Design */
|
| 70 |
+
.material-card {
|
| 71 |
+
background: white;
|
| 72 |
+
border-radius: 12px;
|
| 73 |
+
padding: 1.5rem;
|
| 74 |
+
margin: 1rem 0;
|
| 75 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
| 76 |
+
transition: all 0.3s ease;
|
| 77 |
+
border: 1px solid var(--border-color);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.material-card:hover {
|
| 81 |
+
box-shadow: 0 8px 24px rgba(211, 47, 47, 0.1);
|
| 82 |
+
transform: translateY(-4px);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/* Button Styling */
|
| 86 |
+
.stButton>button {
|
| 87 |
+
border-radius: 8px;
|
| 88 |
+
padding: 0.6rem 1.8rem;
|
| 89 |
+
font-weight: 600;
|
| 90 |
+
background: white;
|
| 91 |
+
color: var(--primary-red);
|
| 92 |
+
border: 1px solid var(--primary-red);
|
| 93 |
+
transition: all 0.2s ease;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.stButton>button:hover {
|
| 97 |
+
background-color: var(--light-red);
|
| 98 |
+
border-color: var(--primary-red);
|
| 99 |
+
color: var(--primary-red);
|
| 100 |
+
box-shadow: 0 2px 8px rgba(211, 47, 47, 0.2);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/* Tab Styling */
|
| 104 |
+
.stTabs [data-baseweb="tab-list"] {
|
| 105 |
+
gap: 15px;
|
| 106 |
+
border-bottom: 2px solid var(--border-color);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.stTabs [data-baseweb="tab"] {
|
| 110 |
+
border-radius: 8px 8px 0 0;
|
| 111 |
+
padding: 12px 24px;
|
| 112 |
+
font-weight: 600;
|
| 113 |
+
background-color: transparent;
|
| 114 |
+
border: none;
|
| 115 |
+
color: #666;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.stTabs [data-baseweb="tab"][aria-selected="true"] {
|
| 119 |
+
color: var(--primary-red);
|
| 120 |
+
border-bottom: 3px solid var(--primary-red);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/* Sidebar Styling */
|
| 124 |
+
section[data-testid="stSidebar"] {
|
| 125 |
+
background-color: #ffffff;
|
| 126 |
+
border-right: 1px solid var(--border-color);
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/* Visualization Container */
|
| 130 |
+
.viz-container {
|
| 131 |
+
background: white;
|
| 132 |
+
border-radius: 16px;
|
| 133 |
+
padding: 2.5rem;
|
| 134 |
+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
|
| 135 |
+
margin: 1.5rem 0;
|
| 136 |
+
border: 1px solid #f0f4f8;
|
| 137 |
+
}
|
| 138 |
+
/* Fix flickering on HuggingFace Spaces with stable selector */
|
| 139 |
+
/* @media (min-width: calc(736px + 8rem)) {
|
| 140 |
+
section[data-testid="stMain"] {
|
| 141 |
+
padding-left: 5rem !important;
|
| 142 |
+
padding-right: 5rem !important;
|
| 143 |
+
}
|
| 144 |
+
} */
|
| 145 |
+
|
| 146 |
+
/* Constrain wide layout to 85% for visualization pages */
|
| 147 |
+
div[data-testid="stMainBlockContainer"] {
|
| 148 |
+
max-width: 95% !important;
|
| 149 |
+
margin: 0 auto !important;
|
| 150 |
+
}
|