Spaces:
Runtime error
Runtime error
from stmol import showmol | |
import py3Dmol | |
import streamlit as st | |
import requests | |
st.markdown("# ESM-2 Protein Folding demo") | |
st.markdown("You can input a single protein sequence and you get the predicted protein structure") | |
option = st.selectbox( | |
'Select a protein', | |
("Antifreeze protein", "Plastic degradation protein", "AI Generated protein", "7-bladed propeller fold", "custom")) | |
if option == "Plastic degradation protein": | |
suggestion = "MGSSHHHHHHSSGLVPRGSHMRGPNPTAASLEASAGPFTVRSFTVSRPSGYGAGTVYYPTNAGGTVGAIAIVPGYTARQSSIKWWGPRLASHGFVVITIDTNSTLDQPSSRSSQQMAALRQVASLNGTSSSPIYGKVDTARMGVMGWSMGGGGSLISAANNPSLKAAAPQAPWDSSTNFSSVTVPTLIFACENDSIAPVNSSALPIYDSMSRNAKQFLEINGGSHSCANSGNSNQALIGKKGVAWMKRFMDNDTRYSTFACENPNSTRVSDFRTANCSLEDPAANKARKEAELAAATAEQ" | |
elif option == "Antifreeze protein": | |
suggestion = "QCTGGADCTSCTGACTGCGNCPNAVTCTNSQHCVKANTCTGSTDCNTAQTCTNSKDCFEANTCTDSTNCYKATACTNSSGCPGH" | |
elif option == "AI Generated protein": | |
suggestion = "MSGMKKLYEYTVTTLDEFLEKLKEFILNTSKDKIYKLTITNPKLIKDIGKAIAKAAEIADVDPKEIEEMIKAVEENELTKLVITIEQTDDKYVIKVELENEDGLVHSFEIYFKNKEEMEKFLELLEKLISKLSGS" | |
elif option == "7-bladed propeller fold": | |
suggestion = "VKLAGNSSLCPINGWAVYSKDNSIRIGSKGDVFVIREPFISCSHLECRTFFLTQGALLNDKHSNGTVKDRSPHRTLMSCPVGEAPSPYNSRFESVAWSASACHDGTSWLTIGISGPDNGAVAVLKYNGIITDTIKSWRNNILRTQESECACVNGSCFTVMTDGPSNGQASYKIFKMEKGKVVKSVELDAPNYHYEECSCYPNAGEITCVCRDNWHGSNRPWVSFNQNLEYQIGYICSGVFGDNPRPNDGTGSCGPVSSNGAYGVKGFSFKYGNGVWIGRTKSTNSRSGFEMIWDPNGWTETDSSFSVKQDIVAITDWSGYSGSFVQHPELTGLDCIRPCFWVELIRGRPKESTIWTSGSSISFCGVNSDTVGWSWPDGAELPFTIDK" | |
else: | |
suggestion = "" | |
sequence = st.text_input(label="Protein Sequence", value=suggestion) | |
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') | |
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).") | |