Spaces:
Running
Running
Update mtdna_backend.py
Browse files- mtdna_backend.py +11 -0
mtdna_backend.py
CHANGED
@@ -312,9 +312,20 @@ def summarize_results(accession, stop_flag=None):
|
|
312 |
|
313 |
# ✅ Read existing data
|
314 |
existing_data = sheet.get_all_values()
|
|
|
315 |
if existing_data:
|
316 |
df_old = pd.DataFrame(existing_data[1:], columns=existing_data[0])
|
317 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
df_old = pd.DataFrame(columns=[
|
319 |
"Sample ID", "Actual_country", "Actual_sample_type", "Country Explanation",
|
320 |
"Match_country", "Match_sample_type", "Predicted Country", "Predicted Sample Type",
|
|
|
312 |
|
313 |
# ✅ Read existing data
|
314 |
existing_data = sheet.get_all_values()
|
315 |
+
|
316 |
if existing_data:
|
317 |
df_old = pd.DataFrame(existing_data[1:], columns=existing_data[0])
|
318 |
else:
|
319 |
+
required_columns = [
|
320 |
+
"Sample ID", "Actual_country", "Actual_sample_type", "Country Explanation",
|
321 |
+
"Match_country", "Match_sample_type", "Predicted Country", "Predicted Sample Type",
|
322 |
+
"Query_cost", "Sample Type Explanation", "Sources", "Time cost", "file_chunk", "file_all_output"
|
323 |
+
]
|
324 |
+
|
325 |
+
for col in required_columns:
|
326 |
+
if col not in df_old.columns:
|
327 |
+
df_old[col] = "" # create empty column
|
328 |
+
|
329 |
df_old = pd.DataFrame(columns=[
|
330 |
"Sample ID", "Actual_country", "Actual_sample_type", "Country Explanation",
|
331 |
"Match_country", "Match_sample_type", "Predicted Country", "Predicted Sample Type",
|