Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import streamlit as st
|
3 |
+
from Bio import pairwise2
|
4 |
+
from Bio.pairwise2 import format_alignment
|
5 |
+
|
6 |
+
# Page Configuration
|
7 |
+
st.set_page_config(
|
8 |
+
page_title="𧬠DNA Sequence Matcher",
|
9 |
+
page_icon="π§¬",
|
10 |
+
layout="centered"
|
11 |
+
)
|
12 |
+
|
13 |
+
# Header
|
14 |
+
st.markdown(
|
15 |
+
"<h1 style='text-align: center; color: #4CAF50;'>𧬠DNA Sequence Matcher</h1>",
|
16 |
+
unsafe_allow_html=True
|
17 |
+
)
|
18 |
+
st.markdown(
|
19 |
+
"<p style='text-align: center; color: #555;'>Align and compare two DNA sequences using Biopython</p>",
|
20 |
+
unsafe_allow_html=True
|
21 |
+
)
|
22 |
+
|
23 |
+
# User Input for DNA Sequences
|
24 |
+
st.subheader("π¬ Input DNA Sequences")
|
25 |
+
seq1 = st.text_area("Enter DNA Sequence 1:", placeholder="e.g., ATCGTACGTA")
|
26 |
+
seq2 = st.text_area("Enter DNA Sequence 2:", placeholder="e.g., ATCGTAGCTA")
|
27 |
+
|
28 |
+
# Alignment Parameters
|
29 |
+
st.subheader("βοΈ Alignment Parameters")
|
30 |
+
match_score = st.slider("Match Score", min_value=1, max_value=5, value=2)
|
31 |
+
mismatch_penalty = st.slider("Mismatch Penalty", min_value=-5, max_value=0, value=-1)
|
32 |
+
gap_open_penalty = st.slider("Gap Open Penalty", min_value=-5, max_value=0, value=-2)
|
33 |
+
gap_extend_penalty = st.slider("Gap Extend Penalty", min_value=-5, max_value=0, value=-0.5)
|
34 |
+
|
35 |
+
# Perform Alignment
|
36 |
+
if st.button("π§ͺ Align Sequences"):
|
37 |
+
if not seq1 or not seq2:
|
38 |
+
st.warning("β οΈ Please enter both DNA sequences.")
|
39 |
+
else:
|
40 |
+
alignments = pairwise2.align.globalms(
|
41 |
+
seq1,
|
42 |
+
seq2,
|
43 |
+
match_score,
|
44 |
+
mismatch_penalty,
|
45 |
+
gap_open_penalty,
|
46 |
+
gap_extend_penalty
|
47 |
+
)
|
48 |
+
|
49 |
+
# Display Results
|
50 |
+
st.subheader("π Alignment Results")
|
51 |
+
if alignments:
|
52 |
+
for alignment in alignments[:1]: # Show only the top alignment
|
53 |
+
st.code(format_alignment(*alignment))
|
54 |
+
else:
|
55 |
+
st.error("β No alignment could be found.")
|
56 |
+
|
57 |
+
# Footer
|
58 |
+
st.markdown(
|
59 |
+
"<hr><p style='text-align: center;'>π» <b>Developed by ChatGPT</b></p>",
|
60 |
+
unsafe_allow_html=True
|
61 |
+
)
|