Spaces:
Running
Running
Gilmullin Almaz
commited on
Commit
·
33f46a2
1
Parent(s):
dfa290e
added clustering and display blocks
Browse files
app.py
CHANGED
|
@@ -19,6 +19,13 @@ from synplan.utils.config import TreeConfig, PolicyNetworkConfig
|
|
| 19 |
from synplan.utils.loading import load_reaction_rules, load_building_blocks
|
| 20 |
from synplan.utils.visualisation import generate_results_html, get_route_svg
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
disable_progress_bars("huggingface_hub")
|
| 23 |
|
| 24 |
smiles_parser = SMILESRead.create_parser(ignore=True)
|
|
@@ -238,6 +245,30 @@ if submit_planning:
|
|
| 238 |
route_score = round(tree.route_score(node_id), 3)
|
| 239 |
st.image(get_route_svg(tree, node_id), caption=f"Route {node_id}; {num_steps} steps; Route score: {route_score}")
|
| 240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
stat_col, download_col = st.columns(2, gap="medium")
|
| 242 |
|
| 243 |
with stat_col:
|
|
|
|
| 19 |
from synplan.utils.loading import load_reaction_rules, load_building_blocks
|
| 20 |
from synplan.utils.visualisation import generate_results_html, get_route_svg
|
| 21 |
|
| 22 |
+
|
| 23 |
+
from cluster.super_cgr import *
|
| 24 |
+
from cluster.rs_cgr import *
|
| 25 |
+
from cluster.clustering import *
|
| 26 |
+
from StructureFingerprint import MorganFingerprint
|
| 27 |
+
|
| 28 |
+
|
| 29 |
disable_progress_bars("huggingface_hub")
|
| 30 |
|
| 31 |
smiles_parser = SMILESRead.create_parser(ignore=True)
|
|
|
|
| 245 |
route_score = round(tree.route_score(node_id), 3)
|
| 246 |
st.image(get_route_svg(tree, node_id), caption=f"Route {node_id}; {num_steps} steps; Route score: {route_score}")
|
| 247 |
|
| 248 |
+
|
| 249 |
+
### Modified part
|
| 250 |
+
submit_clustering = st.button('Start clustering')
|
| 251 |
+
|
| 252 |
+
if submit_clustering:
|
| 253 |
+
st.subheader("Examples of clusters")
|
| 254 |
+
super_cgrs_dict = reassign_nums(tree)
|
| 255 |
+
|
| 256 |
+
reduced_super_cgrs_dict = process_all_rs_cgrs(super_cgrs_dict)
|
| 257 |
+
|
| 258 |
+
mfp = MorganFingerprint()
|
| 259 |
+
|
| 260 |
+
results = cluster_molecules(reduced_super_cgrs_dict, mfp)
|
| 261 |
+
|
| 262 |
+
# Access results
|
| 263 |
+
clusters = results['clusters_dict']
|
| 264 |
+
|
| 265 |
+
for cluster_num, node_id_list in clusters.items():
|
| 266 |
+
print(cluster_num)
|
| 267 |
+
node_id = node_id_list[0]
|
| 268 |
+
num_steps = len(tree.synthesis_route(node_id))
|
| 269 |
+
route_score = round(tree.route_score(node_id), 3)
|
| 270 |
+
st.image(get_route_svg(tree, node_id), caption=f"Route {node_id}; {num_steps} steps; Route score: {route_score}")
|
| 271 |
+
|
| 272 |
stat_col, download_col = st.columns(2, gap="medium")
|
| 273 |
|
| 274 |
with stat_col:
|