File size: 1,582 Bytes
b212cb1
 
2dd6312
 
634752b
2dd6312
 
634752b
 
b212cb1
 
2dd6312
 
 
 
 
 
634752b
 
462a012
2dd6312
 
 
634752b
462a012
 
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
from model import MODELS
from data import Data
import gradio as gr
from tempfile import NamedTemporaryFile

    # scoring strategies
SCORING = ["masked-marginals (more accurate)", "wt-marginals (faster)"]

def app(*argv):
    seq, trg, model_name, scoring_strategy, out_file, *_ = argv
    html = Data(seq, trg, model_name, scoring_strategy, out_file).calculate()
    return html, gr.File.update(value=out_file.name, visible=True)

with gr.Blocks() as demo, NamedTemporaryFile(mode='w+', prefix='out_', suffix='.csv') as out_file, open("instructions.md", "r") as md:
    gr.Markdown(md.read())
    seq = gr.Textbox(lines=2, label="Sequence", placeholder="Sequence here...", value='MVEQYLLEAIVRDARDGITISDCSRPDNPLVFVNDAFTRMTGYDAEEVIGKNCRFLQRGDINLSAVHTIKIAMLTHEPCLVTLKNYRKDGTIFWNELSLTPIINKNGLITHYLGIQKDVSAQVILNQTLHEENHLLKSNKEMLEYLVNIDALTGLHNRRFLEDQLVIQWKLASRHINTITIFMIDIDYFKAFNDTYGHTAGDEALRTIAKTLNNCFMRGSDFVARYGGEEFTILAIGMTELQAHEYSTKLVQKIENLNIHHKGSPLGHLTISLGYSQANPQYHNDQNLVIEQADRALYSAKVEGKNRAVAYREQ')
    trg = gr.Textbox(lines=1, label="Substitutions", placeholder="Substitutions here...", value="61 214 19 30 122 140")
    model_name = gr.Dropdown(MODELS, label="Model", value=MODELS[1])
    scoring_strategy = gr.Dropdown(SCORING, label="Scoring strategy", value=SCORING[1])
    btn = gr.Button(value="Run")
    out = gr.HTML()
    bto = gr.File(value=out_file.name, visible=False, label="Download", file_count='single', interactive=False)
    btn.click(fn=app, inputs=[seq, trg, model_name, scoring_strategy, bto], outputs=[out, bto]) 

if __name__ == "__main__":
    demo.launch()