Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -145,35 +145,47 @@ with tab1:
|
|
| 145 |
st.dataframe(robot_script_df)
|
| 146 |
st.download_button("Download Robot Script CSV", robot_script_df.to_csv(index=False), "robot_script.csv", key="download_csv_tab1_robot")
|
| 147 |
|
| 148 |
-
# === Robot Preparation Script (
|
| 149 |
-
st.subheader("Robot Preparation Script (
|
| 150 |
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
-
#
|
| 154 |
-
|
| 155 |
-
df_sorted_ascend.insert(0, 'Sample', range(1, len(df_sorted_ascend)+1))
|
| 156 |
|
| 157 |
-
#
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
for i, col in enumerate(
|
| 167 |
-
for row_idx, sample in
|
| 168 |
if sample[col] == 1:
|
| 169 |
source = source_wells[i]
|
| 170 |
dest = f"A{sample['Sample']}"
|
| 171 |
vol = round(sample['volume donors (µl)'], 2)
|
| 172 |
-
|
| 173 |
|
| 174 |
-
|
| 175 |
-
st.dataframe(
|
| 176 |
-
st.download_button("Download
|
| 177 |
|
| 178 |
# Tab 2: EF → Binary
|
| 179 |
with tab2:
|
|
|
|
| 145 |
st.dataframe(robot_script_df)
|
| 146 |
st.download_button("Download Robot Script CSV", robot_script_df.to_csv(index=False), "robot_script.csv", key="download_csv_tab1_robot")
|
| 147 |
|
| 148 |
+
# === Robot Preparation Script (Custom Order: 4402 → 3244, 4882 → 4455) ===
|
| 149 |
+
st.subheader("Robot Preparation Script (Custom Order: 4402 → 3244, 4882 → 4455)")
|
| 150 |
|
| 151 |
+
# Include 3614 in custom header list
|
| 152 |
+
custom_headers = [
|
| 153 |
+
4402, 4349, 4298, 4245, 4190, 4145, 4089, 4039,
|
| 154 |
+
3985, 3933, 3879, 3824, 3773, 3720, 3665, 3614,
|
| 155 |
+
3562, 3509, 3455, 3399, 3350, 3297, 3244,
|
| 156 |
+
4882, 4828, 4773, 4720, 4668, 4615, 4561, 4510, 4455
|
| 157 |
+
]
|
| 158 |
|
| 159 |
+
# Create a copy of df and reorder columns based on custom headers
|
| 160 |
+
df_sorted_custom = df[[str(h) for h in custom_headers if str(h) in df.columns]].copy()
|
|
|
|
| 161 |
|
| 162 |
+
# Insert fake column "3614" if missing
|
| 163 |
+
if "3614" not in df_sorted_custom.columns:
|
| 164 |
+
idx = custom_headers.index(3614)
|
| 165 |
+
insert_at = idx # 0-based index
|
| 166 |
+
df_sorted_custom.insert(insert_at, "3614", 0)
|
| 167 |
+
|
| 168 |
+
# Insert 'Sample' if missing
|
| 169 |
+
if "Sample" not in df_sorted_custom.columns:
|
| 170 |
+
df_sorted_custom.insert(0, 'Sample', range(1, len(df_sorted_custom) + 1))
|
| 171 |
+
|
| 172 |
+
# Calculate donor info
|
| 173 |
+
df_sorted_custom['# donors'] = df_sorted_custom.iloc[:, 1:].sum(axis=1)
|
| 174 |
+
df_sorted_custom['volume donors (µl)'] = 32 / df_sorted_custom['# donors']
|
| 175 |
|
| 176 |
+
# Generate robot script
|
| 177 |
+
robot_script_custom = []
|
| 178 |
+
for i, col in enumerate(df_sorted_custom.columns[1:33]): # 32 columns after Sample
|
| 179 |
+
for row_idx, sample in df_sorted_custom.iterrows():
|
| 180 |
if sample[col] == 1:
|
| 181 |
source = source_wells[i]
|
| 182 |
dest = f"A{sample['Sample']}"
|
| 183 |
vol = round(sample['volume donors (µl)'], 2)
|
| 184 |
+
robot_script_custom.append({'Source': source, 'Destination': dest, 'Volume': vol})
|
| 185 |
|
| 186 |
+
robot_script_custom_df = pd.DataFrame(robot_script_custom)
|
| 187 |
+
st.dataframe(robot_script_custom_df)
|
| 188 |
+
st.download_button("Download Custom Order Robot Script CSV", robot_script_custom_df.to_csv(index=False), "robot_script_custom_order.csv", key="download_csv_tab1_robot_custom")
|
| 189 |
|
| 190 |
# Tab 2: EF → Binary
|
| 191 |
with tab2:
|