File size: 1,165 Bytes
0779cd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import streamlit as st
from Bio.Seq import Seq

def find_matches(query_seq, target_seq):
    """Find matching subsequences between query and target sequences."""
    matches = []
    query_len = len(query_seq)
    for i in range(len(target_seq) - query_len + 1):
        subseq = target_seq[i:i+query_len]
        if subseq == query_seq:
            matches.append((i, subseq))
    return matches

st.title("DNA Sequence Matching")

st.sidebar.header("Input Sequences")
query = st.sidebar.text_area("Enter Query Sequence:", "")
target = st.sidebar.text_area("Enter Target Sequence:", "")

if st.sidebar.button("Find Matches"):
    if query and target:
        query_seq = Seq(query.upper())
        target_seq = Seq(target.upper())
        matches = find_matches(query_seq, target_seq)

        st.subheader("Results")
        if matches:
            st.write(f"Found {len(matches)} matches:")
            for idx, (pos, match) in enumerate(matches):
                st.write(f"Match {idx + 1}: Position {pos}, Sequence: {match}")
        else:
            st.write("No matches found.")
    else:
        st.warning("Please enter both query and target sequences.")