psshradha25 commited on
Commit
ff7d16b
·
verified ·
1 Parent(s): 82333fc

Delete streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +0 -452
streamlit_app.py DELETED
@@ -1,452 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
- import matplotlib.pyplot as plt
4
- from scipy.signal import find_peaks
5
- from pypdf import PdfReader
6
-
7
- # =====================================================
8
- # PAGE CONFIG
9
- # =====================================================
10
-
11
- st.set_page_config(
12
- page_title="BioProc AI Assistant",
13
- page_icon="🧬",
14
- layout="wide"
15
- )
16
-
17
- st.title("🧬 BioProc AI Assistant")
18
-
19
- st.write(
20
- "AI assistant for downstream bioprocessing scientists"
21
- )
22
-
23
- # =====================================================
24
- # SIDEBAR
25
- # =====================================================
26
-
27
- st.sidebar.title("Navigation")
28
-
29
- page = st.sidebar.radio(
30
- "Select Tool",
31
- [
32
- "AI Chatbot",
33
- "PDF SOP Analyzer",
34
- "DSP Troubleshooting",
35
- "DSP Calculator",
36
- "Chromatogram Analysis",
37
- "Chromatogram Comparison",
38
- "Pooling Recommendation"
39
- ]
40
- )
41
-
42
- # =====================================================
43
- # AI CHATBOT
44
- # =====================================================
45
-
46
- if page == "AI Chatbot":
47
-
48
- st.header("🧠 DSP AI Chatbot")
49
-
50
- user_question = st.text_area(
51
- "Ask your DSP question",
52
- height=150
53
- )
54
-
55
- if st.button("Ask AI"):
56
-
57
- if user_question.strip() == "":
58
- st.warning("Please enter a question.")
59
-
60
- else:
61
-
62
- answer = f"""
63
- ### DSP AI Response
64
-
65
- Question:
66
- {user_question}
67
-
68
- Possible DSP considerations:
69
-
70
- - Review chromatography loading conditions
71
- - Evaluate conductivity and pH optimization
72
- - Check aggregation risk during low pH hold
73
- - Monitor HCP clearance trends
74
- - Evaluate membrane fouling if UF/DF involved
75
- - Confirm resin binding capacity
76
-
77
- This lightweight demo version is deployment ready.
78
- """
79
-
80
- st.success("AI Response Generated")
81
-
82
- st.markdown(answer)
83
-
84
- # =====================================================
85
- # PDF SOP ANALYZER
86
- # =====================================================
87
-
88
- elif page == "PDF SOP Analyzer":
89
-
90
- st.header("📄 DSP SOP Analyzer")
91
-
92
- uploaded_file = st.file_uploader(
93
- "Upload SOP PDF",
94
- type="pdf"
95
- )
96
-
97
- if uploaded_file is not None:
98
-
99
- try:
100
-
101
- reader = PdfReader(uploaded_file)
102
-
103
- text = ""
104
-
105
- for page_pdf in reader.pages:
106
-
107
- extracted = page_pdf.extract_text()
108
-
109
- if extracted:
110
- text += extracted
111
-
112
- st.success("PDF Loaded Successfully")
113
-
114
- user_question = st.text_area(
115
- "Ask question about SOP",
116
- height=120
117
- )
118
-
119
- if st.button("Analyze SOP"):
120
-
121
- st.markdown("## 🔬 SOP Analysis")
122
-
123
- if user_question.lower() in text.lower():
124
-
125
- st.success(
126
- "Relevant information found in SOP."
127
- )
128
-
129
- else:
130
-
131
- st.warning(
132
- "Exact match not found. Review SOP text below."
133
- )
134
-
135
- with st.expander("View Extracted SOP Text"):
136
-
137
- st.write(text[:5000])
138
-
139
- except Exception as e:
140
-
141
- st.error(f"Error: {e}")
142
-
143
- # =====================================================
144
- # DSP TROUBLESHOOTING
145
- # =====================================================
146
-
147
- elif page == "DSP Troubleshooting":
148
-
149
- st.header("🧪 DSP Troubleshooting Expert")
150
-
151
- issue = st.selectbox(
152
- "Select Issue",
153
- [
154
- "High Aggregates",
155
- "Low Yield",
156
- "High HCP",
157
- "High Pressure",
158
- "Poor Binding",
159
- "Low Purity",
160
- "Membrane Fouling",
161
- "Product Loss",
162
- "Precipitation"
163
- ]
164
- )
165
-
166
- process_step = st.selectbox(
167
- "Process Step",
168
- [
169
- "Protein A Chromatography",
170
- "CEX Chromatography",
171
- "AEX Chromatography",
172
- "UF/DF",
173
- "HIC",
174
- "SEC",
175
- "Virus Filtration",
176
- "Depth Filtration"
177
- ]
178
- )
179
-
180
- if st.button("Analyze Problem"):
181
-
182
- result = f"""
183
- ### DSP Troubleshooting Report
184
-
185
- Issue:
186
- {issue}
187
-
188
- Process Step:
189
- {process_step}
190
-
191
- Possible Root Causes:
192
- - Incorrect pH/conductivity
193
- - Resin overloading
194
- - Membrane fouling
195
- - Aggregation during hold step
196
-
197
- Recommended Actions:
198
- - Optimize loading density
199
- - Reduce process hold time
200
- - Evaluate buffer composition
201
- - Monitor TMP and flux
202
-
203
- Risk Level:
204
- Moderate
205
- """
206
-
207
- st.markdown(result)
208
-
209
- # =====================================================
210
- # DSP CALCULATOR
211
- # =====================================================
212
-
213
- elif page == "DSP Calculator":
214
-
215
- st.header("📊 DSP Engineering Calculator")
216
-
217
- calculator = st.selectbox(
218
- "Select Calculator",
219
- [
220
- "TMP Calculator",
221
- "Flux Calculator",
222
- "Membrane Area Calculator"
223
- ]
224
- )
225
-
226
- if calculator == "TMP Calculator":
227
-
228
- feed = st.number_input(
229
- "Feed Pressure",
230
- value=20.0
231
- )
232
-
233
- ret = st.number_input(
234
- "Retentate Pressure",
235
- value=10.0
236
- )
237
-
238
- perm = st.number_input(
239
- "Permeate Pressure",
240
- value=2.0
241
- )
242
-
243
- if st.button("Calculate TMP"):
244
-
245
- tmp = ((feed + ret) / 2) - perm
246
-
247
- st.success(f"TMP = {tmp:.2f} psi")
248
-
249
- elif calculator == "Flux Calculator":
250
-
251
- flow = st.number_input(
252
- "Flow Rate",
253
- value=50.0
254
- )
255
-
256
- area = st.number_input(
257
- "Membrane Area",
258
- value=0.5
259
- )
260
-
261
- if st.button("Calculate Flux"):
262
-
263
- flux = flow / area
264
-
265
- st.success(f"Flux = {flux:.2f} LMH")
266
-
267
- elif calculator == "Membrane Area Calculator":
268
-
269
- volume = st.number_input(
270
- "Volume",
271
- value=100.0
272
- )
273
-
274
- flux = st.number_input(
275
- "Flux",
276
- value=50.0
277
- )
278
-
279
- time = st.number_input(
280
- "Time",
281
- value=4.0
282
- )
283
-
284
- if st.button("Calculate Area"):
285
-
286
- membrane_area = volume / (flux * time)
287
-
288
- st.success(
289
- f"Required Area = {membrane_area:.2f} m²"
290
- )
291
-
292
- # =====================================================
293
- # CHROMATOGRAM ANALYSIS
294
- # =====================================================
295
-
296
- elif page == "Chromatogram Analysis":
297
-
298
- st.header("📈 AKTA Chromatogram Analysis")
299
-
300
- uploaded_file = st.file_uploader(
301
- "Upload CSV",
302
- type=["csv"]
303
- )
304
-
305
- if uploaded_file is not None:
306
-
307
- try:
308
-
309
- df = pd.read_csv(uploaded_file)
310
-
311
- st.dataframe(df.head())
312
-
313
- x_column = st.selectbox(
314
- "X Axis",
315
- df.columns
316
- )
317
-
318
- y_column = st.selectbox(
319
- "Y Axis",
320
- df.columns
321
- )
322
-
323
- if st.button("Analyze Chromatogram"):
324
-
325
- fig, ax = plt.subplots(figsize=(10, 4))
326
-
327
- ax.plot(df[x_column], df[y_column])
328
-
329
- ax.set_title("Chromatogram")
330
-
331
- st.pyplot(fig)
332
-
333
- peaks, _ = find_peaks(df[y_column])
334
-
335
- st.success(
336
- f"Detected Peaks: {len(peaks)}"
337
- )
338
-
339
- except Exception as e:
340
-
341
- st.error(f"Error: {e}")
342
-
343
- # =====================================================
344
- # CHROMATOGRAM COMPARISON
345
- # =====================================================
346
-
347
- elif page == "Chromatogram Comparison":
348
-
349
- st.header("📊 Chromatogram Run Comparison")
350
-
351
- file1 = st.file_uploader(
352
- "Upload Run 1",
353
- type=["csv"],
354
- key="run1"
355
- )
356
-
357
- file2 = st.file_uploader(
358
- "Upload Run 2",
359
- type=["csv"],
360
- key="run2"
361
- )
362
-
363
- if file1 and file2:
364
-
365
- try:
366
-
367
- df1 = pd.read_csv(file1)
368
- df2 = pd.read_csv(file2)
369
-
370
- st.success("Files Loaded")
371
-
372
- st.write(
373
- "Chromatogram comparison ready."
374
- )
375
-
376
- except Exception as e:
377
-
378
- st.error(f"Error: {e}")
379
-
380
- # =====================================================
381
- # POOLING RECOMMENDATION
382
- # =====================================================
383
-
384
- elif page == "Pooling Recommendation":
385
-
386
- st.header("🧪 AI Pooling Recommendation")
387
-
388
- uploaded_file = st.file_uploader(
389
- "Upload Chromatogram",
390
- type=["csv"]
391
- )
392
-
393
- if uploaded_file is not None:
394
-
395
- try:
396
-
397
- df = pd.read_csv(uploaded_file)
398
-
399
- x_column = st.selectbox(
400
- "Select X Axis",
401
- df.columns
402
- )
403
-
404
- y_column = st.selectbox(
405
- "Select Y Axis",
406
- df.columns
407
- )
408
-
409
- if st.button(
410
- "Generate Pooling Recommendation"
411
- ):
412
-
413
- peak_index = int(
414
- df[y_column].idxmax()
415
- )
416
-
417
- left = max(peak_index - 1, 0)
418
-
419
- right = min(
420
- peak_index + 1,
421
- len(df) - 1
422
- )
423
-
424
- pooling_start = df.loc[
425
- left,
426
- x_column
427
- ]
428
-
429
- pooling_end = df.loc[
430
- right,
431
- x_column
432
- ]
433
-
434
- st.success(
435
- f"Suggested Pooling Window: "
436
- f"{pooling_start} to {pooling_end}"
437
- )
438
-
439
- st.markdown(
440
- """
441
- ### Pooling Assessment
442
-
443
- - Main peak detected successfully
444
- - Low impurity overlap observed
445
- - Suitable for collection
446
- - Monitor shoulder peaks during scale-up
447
- """
448
- )
449
-
450
- except Exception as e:
451
-
452
- st.error(f"Error: {e}")