import gradio as gr import cg2all import os def read_mol(molpath): with open(molpath, "r") as fp: lines = fp.readlines() mol = "" for l in lines: mol += l # mol = mol.replace("OT1", "O ") mol = mol.replace("OT2", "OXT") return mol def molecule(input_pdb): mol = read_mol(input_pdb) x = ( """
""" ) return f"""""" def runner(in_pdb, model_type): out_fn = in_pdb.name[:-4] + "-all.pdb" ckpt_fn = f"model/{model_type}.ckpt" cg2all.convert_cg2all(in_pdb.name, out_fn, model_type=model_type, ckpt_fn=ckpt_fn) view = molecule(out_fn) return out_fn, view with gr.Blocks() as app: gr.Markdown( "# cg2all: conversion of coarse-grained protein structure model to all-atom structure" ) with gr.Row(): with gr.Column(): input_pdb = gr.File( file_count="single", label="Input CG structure", file_types=[".pdb", ".PDB", ".txt", ".TXT"], ) model_type = gr.Radio( [ "CalphaBasedModel", "ResidueBasedModel", "SidechainModel", "CalphaCMModel", "CalphaSCModel", "BackboneModel", "MainchainModel", "Martini", "Martini3", "PRIMO", ], label="Input CG model type", ) # button = gr.Button("Run") # gr.Examples( [ ["inputs/1ab1_A.calpha.pdb", "CalphaBasedModel"], ["inputs/1ab1_A.residue.pdb", "ResidueBasedModel"], ["inputs/1ab1_A.sc.pdb", "SidechainModel"], ["inputs/1ab1_A.cacm.pdb", "CalphaCMModel"], ["inputs/1ab1_A.casc.pdb", "CalphaSCModel"], ["inputs/1ab1_A.bb.pdb", "BackboneModel"], ["inputs/1ab1_A.mc.pdb", "MainchainModel"], ["inputs/1ab1_A.martini.pdb", "Martini"], ["inputs/1ab1_A.martini3.pdb", "Martini3"], ["inputs/1ab1_A.primo.pdb", "PRIMO"], ], [input_pdb, model_type], label="Monomeric coarse-grained structure", ) gr.Examples( [ ["inputs/Q9EP54.sample.pdb", "CalphaBasedModel"], ], [input_pdb, model_type], label="ML(idpGAN)-generated IDP structure", ) gr.Examples( [ ["inputs/3iyg.pdb", "CalphaBasedModel"], ], [input_pdb, model_type], label="Multimeric medium-resolution cryo-EM structure", ) gr.Examples( [ ["inputs/LAF1rgg.sample.pdb", "CalphaBasedModel"], ], [input_pdb, model_type], label="Snapshot of COCOMO simulation of LLPS", ) with gr.Column(): output_pdb = gr.File(file_count="single", label="Output structure") viewer = gr.HTML() button.click(fn=runner, inputs=[input_pdb, model_type], outputs=[output_pdb, viewer]) # gr.Markdown("---") gr.Markdown( "### GitHub repository: [https://github.com/huhlim/cg2all](https://github.com/huhlim/cg2all)" ) gr.Markdown("### Local installation: `pip install git+http://github.com/huhlim/cg2all`") gr.Markdown("### Supported coarse-grained models") gr.Markdown("- CalphaBasedModel: CA-trace") gr.Markdown("- ResidueBasedModel: Residue center-of-mass") gr.Markdown("- SidechainModel: Sidechain center-of-mass") gr.Markdown("- CalphaCMModel: CA-trace + Residue center-of-mass") gr.Markdown("- CalphaSCModel: CA-trace + Sidechain center-of-mass") gr.Markdown("- BackboneModel: Backbone N, CA, and C atoms") gr.Markdown("- MainchainModel: Backbone N, CA, C, and O atoms") gr.Markdown("- Martini: [Martini model](http://cgmartini.nl)") gr.Markdown("- Martini3: [Martini3 model](http://www.cgmartini.nl/index.php/martini-3-0)") gr.Markdown("- PRIMO: [PRIMO model](https://dx.doi.org/10.1002/prot.22645)") gr.Markdown("### Cite: TODO") app.launch()