Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import numpy as np
|
2 |
import matplotlib.pyplot as plt
|
3 |
-
from matplotlib.animation import FuncAnimation
|
4 |
import random
|
5 |
from scipy.stats import entropy as scipy_entropy
|
6 |
import streamlit as st
|
@@ -115,28 +114,17 @@ def draw_world(seq, axs, step, cnt_hist, ent_hist, ac_hist):
|
|
115 |
axs[2].set_title("Автокорреляция углового профиля (структурность) и энтропия")
|
116 |
axs[2].text(0.70,0.70, f"Энтропия: {ent_hist[-1]:.2f}", transform=axs[2].transAxes)
|
117 |
|
118 |
-
def animate(i):
|
119 |
-
global seq, stat_bist_counts, stat_entropy, stat_autocorr
|
120 |
-
if i == 0:
|
121 |
-
stat_bist_counts.clear()
|
122 |
-
stat_entropy.clear()
|
123 |
-
stat_autocorr.clear()
|
124 |
-
else:
|
125 |
-
seq = bio_mutate(seq)
|
126 |
-
torsion_profile = np.array([ANGLE_MAP.get(nt, 0.0) for nt in seq])
|
127 |
-
runs = find_local_min_runs(torsion_profile, min_run, max_run)
|
128 |
-
stat_bist_counts.append(len(runs))
|
129 |
-
ent = compute_entropy(torsion_profile)
|
130 |
-
stat_entropy.append(ent)
|
131 |
-
acorr = compute_autocorr(torsion_profile)
|
132 |
-
stat_autocorr.append(acorr)
|
133 |
-
draw_world(seq, axs, i, stat_bist_counts, stat_entropy, stat_autocorr)
|
134 |
-
return axs
|
135 |
-
|
136 |
# --- Запуск анимации в Streamlit ---
|
137 |
if st.button("Начать анимацию"):
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import numpy as np
|
2 |
import matplotlib.pyplot as plt
|
|
|
3 |
import random
|
4 |
from scipy.stats import entropy as scipy_entropy
|
5 |
import streamlit as st
|
|
|
114 |
axs[2].set_title("Автокорреляция углового профиля (структурность) и энтропия")
|
115 |
axs[2].text(0.70,0.70, f"Энтропия: {ent_hist[-1]:.2f}", transform=axs[2].transAxes)
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
# --- Запуск анимации в Streamlit ---
|
118 |
if st.button("Начать анимацию"):
|
119 |
+
for step in range(steps):
|
120 |
+
seq = bio_mutate(seq)
|
121 |
+
torsion_profile = np.array([ANGLE_MAP.get(nt, 0.0) for nt in seq])
|
122 |
+
runs = find_local_min_runs(torsion_profile, min_run, max_run)
|
123 |
+
stat_bist_counts.append(len(runs))
|
124 |
+
ent = compute_entropy(torsion_profile)
|
125 |
+
stat_entropy.append(ent)
|
126 |
+
acorr = compute_autocorr(torsion_profile)
|
127 |
+
stat_autocorr.append(acorr)
|
128 |
+
draw_world(seq, axs, step, stat_bist_counts, stat_entropy, stat_autocorr)
|
129 |
+
st.pyplot(fig)
|
130 |
+
st.experimental_rerun() # Обновление страницы после каждого шага
|