Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -388,10 +388,43 @@ def get_well_position(sample_index):
|
|
| 388 |
col_number = ((sample_index - 1) % 12) + 1
|
| 389 |
return f"{row_letter}{col_number}"
|
| 390 |
|
|
|
|
| 391 |
# Tab 5: Binary → String
|
| 392 |
with tab5:
|
| 393 |
st.header("Decode Binary Labels to String")
|
| 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 or enter manually below.")
|
|
@@ -453,10 +486,19 @@ with tab5:
|
|
| 453 |
vol = round(sample['volume donors (µl)'], 2)
|
| 454 |
robot_script_32.append({'Source': source, 'Destination': dest, 'Volume': vol})
|
| 455 |
|
|
|
|
|
|
|
|
|
|
| 456 |
robot_script_32_df = pd.DataFrame(robot_script_32)
|
| 457 |
st.dataframe(robot_script_32_df)
|
| 458 |
st.download_button("Download Robot Script (32-bit)", robot_script_32_df.to_csv(index=False), "robot_script_32bit.csv", key="download_robot_32")
|
| 459 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
st.markdown("---")
|
| 461 |
|
| 462 |
# ========== 31-BIT DECODING ==========
|
|
|
|
| 388 |
col_number = ((sample_index - 1) % 12) + 1
|
| 389 |
return f"{row_letter}{col_number}"
|
| 390 |
|
| 391 |
+
# Tab 5: Binary → String
|
| 392 |
# Tab 5: Binary → String
|
| 393 |
with tab5:
|
| 394 |
st.header("Decode Binary Labels to String")
|
| 395 |
|
| 396 |
+
# Utility: Track source volumes and update if exceeds limit
|
| 397 |
+
def track_and_replace_source(source_list, robot_script, volume_limit=180):
|
| 398 |
+
source_volumes = {}
|
| 399 |
+
adjusted_sources = []
|
| 400 |
+
|
| 401 |
+
for entry in robot_script:
|
| 402 |
+
src = entry['Source']
|
| 403 |
+
vol = entry['Volume']
|
| 404 |
+
|
| 405 |
+
if src not in source_volumes:
|
| 406 |
+
source_volumes[src] = 0
|
| 407 |
+
|
| 408 |
+
source_volumes[src] += vol
|
| 409 |
+
|
| 410 |
+
if source_volumes[src] > volume_limit:
|
| 411 |
+
# Convert A->E, B->F, ..., by shifting ASCII code +4
|
| 412 |
+
row_letter = src[0]
|
| 413 |
+
col_number = src[1:]
|
| 414 |
+
new_row_letter = chr(ord(row_letter) + 4)
|
| 415 |
+
new_src = f"{new_row_letter}{col_number}"
|
| 416 |
+
entry['Source'] = new_src
|
| 417 |
+
|
| 418 |
+
# Reset volume tracking for new source
|
| 419 |
+
if new_src not in source_volumes:
|
| 420 |
+
source_volumes[new_src] = 0
|
| 421 |
+
source_volumes[new_src] += vol
|
| 422 |
+
source_volumes[src] -= vol
|
| 423 |
+
|
| 424 |
+
adjusted_sources.append(entry)
|
| 425 |
+
|
| 426 |
+
return adjusted_sources, source_volumes
|
| 427 |
+
|
| 428 |
# ========== 32-BIT DECODING ==========
|
| 429 |
st.subheader("32-bit Binary per Row")
|
| 430 |
st.write("Upload CSV with 32 columns (0 or 1), no headers, from EF Binary format or enter manually below.")
|
|
|
|
| 486 |
vol = round(sample['volume donors (µl)'], 2)
|
| 487 |
robot_script_32.append({'Source': source, 'Destination': dest, 'Volume': vol})
|
| 488 |
|
| 489 |
+
# Adjust for source well volume limit
|
| 490 |
+
robot_script_32, source_volumes_32 = track_and_replace_source(source_wells_32, robot_script_32)
|
| 491 |
+
|
| 492 |
robot_script_32_df = pd.DataFrame(robot_script_32)
|
| 493 |
st.dataframe(robot_script_32_df)
|
| 494 |
st.download_button("Download Robot Script (32-bit)", robot_script_32_df.to_csv(index=False), "robot_script_32bit.csv", key="download_robot_32")
|
| 495 |
|
| 496 |
+
# Show total volume per source well
|
| 497 |
+
st.subheader("Total Volume Used Per Source")
|
| 498 |
+
source_volume_df = pd.DataFrame(list(source_volumes_32.items()), columns=['Source', 'Total Volume (µl)'])
|
| 499 |
+
st.dataframe(source_volume_df)
|
| 500 |
+
st.download_button("Download Source Volumes", source_volume_df.to_csv(index=False), "source_total_volumes.csv", key="download_volume_32")
|
| 501 |
+
|
| 502 |
st.markdown("---")
|
| 503 |
|
| 504 |
# ========== 31-BIT DECODING ==========
|