Spaces:
Running
Running
Update mtdna_backend.py
Browse files- mtdna_backend.py +17 -2
mtdna_backend.py
CHANGED
|
@@ -170,15 +170,29 @@ async def summarize_results(accession, stop_flag=None, niche_cases=None):
|
|
| 170 |
cached = check_known_output(accession, niche_cases)
|
| 171 |
if cached:
|
| 172 |
print(f"✅ Using cached result for {accession}")
|
| 173 |
-
|
|
|
|
| 174 |
cached["Sample ID"] or "unknown",
|
| 175 |
cached["Predicted Country"] or "unknown",
|
| 176 |
cached["Country Explanation"] or "unknown",
|
| 177 |
cached["Predicted Sample Type"] or "unknown",
|
| 178 |
cached["Sample Type Explanation"] or "unknown",
|
|
|
|
|
|
|
| 179 |
cached["Sources"] or "No Links",
|
| 180 |
cached["Time cost"]
|
| 181 |
]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
# only run when nothing in the cache
|
| 183 |
try:
|
| 184 |
print("try gemini pipeline: ",accession)
|
|
@@ -645,7 +659,8 @@ def check_known_output(accession, niche_cases=None):
|
|
| 645 |
if niche_col not in _known_samples_cache.columns:
|
| 646 |
print(f"⚠️ Niche column '{niche_col}' not found in known_samples. Skipping cache.")
|
| 647 |
return None
|
| 648 |
-
output_niche = row.get(
|
|
|
|
| 649 |
if country and country.lower() not in ["","unknown"] and sample_type and sample_type.lower() not in ["","unknown"] and output_niche and output_niche.lower() not in ["","unknown"]:
|
| 650 |
print(f"🎯 Found {accession} in cache")
|
| 651 |
return row.to_dict()
|
|
|
|
| 170 |
cached = check_known_output(accession, niche_cases)
|
| 171 |
if cached:
|
| 172 |
print(f"✅ Using cached result for {accession}")
|
| 173 |
+
if niche_cases:
|
| 174 |
+
return [[
|
| 175 |
cached["Sample ID"] or "unknown",
|
| 176 |
cached["Predicted Country"] or "unknown",
|
| 177 |
cached["Country Explanation"] or "unknown",
|
| 178 |
cached["Predicted Sample Type"] or "unknown",
|
| 179 |
cached["Sample Type Explanation"] or "unknown",
|
| 180 |
+
cached["Predicted "+niche_cases[0]] or "unknown",
|
| 181 |
+
cached[niche_cases[0] + " Explanation"] or "unknown",
|
| 182 |
cached["Sources"] or "No Links",
|
| 183 |
cached["Time cost"]
|
| 184 |
]]
|
| 185 |
+
|
| 186 |
+
else:
|
| 187 |
+
return [[
|
| 188 |
+
cached["Sample ID"] or "unknown",
|
| 189 |
+
cached["Predicted Country"] or "unknown",
|
| 190 |
+
cached["Country Explanation"] or "unknown",
|
| 191 |
+
cached["Predicted Sample Type"] or "unknown",
|
| 192 |
+
cached["Sample Type Explanation"] or "unknown",
|
| 193 |
+
cached["Sources"] or "No Links",
|
| 194 |
+
cached["Time cost"]
|
| 195 |
+
]]
|
| 196 |
# only run when nothing in the cache
|
| 197 |
try:
|
| 198 |
print("try gemini pipeline: ",accession)
|
|
|
|
| 659 |
if niche_col not in _known_samples_cache.columns:
|
| 660 |
print(f"⚠️ Niche column '{niche_col}' not found in known_samples. Skipping cache.")
|
| 661 |
return None
|
| 662 |
+
output_niche = row.get(niche_col, "").strip().lower()
|
| 663 |
+
print("output niche: ", output_niche)
|
| 664 |
if country and country.lower() not in ["","unknown"] and sample_type and sample_type.lower() not in ["","unknown"] and output_niche and output_niche.lower() not in ["","unknown"]:
|
| 665 |
print(f"🎯 Found {accession} in cache")
|
| 666 |
return row.to_dict()
|