# Import necessary libraries import streamlit as st from io import StringIO, BytesIO from Bio import SeqIO from kitikiplot.genomics import grid # Page configuration st.set_page_config( page_title="Genome Grid Plot", page_icon="🧬", layout="wide", initial_sidebar_state="collapsed" ) # Professional styling with blue navigation bar st.markdown(""" """, unsafe_allow_html=True) import base64 with open("src/logo.png", "rb") as img_file: encoded = base64.b64encode(img_file.read()).decode() # Display using HTML st.markdown(f"""
""", unsafe_allow_html=True) # st.markdown(""" # # """, unsafe_allow_html=True) # st.image("banner.png", width=60) # Initialize session state if 'figure' not in st.session_state: st.session_state.figure = None if 'data' not in st.session_state: st.session_state.data = "" if 'plot_generated' not in st.session_state: st.session_state.plot_generated = False # Main layout col1, col2 = st.columns([30, 70]) # Column 1: Upload and Controls with col1: st.markdown('Recommended: sequence length <1000 for detailed analysis
', unsafe_allow_html=True) # Submit button submit = st.button("🔬 Generate Plot", type="primary", key="submit_btn") if submit: with st.spinner("🧬 Generating genome grid plot..."): st.session_state.figure = grid.plot( nucleotide_sequence=data, window_length=window_length ) st.session_state.plot_generated = True except Exception as e: st.error(f"❌ Error processing file: {str(e)}") else: st.info("👆 Please upload a FASTA file to begin visualization") # # Banner image at bottom with error handling # try: # st.image("src/banner.png", use_container_width=True) # except: # pass # Silently ignore if banner not found st.markdown('', unsafe_allow_html=True) # Column 2: Plot Display with col2: if st.session_state.figure is not None and st.session_state.plot_generated: st.markdown('Upload a FASTA file and click "Generate Plot" to visualize your genome sequence.
Genome Grid Plot • Intuitive genomics visualization tool • Built with Streamlit