hiyata commited on
Commit
c5accc7
·
verified ·
1 Parent(s): e9f8387

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -21
app.py CHANGED
@@ -603,26 +603,29 @@ def analyze_sequence_comparison(file1, file2, fasta1="", fasta2=""):
603
  frac_different = np.mean(substantial_diffs)
604
 
605
  # Generate comparison text
606
- comparison_text = f"""Sequence Comparison Results:
607
- Sequence 1: {results1[4]}
608
- Length: {len(shap1):,} bases
609
- Classification: {results1[0].split('Classification: ')[1].split('\n')[0]}
610
-
611
- Sequence 2: {results2[4]}
612
- Length: {len(shap2):,} bases
613
- Classification: {results2[0].split('Classification: ')[1].split('\n')[0]}
614
-
615
- Comparison Statistics:
616
- Average SHAP difference: {avg_diff:.4f}
617
- Standard deviation: {std_diff:.4f}
618
- Max difference: {max_diff:.4f} (Seq2 more human-like)
619
- Min difference: {min_diff:.4f} (Seq1 more human-like)
620
- Fraction of positions with substantial differences: {frac_different:.2%}
621
-
622
- Interpretation:
623
- Positive values (red) indicate regions where Sequence 2 is more "human-like"
624
- Negative values (blue) indicate regions where Sequence 1 is more "human-like"
625
- """
 
 
 
626
 
627
  # Create comparison heatmap
628
  heatmap_fig = plot_comparative_heatmap(shap_diff)
@@ -636,7 +639,7 @@ Negative values (blue) indicate regions where Sequence 1 is more "human-like"
636
  hist_img = fig_to_image(hist_fig)
637
 
638
  return comparison_text, heatmap_img, hist_img
639
-
640
  ###############################################################################
641
  # 9. BUILD GRADIO INTERFACE
642
  ###############################################################################
 
603
  frac_different = np.mean(substantial_diffs)
604
 
605
  # Generate comparison text
606
+ # Format the numbers without using f-string with `:,`
607
+ len1_formatted = "{:,}".format(len(shap1))
608
+ len2_formatted = "{:,}".format(len(shap2))
609
+ frac_formatted = "{:.2%}".format(frac_different)
610
+
611
+ comparison_text = (
612
+ f"Sequence Comparison Results:\n"
613
+ f"Sequence 1: {results1[4]}\n"
614
+ f"Length: {len1_formatted} bases\n"
615
+ f"Classification: {results1[0].split('Classification: ')[1].split('\\n')[0]}\n\n"
616
+ f"Sequence 2: {results2[4]}\n"
617
+ f"Length: {len2_formatted} bases\n"
618
+ f"Classification: {results2[0].split('Classification: ')[1].split('\\n')[0]}\n\n"
619
+ f"Comparison Statistics:\n"
620
+ f"Average SHAP difference: {avg_diff:.4f}\n"
621
+ f"Standard deviation: {std_diff:.4f}\n"
622
+ f"Max difference: {max_diff:.4f} (Seq2 more human-like)\n"
623
+ f"Min difference: {min_diff:.4f} (Seq1 more human-like)\n"
624
+ f"Fraction of positions with substantial differences: {frac_formatted}\n\n"
625
+ f"Interpretation:\n"
626
+ f"Positive values (red) indicate regions where Sequence 2 is more 'human-like'\n"
627
+ f"Negative values (blue) indicate regions where Sequence 1 is more 'human-like'"
628
+ )
629
 
630
  # Create comparison heatmap
631
  heatmap_fig = plot_comparative_heatmap(shap_diff)
 
639
  hist_img = fig_to_image(hist_fig)
640
 
641
  return comparison_text, heatmap_img, hist_img
642
+
643
  ###############################################################################
644
  # 9. BUILD GRADIO INTERFACE
645
  ###############################################################################