Spaces:
Runtime error
Runtime error
from stmol import showmol | |
import py3Dmol | |
import streamlit as st | |
import requests | |
sequence = st.text_input(label="Protein Sequence", value="MGSSHHHHHHSSGLVPRGSHMRGPNPTAASLEASAGPFTVRSFTVSRPSGYGAGTVYYPTNAGGTVGAIAIVPGYTARQSSIKWWGPRLASHGFVVITIDTNSTLDQPSSRSSQQMAALRQVASLNGTSSSPIYGKVDTARMGVMGWSMGGGGSLISAANNPSLKAAAPQAPWDSSTNFSSVTVPTLIFACENDSIAPVNSSALPIYDSMSRNAKQFLEINGGSHSCANSGNSNQALIGKKGVAWMKRFMDNDTRYSTFACENPNSTRVSDFRTANCSLEDPAANKARKEAELAAATAEQ") | |
headers = { | |
'Content-Type': 'application/x-www-form-urlencoded', | |
} | |
response = requests.post('https://api.esmatlas.com/foldSequence/v1/pdb/', headers=headers, data=sequence) | |
name = sequence[:3] + sequence[-3:] | |
pdb_string = response.content.decode('utf-8') | |
st.markdown("# ESM-2 Protein Folding demo") | |
st.markdown("You can input a single protein sequence and you get the predicted protein structure") | |
xyzview = py3Dmol.view() | |
xyzview.addModel(pdb_string,'pdb') | |
xyzview.setStyle({'cartoon':{ | |
"color": "spectrum",}}) | |
xyzview.zoomTo() | |
print("Set style") | |
showmol(xyzview, height = 500,width=800) | |
print("Displayed") | |
st.markdown("[ESM](https://esmatlas.com/about) by Meta using the API. You can also use Hugging Face `transformers` as shown [here](https://github.com/huggingface/notebooks/blob/main/examples/protein_folding.ipynb), which is supported since [v4.24](https://github.com/huggingface/transformers/releases/tag/v4.24.0).") | |