Spaces:
Sleeping
Sleeping
| 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.") | |