Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from rdkit import Chem
|
| 3 |
+
from rdkit.Chem import Descriptors, rdMolDescriptors
|
| 4 |
+
|
| 5 |
+
# دالة SA Score بسيطة
|
| 6 |
+
def simple_sa_score(smiles):
|
| 7 |
+
mol = Chem.MolFromSmiles(smiles)
|
| 8 |
+
if not mol:
|
| 9 |
+
return "❌ SMILES غير صالح"
|
| 10 |
+
|
| 11 |
+
mw = Descriptors.MolWt(mol)
|
| 12 |
+
rot_bonds = rdMolDescriptors.CalcNumRotatableBonds(mol)
|
| 13 |
+
num_atoms = mol.GetNumAtoms()
|
| 14 |
+
|
| 15 |
+
score = 0
|
| 16 |
+
score += 1 if mw > 500 else 0
|
| 17 |
+
score += 1 if rot_bonds > 10 else 0
|
| 18 |
+
score += 1 if num_atoms > 50 else 0
|
| 19 |
+
|
| 20 |
+
sa_score = round(1 + score * 3, 2)
|
| 21 |
+
|
| 22 |
+
if sa_score <= 4:
|
| 23 |
+
level = "🔬 سهل التصنيع ✅"
|
| 24 |
+
elif sa_score <= 7:
|
| 25 |
+
level = "⚠️ متوسط الصعوبة"
|
| 26 |
+
else:
|
| 27 |
+
level = "❌ صعب تصنيعه معمليًا"
|
| 28 |
+
|
| 29 |
+
return f"🧪 SA Score: {sa_score} / 10\n{level}"
|
| 30 |
+
|
| 31 |
+
# واجهة Gradio
|
| 32 |
+
demo = gr.Interface(
|
| 33 |
+
fn=simple_sa_score,
|
| 34 |
+
inputs=gr.Textbox(label="🔬 أدخل SMILES هنا"),
|
| 35 |
+
outputs=gr.Textbox(label="📊 التقييم"),
|
| 36 |
+
title="تقييم SA Score",
|
| 37 |
+
description="تحليل مدى سهولة تصنيع المركب بناءً على SMILES"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
demo.launch()
|