Spaces:
Sleeping
Sleeping
File size: 3,939 Bytes
e9e75df |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
from chroma import api
from chroma import Chroma,conditioners,Protein
import streamlit as st
from stmol import *
# Register your Chroma API key
api.register_key("2cdade6d058b4fd1b85fa5badb501312")
def load_message(protein):
st.header("Protein Information:")
st.write(f"Device: {protein.device}")
st.write(f"Protein Length: {len(protein)} residues")
st.write(f"Structured Residue Count: {protein.length(structured=True)}")
# 显示 Protein 的序列
st.header("Protein Sequence:")
protein_sequence = protein.sequence(format="one-letter-string")
st.write(protein_sequence)
# Display title
st.title("Unconditional sample display")
st.write("slide to choose your chain_lengths:")
chain_lengths = st.slider(label="chain_lengths", min_value=10, max_value=500, key="chain_lengths")
#Generate protein sample
# 显示 Protein 的一些信息
load_message(Protein('sample.cif'))
if st.button("Run Code with Button",key="Unconditional"):
chroma = Chroma()
protein = chroma.sample(chain_lengths=[chain_lengths])
protein.to("sample.pdb")
load_message(protein)
# 显示 Protein 的结构
with open("sample.pdb", "r") as file:
pdb_content = file.read()
obj = makeobj(pdb_content)
# 使用 stmol 展示蛋白质结构
st.header("Protein Structure:")
showmol(obj, width=1800)
st.title("Conditional sample display")
st.write("slide to choose your num_chain_neighbors:")
num_chain_neighbors = st.slider(label="num_chain_neighbors",min_value=1,max_value=10, key="num_chain_neighbors")
conditioner = conditioners.SymmetryConditioner(G="C_3", num_chain_neighbors=num_chain_neighbors)
st.write("slide to choose your chain_lengths:")
chain_lengths_2 = st.slider(label="chain_lengths_2",min_value=10,max_value=500,key="chain_lengths_2")
st.write("slide to choose your langevin_factor:")
langevin_factor = st.slider(label="langevin_factor",min_value=8,max_value=32, key="langevin_factor")
st.write("slide to choose your inverse_temperature:")
inverse_temperature = st.slider(label="inverse_temperature",min_value=8,max_value=64,key="inverse_temperature")
load_message(Protein('sample-C3.pdb'))
if st.button("Run Code with Button",key="Conditional"):
chroma = Chroma()
protein = chroma.sample(
chain_lengths=[chain_lengths_2],
conditioner=conditioner,
langevin_factor=langevin_factor,
inverse_temperature=inverse_temperature,
sde_func="langevin",
potts_symmetry_order=conditioner.potts_symmetry_order)
protein.to("sample-C3.pdb")
load_message(protein)
# 显示 Protein 的结构
with open("sample-C3.pdb", "r") as file:
pdb_content = file.read()
obj = makeobj(pdb_content)
# 使用 stmol 展示蛋白质结构
st.header("Protein Structure:")
showmol(obj, width=1800)
# Display title
st.title("Design display")
load_message(Protein('1GFP'))
if st.button("Run Code with Button",key="Design"):
chroma = Chroma()
protein = Protein('1GFP',device='cuda')
protein = chroma.design(protein)
protein.to("1GFP-redesign.cif")
# 显示 Protein 的结构
with open("1GFP-redesign.cif", "r") as file:
pdb_content = file.read()
obj = makeobj(pdb_content)
# 使用 stmol 展示蛋白质结构
st.header("Protein Structure:")
showmol(obj, width=1800)
# Display title
st.title("Redesign display")
load_message(Protein('my_favorite_protein_redesign.cif'))
if st.button("Run Code with Button",key="Redesign"):
chroma = Chroma()
protein = Protein('sample.cif',device='cuda') # PDB is fine too
protein = chroma.design(protein, design_selection="resid 20-50 around 5.0") # 5 angstrom bubble around indices 20-50
protein.to("my_favorite_protein_redesign.cif")
# 显示 Protein 的结构
with open("my_favorite_protein_redesign.cif", "r") as file:
pdb_content = file.read()
obj = makeobj(pdb_content)
# 使用 stmol 展示蛋白质结构
st.header("Protein Structure:")
showmol(obj, width=1800) |