Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -292,19 +292,31 @@ def extract_window_coords(residues, window_indices):
|
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
-
def generate_windows_from_selection(selected_indices,
|
| 296 |
-
"""Generate windows from selected indices"""
|
| 297 |
-
if len(selected_indices) <
|
| 298 |
return []
|
| 299 |
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
else: # non-contiguous
|
| 306 |
-
|
| 307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
|
| 309 |
def main():
|
| 310 |
st.markdown('<h1 class="main-header">🧬 RNA Motif Multi-Structure Comparison</h1>', unsafe_allow_html=True)
|
|
|
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
+
def generate_windows_from_selection(selected_indices, window_size, window_type):
|
| 296 |
+
"""Generate windows from selected residue indices"""
|
| 297 |
+
if len(selected_indices) < window_size:
|
| 298 |
return []
|
| 299 |
|
| 300 |
+
windows = []
|
| 301 |
+
if window_type == "contiguous":
|
| 302 |
+
# Only sliding windows
|
| 303 |
+
for i in range(len(selected_indices) - window_size + 1):
|
| 304 |
+
windows.append(selected_indices[i:i+window_size])
|
| 305 |
else: # non-contiguous
|
| 306 |
+
from itertools import combinations
|
| 307 |
+
all_combos = list(combinations(selected_indices, window_size))
|
| 308 |
+
|
| 309 |
+
# Get the contiguous windows (to exclude them)
|
| 310 |
+
contiguous_windows = []
|
| 311 |
+
for i in range(len(selected_indices) - window_size + 1):
|
| 312 |
+
contiguous_windows.append(tuple(selected_indices[i:i+window_size]))
|
| 313 |
+
|
| 314 |
+
# Filter: keep only combinations that are NOT in contiguous_windows
|
| 315 |
+
for combo in all_combos:
|
| 316 |
+
if combo not in contiguous_windows:
|
| 317 |
+
windows.append(list(combo))
|
| 318 |
+
|
| 319 |
+
return windows
|
| 320 |
|
| 321 |
def main():
|
| 322 |
st.markdown('<h1 class="main-header">🧬 RNA Motif Multi-Structure Comparison</h1>', unsafe_allow_html=True)
|