Jayesh13 commited on
Commit
cdc95c3
·
verified ·
1 Parent(s): 0c90078

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -1,11 +1,12 @@
1
  import os
2
- os.system("pip install streamlit pandas xlsxwriter openpyxl")
3
 
4
  import streamlit as st
5
  import pandas as pd
6
  import xlsxwriter
7
  from io import BytesIO
8
  from collections import Counter
 
9
 
10
  # Set of 20 standard amino acids
11
  AMINO_ACIDS = set("ACDEFGHIKLMNPQRSTVWY")
@@ -56,6 +57,21 @@ if uploaded_file and st.button("Analyze File"):
56
 
57
  st.dataframe(df_result)
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  # Export to Excel
60
  def to_excel(df):
61
  output = BytesIO()
@@ -82,4 +98,4 @@ if uploaded_file and st.button("Analyze File"):
82
  data=excel_file,
83
  file_name="amino_acid_percentage.xlsx",
84
  mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
85
- )
 
1
  import os
2
+ os.system("pip install streamlit pandas xlsxwriter openpyxl matplotlib")
3
 
4
  import streamlit as st
5
  import pandas as pd
6
  import xlsxwriter
7
  from io import BytesIO
8
  from collections import Counter
9
+ import matplotlib.pyplot as plt # Added for pie chart
10
 
11
  # Set of 20 standard amino acids
12
  AMINO_ACIDS = set("ACDEFGHIKLMNPQRSTVWY")
 
57
 
58
  st.dataframe(df_result)
59
 
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 zero values
68
+ filtered = [(label, size) for label, size in zip(labels, sizes) if size > 0]
69
+ labels, sizes = zip(*filtered)
70
+
71
+ ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90, counterclock=False)
72
+ ax.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
73
+ st.pyplot(fig)
74
+
75
  # Export to Excel
76
  def to_excel(df):
77
  output = BytesIO()
 
98
  data=excel_file,
99
  file_name="amino_acid_percentage.xlsx",
100
  mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
101
+ )