File size: 1,645 Bytes
02a9726 5b50998 02a9726 5b50998 02a9726 5b50998 24b25ab 5b50998 02a9726 7fccc04 |
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
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
# Configure logging
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)
# boltz_predict(source=seq_file, project_code=FOLDING_PROJECT_CODE, output=output_dir, unzip=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()
|