aksell commited on
Commit
08dc5f2
1 Parent(s): b92b272

Add basic streamlit view using stmol

Browse files
README.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Protention
2
+ Visualize attention pattern on 3D protein structures
3
+
4
+ ## Install and run
5
+
6
+ ```shell
7
+ poetry install
8
+
9
+ poetry run streamlit run protention/streamlit/Attention_On_Structure.py
10
+ ```
protention/streamlit/Attention_On_Structure.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import py3Dmol
2
+ import stmol
3
+ import streamlit as st
4
+ from stmol import showmol
5
+
6
+ st.sidebar.title("pLM Attention Visualization")
7
+
8
+ st.title("pLM Attention Visualization")
9
+
10
+ pdb_id = st.text_input("PDB ID", "4RW0")
11
+ chain_id = None
12
+
13
+ left, right = st.columns(2)
14
+ with left:
15
+ layer = st.number_input("Layer", value=8)
16
+ with right:
17
+ head = st.number_input("Head", value=5)
18
+
19
+ min_attn = st.slider("Minimum attention", min_value=0.0, max_value=0.4, value=0.15)
20
+
21
+
22
+ def get_3dview(pdb):
23
+ xyzview = py3Dmol.view(query=f"pdb:{pdb}")
24
+ xyzview.setStyle({"cartoon": {"color": "spectrum"}})
25
+ stmol.add_hover(xyzview, backgroundColor="black", fontColor="white")
26
+ return xyzview
27
+
28
+
29
+ xyzview = get_3dview(pdb_id)
30
+ showmol(xyzview, height=500, width=800)
protention/streamlit/__init__.py ADDED
File without changes