Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import sqlite3
|
| 3 |
import pandas as pd
|
| 4 |
-
import plotly.express as px
|
| 5 |
from datetime import datetime
|
|
|
|
| 6 |
|
| 7 |
# Page configuration
|
| 8 |
st.set_page_config(
|
|
@@ -14,7 +14,184 @@ st.set_page_config(
|
|
| 14 |
# Initialize database
|
| 15 |
@st.cache_resource
|
| 16 |
def init_db():
|
|
|
|
| 17 |
conn = sqlite3.connect('microid.db', check_same_thread=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
return conn
|
| 19 |
|
| 20 |
def load_tests():
|
|
@@ -34,7 +211,7 @@ def identify_organism(reactions):
|
|
| 34 |
query = """
|
| 35 |
SELECT
|
| 36 |
s.id, s.full_name, s.gram_stain, s.morphology,
|
| 37 |
-
bt.position, sp.reaction as expected_reaction
|
| 38 |
FROM species s
|
| 39 |
JOIN species_profiles sp ON s.id = sp.species_id
|
| 40 |
JOIN biochemical_tests bt ON sp.test_id = bt.id
|
|
@@ -112,14 +289,6 @@ st.markdown("""
|
|
| 112 |
margin: 5px;
|
| 113 |
border: 1px solid #e0e0e0;
|
| 114 |
}
|
| 115 |
-
.positive {
|
| 116 |
-
background-color: #d4edda;
|
| 117 |
-
border-color: #28a745;
|
| 118 |
-
}
|
| 119 |
-
.negative {
|
| 120 |
-
background-color: #f8d7da;
|
| 121 |
-
border-color: #dc3545;
|
| 122 |
-
}
|
| 123 |
.result-card {
|
| 124 |
background: white;
|
| 125 |
padding: 1rem;
|
|
@@ -140,6 +309,9 @@ st.markdown("""
|
|
| 140 |
color: #dc3545;
|
| 141 |
font-weight: bold;
|
| 142 |
}
|
|
|
|
|
|
|
|
|
|
| 143 |
</style>
|
| 144 |
""", unsafe_allow_html=True)
|
| 145 |
|
|
@@ -166,6 +338,7 @@ with st.sidebar:
|
|
| 166 |
""")
|
| 167 |
|
| 168 |
st.markdown("## 🧪 Quick Examples")
|
|
|
|
| 169 |
col1, col2 = st.columns(2)
|
| 170 |
with col1:
|
| 171 |
if st.button("🦠 E. coli", use_container_width=True):
|
|
@@ -188,9 +361,11 @@ with st.sidebar:
|
|
| 188 |
conn = init_db()
|
| 189 |
species_count = pd.read_sql_query("SELECT COUNT(*) as count FROM species", conn)['count'][0]
|
| 190 |
test_count = pd.read_sql_query("SELECT COUNT(*) as count FROM biochemical_tests", conn)['count'][0]
|
|
|
|
| 191 |
|
| 192 |
st.metric("Species in Database", species_count)
|
| 193 |
st.metric("Biochemical Tests", test_count)
|
|
|
|
| 194 |
|
| 195 |
# Main content
|
| 196 |
col1, col2 = st.columns([2, 1])
|
|
@@ -221,7 +396,7 @@ with col1:
|
|
| 221 |
st.rerun()
|
| 222 |
|
| 223 |
# Create grid of test buttons
|
| 224 |
-
cols_per_row =
|
| 225 |
for i in range(0, 20, cols_per_row):
|
| 226 |
cols = st.columns(cols_per_row)
|
| 227 |
for j in range(cols_per_row):
|
|
@@ -236,15 +411,13 @@ with col1:
|
|
| 236 |
# Reaction buttons
|
| 237 |
col_a, col_b = st.columns(2)
|
| 238 |
with col_a:
|
| 239 |
-
if st.
|
| 240 |
-
|
| 241 |
-
type="primary" if st.session_state.reactions[idx] == '+' else "secondary"):
|
| 242 |
st.session_state.reactions[idx] = '+'
|
| 243 |
st.rerun()
|
| 244 |
with col_b:
|
| 245 |
-
if st.
|
| 246 |
-
|
| 247 |
-
type="primary" if st.session_state.reactions[idx] == '-' else "secondary"):
|
| 248 |
st.session_state.reactions[idx] = '-'
|
| 249 |
st.rerun()
|
| 250 |
|
|
@@ -301,15 +474,10 @@ with col2:
|
|
| 301 |
</div>
|
| 302 |
""", unsafe_allow_html=True)
|
| 303 |
|
| 304 |
-
# Create
|
|
|
|
| 305 |
match_data = pd.DataFrame(results[:5])
|
| 306 |
-
|
| 307 |
-
title='Match Scores by Species',
|
| 308 |
-
labels={'match_score': 'Match Percentage', 'species': 'Species'},
|
| 309 |
-
color='match_score',
|
| 310 |
-
color_continuous_scale='Viridis')
|
| 311 |
-
fig.update_layout(height=300, showlegend=False)
|
| 312 |
-
st.plotly_chart(fig, use_container_width=True)
|
| 313 |
|
| 314 |
else:
|
| 315 |
st.info("👈 Enter biochemical reactions and click 'IDENTIFY ORGANISM' to see results")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import sqlite3
|
| 3 |
import pandas as pd
|
|
|
|
| 4 |
from datetime import datetime
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
# Page configuration
|
| 8 |
st.set_page_config(
|
|
|
|
| 14 |
# Initialize database
|
| 15 |
@st.cache_resource
|
| 16 |
def init_db():
|
| 17 |
+
"""Initialize SQLite database with species and biochemical profiles"""
|
| 18 |
conn = sqlite3.connect('microid.db', check_same_thread=False)
|
| 19 |
+
cursor = conn.cursor()
|
| 20 |
+
|
| 21 |
+
# Create tables
|
| 22 |
+
cursor.execute('''
|
| 23 |
+
CREATE TABLE IF NOT EXISTS species (
|
| 24 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 25 |
+
genus TEXT NOT NULL,
|
| 26 |
+
species TEXT NOT NULL,
|
| 27 |
+
full_name TEXT UNIQUE NOT NULL,
|
| 28 |
+
gram_stain TEXT,
|
| 29 |
+
morphology TEXT,
|
| 30 |
+
notes TEXT
|
| 31 |
+
)
|
| 32 |
+
''')
|
| 33 |
+
|
| 34 |
+
cursor.execute('''
|
| 35 |
+
CREATE TABLE IF NOT EXISTS biochemical_tests (
|
| 36 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 37 |
+
test_code TEXT UNIQUE NOT NULL,
|
| 38 |
+
test_name TEXT NOT NULL,
|
| 39 |
+
description TEXT,
|
| 40 |
+
position INTEGER
|
| 41 |
+
)
|
| 42 |
+
''')
|
| 43 |
+
|
| 44 |
+
cursor.execute('''
|
| 45 |
+
CREATE TABLE IF NOT EXISTS species_profiles (
|
| 46 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 47 |
+
species_id INTEGER,
|
| 48 |
+
test_id INTEGER,
|
| 49 |
+
reaction TEXT NOT NULL,
|
| 50 |
+
probability REAL DEFAULT 0.95,
|
| 51 |
+
FOREIGN KEY (species_id) REFERENCES species(id),
|
| 52 |
+
FOREIGN KEY (test_id) REFERENCES biochemical_tests(id)
|
| 53 |
+
)
|
| 54 |
+
''')
|
| 55 |
+
|
| 56 |
+
# Check if tests already exist
|
| 57 |
+
cursor.execute("SELECT COUNT(*) FROM biochemical_tests")
|
| 58 |
+
if cursor.fetchone()[0] == 0:
|
| 59 |
+
# Insert biochemical tests
|
| 60 |
+
tests = [
|
| 61 |
+
(1, 'ONPG', 'Beta-galactosidase', 1),
|
| 62 |
+
(2, 'ADH', 'Arginine dihydrolase', 2),
|
| 63 |
+
(3, 'LDC', 'Lysine decarboxylase', 3),
|
| 64 |
+
(4, 'ODC', 'Ornithine decarboxylase', 4),
|
| 65 |
+
(5, 'CIT', 'Citrate utilization', 5),
|
| 66 |
+
(6, 'H2S', 'Hydrogen sulfide', 6),
|
| 67 |
+
(7, 'URE', 'Urease', 7),
|
| 68 |
+
(8, 'TDA', 'Tryptophan deaminase', 8),
|
| 69 |
+
(9, 'IND', 'Indole production', 9),
|
| 70 |
+
(10, 'VP', 'Voges-Proskauer', 10),
|
| 71 |
+
(11, 'GEL', 'Gelatinase', 11),
|
| 72 |
+
(12, 'GLU', 'Glucose fermentation', 12),
|
| 73 |
+
(13, 'MAN', 'Mannitol', 13),
|
| 74 |
+
(14, 'INO', 'Inositol', 14),
|
| 75 |
+
(15, 'SOR', 'Sorbitol', 15),
|
| 76 |
+
(16, 'RHA', 'Rhamnose', 16),
|
| 77 |
+
(17, 'SAC', 'Sucrose', 17),
|
| 78 |
+
(18, 'MEL', 'Melibiose', 18),
|
| 79 |
+
(19, 'AMY', 'Amygdalin', 19),
|
| 80 |
+
(20, 'ARA', 'Arabinose', 20)
|
| 81 |
+
]
|
| 82 |
+
|
| 83 |
+
for test in tests:
|
| 84 |
+
cursor.execute('''
|
| 85 |
+
INSERT INTO biochemical_tests (id, test_code, test_name, position)
|
| 86 |
+
VALUES (?, ?, ?, ?)
|
| 87 |
+
''', test)
|
| 88 |
+
|
| 89 |
+
# Check if species already exist
|
| 90 |
+
cursor.execute("SELECT COUNT(*) FROM species")
|
| 91 |
+
if cursor.fetchone()[0] == 0:
|
| 92 |
+
# Insert species
|
| 93 |
+
species_list = [
|
| 94 |
+
('Escherichia', 'coli', 'Escherichia coli', 'negative', 'rod'),
|
| 95 |
+
('Pseudomonas', 'aeruginosa', 'Pseudomonas aeruginosa', 'negative', 'rod'),
|
| 96 |
+
('Staphylococcus', 'aureus', 'Staphylococcus aureus', 'positive', 'coccus'),
|
| 97 |
+
('Streptococcus', 'pneumoniae', 'Streptococcus pneumoniae', 'positive', 'coccus'),
|
| 98 |
+
('Klebsiella', 'pneumoniae', 'Klebsiella pneumoniae', 'negative', 'rod'),
|
| 99 |
+
('Proteus', 'mirabilis', 'Proteus mirabilis', 'negative', 'rod'),
|
| 100 |
+
('Enterococcus', 'faecalis', 'Enterococcus faecalis', 'positive', 'coccus'),
|
| 101 |
+
('Neisseria', 'gonorrhoeae', 'Neisseria gonorrhoeae', 'negative', 'coccus'),
|
| 102 |
+
('Haemophilus', 'influenzae', 'Haemophilus influenzae', 'negative', 'rod'),
|
| 103 |
+
('Candida', 'albicans', 'Candida albicans', 'yeast', 'yeast'),
|
| 104 |
+
('Salmonella', 'typhimurium', 'Salmonella typhimurium', 'negative', 'rod'),
|
| 105 |
+
('Shigella', 'flexneri', 'Shigella flexneri', 'negative', 'rod'),
|
| 106 |
+
('Bacillus', 'subtilis', 'Bacillus subtilis', 'positive', 'rod'),
|
| 107 |
+
('Clostridium', 'perfringens', 'Clostridium perfringens', 'positive', 'rod'),
|
| 108 |
+
('Listeria', 'monocytogenes', 'Listeria monocytogenes', 'positive', 'rod'),
|
| 109 |
+
('Acinetobacter', 'baumannii', 'Acinetobacter baumannii', 'negative', 'coccus'),
|
| 110 |
+
('Enterobacter', 'cloacae', 'Enterobacter cloacae', 'negative', 'rod'),
|
| 111 |
+
('Serratia', 'marcescens', 'Serratia marcescens', 'negative', 'rod'),
|
| 112 |
+
('Citrobacter', 'freundii', 'Citrobacter freundii', 'negative', 'rod'),
|
| 113 |
+
('Morganella', 'morganii', 'Morganella morganii', 'negative', 'rod'),
|
| 114 |
+
('Yersinia', 'enterocolitica', 'Yersinia enterocolitica', 'negative', 'rod'),
|
| 115 |
+
('Vibrio', 'cholerae', 'Vibrio cholerae', 'negative', 'rod'),
|
| 116 |
+
('Campylobacter', 'jejuni', 'Campylobacter jejuni', 'negative', 'curved rod'),
|
| 117 |
+
('Bacteroides', 'fragilis', 'Bacteroides fragilis', 'negative', 'rod'),
|
| 118 |
+
('Lactobacillus', 'acidophilus', 'Lactobacillus acidophilus', 'positive', 'rod'),
|
| 119 |
+
('Streptococcus', 'pyogenes', 'Streptococcus pyogenes', 'positive', 'coccus'),
|
| 120 |
+
('Staphylococcus', 'epidermidis', 'Staphylococcus epidermidis', 'positive', 'coccus'),
|
| 121 |
+
('Candida', 'glabrata', 'Candida glabrata', 'yeast', 'yeast'),
|
| 122 |
+
('Candida', 'parapsilosis', 'Candida parapsilosis', 'yeast', 'yeast'),
|
| 123 |
+
('Candida', 'tropicalis', 'Candida tropicalis', 'yeast', 'yeast'),
|
| 124 |
+
('Cryptococcus', 'neoformans', 'Cryptococcus neoformans', 'yeast', 'yeast')
|
| 125 |
+
]
|
| 126 |
+
|
| 127 |
+
for species in species_list:
|
| 128 |
+
cursor.execute('''
|
| 129 |
+
INSERT INTO species (genus, species, full_name, gram_stain, morphology)
|
| 130 |
+
VALUES (?, ?, ?, ?, ?)
|
| 131 |
+
''', species)
|
| 132 |
+
|
| 133 |
+
# Get species and test IDs
|
| 134 |
+
cursor.execute('SELECT id, full_name FROM species')
|
| 135 |
+
species_map = {row[1]: row[0] for row in cursor.fetchall()}
|
| 136 |
+
|
| 137 |
+
cursor.execute('SELECT id, test_code FROM biochemical_tests')
|
| 138 |
+
test_map = {row[1]: row[0] for row in cursor.fetchall()}
|
| 139 |
+
|
| 140 |
+
# Check if profiles exist
|
| 141 |
+
cursor.execute("SELECT COUNT(*) FROM species_profiles")
|
| 142 |
+
if cursor.fetchone()[0] == 0:
|
| 143 |
+
# Insert profiles for key species
|
| 144 |
+
profiles = {
|
| 145 |
+
'Escherichia coli': {
|
| 146 |
+
'ONPG':'+', 'ADH':'-', 'LDC':'+', 'ODC':'+', 'CIT':'-',
|
| 147 |
+
'H2S':'-', 'URE':'-', 'TDA':'-', 'IND':'+', 'VP':'-',
|
| 148 |
+
'GEL':'-', 'GLU':'+', 'MAN':'+', 'INO':'-', 'SOR':'+',
|
| 149 |
+
'RHA':'+', 'SAC':'+', 'MEL':'+', 'AMY':'-', 'ARA':'+'
|
| 150 |
+
},
|
| 151 |
+
'Pseudomonas aeruginosa': {
|
| 152 |
+
'ONPG':'-', 'ADH':'+', 'LDC':'-', 'ODC':'-', 'CIT':'+',
|
| 153 |
+
'H2S':'-', 'URE':'-', 'TDA':'-', 'IND':'-', 'VP':'-',
|
| 154 |
+
'GEL':'+', 'GLU':'+', 'MAN':'-', 'INO':'-', 'SOR':'-',
|
| 155 |
+
'RHA':'-', 'SAC':'-', 'MEL':'-', 'AMY':'-', 'ARA':'-'
|
| 156 |
+
},
|
| 157 |
+
'Staphylococcus aureus': {
|
| 158 |
+
'ONPG':'+', 'ADH':'-', 'LDC':'-', 'ODC':'-', 'CIT':'V',
|
| 159 |
+
'H2S':'-', 'URE':'+', 'TDA':'-', 'IND':'-', 'VP':'+',
|
| 160 |
+
'GEL':'V', 'GLU':'+', 'MAN':'+', 'INO':'-', 'SOR':'+',
|
| 161 |
+
'RHA':'V', 'SAC':'+', 'MEL':'-', 'AMY':'V', 'ARA':'-'
|
| 162 |
+
},
|
| 163 |
+
'Klebsiella pneumoniae': {
|
| 164 |
+
'ONPG':'+', 'ADH':'-', 'LDC':'+', 'ODC':'-', 'CIT':'+',
|
| 165 |
+
'H2S':'-', 'URE':'+', 'TDA':'-', 'IND':'-', 'VP':'+',
|
| 166 |
+
'GEL':'-', 'GLU':'+', 'MAN':'+', 'INO':'+', 'SOR':'+',
|
| 167 |
+
'RHA':'+', 'SAC':'+', 'MEL':'+', 'AMY':'+', 'ARA':'+'
|
| 168 |
+
},
|
| 169 |
+
'Proteus mirabilis': {
|
| 170 |
+
'ONPG':'-', 'ADH':'-', 'LDC':'-', 'ODC':'-', 'CIT':'V',
|
| 171 |
+
'H2S':'+', 'URE':'+', 'TDA':'+', 'IND':'-', 'VP':'-',
|
| 172 |
+
'GEL':'-', 'GLU':'+', 'MAN':'-', 'INO':'-', 'SOR':'-',
|
| 173 |
+
'RHA':'-', 'SAC':'-', 'MEL':'-', 'AMY':'-', 'ARA':'-'
|
| 174 |
+
},
|
| 175 |
+
'Enterococcus faecalis': {
|
| 176 |
+
'ONPG':'+', 'ADH':'+', 'LDC':'-', 'ODC':'-', 'CIT':'-',
|
| 177 |
+
'H2S':'-', 'URE':'-', 'TDA':'-', 'IND':'-', 'VP':'-',
|
| 178 |
+
'GEL':'V', 'GLU':'+', 'MAN':'+', 'INO':'-', 'SOR':'-',
|
| 179 |
+
'RHA':'-', 'SAC':'+', 'MEL':'-', 'AMY':'-', 'ARA':'-'
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
for species_name, reactions in profiles.items():
|
| 184 |
+
if species_name in species_map:
|
| 185 |
+
species_id = species_map[species_name]
|
| 186 |
+
for test_code, reaction in reactions.items():
|
| 187 |
+
if test_code in test_map:
|
| 188 |
+
test_id = test_map[test_code]
|
| 189 |
+
cursor.execute('''
|
| 190 |
+
INSERT INTO species_profiles (species_id, test_id, reaction)
|
| 191 |
+
VALUES (?, ?, ?)
|
| 192 |
+
''', (species_id, test_id, reaction))
|
| 193 |
+
|
| 194 |
+
conn.commit()
|
| 195 |
return conn
|
| 196 |
|
| 197 |
def load_tests():
|
|
|
|
| 211 |
query = """
|
| 212 |
SELECT
|
| 213 |
s.id, s.full_name, s.gram_stain, s.morphology,
|
| 214 |
+
bt.position, bt.test_code, sp.reaction as expected_reaction
|
| 215 |
FROM species s
|
| 216 |
JOIN species_profiles sp ON s.id = sp.species_id
|
| 217 |
JOIN biochemical_tests bt ON sp.test_id = bt.id
|
|
|
|
| 289 |
margin: 5px;
|
| 290 |
border: 1px solid #e0e0e0;
|
| 291 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
.result-card {
|
| 293 |
background: white;
|
| 294 |
padding: 1rem;
|
|
|
|
| 309 |
color: #dc3545;
|
| 310 |
font-weight: bold;
|
| 311 |
}
|
| 312 |
+
.stButton > button {
|
| 313 |
+
width: 100%;
|
| 314 |
+
}
|
| 315 |
</style>
|
| 316 |
""", unsafe_allow_html=True)
|
| 317 |
|
|
|
|
| 338 |
""")
|
| 339 |
|
| 340 |
st.markdown("## 🧪 Quick Examples")
|
| 341 |
+
|
| 342 |
col1, col2 = st.columns(2)
|
| 343 |
with col1:
|
| 344 |
if st.button("🦠 E. coli", use_container_width=True):
|
|
|
|
| 361 |
conn = init_db()
|
| 362 |
species_count = pd.read_sql_query("SELECT COUNT(*) as count FROM species", conn)['count'][0]
|
| 363 |
test_count = pd.read_sql_query("SELECT COUNT(*) as count FROM biochemical_tests", conn)['count'][0]
|
| 364 |
+
profile_count = pd.read_sql_query("SELECT COUNT(*) as count FROM species_profiles", conn)['count'][0]
|
| 365 |
|
| 366 |
st.metric("Species in Database", species_count)
|
| 367 |
st.metric("Biochemical Tests", test_count)
|
| 368 |
+
st.metric("Profile Entries", profile_count)
|
| 369 |
|
| 370 |
# Main content
|
| 371 |
col1, col2 = st.columns([2, 1])
|
|
|
|
| 396 |
st.rerun()
|
| 397 |
|
| 398 |
# Create grid of test buttons
|
| 399 |
+
cols_per_row = 4
|
| 400 |
for i in range(0, 20, cols_per_row):
|
| 401 |
cols = st.columns(cols_per_row)
|
| 402 |
for j in range(cols_per_row):
|
|
|
|
| 411 |
# Reaction buttons
|
| 412 |
col_a, col_b = st.columns(2)
|
| 413 |
with col_a:
|
| 414 |
+
button_type = "primary" if st.session_state.reactions[idx] == '+' else "secondary"
|
| 415 |
+
if st.button(f"+", key=f"pos_{idx}", use_container_width=True, type=button_type):
|
|
|
|
| 416 |
st.session_state.reactions[idx] = '+'
|
| 417 |
st.rerun()
|
| 418 |
with col_b:
|
| 419 |
+
button_type = "primary" if st.session_state.reactions[idx] == '-' else "secondary"
|
| 420 |
+
if st.button(f"-", key=f"neg_{idx}", use_container_width=True, type=button_type):
|
|
|
|
| 421 |
st.session_state.reactions[idx] = '-'
|
| 422 |
st.rerun()
|
| 423 |
|
|
|
|
| 474 |
</div>
|
| 475 |
""", unsafe_allow_html=True)
|
| 476 |
|
| 477 |
+
# Create simple bar chart using Streamlit
|
| 478 |
+
st.markdown("### 📊 Match Scores")
|
| 479 |
match_data = pd.DataFrame(results[:5])
|
| 480 |
+
st.bar_chart(match_data.set_index('species')['match_score'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 481 |
|
| 482 |
else:
|
| 483 |
st.info("👈 Enter biochemical reactions and click 'IDENTIFY ORGANISM' to see results")
|