File size: 511 Bytes
c68d708
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import matplotlib.pyplot as plt
import numpy as np
import streamlit as st

def plot_dot_matrix(seq1, seq2, window=1):
    matrix = np.zeros((len(seq1), len(seq2)))
    for i in range(len(seq1) - window + 1):
        for j in range(len(seq2) - window + 1):
            if seq1[i:i+window] == seq2[j:j+window]:
                matrix[i][j] = 1
    fig, ax = plt.subplots()
    ax.imshow(matrix, cmap="Greys", interpolation="none")
    ax.set_xlabel("Sequence B")
    ax.set_ylabel("Sequence A")
    st.pyplot(fig)