yashm commited on
Commit
04fd093
·
verified ·
1 Parent(s): 37dedd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -63,6 +63,26 @@ def add_protein_features(cds_info):
63
  cds['Isoelectric Point'] = 'N/A'
64
  return cds_info
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  # Streamlit UI
67
  st.set_page_config(page_title="Genomic Data Dashboard", page_icon="🧬", layout="wide")
68
  uploaded_file = st.file_uploader("Upload a GenBank file", type=['gb', 'gbk'])
@@ -106,6 +126,13 @@ if uploaded_file is not None:
106
  kmers = calculate_kmers(sequence, k)
107
  st.bar_chart(pd.DataFrame.from_dict(kmers, orient='index', columns=['Frequency']).sort_values('Frequency', ascending=False).head(20))
108
 
 
 
 
 
 
 
 
109
  # Additional Information
110
  with st.expander("View All Genes"):
111
  st.dataframe(gene_df)
 
63
  cds['Isoelectric Point'] = 'N/A'
64
  return cds_info
65
 
66
+ # Function to add genome_diagram
67
+ def create_genome_diagram(genbank_content, output_file_path):
68
+ record = SeqIO.read(StringIO(genbank_content), "genbank")
69
+ gd_diagram = GenomeDiagram.Diagram(record.id)
70
+ gd_track_for_features = gd_diagram.new_track(1, name="Annotated Features")
71
+ gd_feature_set = gd_track_for_features.new_set()
72
+
73
+ for feature in record.features:
74
+ if feature.type not in ["gene", "CDS"]:
75
+ continue
76
+ if len(gd_feature_set) % 2 == 0:
77
+ color = colors.blue
78
+ else:
79
+ color = colors.lightblue
80
+ gd_feature_set.add_feature(feature, color=color, label=True, label_size=10, label_angle=0)
81
+
82
+ gd_diagram.draw(format="circular", circular=True, pagesize=(20*cm, 20*cm), start=0, end=len(record), circle_core=0.7)
83
+ gd_diagram.write(output_file_path, "PNG")
84
+
85
+
86
  # Streamlit UI
87
  st.set_page_config(page_title="Genomic Data Dashboard", page_icon="🧬", layout="wide")
88
  uploaded_file = st.file_uploader("Upload a GenBank file", type=['gb', 'gbk'])
 
126
  kmers = calculate_kmers(sequence, k)
127
  st.bar_chart(pd.DataFrame.from_dict(kmers, orient='index', columns=['Frequency']).sort_values('Frequency', ascending=False).head(20))
128
 
129
+ # Generate genome diagram
130
+ output_file_path = os.path.join(st.session_state.get("temp_dir", "."), "genome_diagram.png")
131
+ create_genome_diagram(uploaded_file.getvalue().decode("utf-8"), output_file_path)
132
+
133
+ # Display genome diagram
134
+ st.image(output_file_path, caption='Genome Diagram')
135
+
136
  # Additional Information
137
  with st.expander("View All Genes"):
138
  st.dataframe(gene_df)