wenjun99 commited on
Commit
0096c5b
·
verified ·
1 Parent(s): e36ad7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -150,14 +150,18 @@ with tab1:
150
  st.subheader("Robot Preparation Script (Based on Ascending Order 3244 → 4882)")
151
 
152
  df_sorted_ascend = df_sorted.copy()
153
- df_sorted_ascend.insert(0, 'Sample', range(1, len(df_sorted_ascend)+1))
154
 
 
 
 
 
 
155
  df_sorted_ascend['# donors'] = df_sorted_ascend.iloc[:, 1:].sum(axis=1)
156
  df_sorted_ascend['volume donors (µl)'] = 32 / df_sorted_ascend['# donors']
157
 
158
  robot_script_ascend = []
159
- # Use the same source wells (length should be 32 already)
160
- for i, col in enumerate(df_sorted_ascend.columns[1:33]): # 32 binary columns
161
  for row_idx, sample in df_sorted_ascend.iterrows():
162
  if sample[col] == 1:
163
  source = source_wells[i]
@@ -169,7 +173,6 @@ with tab1:
169
  st.dataframe(robot_script_ascend_df)
170
  st.download_button("Download Ascending Robot Script CSV", robot_script_ascend_df.to_csv(index=False), "robot_script_ascending.csv", key="download_csv_tab1_robot_ascend")
171
 
172
-
173
  # Tab 2: EF → Binary
174
  with tab2:
175
  st.write("Upload an Editing Frequency CSV or enter manually:")
 
150
  st.subheader("Robot Preparation Script (Based on Ascending Order 3244 → 4882)")
151
 
152
  df_sorted_ascend = df_sorted.copy()
 
153
 
154
+ # Only insert 'Sample' if it doesn't already exist
155
+ if 'Sample' not in df_sorted_ascend.columns:
156
+ df_sorted_ascend.insert(0, 'Sample', range(1, len(df_sorted_ascend)+1))
157
+
158
+ # Recalculate donors and volume
159
  df_sorted_ascend['# donors'] = df_sorted_ascend.iloc[:, 1:].sum(axis=1)
160
  df_sorted_ascend['volume donors (µl)'] = 32 / df_sorted_ascend['# donors']
161
 
162
  robot_script_ascend = []
163
+ # Use the same 32 source wells
164
+ for i, col in enumerate(df_sorted_ascend.columns[1:33]):
165
  for row_idx, sample in df_sorted_ascend.iterrows():
166
  if sample[col] == 1:
167
  source = source_wells[i]
 
173
  st.dataframe(robot_script_ascend_df)
174
  st.download_button("Download Ascending Robot Script CSV", robot_script_ascend_df.to_csv(index=False), "robot_script_ascending.csv", key="download_csv_tab1_robot_ascend")
175
 
 
176
  # Tab 2: EF → Binary
177
  with tab2:
178
  st.write("Upload an Editing Frequency CSV or enter manually:")