Update app.py
Browse files
app.py
CHANGED
@@ -216,10 +216,11 @@ def assess_drug_likeness(df: pd.DataFrame):
|
|
216 |
df_copy['HBD_OK'] = df_copy['HBD'] <= 5
|
217 |
df_copy['HBA_OK'] = df_copy['HBA'] <= 10
|
218 |
df_copy['Lipinski_Violations'] = (~df_copy[['MW_OK', 'LogP_OK', 'HBD_OK', 'HBA_OK']]).sum(axis=1)
|
219 |
-
|
|
|
220 |
log = "β
Assessed drug-likeness using Lipinski's Rule of Five.\n"
|
221 |
return df_copy, log
|
222 |
-
|
223 |
def plot_properties_dashboard(df: pd.DataFrame):
|
224 |
"""
|
225 |
Creates a 2x2 dashboard of molecular property visualizations.
|
@@ -447,7 +448,9 @@ def calculate_comprehensive_properties(smiles_dict: dict):
|
|
447 |
analysis.append({'Compound': name, 'Molecular_Weight': mw, 'LogP': logp, 'HBD': hbd, 'HBA': hba,
|
448 |
'TPSA': Descriptors.TPSA(mol), 'Rotatable_Bonds': Descriptors.NumRotatableBonds(mol),
|
449 |
'Aromatic_Rings': Descriptors.NumAromaticRings(mol),
|
450 |
-
'Lipinski_Violations': violations,
|
|
|
|
|
451 |
df = pd.DataFrame(analysis).round(2)
|
452 |
log += f"β
Calculated comprehensive properties for {len(df)} compounds.\n"
|
453 |
return df, log
|
@@ -471,9 +474,10 @@ def predict_toxicity(properties_df: pd.DataFrame):
|
|
471 |
toxicity_prob = rf_model.predict_proba(X_pred)[:, 1]
|
472 |
results_df = properties_df[['Compound']].copy()
|
473 |
results_df['Toxicity_Probability'] = np.round(toxicity_prob, 3)
|
|
|
474 |
results_df['Predicted_Risk'] = ["π’ LOW" if p < 0.3 else "π‘ MODERATE" if p < 0.7 else "π΄ HIGH" for p in toxicity_prob]
|
475 |
return results_df, "β
Predicted toxicity using a pre-trained simulation model.\n"
|
476 |
-
|
477 |
# ===== Phase 4 Functions =====
|
478 |
def get_regulatory_summary():
|
479 |
summary = {'Component': ['Data Governance', 'Model Architecture', 'Model Validation', 'Interpretability'],
|
|
|
216 |
df_copy['HBD_OK'] = df_copy['HBD'] <= 5
|
217 |
df_copy['HBA_OK'] = df_copy['HBA'] <= 10
|
218 |
df_copy['Lipinski_Violations'] = (~df_copy[['MW_OK', 'LogP_OK', 'HBD_OK', 'HBA_OK']]).sum(axis=1)
|
219 |
+
# Fixed: Use proper colored emojis instead of boolean values
|
220 |
+
df_copy['Drug_Like'] = df_copy['Lipinski_Violations'].apply(lambda x: 'β
Yes' if x <= 1 else 'β No')
|
221 |
log = "β
Assessed drug-likeness using Lipinski's Rule of Five.\n"
|
222 |
return df_copy, log
|
223 |
+
|
224 |
def plot_properties_dashboard(df: pd.DataFrame):
|
225 |
"""
|
226 |
Creates a 2x2 dashboard of molecular property visualizations.
|
|
|
448 |
analysis.append({'Compound': name, 'Molecular_Weight': mw, 'LogP': logp, 'HBD': hbd, 'HBA': hba,
|
449 |
'TPSA': Descriptors.TPSA(mol), 'Rotatable_Bonds': Descriptors.NumRotatableBonds(mol),
|
450 |
'Aromatic_Rings': Descriptors.NumAromaticRings(mol),
|
451 |
+
'Lipinski_Violations': violations,
|
452 |
+
# Fixed: Use proper colored emojis instead of text
|
453 |
+
'Drug_Like': 'β
Yes' if violations <= 1 else 'β No'})
|
454 |
df = pd.DataFrame(analysis).round(2)
|
455 |
log += f"β
Calculated comprehensive properties for {len(df)} compounds.\n"
|
456 |
return df, log
|
|
|
474 |
toxicity_prob = rf_model.predict_proba(X_pred)[:, 1]
|
475 |
results_df = properties_df[['Compound']].copy()
|
476 |
results_df['Toxicity_Probability'] = np.round(toxicity_prob, 3)
|
477 |
+
# Fixed: Use proper colored emojis that will display correctly
|
478 |
results_df['Predicted_Risk'] = ["π’ LOW" if p < 0.3 else "π‘ MODERATE" if p < 0.7 else "π΄ HIGH" for p in toxicity_prob]
|
479 |
return results_df, "β
Predicted toxicity using a pre-trained simulation model.\n"
|
480 |
+
|
481 |
# ===== Phase 4 Functions =====
|
482 |
def get_regulatory_summary():
|
483 |
summary = {'Component': ['Data Governance', 'Model Architecture', 'Model Validation', 'Interpretability'],
|