Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -71,7 +71,7 @@ def binary_labels_to_string(bits: list[int]) -> str:
|
|
71 |
# === Streamlit App ===
|
72 |
|
73 |
st.title("ASCII & Binary Label Converter")
|
74 |
-
tab1, tab2, tab3, tab4 = st.tabs(["Text to Binary Labels (31)", "EF β Binary (31)", "Text to Binary Labels (32)", "EF β Binary (
|
75 |
|
76 |
# Tab 1: Text to Binary
|
77 |
with tab1:
|
@@ -340,3 +340,34 @@ with tab4:
|
|
340 |
st.subheader("Decoded String (continuous across rows)")
|
341 |
st.write(decoded_string)
|
342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
# === Streamlit App ===
|
72 |
|
73 |
st.title("ASCII & Binary Label Converter")
|
74 |
+
tab1, tab2, tab3, tab4, tab5 = st.tabs(["Text to Binary Labels (31)", "EF β Binary β String (31)", "Text to Binary Labels (32)", "EF β Binary (32)", "Binary β String"])
|
75 |
|
76 |
# Tab 1: Text to Binary
|
77 |
with tab1:
|
|
|
340 |
st.subheader("Decoded String (continuous across rows)")
|
341 |
st.write(decoded_string)
|
342 |
|
343 |
+
# Tab 5: Binary β String
|
344 |
+
with tab5:
|
345 |
+
st.write("Upload a Binary Labels CSV (values 0 or 1 only):")
|
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 |
+
if binary_file:
|
350 |
+
binary_df = pd.read_csv(binary_file, header=None)
|
351 |
+
|
352 |
+
# Format for reordered (4402β3244, 4882β4455)
|
353 |
+
binary_reordered = binary_df.iloc[:, :32].copy()
|
354 |
+
binary_reordered.columns = [str(h) for h in mutation_site_headers_3614 if str(h) in binary_reordered.columns]
|
355 |
+
|
356 |
+
all_bits_reordered = binary_reordered.values.flatten().astype(int).tolist()
|
357 |
+
decoded_reordered = binary_labels_to_string(all_bits_reordered)
|
358 |
+
|
359 |
+
st.subheader("Decoded String (Reordered 4402β3244, 4882β4455)")
|
360 |
+
st.write(decoded_reordered)
|
361 |
+
st.download_button("Download Reordered CSV", binary_reordered.to_csv(index=False), "binary_input_reordered.csv", key="download_csv_tab5_reordered")
|
362 |
+
|
363 |
+
# Format for ascending (3244β4882)
|
364 |
+
binary_ascending = binary_df.copy()
|
365 |
+
binary_ascending.columns = [str(h) for h in mutation_site_headers_actual_3614 if str(h) in binary_ascending.columns]
|
366 |
+
|
367 |
+
all_bits_ascending = binary_ascending.values.flatten().astype(int).tolist()
|
368 |
+
decoded_ascending = binary_labels_to_string(all_bits_ascending)
|
369 |
+
|
370 |
+
st.subheader("Decoded String (Ascending 3244β4882)")
|
371 |
+
st.write(decoded_ascending)
|
372 |
+
st.download_button("Download Ascending Order CSV", binary_ascending.to_csv(index=False), "binary_input_ascending.csv", key="download_csv_tab5_ascending")
|
373 |
+
|