alidenewade commited on
Commit
e29251e
Β·
verified Β·
1 Parent(s): fdc9ad2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
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
- df_copy['Drug_Like'] = df_copy['Lipinski_Violations'] <= 1
 
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, 'Drug_Like': 'Yes' if violations <= 1 else 'No'})
 
 
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'],