zsp / app.py
MassimoGregorioTotaro
fix ok, reformatting
b212cb1
raw
history blame
1.58 kB
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()