Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -342,32 +342,55 @@ with tab4:
|
|
| 342 |
|
| 343 |
# Tab 5: Binary β String
|
| 344 |
with tab5:
|
| 345 |
-
st.
|
| 346 |
-
st.write("**Note:** Please upload CSV files **without column headers**.")
|
| 347 |
-
binary_file = st.file_uploader("Upload Binary CSV", type=["csv"], key="binary_csv")
|
| 348 |
|
| 349 |
-
|
| 350 |
-
|
|
|
|
| 351 |
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
|
| 356 |
-
|
| 357 |
-
|
|
|
|
| 358 |
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
|
| 367 |
-
|
| 368 |
-
decoded_ascending = binary_labels_to_string(all_bits_ascending)
|
| 369 |
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
|
|
|
|
| 342 |
|
| 343 |
# Tab 5: Binary β String
|
| 344 |
with tab5:
|
| 345 |
+
st.header("Decode Binary Labels to String")
|
|
|
|
|
|
|
| 346 |
|
| 347 |
+
st.subheader("π Option 1: 32-bit Binary per Row")
|
| 348 |
+
st.write("Upload CSV with 32 columns (0 or 1), no headers, from EF Binary format.")
|
| 349 |
+
binary32_file = st.file_uploader("Upload 32-bit Binary CSV", type=["csv"], key="binary_32")
|
| 350 |
|
| 351 |
+
if binary32_file:
|
| 352 |
+
df_32 = pd.read_csv(binary32_file, header=None)
|
| 353 |
+
if df_32.shape[1] != 32:
|
| 354 |
+
st.warning("β οΈ CSV must have exactly 32 columns.")
|
| 355 |
+
else:
|
| 356 |
+
# Reordered: 4402 β 3244, 4882 β 4455
|
| 357 |
+
df_32.columns = [str(h) for h in mutation_site_headers_3614]
|
| 358 |
+
all_bits = df_32.values.flatten().astype(int).tolist()
|
| 359 |
+
decoded_reordered = binary_labels_to_string(all_bits)
|
| 360 |
|
| 361 |
+
st.subheader("Decoded String (Reordered 4402β3244, 4882β4455)")
|
| 362 |
+
st.write(decoded_reordered)
|
| 363 |
+
st.download_button("Download Reordered CSV", df_32.to_csv(index=False), "decoded_binary_32_reordered.csv", key="download_csv_tab5_32_reordered")
|
| 364 |
|
| 365 |
+
# Ascending: 3244 β 4882
|
| 366 |
+
df_ascending = df_32[[str(h) for h in mutation_site_headers_actual_3614 if str(h) in df_32.columns]]
|
| 367 |
+
decoded_asc = binary_labels_to_string(df_ascending.values.flatten().astype(int).tolist())
|
| 368 |
|
| 369 |
+
st.subheader("Decoded String (Ascending 3244β4882)")
|
| 370 |
+
st.write(decoded_asc)
|
| 371 |
+
st.download_button("Download Ascending CSV", df_ascending.to_csv(index=False), "decoded_binary_32_ascending.csv", key="download_csv_tab5_32_ascend")
|
| 372 |
|
| 373 |
+
st.markdown("---")
|
|
|
|
| 374 |
|
| 375 |
+
st.subheader("π Option 2: 31-bit Binary Grouped per Row")
|
| 376 |
+
st.write("Upload CSV with 31 columns per row (each row = one 6-bit ASCII chunk group).")
|
| 377 |
+
binary31_file = st.file_uploader("Upload 31-bit Group CSV", type=["csv"], key="binary_31")
|
| 378 |
+
|
| 379 |
+
if binary31_file:
|
| 380 |
+
df_31 = pd.read_csv(binary31_file, header=None)
|
| 381 |
+
|
| 382 |
+
def trim_row(row):
|
| 383 |
+
bits = row.dropna().astype(int).tolist()[:31]
|
| 384 |
+
return bits
|
| 385 |
+
|
| 386 |
+
decoded_rows = []
|
| 387 |
+
for _, row in df_31.iterrows():
|
| 388 |
+
bits = trim_row(row)
|
| 389 |
+
decoded_rows.append(binary_labels_to_string(bits))
|
| 390 |
+
|
| 391 |
+
st.subheader("Decoded String from 31-bit Chunks")
|
| 392 |
+
full_decoded = "".join(decoded_rows)
|
| 393 |
+
st.write(full_decoded)
|
| 394 |
+
|
| 395 |
+
st.download_button("Download Concatenated Output", full_decoded, "decoded_31bit_string.txt", key="download_csv_tab5_31")
|
| 396 |
|