jiehou commited on
Commit
d30c23c
·
verified ·
1 Parent(s): ce2d454

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -10
app.py CHANGED
@@ -24,6 +24,13 @@ from rmsd_utils import (
24
  get_base_coords_from_residue
25
  )
26
 
 
 
 
 
 
 
 
27
  # Page configuration
28
  st.set_page_config(
29
  page_title="RNA Motif Multi-Structure Comparison",
@@ -280,18 +287,66 @@ def main():
280
  # Sidebar
281
  st.sidebar.header("⚙️ Configuration")
282
 
283
- # Step 1: File upload
284
- st.sidebar.subheader("1️⃣ Upload Structures")
285
- uploaded_files = st.sidebar.file_uploader(
286
- "Upload RNA Motif PDB files",
287
- type=['pdb', 'PDB'],
288
- accept_multiple_files=True,
289
- key="structures",
290
- help="Upload all RNA motif structures to compare"
 
291
  )
292
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  if not uploaded_files:
294
- st.info("👈 Please upload RNA motif PDB files to begin analysis")
295
  with st.expander("ℹ️ About this tool"):
296
  st.markdown("""
297
  ### Multi-Structure RNA Motif Comparison
@@ -299,7 +354,7 @@ def main():
299
  This tool compares multiple RNA motif structures simultaneously using window-based alignment.
300
 
301
  **Workflow:**
302
- 1. Upload all PDB structures
303
  2. Structures ranked by length (shortest first)
304
  3. Select residues for each structure via dropdown
305
  4. Choose reference structure (default: shortest)
@@ -313,6 +368,12 @@ def main():
313
  - Interactive 3D visualization with all structures
314
  - Color-coded structures
315
  - RMSD-based alignment quality
 
 
 
 
 
 
316
  """)
317
  return
318
 
 
24
  get_base_coords_from_residue
25
  )
26
 
27
+ # Import example data loader
28
+ from example_data_loader import (
29
+ get_example_pdbs,
30
+ load_example_as_uploaded_file,
31
+ get_example_info
32
+ )
33
+
34
  # Page configuration
35
  st.set_page_config(
36
  page_title="RNA Motif Multi-Structure Comparison",
 
287
  # Sidebar
288
  st.sidebar.header("⚙️ Configuration")
289
 
290
+ # Step 1: File upload or Example data
291
+ st.sidebar.subheader("1️⃣ Load Structures")
292
+
293
+ # Add tabs for Upload vs Examples
294
+ data_source = st.sidebar.radio(
295
+ "Data Source",
296
+ ["Upload Files", "Use Examples"],
297
+ key="data_source",
298
+ help="Choose to upload your own files or use example data"
299
  )
300
 
301
+ uploaded_files = []
302
+
303
+ if data_source == "Upload Files":
304
+ uploaded_files_raw = st.sidebar.file_uploader(
305
+ "Upload RNA Motif PDB files",
306
+ type=['pdb', 'PDB'],
307
+ accept_multiple_files=True,
308
+ key="structures",
309
+ help="Upload all RNA motif structures to compare"
310
+ )
311
+ if uploaded_files_raw:
312
+ uploaded_files = list(uploaded_files_raw)
313
+
314
+ else: # Use Examples
315
+ # Check if data folder exists
316
+ data_folder = "data"
317
+ examples = get_example_pdbs(data_folder)
318
+
319
+ if not examples:
320
+ st.sidebar.warning(f"⚠️ No example files found in '{data_folder}/' folder")
321
+ st.sidebar.info("💡 Create a 'data/' folder and add .pdb files to use examples")
322
+ else:
323
+ st.sidebar.success(f"📁 Found {len(examples)} example files")
324
+
325
+ # Show example info in expander
326
+ with st.sidebar.expander("📋 View Example Files"):
327
+ example_info = get_example_info(data_folder)
328
+ for name, info in sorted(example_info.items()):
329
+ if 'error' not in info:
330
+ st.caption(f"**{name}**")
331
+ st.caption(f" └ {info['atoms']} atoms")
332
+
333
+ # Multiselect for examples
334
+ selected_names = st.sidebar.multiselect(
335
+ "Select example PDB files",
336
+ options=sorted(examples.keys()),
337
+ default=sorted(examples.keys())[:3] if len(examples) >= 3 else sorted(examples.keys()),
338
+ help="Choose one or more example structures"
339
+ )
340
+
341
+ if selected_names:
342
+ # Convert example files to uploaded file format
343
+ for name in selected_names:
344
+ uploaded_files.append(load_example_as_uploaded_file(examples[name]))
345
+
346
+ st.sidebar.success(f"✅ Loaded {len(uploaded_files)} example file(s)")
347
+
348
  if not uploaded_files:
349
+ st.info("👈 Please upload RNA motif PDB files or select examples to begin analysis")
350
  with st.expander("ℹ️ About this tool"):
351
  st.markdown("""
352
  ### Multi-Structure RNA Motif Comparison
 
354
  This tool compares multiple RNA motif structures simultaneously using window-based alignment.
355
 
356
  **Workflow:**
357
+ 1. Upload PDB structures or use examples
358
  2. Structures ranked by length (shortest first)
359
  3. Select residues for each structure via dropdown
360
  4. Choose reference structure (default: shortest)
 
368
  - Interactive 3D visualization with all structures
369
  - Color-coded structures
370
  - RMSD-based alignment quality
371
+ - Example data for testing
372
+
373
+ **Using Examples:**
374
+ - Create a folder named `data/` in your app directory
375
+ - Add .pdb files to the data folder
376
+ - Select "Use Examples" to load them
377
  """)
378
  return
379