Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import pandas as pd
|
|
6 |
import xlsxwriter
|
7 |
from io import BytesIO
|
8 |
from collections import Counter
|
9 |
-
import matplotlib.pyplot as plt #
|
10 |
|
11 |
# Set of 20 standard amino acids
|
12 |
AMINO_ACIDS = set("ACDEFGHIKLMNPQRSTVWY")
|
@@ -60,17 +60,20 @@ if uploaded_file and st.button("Analyze File"):
|
|
60 |
# 🔵 Pie Chart for Overall Stats
|
61 |
st.subheader("🧁 Overall Amino Acid Composition (Pie Chart)")
|
62 |
|
63 |
-
fig, ax = plt.subplots()
|
64 |
labels = list(overall_percentage.keys())
|
65 |
sizes = list(overall_percentage.values())
|
66 |
|
67 |
-
# Filter
|
68 |
filtered = [(label, size) for label, size in zip(labels, sizes) if size > 0]
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
74 |
|
75 |
# Export to Excel
|
76 |
def to_excel(df):
|
|
|
6 |
import xlsxwriter
|
7 |
from io import BytesIO
|
8 |
from collections import Counter
|
9 |
+
import matplotlib.pyplot as plt # For pie chart
|
10 |
|
11 |
# Set of 20 standard amino acids
|
12 |
AMINO_ACIDS = set("ACDEFGHIKLMNPQRSTVWY")
|
|
|
60 |
# 🔵 Pie Chart for Overall Stats
|
61 |
st.subheader("🧁 Overall Amino Acid Composition (Pie Chart)")
|
62 |
|
63 |
+
fig, ax = plt.subplots(figsize=(6, 6)) # 50% of typical view size
|
64 |
labels = list(overall_percentage.keys())
|
65 |
sizes = list(overall_percentage.values())
|
66 |
|
67 |
+
# Filter out amino acids with 0% to avoid clutter
|
68 |
filtered = [(label, size) for label, size in zip(labels, sizes) if size > 0]
|
69 |
+
if filtered:
|
70 |
+
labels, sizes = zip(*filtered)
|
71 |
+
|
72 |
+
ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90, counterclock=False)
|
73 |
+
ax.axis('equal') # Equal aspect ratio ensures the pie is circular.
|
74 |
+
st.pyplot(fig)
|
75 |
+
else:
|
76 |
+
st.info("No valid amino acids found to display in pie chart.")
|
77 |
|
78 |
# Export to Excel
|
79 |
def to_excel(df):
|