Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -394,21 +394,17 @@ with tab5:
|
|
| 394 |
|
| 395 |
# ========== 32-BIT DECODING ==========
|
| 396 |
st.subheader("32-bit Binary per Row")
|
| 397 |
-
st.write("Upload CSV with 32 columns (0 or 1), no headers, from EF Binary format
|
| 398 |
-
|
| 399 |
binary32_file = st.file_uploader("Upload 32-bit Binary CSV", type=["csv"], key="binary_32")
|
| 400 |
|
|
|
|
|
|
|
|
|
|
| 401 |
if binary32_file:
|
| 402 |
df_32 = pd.read_csv(binary32_file, header=None)
|
| 403 |
df_32.columns = [str(h) for h in mutation_site_headers_actual_3614] # assume ascending
|
| 404 |
-
else:
|
| 405 |
-
df_32 = st.data_editor(
|
| 406 |
-
pd.DataFrame(columns=[str(h) for h in mutation_site_headers_actual_3614]),
|
| 407 |
-
num_rows="dynamic",
|
| 408 |
-
key="manual_32_input"
|
| 409 |
-
)
|
| 410 |
|
| 411 |
-
|
| 412 |
reordered_df_32 = df_32[[str(h) for h in mutation_site_headers_3614 if str(h) in df_32.columns]]
|
| 413 |
st.subheader("Binary Labels (Reordered 4402β3244, 4882β4455)")
|
| 414 |
st.dataframe(reordered_df_32.style.applymap(lambda v: "background-color: lightgreen" if v == 1 else "background-color: lightcoral"))
|
|
@@ -418,6 +414,7 @@ with tab5:
|
|
| 418 |
st.subheader("Decoded String (Reordered 4402β3244, 4882β4455)")
|
| 419 |
st.write(decoded_reordered)
|
| 420 |
|
|
|
|
| 421 |
df_ascending = df_32[[str(h) for h in mutation_site_headers_actual_3614 if str(h) in df_32.columns]]
|
| 422 |
st.subheader("Binary Labels (Ascending 3244β4882)")
|
| 423 |
st.dataframe(df_ascending.style.applymap(lambda v: "background-color: lightgreen" if v == 1 else "background-color: lightcoral"))
|
|
@@ -447,7 +444,7 @@ with tab5:
|
|
| 447 |
for row_idx, sample in df_32_robot.iterrows():
|
| 448 |
if sample[col] == 1:
|
| 449 |
source = source_wells_32[i]
|
| 450 |
-
dest =
|
| 451 |
vol = round(sample['volume donors (Β΅l)'], 2)
|
| 452 |
robot_script_32.append({'Source': source, 'Destination': dest, 'Volume': vol})
|
| 453 |
|
|
@@ -455,11 +452,12 @@ with tab5:
|
|
| 455 |
st.dataframe(robot_script_32_df)
|
| 456 |
st.download_button("Download Robot Script (32-bit)", robot_script_32_df.to_csv(index=False), "robot_script_32bit.csv", key="download_robot_32")
|
| 457 |
|
|
|
|
| 458 |
st.markdown("---")
|
| 459 |
|
| 460 |
# ========== 31-BIT DECODING ==========
|
| 461 |
st.subheader("31-bit Binary Grouped per Row")
|
| 462 |
-
st.write("Upload CSV with 31 columns (no headers), each row = one 6-bit ASCII character group
|
| 463 |
|
| 464 |
binary31_file = st.file_uploader("Upload 31-bit Group CSV", type=["csv"], key="binary_31")
|
| 465 |
|
|
@@ -472,28 +470,33 @@ with tab5:
|
|
| 472 |
num_rows="dynamic",
|
| 473 |
key="manual_31_input"
|
| 474 |
)
|
| 475 |
-
|
| 476 |
if not df_31.empty:
|
|
|
|
|
|
|
| 477 |
reordered_df_31 = df_31[[str(h) for h in mutation_site_headers if str(h) in df_31.columns]]
|
| 478 |
st.subheader("Binary Labels (Reordered 4402β3244, 4882β4455)")
|
| 479 |
st.dataframe(reordered_df_31.style.applymap(lambda v: "background-color: lightgreen" if v == 1 else "background-color: lightcoral"))
|
| 480 |
st.download_button("Download Reordered CSV", reordered_df_31.to_csv(index=False), "decoded_binary_31_reordered.csv", key="download_csv_tab5_31_reordered")
|
| 481 |
|
|
|
|
| 482 |
decoded_flat_reordered = binary_labels_to_string(reordered_df_31.values.flatten().astype(int).tolist())
|
| 483 |
st.subheader("Decoded String (Flattened 31-bit Reordered)")
|
| 484 |
st.write(decoded_flat_reordered)
|
| 485 |
st.download_button("Download Concatenated Output", decoded_flat_reordered, "decoded_31bit_string_reordered.txt", key="download_csv_tab5_31")
|
| 486 |
|
|
|
|
| 487 |
df_31_asc = df_31[[str(h) for h in mutation_site_headers_actual if str(h) in df_31.columns]]
|
| 488 |
st.subheader("Binary Labels (Ascending 3244β4882)")
|
| 489 |
st.dataframe(df_31_asc.style.applymap(lambda v: "background-color: lightgreen" if v == 1 else "background-color: lightcoral"))
|
| 490 |
st.download_button("Download Ascending CSV", df_31_asc.to_csv(index=False), "decoded_binary_31_ascending.csv", key="download_csv_tab5_31_ascend")
|
| 491 |
|
|
|
|
| 492 |
decoded_flat_asc = binary_labels_to_string(df_31_asc.values.flatten().astype(int).tolist())
|
| 493 |
st.subheader("Decoded String (Flattened 31-bit Ascending)")
|
| 494 |
st.write(decoded_flat_asc)
|
| 495 |
st.download_button("Download Concatenated Output", decoded_flat_asc, "decoded_31bit_string_ascending.txt", key="download_csv_tab5_31_asc")
|
| 496 |
-
|
| 497 |
# === Robot Preparation Script from 31-bit Binary ===
|
| 498 |
st.subheader("Robot Preparation Script from 31-bit Binary")
|
| 499 |
robot_template_31 = pd.read_csv("/home/user/app/Robot2.csv", skiprows=3)
|
|
@@ -520,5 +523,4 @@ with tab5:
|
|
| 520 |
|
| 521 |
robot_script_31_df = pd.DataFrame(robot_script_31)
|
| 522 |
st.dataframe(robot_script_31_df)
|
| 523 |
-
st.download_button("Download Robot Script (31-bit)", robot_script_31_df.to_csv(index=False), "robot_script_31bit.csv", key="download_robot_31")
|
| 524 |
-
|
|
|
|
| 394 |
|
| 395 |
# ========== 32-BIT DECODING ==========
|
| 396 |
st.subheader("32-bit Binary per Row")
|
| 397 |
+
st.write("Upload CSV with 32 columns (0 or 1), no headers, from EF Binary format.")
|
|
|
|
| 398 |
binary32_file = st.file_uploader("Upload 32-bit Binary CSV", type=["csv"], key="binary_32")
|
| 399 |
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
|
| 403 |
if binary32_file:
|
| 404 |
df_32 = pd.read_csv(binary32_file, header=None)
|
| 405 |
df_32.columns = [str(h) for h in mutation_site_headers_actual_3614] # assume ascending
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
|
| 407 |
+
# Reordered: 4402 β 3244, 4882 β 4455
|
| 408 |
reordered_df_32 = df_32[[str(h) for h in mutation_site_headers_3614 if str(h) in df_32.columns]]
|
| 409 |
st.subheader("Binary Labels (Reordered 4402β3244, 4882β4455)")
|
| 410 |
st.dataframe(reordered_df_32.style.applymap(lambda v: "background-color: lightgreen" if v == 1 else "background-color: lightcoral"))
|
|
|
|
| 414 |
st.subheader("Decoded String (Reordered 4402β3244, 4882β4455)")
|
| 415 |
st.write(decoded_reordered)
|
| 416 |
|
| 417 |
+
# Ascending: 3244 β 4882
|
| 418 |
df_ascending = df_32[[str(h) for h in mutation_site_headers_actual_3614 if str(h) in df_32.columns]]
|
| 419 |
st.subheader("Binary Labels (Ascending 3244β4882)")
|
| 420 |
st.dataframe(df_ascending.style.applymap(lambda v: "background-color: lightgreen" if v == 1 else "background-color: lightcoral"))
|
|
|
|
| 444 |
for row_idx, sample in df_32_robot.iterrows():
|
| 445 |
if sample[col] == 1:
|
| 446 |
source = source_wells_32[i]
|
| 447 |
+
dest = f"A{sample['Sample']}"
|
| 448 |
vol = round(sample['volume donors (Β΅l)'], 2)
|
| 449 |
robot_script_32.append({'Source': source, 'Destination': dest, 'Volume': vol})
|
| 450 |
|
|
|
|
| 452 |
st.dataframe(robot_script_32_df)
|
| 453 |
st.download_button("Download Robot Script (32-bit)", robot_script_32_df.to_csv(index=False), "robot_script_32bit.csv", key="download_robot_32")
|
| 454 |
|
| 455 |
+
|
| 456 |
st.markdown("---")
|
| 457 |
|
| 458 |
# ========== 31-BIT DECODING ==========
|
| 459 |
st.subheader("31-bit Binary Grouped per Row")
|
| 460 |
+
st.write("Upload CSV with 31 columns (no headers), each row = one 6-bit ASCII character group.")
|
| 461 |
|
| 462 |
binary31_file = st.file_uploader("Upload 31-bit Group CSV", type=["csv"], key="binary_31")
|
| 463 |
|
|
|
|
| 470 |
num_rows="dynamic",
|
| 471 |
key="manual_31_input"
|
| 472 |
)
|
| 473 |
+
|
| 474 |
if not df_31.empty:
|
| 475 |
+
|
| 476 |
+
# Reordered: 4402 β 3244, 4882 β 4455
|
| 477 |
reordered_df_31 = df_31[[str(h) for h in mutation_site_headers if str(h) in df_31.columns]]
|
| 478 |
st.subheader("Binary Labels (Reordered 4402β3244, 4882β4455)")
|
| 479 |
st.dataframe(reordered_df_31.style.applymap(lambda v: "background-color: lightgreen" if v == 1 else "background-color: lightcoral"))
|
| 480 |
st.download_button("Download Reordered CSV", reordered_df_31.to_csv(index=False), "decoded_binary_31_reordered.csv", key="download_csv_tab5_31_reordered")
|
| 481 |
|
| 482 |
+
# Flattened decoding for reordered
|
| 483 |
decoded_flat_reordered = binary_labels_to_string(reordered_df_31.values.flatten().astype(int).tolist())
|
| 484 |
st.subheader("Decoded String (Flattened 31-bit Reordered)")
|
| 485 |
st.write(decoded_flat_reordered)
|
| 486 |
st.download_button("Download Concatenated Output", decoded_flat_reordered, "decoded_31bit_string_reordered.txt", key="download_csv_tab5_31")
|
| 487 |
|
| 488 |
+
# Ascending: 3244 β 4882
|
| 489 |
df_31_asc = df_31[[str(h) for h in mutation_site_headers_actual if str(h) in df_31.columns]]
|
| 490 |
st.subheader("Binary Labels (Ascending 3244β4882)")
|
| 491 |
st.dataframe(df_31_asc.style.applymap(lambda v: "background-color: lightgreen" if v == 1 else "background-color: lightcoral"))
|
| 492 |
st.download_button("Download Ascending CSV", df_31_asc.to_csv(index=False), "decoded_binary_31_ascending.csv", key="download_csv_tab5_31_ascend")
|
| 493 |
|
| 494 |
+
# Flattened decoding for ascending
|
| 495 |
decoded_flat_asc = binary_labels_to_string(df_31_asc.values.flatten().astype(int).tolist())
|
| 496 |
st.subheader("Decoded String (Flattened 31-bit Ascending)")
|
| 497 |
st.write(decoded_flat_asc)
|
| 498 |
st.download_button("Download Concatenated Output", decoded_flat_asc, "decoded_31bit_string_ascending.txt", key="download_csv_tab5_31_asc")
|
| 499 |
+
|
| 500 |
# === Robot Preparation Script from 31-bit Binary ===
|
| 501 |
st.subheader("Robot Preparation Script from 31-bit Binary")
|
| 502 |
robot_template_31 = pd.read_csv("/home/user/app/Robot2.csv", skiprows=3)
|
|
|
|
| 523 |
|
| 524 |
robot_script_31_df = pd.DataFrame(robot_script_31)
|
| 525 |
st.dataframe(robot_script_31_df)
|
| 526 |
+
st.download_button("Download Robot Script (31-bit)", robot_script_31_df.to_csv(index=False), "robot_script_31bit.csv", key="download_robot_31")
|
|
|