wenjun99 commited on
Commit
1f5b7cf
·
verified ·
1 Parent(s): 08696fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -150,6 +150,37 @@ with tab1:
150
  st.dataframe(df_sorted)
151
  st.download_button("Download Ascending Order CSV", df_sorted.to_csv(index=False), "text_binary_labels_ascending.csv")
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  # Tab 2: EF → Binary
154
  with tab2:
155
  st.write("Upload an Editing Frequency CSV or enter manually:")
 
150
  st.dataframe(df_sorted)
151
  st.download_button("Download Ascending Order CSV", df_sorted.to_csv(index=False), "text_binary_labels_ascending.csv")
152
 
153
+ # === Robot Preparation Script Generation ===
154
+ st.subheader("Robot Preparation Script")
155
+ robot_template = pd.read_csv("Robot.csv", skiprows=3)
156
+ robot_template.columns = ['Labware', 'Source', 'Labware_2', 'Destination', 'Volume', 'Tool', 'Name']
157
+
158
+ # Add Sample numbers for well referencing
159
+ df_sorted.insert(0, 'Sample', range(1, len(df_sorted)+1))
160
+
161
+ # Step 1: Count the number of edited sites per row
162
+ df_sorted['# donors'] = df_sorted.iloc[:, 1:].sum(axis=1)
163
+
164
+ # Step 2: Calculate volume per donor (32 / # donors)
165
+ df_sorted['volume donors (µl)'] = 32 / df_sorted['# donors']
166
+
167
+ # Step 3: Generate the robot script
168
+ robot_script = []
169
+ source_wells = robot_template['Source'].unique().tolist()[:32]
170
+
171
+ for i, col in enumerate(df_sorted.columns[1:33]):
172
+ for row_idx, sample in df_sorted.iterrows():
173
+ if sample[col] == 1:
174
+ source = source_wells[i]
175
+ dest = f"A{sample['Sample']}"
176
+ vol = round(sample['volume donors (µl)'], 2)
177
+ robot_script.append({'Source': source, 'Destination': dest, 'Volume': vol})
178
+
179
+ robot_script_df = pd.DataFrame(robot_script)
180
+ st.dataframe(robot_script_df)
181
+ st.download_button("Download Robot Script CSV", robot_script_df.to_csv(index=False), "robot_script.csv")
182
+
183
+
184
  # Tab 2: EF → Binary
185
  with tab2:
186
  st.write("Upload an Editing Frequency CSV or enter manually:")