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_filename = "test.pdb" pdb_string = response.content.decode('utf-8') #with open(pdb_filename, "w") as out: # out.write(pdb_string) # print(pdb_string) #xyzview = py3Dmol.view(js='https://3dmol.org/build/3Dmol.js', width=800, height=400) xyzview = py3Dmol.view() #xyzview.addModel(pdb_filename, "pdb") xyzview.addModel(pdb_string,'pdb') xyzview.setStyle({'cartoon':{ "color": "spectrum",}}) xyzview.zoomTo() print("Set style") showmol(xyzview, height = 500,width=800) print("Displayed")