Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from Bio.Seq import Seq
|
| 3 |
+
|
| 4 |
+
def find_matches(query_seq, target_seq):
|
| 5 |
+
"""Find matching subsequences between query and target sequences."""
|
| 6 |
+
matches = []
|
| 7 |
+
query_len = len(query_seq)
|
| 8 |
+
for i in range(len(target_seq) - query_len + 1):
|
| 9 |
+
subseq = target_seq[i:i+query_len]
|
| 10 |
+
if subseq == query_seq:
|
| 11 |
+
matches.append((i, subseq))
|
| 12 |
+
return matches
|
| 13 |
+
|
| 14 |
+
st.title("DNA Sequence Matching")
|
| 15 |
+
|
| 16 |
+
st.sidebar.header("Input Sequences")
|
| 17 |
+
query = st.sidebar.text_area("Enter Query Sequence:", "")
|
| 18 |
+
target = st.sidebar.text_area("Enter Target Sequence:", "")
|
| 19 |
+
|
| 20 |
+
if st.sidebar.button("Find Matches"):
|
| 21 |
+
if query and target:
|
| 22 |
+
query_seq = Seq(query.upper())
|
| 23 |
+
target_seq = Seq(target.upper())
|
| 24 |
+
matches = find_matches(query_seq, target_seq)
|
| 25 |
+
|
| 26 |
+
st.subheader("Results")
|
| 27 |
+
if matches:
|
| 28 |
+
st.write(f"Found {len(matches)} matches:")
|
| 29 |
+
for idx, (pos, match) in enumerate(matches):
|
| 30 |
+
st.write(f"Match {idx + 1}: Position {pos}, Sequence: {match}")
|
| 31 |
+
else:
|
| 32 |
+
st.write("No matches found.")
|
| 33 |
+
else:
|
| 34 |
+
st.warning("Please enter both query and target sequences.")
|