VyLala commited on
Commit
1ba0b1f
·
verified ·
1 Parent(s): 81e271a

Update mtdna_backend.py

Browse files
Files changed (1) hide show
  1. mtdna_backend.py +6 -13
mtdna_backend.py CHANGED
@@ -236,10 +236,10 @@ def summarize_results(accession, stop_flag=None):
236
  "Predicted Sample Type":pred_sample or "unknown",
237
  "Sample Type Explanation":sample_explanation or "unknown",
238
  "Sources": "\n".join(outputs[key]["source"]) or "No Links",
239
- "Query_cost": outputs[key]["query_cost"],
240
- "Time cost": outputs[key]["time_cost"],
241
- "file_chunk":outputs[key]["file_chunk"],
242
- "file_all_output":outputs[key]["file_all_output"]
243
  }
244
  #row_score.append(row)
245
  save_rows.append(list(save_row.values()))
@@ -315,23 +315,16 @@ def summarize_results(accession, stop_flag=None):
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",
332
  "Query_cost", "Sample Type Explanation", "Sources", "Time cost", "file_chunk", "file_all_output"
333
  ])
334
 
 
335
  # ✅ Index by Sample ID
336
  df_old.set_index("Sample ID", inplace=True)
337
  df_new.set_index("Sample ID", inplace=True)
 
236
  "Predicted Sample Type":pred_sample or "unknown",
237
  "Sample Type Explanation":sample_explanation or "unknown",
238
  "Sources": "\n".join(outputs[key]["source"]) or "No Links",
239
+ "Query_cost": outputs[key]["query_cost"] or "",
240
+ "Time cost": outputs[key]["time_cost"] or "",
241
+ "file_chunk":outputs[key]["file_chunk"] or "",
242
+ "file_all_output":outputs[key]["file_all_output"] or ""
243
  }
244
  #row_score.append(row)
245
  save_rows.append(list(save_row.values()))
 
315
 
316
  if existing_data:
317
  df_old = pd.DataFrame(existing_data[1:], columns=existing_data[0])
318
+
319
  else:
 
 
 
 
 
320
 
 
 
 
 
321
  df_old = pd.DataFrame(columns=[
322
  "Sample ID", "Actual_country", "Actual_sample_type", "Country Explanation",
323
  "Match_country", "Match_sample_type", "Predicted Country", "Predicted Sample Type",
324
  "Query_cost", "Sample Type Explanation", "Sources", "Time cost", "file_chunk", "file_all_output"
325
  ])
326
 
327
+
328
  # ✅ Index by Sample ID
329
  df_old.set_index("Sample ID", inplace=True)
330
  df_new.set_index("Sample ID", inplace=True)