Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,7 +23,8 @@ def get_admet(smiles):
|
|
| 23 |
# المعالجة الرئيسية
|
| 24 |
def analyze_smiles(file):
|
| 25 |
try:
|
| 26 |
-
|
|
|
|
| 27 |
smiles_list = [line.strip() for line in content.splitlines() if line.strip()]
|
| 28 |
df = pd.DataFrame({"SMILES": smiles_list})
|
| 29 |
admet_df = df["SMILES"].apply(get_admet)
|
|
@@ -36,12 +37,16 @@ def analyze_smiles(file):
|
|
| 36 |
excel_b64 = base64.b64encode(excel_data).decode()
|
| 37 |
|
| 38 |
# Markdown table
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
return (
|
| 42 |
"✅ التحليل ناجح!",
|
| 43 |
table_md,
|
| 44 |
-
f'<a download="ADMET_Analysis.xlsx" href="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,{excel_b64}">⬇️ تحميل ملف Excel</a>'
|
| 45 |
)
|
| 46 |
|
| 47 |
except Exception as e:
|
|
|
|
| 23 |
# المعالجة الرئيسية
|
| 24 |
def analyze_smiles(file):
|
| 25 |
try:
|
| 26 |
+
with open(file.name, "r", encoding="utf-8") as f:
|
| 27 |
+
content = f.read()
|
| 28 |
smiles_list = [line.strip() for line in content.splitlines() if line.strip()]
|
| 29 |
df = pd.DataFrame({"SMILES": smiles_list})
|
| 30 |
admet_df = df["SMILES"].apply(get_admet)
|
|
|
|
| 37 |
excel_b64 = base64.b64encode(excel_data).decode()
|
| 38 |
|
| 39 |
# Markdown table
|
| 40 |
+
try:
|
| 41 |
+
import tabulate # Try to import it explicitly
|
| 42 |
+
table_md = final_df.to_markdown(index=False)
|
| 43 |
+
except ImportError:
|
| 44 |
+
table_md = "❌ مكتبة 'tabulate' مطلوبة لعرض الجدول. استخدم: pip install tabulate"
|
| 45 |
|
| 46 |
return (
|
| 47 |
"✅ التحليل ناجح!",
|
| 48 |
table_md,
|
| 49 |
+
f'<a download="ADMET_Analysis.xlsx" href="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,{excel_b64}">⬇️ تحميل ملف Excel</a>'
|
| 50 |
)
|
| 51 |
|
| 52 |
except Exception as e:
|