Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -539,3 +539,155 @@ def combined_generation(name, strength, flexibility, speed, defense, size, abili
|
|
539 |
)
|
540 |
|
541 |
with gr.Blocks(theme='ParityError/Interstellar') as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
)
|
540 |
|
541 |
with gr.Blocks(theme='ParityError/Interstellar') as demo:
|
542 |
+
with gr.Row():
|
543 |
+
with gr.Column():
|
544 |
+
gr.Markdown("# 🦸♂️ 슈퍼히어로 단백질 만들기")
|
545 |
+
|
546 |
+
with gr.Tabs():
|
547 |
+
with gr.TabItem("히어로 디자인"):
|
548 |
+
# 히어로 기본 정보
|
549 |
+
hero_name = gr.Textbox(label="히어로 이름", placeholder="당신의 히어로 이름을 지어주세요!")
|
550 |
+
|
551 |
+
# 능력치 설정
|
552 |
+
gr.Markdown("### 💪 히어로 능력치 설정")
|
553 |
+
with gr.Row():
|
554 |
+
strength = gr.Slider(minimum=0.0, maximum=0.05, label="💪 초강력(근력)", value=0.02)
|
555 |
+
flexibility = gr.Slider(minimum=0.0, maximum=0.05, label="🤸♂️ 유연성", value=0.02)
|
556 |
+
|
557 |
+
with gr.Row():
|
558 |
+
speed = gr.Slider(minimum=0.0, maximum=0.20, label="⚡ 스피드", value=0.1)
|
559 |
+
defense = gr.Slider(minimum=-10, maximum=10, label="🛡️ 방어력", value=0)
|
560 |
+
|
561 |
+
# 히어로 크기 설정
|
562 |
+
hero_size = gr.Slider(minimum=50, maximum=200, label="히어로 크기", value=100)
|
563 |
+
|
564 |
+
# 특수 능력 설정
|
565 |
+
with gr.Accordion("🌟 특수 능력", open=False):
|
566 |
+
special_ability = gr.CheckboxGroup(
|
567 |
+
choices=["자가 회복", "원거리 공격", "방어막 생성"],
|
568 |
+
label="특수 능력 선택"
|
569 |
+
)
|
570 |
+
|
571 |
+
# 생성 버튼
|
572 |
+
create_btn = gr.Button("히어로 생성!", variant="primary")
|
573 |
+
|
574 |
+
with gr.TabItem("Inputs"):
|
575 |
+
gr.Markdown("""## INPUTS""")
|
576 |
+
gr.Markdown("""#### Start Sequence
|
577 |
+
Specify the protein length for complete unconditional generation, or scaffold a motif (or your name) using the custom sequence input""")
|
578 |
+
seq_opt = gr.Radio(["protein length","custom sequence"], label="How would you like to specify the starting sequence?", value='protein length')
|
579 |
+
|
580 |
+
sequence = gr.Textbox(label="custom sequence", lines=1, placeholder='AMINO ACIDS: A,C,D,E,F,G,H,I,K,L,M,N,P,Q,R,S,T,V,W,Y\n MASK TOKEN: X', visible=False)
|
581 |
+
seq_len = gr.Slider(minimum=5.0, maximum=250.0, label="protein length", value=100, visible=True)
|
582 |
+
|
583 |
+
seq_opt.change(fn=toggle_seq_input,
|
584 |
+
inputs=[seq_opt],
|
585 |
+
outputs=[seq_len, sequence],
|
586 |
+
queue=False)
|
587 |
+
|
588 |
+
gr.Markdown("""### Optional Parameters""")
|
589 |
+
with gr.Accordion(label='Secondary Structure',open=True):
|
590 |
+
gr.Markdown("""Try changing the sliders or inputing explicit secondary structure conditioning for each residue""")
|
591 |
+
sec_str_opt = gr.Radio(["sliders","explicit"], label="How would you like to specify secondary structure?", value='sliders')
|
592 |
+
|
593 |
+
secondary_structure = gr.Textbox(label="secondary structure", lines=1, placeholder='HELIX = H STRAND = S LOOP = L MASK = X(must be the same length as input sequence)', visible=False)
|
594 |
+
|
595 |
+
with gr.Column():
|
596 |
+
helix_bias = gr.Slider(minimum=0.0, maximum=0.05, label="helix bias", visible=True)
|
597 |
+
strand_bias = gr.Slider(minimum=0.0, maximum=0.05, label="strand bias", visible=True)
|
598 |
+
loop_bias = gr.Slider(minimum=0.0, maximum=0.20, label="loop bias", visible=True)
|
599 |
+
|
600 |
+
sec_str_opt.change(fn=toggle_secondary_structure,
|
601 |
+
inputs=[sec_str_opt],
|
602 |
+
outputs=[helix_bias,strand_bias,loop_bias,secondary_structure],
|
603 |
+
queue=False)
|
604 |
+
|
605 |
+
with gr.Accordion(label='Amino Acid Compositional Bias',open=False):
|
606 |
+
gr.Markdown("""Bias sequence composition for particular amino acids by specifying the one letter code followed by the fraction to bias. This can be input as a list for example: W0.2,E0.1""")
|
607 |
+
with gr.Row():
|
608 |
+
aa_bias = gr.Textbox(label="aa bias", lines=1, placeholder='specify one letter AA and fraction to bias, for example W0.1 or M0.1,K0.1' )
|
609 |
+
aa_bias_potential = gr.Textbox(label="aa bias scale", lines=1, placeholder='AA Bias potential scale (recomended range 1.0-5.0)')
|
610 |
+
|
611 |
+
with gr.Accordion(label='Hydrophobic Bias',open=False):
|
612 |
+
gr.Markdown("""Bias for or against hydrophobic composition, to get more soluble proteins, bias away with a negative target score (ex. -5)""")
|
613 |
+
with gr.Row():
|
614 |
+
hydrophobic_target_score = gr.Textbox(label="hydrophobic score", lines=1, placeholder='hydrophobic score to target (negative score is good for solublility)')
|
615 |
+
hydrophobic_potential = gr.Textbox(label="hydrophobic potential scale", lines=1, placeholder='hydrophobic potential scale (recomended range 1.0-2.0)')
|
616 |
+
|
617 |
+
with gr.Accordion(label='Diffusion Params',open=False):
|
618 |
+
gr.Markdown("""Increasing T to more steps can be helpful for harder design challenges, sampling from different distributions can change the sequence and structural composition""")
|
619 |
+
with gr.Row():
|
620 |
+
num_steps = gr.Textbox(label="T", lines=1, placeholder='number of diffusion steps (25 or less will speed things up)')
|
621 |
+
noise = gr.Dropdown(['normal','gmm2 [-1,1]','gmm3 [-1,0,1]'], label='noise type', value='normal')
|
622 |
+
|
623 |
+
with gr.TabItem("Motif Selection"):
|
624 |
+
gr.Markdown("""### Motif Selection Preview""")
|
625 |
+
gr.Markdown('Contigs explained: to grab residues (seq and str) on a pdb chain you will provide the chain letter followed by a range of residues as indexed in the pdb file for example (A3-10) is the syntax to select residues 3-10 on chain A (the chain always needs to be specified). To add diffused residues to either side of this motif you can specify a range or discrete value without a chain letter infront. To add 15 residues before the motif and 20-30 residues (randomly sampled) after use the following syntax: 15,A3-10,20-30 commas are used to separate regions selected from the pdb and designed (diffused) resiudes which will be added. ')
|
626 |
+
pdb_id_code = gr.Textbox(label="PDB ID", lines=1, placeholder='INPUT PDB ID TO FETCH (ex. 1DPX)', visible=True)
|
627 |
+
contigs = gr.Textbox(label="contigs", lines=1, placeholder='specify contigs to grab particular residues from pdb ()', visible=True)
|
628 |
+
gr.Markdown('Using the same contig syntax, seq or str of input motif residues can be masked, allowing the model to hold strucutre fixed and design sequence or vice-versa')
|
629 |
+
with gr.Row():
|
630 |
+
seq_mask = gr.Textbox(label='seq mask',lines=1,placeholder='input residues to mask sequence')
|
631 |
+
str_mask = gr.Textbox(label='str mask',lines=1,placeholder='input residues to mask structure')
|
632 |
+
preview_viewer = gr.HTML()
|
633 |
+
rewrite_pdb = gr.File(label='PDB file')
|
634 |
+
preview_btn = gr.Button("Preview Motif")
|
635 |
+
|
636 |
+
with gr.TabItem("MSA to PSSM"):
|
637 |
+
gr.Markdown("""### MSA to PSSM Generation""")
|
638 |
+
gr.Markdown('input either an MSA or PSSM to guide the model toward generating samples within your family of interest')
|
639 |
+
with gr.Row():
|
640 |
+
fasta_msa = gr.File(label='MSA')
|
641 |
+
input_pssm = gr.File(label='PSSM (.csv)')
|
642 |
+
pssm = gr.File(label='Generated PSSM')
|
643 |
+
pssm_view = gr.Plot(label='PSSM Viewer')
|
644 |
+
pssm_gen_btn = gr.Button("Generate PSSM")
|
645 |
+
|
646 |
+
with gr.Column():
|
647 |
+
gr.Markdown("## 🦸♂️ 히어로 프로필")
|
648 |
+
|
649 |
+
# 능력치 레이더 차트
|
650 |
+
hero_stats = gr.Plot(label="능력치 분석")
|
651 |
+
|
652 |
+
# 히어로 설명
|
653 |
+
hero_description = gr.Textbox(label="히어로 특성", lines=3)
|
654 |
+
|
655 |
+
# 다운로드 버튼
|
656 |
+
download_btn = gr.Button("히어로 데이터 다운로드")
|
657 |
+
|
658 |
+
gr.Markdown("""## OUTPUTS""")
|
659 |
+
gr.Markdown("""#### Confidence score for generated structure at each timestep""")
|
660 |
+
plddt_plot = gr.Plot(label='plddt at step t')
|
661 |
+
gr.Markdown("""#### Output protein sequnece""")
|
662 |
+
output_seq = gr.Textbox(label="sequence")
|
663 |
+
gr.Markdown("""#### Download PDB file""")
|
664 |
+
output_pdb = gr.File(label="PDB file")
|
665 |
+
gr.Markdown("""#### Structure viewer""")
|
666 |
+
output_viewer = gr.HTML()
|
667 |
+
|
668 |
+
# 이벤트 연결
|
669 |
+
preview_btn.click(get_motif_preview,[pdb_id_code, contigs],[preview_viewer, rewrite_pdb])
|
670 |
+
pssm_gen_btn.click(get_pssm,[fasta_msa,input_pssm],[pssm_view, pssm])
|
671 |
+
|
672 |
+
# generate_hero와 protein_diffusion_model을 combined_generation으로 통합
|
673 |
+
create_btn.click(
|
674 |
+
combined_generation,
|
675 |
+
inputs=[
|
676 |
+
hero_name, strength, flexibility, speed, defense, hero_size, special_ability,
|
677 |
+
sequence, seq_len, helix_bias, strand_bias, loop_bias,
|
678 |
+
secondary_structure, aa_bias, aa_bias_potential,
|
679 |
+
num_steps, noise, hydrophobic_target_score, hydrophobic_potential,
|
680 |
+
contigs, pssm, seq_mask, str_mask, rewrite_pdb
|
681 |
+
],
|
682 |
+
outputs=[
|
683 |
+
hero_stats,
|
684 |
+
hero_description,
|
685 |
+
output_seq,
|
686 |
+
output_pdb,
|
687 |
+
output_viewer,
|
688 |
+
plddt_plot
|
689 |
+
]
|
690 |
+
)
|
691 |
+
|
692 |
+
demo.queue()
|
693 |
+
demo.launch(debug=True)
|