Geonomic commited on
Commit
1c919fb
Β·
verified Β·
1 Parent(s): 7217daf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -87,12 +87,12 @@ def run_deep_learning_cascade(dna_sequence):
87
  p_coding = clf_coding.predict_proba(vector)[0][1]
88
  is_coding = p_coding >= 0.60
89
 
90
- raw_scores = {"Gatekeeper (Gene Likelihood)": p_coding}
91
 
92
  # --- LEVEL 2: LightGBM Structural Classification ---
93
  lgb_prediction = int(lightgbm_model.predict(vector)[0])
94
  structural_feature = FEATURE_DICT.get(lgb_prediction, "Unknown Region")
95
- raw_scores["Predicted Structure"] = structural_feature
96
 
97
  # --- LEVEL 3: The Deep Learning Branching Logic ---
98
  final_label = f"{'GENE' if is_coding else 'NON-CODING'} | Feature: {structural_feature}"
@@ -125,7 +125,7 @@ def run_deep_learning_cascade(dna_sequence):
125
 
126
  validation = "High Confidence Regulatory Element" if p_promoter >= 0.50 else "Weak Regulatory Signal"
127
  final_label += f" | Validation: {validation}"
128
- raw_scores["DNABERT-2 Promoter Signal"] = p_promoter
129
 
130
  return final_label, confidence, raw_scores
131
 
@@ -207,21 +207,21 @@ def gradio_inference(dna_sequence, run_mapping):
207
  context_output = f"❌ Mapping failed: {context['error']}"
208
  elif "location" in context:
209
  context_lines = [
210
- f"🎯 **Location:** {context['location']}",
211
- f"🧬 **Strand:** {context['strand']}",
212
- f"🧭 **Coordinates:** {context['start']:,} – {context['end']:,}",
213
- f"πŸ”¬ **Notes:** {context['metadata']}"
214
  ]
215
  context_output = "\n".join(context_lines)
216
  else:
217
  context_output = "⚠️ Could not map sequence."
218
  else:
219
- context_output = "πŸ—ΊοΈ Spatial mapping skipped (disable checkbox to run)."
220
 
221
  summary = (
222
  f"βœ… Deep Scan Complete\n\n"
223
- f"🎯 **Final Classification:** {label}\n"
224
- f"πŸ“Š **Base Confidence:** {conf:.2%}"
225
  )
226
 
227
  return summary, "\n".join(stats_lines), context_output, ""
@@ -261,8 +261,8 @@ with gr.Blocks(theme=gr.themes.Soft(), title="🧬 The Genomic Oracle 🧬") as
261
  submit_btn = gr.Button("πŸš€ Initialize Deep Scan", variant="primary")
262
 
263
  with gr.Column(scale=2):
264
- output_summary = gr.Textbox(label="βœ… Classification Summary", lines=4)
265
- stats_panel = gr.Textbox(label="πŸ“Š Internal Pipeline Statistics", lines=4)
266
  mapping_section = gr.Accordion("🌐 Genomic Context (BLAST/Ensembl)", open=False)
267
  with mapping_section:
268
  context_output = gr.Textbox(label="Mapping Results", lines=5, placeholder="Results will appear here...")
 
87
  p_coding = clf_coding.predict_proba(vector)[0][1]
88
  is_coding = p_coding >= 0.60
89
 
90
+ raw_scores = {" Protein-Coding Probability": p_coding}
91
 
92
  # --- LEVEL 2: LightGBM Structural Classification ---
93
  lgb_prediction = int(lightgbm_model.predict(vector)[0])
94
  structural_feature = FEATURE_DICT.get(lgb_prediction, "Unknown Region")
95
+ raw_scores[" Predicted Structure"] = structural_feature
96
 
97
  # --- LEVEL 3: The Deep Learning Branching Logic ---
98
  final_label = f"{'GENE' if is_coding else 'NON-CODING'} | Feature: {structural_feature}"
 
125
 
126
  validation = "High Confidence Regulatory Element" if p_promoter >= 0.50 else "Weak Regulatory Signal"
127
  final_label += f" | Validation: {validation}"
128
+ raw_scores[" Promoter Signal"] = p_promoter
129
 
130
  return final_label, confidence, raw_scores
131
 
 
207
  context_output = f"❌ Mapping failed: {context['error']}"
208
  elif "location" in context:
209
  context_lines = [
210
+ f" Location: {context['location']}",
211
+ f" Strand: {context['strand']}",
212
+ f" Coordinates: {context['start']:,} – {context['end']:,}",
213
+ f" Notes: {context['metadata']}"
214
  ]
215
  context_output = "\n".join(context_lines)
216
  else:
217
  context_output = "⚠️ Could not map sequence."
218
  else:
219
+ context_output = "πŸ—ΊοΈ Spatial mapping skipped (Enable checkbox to query NCBI)."
220
 
221
  summary = (
222
  f"βœ… Deep Scan Complete\n\n"
223
+ f" Final Classification: {label}\n\n"
224
+ f" Confidence Score: {conf:.2%}"
225
  )
226
 
227
  return summary, "\n".join(stats_lines), context_output, ""
 
261
  submit_btn = gr.Button("πŸš€ Initialize Deep Scan", variant="primary")
262
 
263
  with gr.Column(scale=2):
264
+ output_summary = gr.Textbox(label="Classification Summary", lines=4)
265
+ stats_panel = gr.Textbox(label="Internal Pipeline Statistics", lines=4)
266
  mapping_section = gr.Accordion("🌐 Genomic Context (BLAST/Ensembl)", open=False)
267
  with mapping_section:
268
  context_output = gr.Textbox(label="Mapping Results", lines=5, placeholder="Results will appear here...")