Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from rdkit import Chem
|
3 |
+
from rdkit.Chem import AllChem, rdmolfiles
|
4 |
+
import os
|
5 |
+
|
6 |
+
def smiles_to_pdb(smiles):
|
7 |
+
mol = Chem.MolFromSmiles(smiles)
|
8 |
+
if not mol:
|
9 |
+
return "❌ SMILES غير صالح. تأكد من صحة الإدخال.", None
|
10 |
+
mol = Chem.AddHs(mol)
|
11 |
+
result = AllChem.EmbedMolecule(mol, AllChem.ETKDG())
|
12 |
+
if result != 0:
|
13 |
+
return "❌ فشل في توليد الشكل ثلاثي الأبعاد للجزيء.", None
|
14 |
+
|
15 |
+
AllChem.UFFOptimizeMolecule(mol)
|
16 |
+
pdb_filename = "drug_candidate.pdb"
|
17 |
+
writer = rdmolfiles.PDBWriter(pdb_filename)
|
18 |
+
writer.write(mol)
|
19 |
+
writer.close()
|
20 |
+
return "✅ تم توليد الملف بنجاح!", pdb_filename
|
21 |
+
|
22 |
+
title = "🧪 SMILES → PDB Generator"
|
23 |
+
description = "أدخل SMILES وسيتم توليد ملف .pdb قابل للتنزيل."
|
24 |
+
|
25 |
+
gr.Interface(
|
26 |
+
fn=smiles_to_pdb,
|
27 |
+
inputs=gr.Textbox(label="✏️ أدخل SMILES", placeholder="CC(=O)Oc1ccccc1C(=O)O"),
|
28 |
+
outputs=[
|
29 |
+
gr.Textbox(label="📢 الحالة"),
|
30 |
+
gr.File(label="⬇️ تحميل ملف PDB")
|
31 |
+
],
|
32 |
+
title=title,
|
33 |
+
description=description,
|
34 |
+
allow_flagging="never"
|
35 |
+
).launch()
|