| import numpy as np |
| import plotly.graph_objects as go |
|
|
| class MetabolicTwinV10: |
| def __init__(self): |
| |
| self.phenotype_map = { |
| "Poor": 0.2, |
| "Intermediate": 0.5, |
| "Normal": 1.0, |
| "Rapid": 1.5 |
| } |
|
|
| def simulate_drug_clearance(self, drug_name, phenotype="Normal"): |
| """ |
| Simulates serum concentration over 48 hours using a |
| one-compartment pharmacokinetic model. |
| """ |
| factor = self.phenotype_map.get(phenotype, 1.0) |
| t = np.linspace(0, 48, 100) |
| |
| |
| |
| ke = 0.1 / factor |
| concentration = 100 * np.exp(-ke * t) |
| |
| fig = go.Figure() |
| fig.add_trace(go.Scatter(x=t, y=concentration, mode='lines', |
| name=f"{drug_name} ({phenotype})", |
| line=dict(color='#4285f4' if factor == 1.0 else '#ea4335'))) |
| |
| fig.update_layout( |
| title=f"Metabolic Stress Test: {drug_name}", |
| xaxis_title="Hours Post-Dose", |
| yaxis_title="Serum Concentration (%)", |
| paper_bgcolor='rgba(0,0,0,0)', |
| plot_bgcolor='rgba(0,0,0,0)', |
| font_color="#e0e0e0" |
| ) |
| return fig |