Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from rdkit import Chem | |
| from rdkit.Chem import Descriptors, rdMolDescriptors | |
| # دالة SA Score بسيطة | |
| def simple_sa_score(smiles): | |
| mol = Chem.MolFromSmiles(smiles) | |
| if not mol: | |
| return "❌ SMILES غير صالح" | |
| mw = Descriptors.MolWt(mol) | |
| rot_bonds = rdMolDescriptors.CalcNumRotatableBonds(mol) | |
| num_atoms = mol.GetNumAtoms() | |
| score = 0 | |
| score += 1 if mw > 500 else 0 | |
| score += 1 if rot_bonds > 10 else 0 | |
| score += 1 if num_atoms > 50 else 0 | |
| sa_score = round(1 + score * 3, 2) | |
| if sa_score <= 4: | |
| level = "🔬 سهل التصنيع ✅" | |
| elif sa_score <= 7: | |
| level = "⚠️ متوسط الصعوبة" | |
| else: | |
| level = "❌ صعب تصنيعه معمليًا" | |
| return f"🧪 SA Score: {sa_score} / 10\n{level}" | |
| # واجهة Gradio | |
| demo = gr.Interface( | |
| fn=simple_sa_score, | |
| inputs=gr.Textbox(label="🔬 أدخل SMILES هنا"), | |
| outputs=gr.Textbox(label="📊 التقييم"), | |
| title="تقييم SA Score", | |
| description="تحليل مدى سهولة تصنيع المركب بناءً على SMILES" | |
| ) | |
| demo.launch() | |