Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 = {"
|
| 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["
|
| 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"
|
| 211 |
-
f"
|
| 212 |
-
f"
|
| 213 |
-
f"
|
| 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 (
|
| 220 |
|
| 221 |
summary = (
|
| 222 |
f"β
Deep Scan Complete\n\n"
|
| 223 |
-
f"
|
| 224 |
-
f"
|
| 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="
|
| 265 |
-
stats_panel = gr.Textbox(label="
|
| 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...")
|