|
import gradio as gr |
|
from pathlib import Path |
|
from folding_studio.commands.predict import af2 as af2_predict |
|
from folding_studio.commands.predict import boltz as boltz_predict |
|
from folding_studio.config import FOLDING_PROJECT_CODE |
|
import logging |
|
|
|
from molecule import molecule |
|
|
|
|
|
logging.basicConfig( |
|
level=logging.INFO, |
|
format='%(asctime)s - %(levelname)s - %(message)s', |
|
handlers=[ |
|
logging.StreamHandler(), |
|
logging.FileHandler('folding.log') |
|
] |
|
) |
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
def predict(sequence: str): |
|
seq_file = Path("sequence.fasta") |
|
with open(seq_file, "w") as f: |
|
f.write(f">A|protein\n{sequence}") |
|
logger.info(f"Predicting {seq_file.stem} with project code {FOLDING_PROJECT_CODE}") |
|
output_dir = Path("boltz_results") |
|
output_dir.mkdir(parents=True, exist_ok=True) |
|
|
|
logger.info("Prediction done. Output directory: %s", output_dir) |
|
outs = list(output_dir.rglob("*_model_0.cif")) |
|
logger.info("Output files: %s", outs) |
|
input_pdb = outs[0] |
|
aligned_pdb = outs[0] |
|
mol = molecule( |
|
input_pdb, |
|
aligned_pdb, |
|
lenSeqs=0, |
|
num_res=len(sequence), |
|
selectedResidues=list(range(1, len(sequence) + 1)), |
|
allSeqs=[sequence], |
|
sequences=[{"Score": 0, "RMSD": 0, "Recovery": 0, "Mean pLDDT": 0, "seq": sequence}], |
|
random_dir=output_dir, |
|
) |
|
|
|
return mol |
|
|
|
mol = gr.HTML() |
|
demo = gr.Interface(fn=predict, inputs="text", outputs=mol) |
|
demo.launch() |
|
|
|
|