Spaces:
Sleeping
Sleeping
# app.py | |
import streamlit as st | |
from Bio import pairwise2 | |
from Bio.pairwise2 import format_alignment | |
# Page Configuration | |
st.set_page_config( | |
page_title="𧬠DNA Sequence Matcher", | |
page_icon="π§¬", | |
layout="centered" | |
) | |
# Header | |
st.markdown( | |
"<h1 style='text-align: center; color: #4CAF50;'>𧬠DNA Sequence Matcher</h1>", | |
unsafe_allow_html=True | |
) | |
st.markdown( | |
"<p style='text-align: center; color: #555;'>Align and compare two DNA sequences using Biopython</p>", | |
unsafe_allow_html=True | |
) | |
# User Input for DNA Sequences | |
st.subheader("π¬ Input DNA Sequences") | |
seq1 = st.text_area("Enter DNA Sequence 1:", placeholder="e.g., ATCGTACGTA") | |
seq2 = st.text_area("Enter DNA Sequence 2:", placeholder="e.g., ATCGTAGCTA") | |
# Alignment Parameters | |
st.subheader("βοΈ Alignment Parameters") | |
match_score = st.slider("Match Score", min_value=1, max_value=5, value=2) | |
mismatch_penalty = st.slider("Mismatch Penalty", min_value=-5, max_value=0, value=-1) | |
gap_open_penalty = st.slider("Gap Open Penalty", min_value=-5, max_value=0, value=-2) | |
gap_extend_penalty = st.slider("Gap Extend Penalty", min_value=-5.0, max_value=0.0, value=-0.5, step=0.1) | |
# Perform Alignment | |
if st.button("π§ͺ Align Sequences"): | |
if not seq1 or not seq2: | |
st.warning("β οΈ Please enter both DNA sequences.") | |
else: | |
alignments = pairwise2.align.globalms( | |
seq1, | |
seq2, | |
match_score, | |
mismatch_penalty, | |
gap_open_penalty, | |
gap_extend_penalty | |
) | |
# Display Results | |
st.subheader("π Alignment Results") | |
if alignments: | |
for alignment in alignments[:1]: # Show only the top alignment | |
st.code(format_alignment(*alignment)) | |
else: | |
st.error("β No alignment could be found.") | |
# Footer | |
st.markdown( | |
"<hr><p style='text-align: center;'>π» <b>Developed by ChatGPT</b></p>", | |
unsafe_allow_html=True | |
) | |