Skip to content

Commit

Permalink
Merge pull request #22 from avrabyt/master
Browse files Browse the repository at this point in the history
🚀 demo app added,Article requirements ❇️
  • Loading branch information
napoles-uach authored Aug 14, 2022
2 parents dac7316 + 76104bb commit eedee6a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 6 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ipywidgets(==7.6.3)

## Quickstart

##### Protein visualization using `showmol()`function
##### 1. Protein visualization using `showmol()`function

- **Using `py3Dmol object`**

Expand All @@ -60,14 +60,19 @@ The `render_pdb()` function accepts any PDB ID and returns a py3Dmol object.
from stmol import *
showmol(render_pdb(id = '1A2C'))
```
![Quickstart-1](https://github.com/avrabyt/stmol/blob/master/Resources/Quickstart-1.png)
![Quickstart-1](https://github.com/napoles-uach/stmol/blob/master/Resources/Quickstart-1.png)

##### Labelling protein using `render_pdb()`function
##### 2. Labelling protein using `render_pdb()`function
Inorder to mark the residues, we can use the `render_pdb()` function, which in this example marks the *Alanine* [ALA] residues,
```python
showmol(render_pdb_resn(viewer = render_pdb(id = '1A2C'),resn_lst = ['ALA',]))
```
![Quickstart-1](https://github.com/avrabyt/stmol/blob/master/Resources/Quickstart-1.png)
![Quickstart-1](https://github.com/napoles-uach/stmol/blob/master/Resources/Quickstart-2.png)

###### Refer to the documentation [here](https://napoles-uach-stmol-home-pom051.streamlitapp.com/Documentation)
----------
### Examples
You can find several `stmol` examples [here](https://napoles-uach-stmol-home-pom051.streamlitapp.com/Examples).

----------------
## Dependencies
Expand All @@ -83,4 +88,8 @@ We appreciate contributions from the community! Every little bit helps, and cred
- **Fix Bugs** - Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to help with it.
- **Implement Features** - Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
- **Submit Feedback** - The best way to send feedback is to file an issue at https://github.com/napoles-uach/stmol/issues

--------------
## Authors
- J. M. N ́apoles-Duarte <jnapoles@uach.mx>
- Avratanu Biswas <avratanu.biswas@brc.hu>
- Mitchell I. Parker <mip34@drexel.edu>
File renamed without changes.
66 changes: 66 additions & 0 deletions pages/2_Demo stmol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

### Step 1) Imports

import streamlit as st
import py3Dmol
from stmol import showmol

### Step 2) Streamlit

st.sidebar.title("View Settings")

pdb_code = st.sidebar.text_input(
label="PDB Code",
value="3K8Y",
)

hl_resi_list = st.sidebar.multiselect(label="Highlight Residues",options=list(range(1,5000)))

hl_chain = st.sidebar.text_input(label="Highlight Chain",value="A")

label_resi = st.sidebar.checkbox(label="Label Residues", value=True)

surf_transp = st.sidebar.slider("Surface Transparency", min_value=0.0, max_value=1.0, value=0.0)

hl_color = st.sidebar.text_input(label="Highlight Color",value="red")

bb_color = st.sidebar.text_input(label="Backbone Color",value="lightgrey")
lig_color = st.sidebar.text_input(label="Ligand Color",value="white")

st.markdown(f"## Stmol-App: PDB [{pdb_code.upper()}](https://www.rcsb.org/structure/{pdb_code}) (Chain {hl_chain})")

### Step 3) Py3Dmol

width = 700
height = 700

cartoon_radius = 0.2
stick_radius = 0.2

view = py3Dmol.view(query=f"pdb:{pdb_code.lower()}", width=width, height=height)

view.setStyle({"cartoon": {"style": "oval","color": bb_color,"thickness": cartoon_radius}})

view.addSurface(py3Dmol.VDW, {"opacity": surf_transp, "color": bb_color},{"hetflag": False})

view.addStyle({"elem": "C", "hetflag": True},
{"stick": {"color": lig_color, "radius": stick_radius}})

view.addStyle({"hetflag": True},
{"stick": {"radius": stick_radius}})

for hl_resi in hl_resi_list:
view.addStyle({"chain": hl_chain, "resi": hl_resi, "elem": "C"},
{"stick": {"color": hl_color, "radius": stick_radius}})

view.addStyle({"chain": hl_chain, "resi": hl_resi},
{"stick": {"radius": stick_radius}})

if label_resi:
for hl_resi in hl_resi_list:
view.addResLabels({"chain": hl_chain,"resi": hl_resi},
{"backgroundColor": "lightgray","fontColor": "black","backgroundOpacity": 0.5})

### Step 4) Stmol

showmol(view, height=height, width=width)
4 changes: 3 additions & 1 deletion pages/3_Examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,6 @@

with tab3 :
with st.echo():
showmol(render_pdb_resn(viewer = render_pdb(id = '1A2C'),resn_lst = ['ALA',]))
showmol(render_pdb_resn(viewer = render_pdb(id = '1A2C'),resn_lst = ['ALA',]),height=700,width=700)


0 comments on commit eedee6a

Please sign in to comment.