succ1 / app.py
jie1's picture
Update app.py
fba4b84
import gradio as gr
import sys
sys.path.append('/home/user/app/ProteinMPNN-main/')
from helper_scripts.parse_multiple_chains import *
from protein_mpnn_run import *
from helper_scripts.assign_fixed_chains import *
from helper_scripts.make_fixed_positions_dict import *
from helper_scripts.make_tied_positions_dict import *
from helper_scripts.make_bias_AA import *
sys.path.append('/home/user/app/file/')
from Sort_Scores import *
from Preinput_Merge import *
from Sort_Dlkcat import *
from Merge_Dlsc import *
from Sort_Sco_Kcat import *
sys.path.append('/home/user/app/DLKcat/DeeplearningApproach/Code/example/')
# from model import *
from prediction_for_input import *
with gr.Blocks(css=".gradio-container {background-image: url('file=background.jpeg')}") as demo:
gr.Markdown("Welcome using this demo.")
with gr.Tab("HelloWorld"):
gr.Markdown("Welcome using this demo.")
gr.Markdown("This is a succend test")
gr.Markdown("I think this demo can do some things")
gr.Markdown("这一平台主要分为三部分,ProteinMPNN,DLKcat以及对文件的处理,可以在Files and versions 下看各自的README.md文件")
with gr.Tab("helper_scripts"):
with gr.Row():
input_files = gr.Files(label="input_files")
input_file = gr.File(label="input_file")
with gr.Column():
output_file = gr.Textbox(label="output_file")
ca_only = gr.Checkbox(label="ca_only", value=False)
chain_list = gr.Textbox(label="chain_list", value="")
AA_list = gr.Textbox(label="AA_list", value="")
with gr.Column():
position_list = gr.Textbox(label="position_list", value="")
specify_non_fixed = gr.Checkbox(label="specify_non_fixed", value=False)
homooligomer = gr.Number(label="homooligomer", value=0)
bias_list = gr.Textbox(label="bias_list", value="")
output = gr.File()
with gr.Row():
pmc_button = gr.Button("parse_multiple_chains")
afc_button = gr.Button("assign_fixed_chains")
mfpd_button = gr.Button("make_fixed_positions_dict")
mtpd_button = gr.Button("make_tied_positions_dict")
mbA_button = gr.Button("make_bias_AA")
pmc_button.click(p_m_c, inputs=[input_files, output_file, ca_only], outputs=output)
afc_button.click(a_f_c, inputs=[input_file, output_file, chain_list], outputs=output)
mfpd_button.click(m_f_p_d, inputs=[input_file, output_file, chain_list, position_list, specify_non_fixed], outputs=output)
mtpd_button.click(m_t_p_d, inputs=[input_file, output_file, chain_list, position_list, homooligomer], outputs=output)
mbA_button.click(m_b_A, inputs=[output_file, AA_list, bias_list], outputs=output)
with gr.Tab("protein_mpnn_run"):
with gr.Box():
ca_only = gr.Checkbox(label="ca_only", value=False, visible=False)
path_to_model_weights = gr.Textbox(label="path_to_model_weights", value="", visible=False)
model_name = gr.Textbox(label="model_name", value="v_48_020", visible=False)
with gr.Row():
seed = gr.Number(value=int(0), label="seed")
save_score = gr.Number(label="save_score", value=int(0), visible=False)
save_probs = gr.Number(label="save_probs", value=int(0), visible=False)
score_only = gr.Number(label="score_only", value=int(0))
conditional_probs_only = gr.Number(label="conditional_probs_only", value=int(0), visible=False)
conditional_probs_only_backbone = gr.Number(label="conditional_probs_only_backbone", value=int(0), visible=False)
with gr.Row():
unconditional_probs_only = gr.Number(label="unconditional_probs_only", value=int(0))
backbone_noise = gr.Number(label="backbone_noise", value=0.00, visible=False)
num_seq_per_target = gr.Number(value=int(1), label="num_seq_per_target")
with gr.Row():
batch_size = gr.Number(value=int(1), label="batch_size")
max_length = gr.Number(label="max_length", value=int(200000), visible=False)
sampling_temp = gr.Textbox(value="0.1", label="sampling_temp")
out_folder = gr.Textbox(label="out_folder")
pdb_path_chains = gr.Textbox(label="pdb_path_chains", value="")
with gr.Box():
with gr.Row():
pdb_path = gr.File(label="pdb_path")
jsonl_path = gr.File(label="jsonl_path")
with gr.Row():
chain_id_jsonl = gr.File(label="chain_id_jsonl")
fixed_positions_jsonl = gr.File(label="fixed_positions_jsonl")
omit_AAs = gr.Textbox(label="omit_AAs", value="X", visible=False)
with gr.Row():
bias_AA_jsonl = gr.File(label="bias_AA_jsonl")
tied_positions_jsonl = gr.File(label="tied_positions_jsonl")
bias_by_res_jsonl = gr.Textbox(label="bias_by_res_jsonl", value="", visible=False)
omit_AA_jsonl = gr.Textbox(label="omit_AA_jsonl", value="", visible=False)
pssm_jsonl = gr.Textbox(label="pssm_jsonl", value="", visible=False)
pssm_multi = gr.Number(label="pssm_multi", value=0.0, visible=False)
pssm_threshold = gr.Number(label="pssm_threshold", value=0.0, visible=False)
pssm_log_odds_flag = gr.Number(label="pssm_log_odds_flag", value=int(0), visible=False)
pssm_bias_flag = gr.Number(label="pssm_bias_flag", value=int(0), visible=False)
pmroutput = gr.Files()
pmr_button = gr.Button("protein_mpnn_run")
pmr_button.click(p_m_r,
inputs=[ca_only, path_to_model_weights, model_name, seed, save_score, save_probs, score_only,
conditional_probs_only,
conditional_probs_only_backbone
, unconditional_probs_only, backbone_noise, num_seq_per_target, batch_size, max_length,
sampling_temp, out_folder,
pdb_path, pdb_path_chains, jsonl_path, chain_id_jsonl, fixed_positions_jsonl, omit_AAs,
bias_AA_jsonl, bias_by_res_jsonl
, omit_AA_jsonl, pssm_jsonl, pssm_multi, pssm_threshold, pssm_log_odds_flag,
pssm_bias_flag, tied_positions_jsonl], outputs=pmroutput)
with gr.Tab("Sort"):
file1_input = gr.File(label="输入相关文件")
file1_output = gr.File()
with gr.Row():
file1_button1 = gr.Button("Sort Scores")
file1_button2 = gr.Button("Sort Dlkcat")
file1_button3 = gr.Button("Sort Mergekcat")
with gr.Tab("Pre Merge"):
with gr.Row():
file2_input1 = gr.File(label="strip_file")
file2_input2 = gr.File(label="smi_file")
file2_input3 = gr.File(label="seq_file")
file2_output = gr.File()
file2_button1 = gr.Button("Strip")
with gr.Row():
file2_button2 = gr.Button("Merge")
file2_button3 = gr.Button("Merge All")
with gr.Tab("Merge Dlsc"):
with gr.Row():
file4_input1 = gr.File(label="sc_file")
file4_input2 = gr.File(label="cat_file")
file4_output = gr.File()
file4_button = gr.Button("Merge")
with gr.Tab("Prediction Dlkcat"):
file6_input = gr.File(label="输入相关文件")
file6_output = gr.File()
file6_button = gr.Button("Prediction_Dlkcat")
with gr.Accordion("Open for More!"):
gr.Markdown("Look at me...")
file1_button1.click(Sort_Scores, inputs=file1_input, outputs=file1_output)
file1_button2.click(Sort_Dlkcat, inputs=file1_input, outputs=file1_output)
file1_button3.click(Sort_Sco_Kcat, inputs=file1_input, outputs=file1_output)
file2_button1.click(Strip, inputs=file2_input1, outputs=file2_output)
file2_button2.click(Merge, inputs=[file2_input2, file2_input3], outputs=file2_output)
file2_button3.click(Merge_All, inputs=[file2_input2, file2_input3], outputs=file2_output)
file4_button.click(Merge_Dlsc, inputs=[file4_input1, file4_input2], outputs=file4_output)
file6_button.click(test, inputs=file6_input, outputs=file6_output)
if __name__ == "__main__":
demo.launch()