Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,10 +108,11 @@ def run_deep_learning_cascade(dna_sequence):
|
|
| 108 |
is_coding = False
|
| 109 |
confidence = (1 - p_coding) if p_coding < 0.50 else 0.85
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
| 115 |
|
| 116 |
# BRANCH A: Phenotype Analysis (Triggered if Coding AND is CDS/Exon)
|
| 117 |
if is_coding and lgb_prediction == 0:
|
|
@@ -125,7 +126,7 @@ def run_deep_learning_cascade(dna_sequence):
|
|
| 125 |
prob_obese, prob_lean = probs[0][0].item(), probs[0][1].item()
|
| 126 |
|
| 127 |
phenotype = "Obesity-Associated" if prob_obese > prob_lean else "Lean-Associated"
|
| 128 |
-
|
| 129 |
raw_scores["Phenotype (Obese)"] = prob_obese
|
| 130 |
raw_scores["Phenotype (Lean)"] = prob_lean
|
| 131 |
|
|
@@ -139,10 +140,10 @@ def run_deep_learning_cascade(dna_sequence):
|
|
| 139 |
p_promoter = probs[0][0].item()
|
| 140 |
|
| 141 |
validation = "High Confidence Regulatory Element" if p_promoter >= 0.50 else "Weak Regulatory Signal"
|
| 142 |
-
|
| 143 |
-
raw_scores["Promoter Signal"] = p_promoter
|
| 144 |
|
| 145 |
-
return
|
| 146 |
|
| 147 |
# ===================================
|
| 148 |
# 3. SPATIAL MAPPING (NCBI / ENSEMBL)
|
|
@@ -239,7 +240,7 @@ def gradio_inference(dna_sequence, run_mapping):
|
|
| 239 |
summary_html = f"""
|
| 240 |
<div style="border: 1px solid #4b5563; border-radius: 8px; padding: 15px; margin-bottom: 15px;">
|
| 241 |
<h3 style="margin-top: 0; margin-bottom: 10px;"> Classification Summary <span style="color: #10b981; font-size: 0.85em; font-weight: normal;">(Deep Scan Complete)</span></h3>
|
| 242 |
-
<div style="font-size: 1.15em; line-height: 1.8
|
| 243 |
Final Classification: <b style="color: #0d6efd;">{summary_dict.get('Final Classification')}</b><br>
|
| 244 |
Feature: <b>{summary_dict.get('Feature')}</b><br>
|
| 245 |
"""
|
|
|
|
| 108 |
is_coding = False
|
| 109 |
confidence = (1 - p_coding) if p_coding < 0.50 else 0.85
|
| 110 |
|
| 111 |
+
# --- LEVEL 3: The Deep Learning Branching Logic ---
|
| 112 |
+
summary_dict = {
|
| 113 |
+
"Final Classification": "GENE" if is_coding else "NON-CODING",
|
| 114 |
+
"Feature": structural_feature
|
| 115 |
+
}
|
| 116 |
|
| 117 |
# BRANCH A: Phenotype Analysis (Triggered if Coding AND is CDS/Exon)
|
| 118 |
if is_coding and lgb_prediction == 0:
|
|
|
|
| 126 |
prob_obese, prob_lean = probs[0][0].item(), probs[0][1].item()
|
| 127 |
|
| 128 |
phenotype = "Obesity-Associated" if prob_obese > prob_lean else "Lean-Associated"
|
| 129 |
+
summary_dict["Phenotype"] = phenotype
|
| 130 |
raw_scores["Phenotype (Obese)"] = prob_obese
|
| 131 |
raw_scores["Phenotype (Lean)"] = prob_lean
|
| 132 |
|
|
|
|
| 140 |
p_promoter = probs[0][0].item()
|
| 141 |
|
| 142 |
validation = "High Confidence Regulatory Element" if p_promoter >= 0.50 else "Weak Regulatory Signal"
|
| 143 |
+
summary_dict["Validation"] = validation
|
| 144 |
+
raw_scores["DNABERT-2 Promoter Signal"] = p_promoter
|
| 145 |
|
| 146 |
+
return summary_dict, confidence, raw_scores
|
| 147 |
|
| 148 |
# ===================================
|
| 149 |
# 3. SPATIAL MAPPING (NCBI / ENSEMBL)
|
|
|
|
| 240 |
summary_html = f"""
|
| 241 |
<div style="border: 1px solid #4b5563; border-radius: 8px; padding: 15px; margin-bottom: 15px;">
|
| 242 |
<h3 style="margin-top: 0; margin-bottom: 10px;"> Classification Summary <span style="color: #10b981; font-size: 0.85em; font-weight: normal;">(Deep Scan Complete)</span></h3>
|
| 243 |
+
<div style="font-size: 1.15em; line-height: 1.8">
|
| 244 |
Final Classification: <b style="color: #0d6efd;">{summary_dict.get('Final Classification')}</b><br>
|
| 245 |
Feature: <b>{summary_dict.get('Feature')}</b><br>
|
| 246 |
"""
|