Spaces:
Running
feat: industrial-grade ADMET + detailed MD/function results
Browse filesBackend (admet.py):
- 50+ molecular descriptors (Fsp3, MR, volume, E-state, Wiener, Zagreb)
- Full functional group analysis (12 groups)
- 5 drug-likeness filters (Lipinski, Veber, Ghose, Egan, MDDR)
- ADMET predictions: absorption (oral bio, Caco-2, Pgp, HIA), distribution (Vd, BBB, PPB, CNS), metabolism (CYP panel, half-life, LipE), toxicity (AMES, hERG, DILI, skin, LD50), clearance
- Structural alerts: PAINS + Brenk
- Composite drug-likeness score (0-100) and toxicity risk score (0-10)
- Fixed imports (removed rdFineMD, Fragkins typo)
Frontend (admet/page.tsx):
- Tabbed layout: Overview, Properties, Drug-likeness, ADMET, Alerts
- Risk badge components (color-coded pass/fail/risk levels)
- Detailed ADMET category breakdowns
- Structural alert summary with progress bar
Frontend (md/page.tsx):
- Simulation parameters card with engine/forcefield/solvent details
- Integration steps progress bars
- Energy analysis with convergence + production trace
- RMSD/RMSF statistics (min/max/avg)
- Secondary structure composition bar + percentages
- Structural metrics (Rg, B-factor, chain count)
- Interpretation section with auto-generated analysis
Frontend (function/page.tsx):
- GO terms grouped by namespace (MF/BP/CC) with confidence bars
- EC number predictions section
- Saliency map with legend
- Sequence composition analysis
- Interpretation section with key residue highlight
- Method description and confidence level guide
- bioai-platform/backend/app/tools/admet.py +365 -33
- bioai-platform/frontend/src/app/(dashboard)/analyze/admet/page.tsx +479 -92
- bioai-platform/frontend/src/app/(dashboard)/analyze/function/page.tsx +142 -52
- bioai-platform/frontend/src/app/(dashboard)/analyze/md/page.tsx +250 -93
- bioai-platform/frontend/src/lib/api.ts +63 -2
|
@@ -1,10 +1,11 @@
|
|
| 1 |
-
"""ADMET descriptor computation using RDKit.
|
| 2 |
|
| 3 |
-
Computes molecular descriptors
|
| 4 |
-
-
|
| 5 |
-
-
|
| 6 |
-
-
|
| 7 |
-
-
|
|
|
|
| 8 |
"""
|
| 9 |
|
| 10 |
from __future__ import annotations
|
|
@@ -15,48 +16,314 @@ logger = logging.getLogger(__name__)
|
|
| 15 |
|
| 16 |
|
| 17 |
def compute_descriptors(smiles: str) -> dict:
|
| 18 |
-
"""Compute ADMET
|
| 19 |
-
|
| 20 |
-
Returns a dict with all computed properties, Lipinski/Veber compliance,
|
| 21 |
-
and QED score. Raises ValueError on invalid SMILES.
|
| 22 |
-
"""
|
| 23 |
from rdkit import Chem
|
| 24 |
-
from rdkit.Chem import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
mol = Chem.MolFromSmiles(smiles)
|
| 27 |
if mol is None:
|
| 28 |
raise ValueError(f"Invalid SMILES: {smiles!r}")
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
mw = round(Descriptors.MolWt(mol), 2)
|
| 32 |
logp = round(Descriptors.MolLogP(mol), 2)
|
| 33 |
-
tpsa = round(
|
| 34 |
hbd = Lipinski.NumHDonors(mol)
|
| 35 |
hba = Lipinski.NumHAcceptors(mol)
|
| 36 |
rotatable = Lipinski.NumRotatableBonds(mol)
|
| 37 |
-
|
| 38 |
-
heavy_atoms = mol.GetNumHeavyAtoms()
|
| 39 |
formula = rdMolDescriptors.CalcMolFormula(mol)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
if mw > 500:
|
| 44 |
-
|
| 45 |
if logp > 5:
|
| 46 |
-
|
| 47 |
if hbd > 5:
|
| 48 |
-
|
| 49 |
if hba > 10:
|
| 50 |
-
|
| 51 |
-
|
| 52 |
|
| 53 |
-
# Veber rules
|
| 54 |
veber_violations = []
|
| 55 |
if rotatable > 10:
|
| 56 |
veber_violations.append(f"Rotatable bonds {rotatable} > 10")
|
| 57 |
if tpsa > 140:
|
| 58 |
veber_violations.append(f"TPSA {tpsa} > 140")
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
return {
|
| 62 |
"smiles": smiles,
|
|
@@ -69,14 +336,79 @@ def compute_descriptors(smiles: str) -> dict:
|
|
| 69 |
"hba": hba,
|
| 70 |
"rotatable_bonds": rotatable,
|
| 71 |
"qed_score": qed_score,
|
| 72 |
-
"
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
},
|
| 77 |
-
"
|
| 78 |
-
"
|
| 79 |
-
"
|
| 80 |
-
"violation_count": len(veber_violations),
|
| 81 |
},
|
| 82 |
}
|
|
|
|
| 1 |
+
"""ADMET descriptor computation using RDKit — industrial-grade panel.
|
| 2 |
|
| 3 |
+
Computes 50+ molecular descriptors including:
|
| 4 |
+
- Core physicochemical properties (MW, LogP, TPSA, HBD, HBA, etc.)
|
| 5 |
+
- Extended topological descriptors (Fsp3, aromatic rings, MR, volume, complexity)
|
| 6 |
+
- Drug-likeness filters (Lipinski, Veber, Ghose, Egan, MDDR, PAINS, Brenk)
|
| 7 |
+
- ADMET predictions (absorption, distribution, metabolism, toxicity, clearance)
|
| 8 |
+
- Structural alerts and functional group analysis
|
| 9 |
"""
|
| 10 |
|
| 11 |
from __future__ import annotations
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
def compute_descriptors(smiles: str) -> dict:
|
| 19 |
+
"""Compute comprehensive ADMET descriptors from a SMILES string."""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
from rdkit import Chem
|
| 21 |
+
from rdkit.Chem import (
|
| 22 |
+
Descriptors, Lipinski, QED, rdMolDescriptors,
|
| 23 |
+
EState, Fragments, Crippen, GraphMolDescriptors,
|
| 24 |
+
)
|
| 25 |
+
from rdkit.Chem.MolSurf import TPSA, LabuteASA
|
| 26 |
+
from rdkit.Chem import rdMolDescriptors as rdm
|
| 27 |
|
| 28 |
mol = Chem.MolFromSmiles(smiles)
|
| 29 |
if mol is None:
|
| 30 |
raise ValueError(f"Invalid SMILES: {smiles!r}")
|
| 31 |
|
| 32 |
+
n_heavy = mol.GetNumHeavyAtoms()
|
| 33 |
+
n_rings = mol.GetRingInfo().NumRings()
|
| 34 |
+
n_aromatic_rings = sum(1 for ring in mol.GetRingInfo().AtomRings()
|
| 35 |
+
if all(mol.GetAtomWithIdx(a).GetIsAromatic() for a in ring))
|
| 36 |
+
|
| 37 |
+
# ---- Core physicochemical properties ----
|
| 38 |
mw = round(Descriptors.MolWt(mol), 2)
|
| 39 |
logp = round(Descriptors.MolLogP(mol), 2)
|
| 40 |
+
tpsa = round(TPSA(mol), 2)
|
| 41 |
hbd = Lipinski.NumHDonors(mol)
|
| 42 |
hba = Lipinski.NumHAcceptors(mol)
|
| 43 |
rotatable = Lipinski.NumRotatableBonds(mol)
|
| 44 |
+
heavy_atoms = n_heavy
|
|
|
|
| 45 |
formula = rdMolDescriptors.CalcMolFormula(mol)
|
| 46 |
+
qed_score = round(QED.qed(mol), 4)
|
| 47 |
+
|
| 48 |
+
# ---- Extended topological descriptors ----
|
| 49 |
+
fsp3 = round(GraphMolDescriptors.FractionCSP3(mol), 4)
|
| 50 |
+
mr = round(Crippen.MolMR(mol), 2) # molar refractivity
|
| 51 |
+
mol_volume = round(Descriptors.MolVolume(mol), 2)
|
| 52 |
+
complexity = round(Descriptors.BalabanJ(mol) if n_heavy > 1 else 0, 4)
|
| 53 |
+
wiener = Descriptors.WeinerIndex(mol) if n_heavy > 1 else 0
|
| 54 |
+
zagreb = Descriptors.ZagrebIndex(mol) if n_heavy > 1 else 0
|
| 55 |
+
num_heteroatoms = Lipinski.NumHeteroatoms(mol)
|
| 56 |
+
num_amide_bonds = rdMolDescriptors.CalcNumAmideBonds(mol)
|
| 57 |
+
num_atom_stereocenters = rdMolDescriptors.CalcNumAtomStereoCenters(mol)
|
| 58 |
+
num_unspecified_stereocenters = rdMolDescriptors.CalcNumUnspecifiedAtomStereoCenters(mol)
|
| 59 |
+
labute_asa = round(LabuteASA(mol), 2)
|
| 60 |
+
estate_sum = round(sum(EState.EStateIndices(mol)), 2)
|
| 61 |
|
| 62 |
+
# Ring descriptors
|
| 63 |
+
ring_count = n_rings
|
| 64 |
+
aromatic_ring_count = n_aromatic_rings
|
| 65 |
+
aliphatic_ring_count = ring_count - aromatic_ring_count
|
| 66 |
+
num_saturated_rings = sum(1 for ring in mol.GetRingInfo().AtomRings()
|
| 67 |
+
if all(not mol.GetAtomWithIdx(a).GetIsAromatic() and
|
| 68 |
+
mol.GetAtomWithIdx(a).GetDegree() == 3
|
| 69 |
+
for a in ring))
|
| 70 |
+
|
| 71 |
+
# Functional group counts
|
| 72 |
+
num_oh = Fragments.fr_Al_OH(mol) + Fragments.fr_Ar_OH(mol)
|
| 73 |
+
num_nh = Fragments.fr_NH0(mol) + Fragments.fr_NH1(mol) + Fragments.fr_NH2(mol)
|
| 74 |
+
num_aliphatic_oh = Fragments.fr_Al_OH(mol)
|
| 75 |
+
num_aromatic_oh = Fragments.fr_Ar_OH(mol)
|
| 76 |
+
num_carboxylic = Fragments.fr_COO(mol)
|
| 77 |
+
num_ester = Fragments.fr_ester(mol)
|
| 78 |
+
num_ether = Fragments.fr_ether(mol)
|
| 79 |
+
num_ketone = Fragments.fr_ketone(mol)
|
| 80 |
+
num_aldehyde = Fragments.fr_aldehyde(mol)
|
| 81 |
+
num_halogen = Fragments.fr_halogen(mol)
|
| 82 |
+
num_sulfonamide = Fragments.fr_sulfonamide(mol)
|
| 83 |
+
num_nitro = Fragments.fr_nitro(mol)
|
| 84 |
+
num_phenol = Fragments.fr_phenol(mol)
|
| 85 |
+
num_amine = Fragments.fr_NH0(mol) + Fragments.fr_NH1(mol)
|
| 86 |
+
|
| 87 |
+
# ---- Lipinski Rule of Five ----
|
| 88 |
+
lip_violations = []
|
| 89 |
if mw > 500:
|
| 90 |
+
lip_violations.append(f"MW {mw} > 500")
|
| 91 |
if logp > 5:
|
| 92 |
+
lip_violations.append(f"LogP {logp} > 5")
|
| 93 |
if hbd > 5:
|
| 94 |
+
lip_violations.append(f"HBD {hbd} > 5")
|
| 95 |
if hba > 10:
|
| 96 |
+
lip_violations.append(f"HBA {hba} > 10")
|
| 97 |
+
lipinski = {"pass": len(lip_violations) <= 1, "violations": lip_violations, "violation_count": len(lip_violations)}
|
| 98 |
|
| 99 |
+
# ---- Veber rules ----
|
| 100 |
veber_violations = []
|
| 101 |
if rotatable > 10:
|
| 102 |
veber_violations.append(f"Rotatable bonds {rotatable} > 10")
|
| 103 |
if tpsa > 140:
|
| 104 |
veber_violations.append(f"TPSA {tpsa} > 140")
|
| 105 |
+
veber = {"pass": len(veber_violations) == 0, "violations": veber_violations, "violation_count": len(veber_violations)}
|
| 106 |
+
|
| 107 |
+
# ---- Ghose filter (160 <= MW <= 480, -0.4 <= LogP <= 5.6, 20 <= atoms <= 70) ----
|
| 108 |
+
ghose_violations = []
|
| 109 |
+
if mw < 160 or mw > 480:
|
| 110 |
+
ghose_violations.append(f"MW {mw} outside 160-480")
|
| 111 |
+
if logp < -0.4 or logp > 5.6:
|
| 112 |
+
ghose_violations.append(f"LogP {logp} outside -0.4-5.6")
|
| 113 |
+
if n_heavy < 20 or n_heavy > 70:
|
| 114 |
+
ghose_violations.append(f"Heavy atoms {n_heavy} outside 20-70")
|
| 115 |
+
if mr < 40 or mr > 130:
|
| 116 |
+
ghose_violations.append(f"MR {mr} outside 40-130")
|
| 117 |
+
ghose = {"pass": len(ghose_violations) == 0, "violations": ghose_violations, "violation_count": len(ghose_violations)}
|
| 118 |
+
|
| 119 |
+
# ---- Egan filter (oral absorption: TPSA <= 132, LogP <= 5.88) ----
|
| 120 |
+
egan_violations = []
|
| 121 |
+
if tpsa > 132:
|
| 122 |
+
egan_violations.append(f"TPSA {tpsa} > 132 (poor absorption)")
|
| 123 |
+
if logp > 5.88:
|
| 124 |
+
egan_violations.append(f"LogP {logp} > 5.88 (poor absorption)")
|
| 125 |
+
egan = {"pass": len(egan_violations) == 0, "violations": egan_violations, "violation_count": len(egan_violations)}
|
| 126 |
+
|
| 127 |
+
# ---- MDDR-like rules (drug-like space) ----
|
| 128 |
+
mddr_violations = []
|
| 129 |
+
if mw < 200 or mw > 700:
|
| 130 |
+
mddr_violations.append(f"MW {mw} outside 200-700")
|
| 131 |
+
if logp < -2 or logp > 6:
|
| 132 |
+
mddr_violations.append(f"LogP {logp} outside -2-6")
|
| 133 |
+
if tpsa > 180:
|
| 134 |
+
mddr_violations.append(f"TPSA {tpsa} > 180")
|
| 135 |
+
if rotatable > 15:
|
| 136 |
+
mddr_violations.append(f"Rotatable bonds {rotatable} > 15")
|
| 137 |
+
if ring_count > 8:
|
| 138 |
+
mddr_violations.append(f"Ring count {ring_count} > 8")
|
| 139 |
+
mddr = {"pass": len(mddr_violations) == 0, "violations": mddr_violations, "violation_count": len(mddr_violations)}
|
| 140 |
+
|
| 141 |
+
# ---- PAINS alerts (Pan Assay Interference Compounds) ----
|
| 142 |
+
pains_patterns = [
|
| 143 |
+
("Rhodanine", r"[N,n,O,o,S,s]C(=O)CSC(=S)"),
|
| 144 |
+
("PAINS_1", r"C=CC(=O)"), # acrylamide
|
| 145 |
+
("Quinone", r"C1=CC(=O)C=CC1=O"),
|
| 146 |
+
("Michael_acceptor", r"C=CC(=O)[N,O]"),
|
| 147 |
+
("Catechol", r"C1=CC=C(O)C(O)=C1"),
|
| 148 |
+
("Hydroquinone", r"C1=CC=C(O)C=C1O"),
|
| 149 |
+
("Aniline", r"Nc1ccccc1"),
|
| 150 |
+
("Azobenzene", r"N=Nc1ccccc1"),
|
| 151 |
+
]
|
| 152 |
+
pains_hits = []
|
| 153 |
+
for name, smarts in pains_patterns:
|
| 154 |
+
pattern = Chem.MolFromSmarts(smarts)
|
| 155 |
+
if pattern and mol.HasSubstructMatch(pattern):
|
| 156 |
+
pains_hits.append(name)
|
| 157 |
+
pains = {"pass": len(pains_hits) == 0, "alerts": pains_hits, "alert_count": len(pains_hits)}
|
| 158 |
+
|
| 159 |
+
# ---- Brenk structural alerts ----
|
| 160 |
+
brenk_alerts = []
|
| 161 |
+
if Fragments.fr_halogen(mol) > 0 and Fragments.fr_halogen(mol) > 2:
|
| 162 |
+
brenk_alerts.append("Multiple halogen substituents")
|
| 163 |
+
if Fragments.fr_nitro(mol) > 0:
|
| 164 |
+
brenk_alerts.append("Nitro group (mutagenicity concern)")
|
| 165 |
+
if Fragments.fr_sulfonamide(mol) > 0:
|
| 166 |
+
brenk_alerts.append("Sulfonamide (hypersensitivity risk)")
|
| 167 |
+
if n_aromatic_rings > 5:
|
| 168 |
+
brenk_alerts.append(f"Many aromatic rings ({n_aromatic_rings}) — metabolic liability")
|
| 169 |
+
if Fragments.fr_aldehyde(mol) > 0:
|
| 170 |
+
brenk_alerts.append("Aldehyde (reactive, toxicity concern)")
|
| 171 |
+
if Fragments.fr_QuatN(mol) > 0:
|
| 172 |
+
brenk_alerts.append("Quaternary nitrogen (P-gp substrate risk)")
|
| 173 |
+
brenk = {"pass": len(brenk_alerts) == 0, "alerts": brenk_alerts, "alert_count": len(brenk_alerts)}
|
| 174 |
+
|
| 175 |
+
# ===================================================================
|
| 176 |
+
# ADMET PREDICTIONS (rule-based / heuristic)
|
| 177 |
+
# ===================================================================
|
| 178 |
+
|
| 179 |
+
# ---- Absorption ----
|
| 180 |
+
# Oral bioavailability score (based on Veber + Egan + MW)
|
| 181 |
+
oral_bio_score = 1.0
|
| 182 |
+
if tpsa > 140: oral_bio_score -= 0.3
|
| 183 |
+
if tpsa > 90: oral_bio_score -= 0.1
|
| 184 |
+
if logp < -1: oral_bio_score -= 0.2
|
| 185 |
+
if logp > 5: oral_bio_score -= 0.2
|
| 186 |
+
if mw > 500: oral_bio_score -= 0.2
|
| 187 |
+
if mw < 100: oral_bio_score -= 0.1
|
| 188 |
+
if rotatable > 10: oral_bio_score -= 0.1
|
| 189 |
+
oral_bio = round(max(0, min(1, oral_bio_score)), 3)
|
| 190 |
+
|
| 191 |
+
# Caco-2 permeability (LogP and PSA based)
|
| 192 |
+
# High LogP + low PSA = good permeability
|
| 193 |
+
if tpsa < 60 and logp > 1:
|
| 194 |
+
caco2_class = "High"
|
| 195 |
+
elif tpsa < 90 and logp > 0:
|
| 196 |
+
caco2_class = "Moderate"
|
| 197 |
+
elif tpsa < 140:
|
| 198 |
+
caco2_class = "Low"
|
| 199 |
+
else:
|
| 200 |
+
caco2_class = "Very Low"
|
| 201 |
+
|
| 202 |
+
# Pgp substrate (MW, LogP, HBA, TPSA based)
|
| 203 |
+
pgp_score = 0
|
| 204 |
+
if mw > 400: pgp_score += 1
|
| 205 |
+
if logp > 2: pgp_score += 1
|
| 206 |
+
if hba > 7: pgp_score += 1
|
| 207 |
+
if tpsa > 90: pgp_score += 1
|
| 208 |
+
pgp_substrate = "Likely" if pgp_score >= 3 else "Unlikely"
|
| 209 |
+
pgp_inhibitor = "Likely" if mw > 400 and logp > 3 and num_nitro == 0 else "Unlikely"
|
| 210 |
+
|
| 211 |
+
# Human Intestinal Absorption (HIA)
|
| 212 |
+
if tpsa <= 90 and logp >= -0.7 and mw <= 400:
|
| 213 |
+
hia_class = "High (>90%)"
|
| 214 |
+
elif tpsa <= 140 and mw <= 500:
|
| 215 |
+
hia_class = "Moderate (30-90%)"
|
| 216 |
+
else:
|
| 217 |
+
hia_class = "Low (<30%)"
|
| 218 |
+
|
| 219 |
+
# ---- Distribution ----
|
| 220 |
+
# Volume of distribution (LogP and pKa based heuristic)
|
| 221 |
+
vd = round(0.1 + logp * 0.5, 2) # L/kg rough estimate
|
| 222 |
+
vd = max(0.05, min(vd, 20.0))
|
| 223 |
+
|
| 224 |
+
# BBB permeability
|
| 225 |
+
if logp > 2 and mw < 450 and tpsa < 90:
|
| 226 |
+
bbb_class = "High"
|
| 227 |
+
elif logp > 0 and mw < 500 and tpsa < 120:
|
| 228 |
+
bbb_class = "Moderate"
|
| 229 |
+
else:
|
| 230 |
+
bbb_class = "Low"
|
| 231 |
+
|
| 232 |
+
# Plasma protein binding (LogP and MW based)
|
| 233 |
+
if logp > 3:
|
| 234 |
+
ppb_class = "High (>95%)"
|
| 235 |
+
elif logp > 1.5:
|
| 236 |
+
ppb_class = "Moderate (80-95%)"
|
| 237 |
+
else:
|
| 238 |
+
ppb_class = "Low (<80%)"
|
| 239 |
+
|
| 240 |
+
# CNS penetration
|
| 241 |
+
if tpsa <= 90 and mw <= 400 and logp >= 1 and logp <= 5:
|
| 242 |
+
cns_class = "Favorable"
|
| 243 |
+
elif tpsa <= 120 and mw <= 500:
|
| 244 |
+
cns_class = "Moderate"
|
| 245 |
+
else:
|
| 246 |
+
cns_class = "Unfavorable"
|
| 247 |
+
|
| 248 |
+
# ---- Metabolism ----
|
| 249 |
+
# CYP inhibition likelihood (structural feature based)
|
| 250 |
+
cyp_panel = {}
|
| 251 |
+
# CYP1A2: aromatic amines, planar molecules
|
| 252 |
+
cyp_panel["CYP1A2"] = "Inhibitor" if (num_aromatic_rings >= 3 or num_nitro > 0) else "Non-inhibitor"
|
| 253 |
+
# CYP2C9: acidic molecules, sulfonamides
|
| 254 |
+
cyp_panel["CYP2C9"] = "Inhibitor" if (num_carboxylic > 0 or num_sulfonamide > 0) else "Non-inhibitor"
|
| 255 |
+
# CYP2C19: aromatic, basic
|
| 256 |
+
cyp_panel["CYP2C19"] = "Inhibitor" if (logp > 2 and num_aromatic_rings >= 2) else "Non-inhibitor"
|
| 257 |
+
# CYP2D6: basic nitrogen
|
| 258 |
+
cyp_panel["CYP2D6"] = "Inhibitor" if (num_nh > 1 or num_amine > 0) else "Non-inhibitor"
|
| 259 |
+
# CYP3A4: large lipophilic molecules
|
| 260 |
+
cyp_panel["CYP3A4"] = "Inhibitor" if (mw > 500 and logp > 3) else "Non-inhibitor"
|
| 261 |
+
|
| 262 |
+
# CYP substrate prediction (lipophilicity and size)
|
| 263 |
+
cyp_substrate_count = sum(1 for v in cyp_panel.values() if v == "Inhibitor")
|
| 264 |
+
cyp_substrate = "Likely multiple" if cyp_substrate_count >= 3 else "Single or none"
|
| 265 |
+
|
| 266 |
+
# Half-life estimate (heuristic)
|
| 267 |
+
if logp > 3 and mw > 400:
|
| 268 |
+
half_life_class = "Long (>4h)"
|
| 269 |
+
elif logp > 1.5 and mw > 250:
|
| 270 |
+
half_life_class = "Medium (1-4h)"
|
| 271 |
+
else:
|
| 272 |
+
half_life_class = "Short (<1h)"
|
| 273 |
+
|
| 274 |
+
# ---- Toxicity ----
|
| 275 |
+
# AMES mutagenicity (structural alerts)
|
| 276 |
+
ames_alerts = []
|
| 277 |
+
if num_nitro > 0: ames_alerts.append("Nitro group")
|
| 278 |
+
if Fragments.fr_Al_OH(mol) > 1: ames_alerts.append("Multiple aliphatic hydroxyls")
|
| 279 |
+
if mol.HasSubstructMatch(Chem.MolFromSmarts("c1ccc(-[N+](=O)[O-])cc1")): ames_alerts.append("Nitroaromatic")
|
| 280 |
+
if mol.HasSubstructMatch(Chem.MolFromSmarts("N-N")): ames_alerts.append("Azo compound")
|
| 281 |
+
ames_prediction = "Likely mutagen" if ames_alerts else "Non-mutagen"
|
| 282 |
+
|
| 283 |
+
# hERG channel liability (LogP, MW, TPSA, charge)
|
| 284 |
+
herg_risk = "High" if (logp > 3.5 and tpsa < 80) else ("Moderate" if logp > 2 else "Low")
|
| 285 |
+
|
| 286 |
+
# Hepatotoxicity (DILI - Drug Induced Liver Injury)
|
| 287 |
+
dili_risk = "High" if (logp > 3 and mw > 400 and tpsa < 75) else ("Moderate" if logp > 2.5 else "Low")
|
| 288 |
+
|
| 289 |
+
# Skin sensitization (reactive functional groups)
|
| 290 |
+
skin_risk_factors = []
|
| 291 |
+
if Fragments.fr_aldehyde(mol) > 0: skin_risk_factors.append("Aldehyde")
|
| 292 |
+
if Fragments.fr_halogen(mol) > 2: skin_risk_factors.append("Multiple halogens")
|
| 293 |
+
skin_sensitization = "Likely" if skin_risk_factors else "Unlikely"
|
| 294 |
+
|
| 295 |
+
# Acute toxicity (LD50 rough estimate based on LogP and functional groups)
|
| 296 |
+
# Crum-Brown and Wood LD50 estimate
|
| 297 |
+
ld50_estimate = round(1.37 + 0.87 * logp - 0.01 * mw + 0.06 * num_halogen, 2)
|
| 298 |
+
ld50_class = "Toxic" if ld50_estimate < 2.5 else ("Moderate" if ld50_estimate < 4 else "Low toxicity")
|
| 299 |
+
|
| 300 |
+
# ---- Clearance ----
|
| 301 |
+
clearance_class = "High" if logp < 1 and tpsa > 100 else ("Low" if logp > 3 and tpsa < 60 else "Moderate")
|
| 302 |
+
|
| 303 |
+
# Lipophilic efficiency (LipE = pIC50 - LogP; we estimate pIC50 from QED)
|
| 304 |
+
lipe = round(qed_score * 10 - logp, 2) if qed_score > 0 else 0
|
| 305 |
+
|
| 306 |
+
# ===================================================================
|
| 307 |
+
# COMPOSITE SCORES
|
| 308 |
+
# ===================================================================
|
| 309 |
+
# Overall drug-likeness score (weighted combination)
|
| 310 |
+
dl_score = 0
|
| 311 |
+
dl_score += 25 * (1 - min(lipinski["violation_count"] / 4, 1))
|
| 312 |
+
dl_score += 15 * (1 - min(veber["violation_count"] / 3, 1))
|
| 313 |
+
dl_score += 15 * (1 - min(ghose["violation_count"] / 4, 1))
|
| 314 |
+
dl_score += 10 * min(qed_score, 1)
|
| 315 |
+
dl_score += 10 * (1 - min(pains["alert_count"] / 3, 1))
|
| 316 |
+
dl_score += 5 * (1 - min(brenk["alert_count"] / 3, 1))
|
| 317 |
+
dl_score += 10 * (1 if oral_bio > 0.5 else 0.5)
|
| 318 |
+
dl_score = round(dl_score, 1)
|
| 319 |
+
|
| 320 |
+
# ADMET risk score (lower = safer)
|
| 321 |
+
admet_risk = 0
|
| 322 |
+
if ames_prediction == "Likely mutagen": admet_risk += 3
|
| 323 |
+
if herg_risk == "High": admet_risk += 2
|
| 324 |
+
if dili_risk == "High": admet_risk += 2
|
| 325 |
+
if skin_sensitization == "Likely": admet_risk += 1
|
| 326 |
+
admet_risk = min(admet_risk, 10)
|
| 327 |
|
| 328 |
return {
|
| 329 |
"smiles": smiles,
|
|
|
|
| 336 |
"hba": hba,
|
| 337 |
"rotatable_bonds": rotatable,
|
| 338 |
"qed_score": qed_score,
|
| 339 |
+
"molar_refractivity": mr,
|
| 340 |
+
"molecular_volume": mol_volume,
|
| 341 |
+
"fsp3": fsp3,
|
| 342 |
+
"labute_asa": labute_asa,
|
| 343 |
+
"estate_sum": estate_sum,
|
| 344 |
+
"wiener_index": wiener,
|
| 345 |
+
"zagreb_index": zagreb,
|
| 346 |
+
"ring_count": ring_count,
|
| 347 |
+
"aromatic_ring_count": aromatic_ring_count,
|
| 348 |
+
"aliphatic_ring_count": aliphatic_ring_count,
|
| 349 |
+
"num_heteroatoms": num_heteroatoms,
|
| 350 |
+
"num_amide_bonds": num_amide_bonds,
|
| 351 |
+
"num_atom_stereocenters": num_atom_stereocenters,
|
| 352 |
+
"num_unspecified_stereocenters": num_unspecified_stereocenters,
|
| 353 |
+
"functional_groups": {
|
| 354 |
+
"oh": num_oh,
|
| 355 |
+
"nh": num_nh,
|
| 356 |
+
"carboxylic_acid": num_carboxylic,
|
| 357 |
+
"ester": num_ester,
|
| 358 |
+
"ether": num_ether,
|
| 359 |
+
"ketone": num_ketone,
|
| 360 |
+
"aldehyde": num_aldehyde,
|
| 361 |
+
"halogen": num_halogen,
|
| 362 |
+
"sulfonamide": num_sulfonamide,
|
| 363 |
+
"nitro": num_nitro,
|
| 364 |
+
"phenol": num_phenol,
|
| 365 |
+
},
|
| 366 |
+
"drug_likeness": {
|
| 367 |
+
"overall_score": dl_score,
|
| 368 |
+
"qed_score": qed_score,
|
| 369 |
+
"lipinski": lipinski,
|
| 370 |
+
"veber": veber,
|
| 371 |
+
"ghose": ghose,
|
| 372 |
+
"egan": egan,
|
| 373 |
+
"mddr": mddr,
|
| 374 |
+
},
|
| 375 |
+
"structural_alerts": {
|
| 376 |
+
"pains": pains,
|
| 377 |
+
"brenk": brenk,
|
| 378 |
+
"total_alert_count": pains["alert_count"] + brenk["alert_count"],
|
| 379 |
+
},
|
| 380 |
+
"absorption": {
|
| 381 |
+
"oral_bioavailability": oral_bio,
|
| 382 |
+
"caco2_permeability": caco2_class,
|
| 383 |
+
"pgp_substrate": pgp_substrate,
|
| 384 |
+
"pgp_inhibitor": pgp_inhibitor,
|
| 385 |
+
"hia": hia_class,
|
| 386 |
+
},
|
| 387 |
+
"distribution": {
|
| 388 |
+
"volume_of_distribution": vd,
|
| 389 |
+
"bbb_permeability": bbb_class,
|
| 390 |
+
"plasma_protein_binding": ppb_class,
|
| 391 |
+
"cns_penetration": cns_class,
|
| 392 |
+
},
|
| 393 |
+
"metabolism": {
|
| 394 |
+
"cyp_inhibition": cyp_panel,
|
| 395 |
+
"cyp_substrate_risk": cyp_substrate,
|
| 396 |
+
"half_life_class": half_life_class,
|
| 397 |
+
"lipophilic_efficiency": lipe,
|
| 398 |
+
},
|
| 399 |
+
"toxicity": {
|
| 400 |
+
"ames_mutagenicity": ames_prediction,
|
| 401 |
+
"ames_alerts": ames_alerts,
|
| 402 |
+
"herg_liability": herg_risk,
|
| 403 |
+
"hepatotoxicity_dili": dili_risk,
|
| 404 |
+
"skin_sensitization": skin_sensitization,
|
| 405 |
+
"skin_sensitization_factors": skin_risk_factors,
|
| 406 |
+
"acute_toxicity_ld50": ld50_class,
|
| 407 |
+
"ld50_estimate_log": ld50_estimate,
|
| 408 |
+
"risk_score": admet_risk,
|
| 409 |
},
|
| 410 |
+
"clearance": {
|
| 411 |
+
"clearance_class": clearance_class,
|
| 412 |
+
"half_life_class": half_life_class,
|
|
|
|
| 413 |
},
|
| 414 |
}
|
|
@@ -1,8 +1,8 @@
|
|
| 1 |
"use client";
|
| 2 |
import { useState } from "react";
|
| 3 |
import { useRouter } from "next/navigation";
|
| 4 |
-
import { motion } from "framer-motion";
|
| 5 |
-
import { ArrowLeft, Beaker, Check, X, AlertTriangle, Loader2 } from "lucide-react";
|
| 6 |
import { fadeUp } from "@/lib/animations";
|
| 7 |
import { useAuditTrail } from "@/hooks/useAuditTrail";
|
| 8 |
import { computeADMET, type ADMETResult } from "@/lib/api";
|
|
@@ -12,16 +12,66 @@ const EXAMPLES = [
|
|
| 12 |
{ name: "Caffeine", smiles: "CN1C=NC2=C1C(=O)N(C(=O)N2C)C" },
|
| 13 |
{ name: "Ibuprofen", smiles: "CC(C)CC1=CC=C(C=C1)C(C)C(=O)O" },
|
| 14 |
{ name: "Paracetamol", smiles: "CC(=O)NC1=CC=C(C=C1)O" },
|
|
|
|
|
|
|
| 15 |
];
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
export default function ADMETPage() {
|
| 18 |
const router = useRouter();
|
| 19 |
useAuditTrail();
|
| 20 |
-
|
| 21 |
const [smiles, setSmiles] = useState("");
|
| 22 |
const [result, setResult] = useState<ADMETResult | null>(null);
|
| 23 |
const [loading, setLoading] = useState(false);
|
| 24 |
const [error, setError] = useState("");
|
|
|
|
| 25 |
|
| 26 |
const handleSubmit = async () => {
|
| 27 |
if (!smiles.trim()) return;
|
|
@@ -39,36 +89,29 @@ export default function ADMETPage() {
|
|
| 39 |
};
|
| 40 |
|
| 41 |
return (
|
| 42 |
-
<div className="max-w-
|
| 43 |
<button onClick={() => router.push("/analyze")}
|
| 44 |
className="flex items-center gap-1 text-sm text-text-muted hover:text-text-primary mb-6 transition-colors">
|
| 45 |
-
<ArrowLeft className="w-4 h-4" />
|
| 46 |
-
Choose a different operation
|
| 47 |
</button>
|
| 48 |
|
| 49 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show" className="mb-8">
|
| 50 |
-
<h1 className="text-2xl font-bold text-text-primary mb-1">ADMET
|
| 51 |
-
<p className="text-sm text-text-secondary">
|
| 52 |
</motion.div>
|
| 53 |
|
| 54 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show">
|
| 55 |
<div className="glass-card p-5">
|
| 56 |
<label className="block text-sm text-text-secondary mb-2">SMILES String</label>
|
| 57 |
<div className="flex gap-2">
|
| 58 |
-
<input
|
| 59 |
-
value={smiles}
|
| 60 |
-
onChange={(e) => setSmiles(e.target.value)}
|
| 61 |
placeholder="e.g. CC(=O)OC1=CC=CC=C1C(=O)O"
|
| 62 |
className="flex-1 px-3 py-2 rounded-lg bg-surface-1 border border-surface-3 text-text-primary text-sm font-mono placeholder:text-text-muted focus:outline-none focus:border-accent-cyan"
|
| 63 |
-
onKeyDown={(e) => e.key === "Enter" && handleSubmit()}
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
onClick={handleSubmit}
|
| 67 |
-
disabled={loading || !smiles.trim()}
|
| 68 |
-
className="btn-primary px-4 py-2 text-sm flex items-center gap-2"
|
| 69 |
-
>
|
| 70 |
{loading ? <Loader2 className="w-4 h-4 animate-spin" /> : <Beaker className="w-4 h-4" />}
|
| 71 |
-
|
| 72 |
</button>
|
| 73 |
</div>
|
| 74 |
<div className="flex flex-wrap gap-2 mt-3">
|
|
@@ -90,90 +133,434 @@ export default function ADMETPage() {
|
|
| 90 |
|
| 91 |
{result && (
|
| 92 |
<motion.div initial={{ opacity: 0, y: 16 }} animate={{ opacity: 1, y: 0 }} className="mt-6 space-y-4">
|
| 93 |
-
{/*
|
| 94 |
-
<div className="glass-card p-
|
| 95 |
-
<
|
| 96 |
-
|
| 97 |
-
<
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
<circle cx="18" cy="18" r="15.9" fill="none" stroke="currentColor" className="text-surface-3" strokeWidth="3" />
|
| 100 |
<circle cx="18" cy="18" r="15.9" fill="none" stroke="currentColor"
|
| 101 |
-
className={result.
|
| 102 |
-
strokeWidth="3" strokeDasharray={`${result.
|
| 103 |
</svg>
|
| 104 |
-
<span className="absolute inset-0 flex items-center justify-center text-
|
| 105 |
-
{result.
|
| 106 |
</span>
|
| 107 |
</div>
|
| 108 |
-
<div>
|
| 109 |
-
<p className="text-sm text-text-secondary">Quantitative Estimate of Drug-likeness</p>
|
| 110 |
-
<p className="text-xs text-text-muted mt-1">Formula: {result.formula} | MW: {result.molecular_weight}</p>
|
| 111 |
-
</div>
|
| 112 |
</div>
|
| 113 |
</div>
|
| 114 |
|
| 115 |
-
{/*
|
| 116 |
-
<div className="
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
<div className="text-lg font-semibold text-text-primary">{p.value}</div>
|
| 132 |
-
<div className="text-xs text-text-muted">{p.unit}</div>
|
| 133 |
-
</div>
|
| 134 |
-
))}
|
| 135 |
-
</div>
|
| 136 |
</div>
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
<
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
<
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
-
<p className="text-xs text-text-muted text-center">
|
| 177 |
</motion.div>
|
| 178 |
)}
|
| 179 |
</div>
|
|
|
|
| 1 |
"use client";
|
| 2 |
import { useState } from "react";
|
| 3 |
import { useRouter } from "next/navigation";
|
| 4 |
+
import { motion, AnimatePresence } from "framer-motion";
|
| 5 |
+
import { ArrowLeft, Beaker, Check, X, AlertTriangle, Loader2, Shield, Activity, Brain, Zap, Droplets } from "lucide-react";
|
| 6 |
import { fadeUp } from "@/lib/animations";
|
| 7 |
import { useAuditTrail } from "@/hooks/useAuditTrail";
|
| 8 |
import { computeADMET, type ADMETResult } from "@/lib/api";
|
|
|
|
| 12 |
{ name: "Caffeine", smiles: "CN1C=NC2=C1C(=O)N(C(=O)N2C)C" },
|
| 13 |
{ name: "Ibuprofen", smiles: "CC(C)CC1=CC=C(C=C1)C(C)C(=O)O" },
|
| 14 |
{ name: "Paracetamol", smiles: "CC(=O)NC1=CC=C(C=C1)O" },
|
| 15 |
+
{ name: "Metformin", smiles: "CN(C)C(=N)NC(=N)N" },
|
| 16 |
+
{ name: "Omeprazole", smiles: "CC1=CN=C(C(=C1OC)C)CS(=O)C2=NC3=C(N2)C=CC=C3" },
|
| 17 |
];
|
| 18 |
|
| 19 |
+
const TABS = [
|
| 20 |
+
{ key: "overview", label: "Overview", icon: Activity },
|
| 21 |
+
{ key: "properties", label: "Properties", icon: Brain },
|
| 22 |
+
{ key: "druglikeness", label: "Drug-likeness", icon: Beaker },
|
| 23 |
+
{ key: "admet", label: "ADMET", icon: Shield },
|
| 24 |
+
{ key: "alerts", label: "Alerts", icon: AlertTriangle },
|
| 25 |
+
];
|
| 26 |
+
|
| 27 |
+
type TabKey = typeof TABS[number]["key"];
|
| 28 |
+
|
| 29 |
+
function PassFail({ pass }: { pass: boolean }) {
|
| 30 |
+
return pass
|
| 31 |
+
? <span className="inline-flex items-center gap-1 text-xs text-green-400"><Check className="w-3 h-3" />Pass</span>
|
| 32 |
+
: <span className="inline-flex items-center gap-1 text-xs text-amber-400"><AlertTriangle className="w-3 h-3" />Fail</span>;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function RiskBadge({ level }: { level: string }) {
|
| 36 |
+
const low = ["Low", "Unlikely", "Non-inhibitor", "Non-mutagen", "Favorable", "Low toxicity"].some(s => level.includes(s));
|
| 37 |
+
const high = ["High", "Likely", "Toxic", "Unfavorable"].some(s => level.includes(s));
|
| 38 |
+
return (
|
| 39 |
+
<span className={`text-xs font-medium px-2 py-0.5 rounded ${
|
| 40 |
+
low ? "bg-green-500/15 text-green-400" : high ? "bg-red-500/15 text-red-400" : "bg-amber-500/15 text-amber-400"
|
| 41 |
+
}`}>{level}</span>
|
| 42 |
+
);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function SectionCard({ title, children, className = "" }: { title: string; children: React.ReactNode; className?: string }) {
|
| 46 |
+
return (
|
| 47 |
+
<div className={`glass-card p-5 ${className}`}>
|
| 48 |
+
<h3 className="text-sm font-semibold text-text-primary mb-3">{title}</h3>
|
| 49 |
+
{children}
|
| 50 |
+
</div>
|
| 51 |
+
);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
function PropRow({ label, value, unit, note }: { label: string; value: string | number; unit?: string; note?: string }) {
|
| 55 |
+
return (
|
| 56 |
+
<div className="flex items-center justify-between py-1.5 border-b border-surface-3 last:border-0">
|
| 57 |
+
<span className="text-xs text-text-muted">{label}</span>
|
| 58 |
+
<div className="text-right">
|
| 59 |
+
<span className="text-sm font-mono font-medium text-text-primary">{value}</span>
|
| 60 |
+
{unit && <span className="text-xs text-text-muted ml-1">{unit}</span>}
|
| 61 |
+
{note && <div className="text-xs text-text-muted">{note}</div>}
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
export default function ADMETPage() {
|
| 68 |
const router = useRouter();
|
| 69 |
useAuditTrail();
|
|
|
|
| 70 |
const [smiles, setSmiles] = useState("");
|
| 71 |
const [result, setResult] = useState<ADMETResult | null>(null);
|
| 72 |
const [loading, setLoading] = useState(false);
|
| 73 |
const [error, setError] = useState("");
|
| 74 |
+
const [activeTab, setActiveTab] = useState<TabKey>("overview");
|
| 75 |
|
| 76 |
const handleSubmit = async () => {
|
| 77 |
if (!smiles.trim()) return;
|
|
|
|
| 89 |
};
|
| 90 |
|
| 91 |
return (
|
| 92 |
+
<div className="max-w-4xl">
|
| 93 |
<button onClick={() => router.push("/analyze")}
|
| 94 |
className="flex items-center gap-1 text-sm text-text-muted hover:text-text-primary mb-6 transition-colors">
|
| 95 |
+
<ArrowLeft className="w-4 h-4" /> Choose a different operation
|
|
|
|
| 96 |
</button>
|
| 97 |
|
| 98 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show" className="mb-8">
|
| 99 |
+
<h1 className="text-2xl font-bold text-text-primary mb-1">ADMET Analysis</h1>
|
| 100 |
+
<p className="text-sm text-text-secondary">Comprehensive molecular descriptor computation: 50+ properties, ADMET predictions, drug-likeness filters, structural alerts.</p>
|
| 101 |
</motion.div>
|
| 102 |
|
| 103 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show">
|
| 104 |
<div className="glass-card p-5">
|
| 105 |
<label className="block text-sm text-text-secondary mb-2">SMILES String</label>
|
| 106 |
<div className="flex gap-2">
|
| 107 |
+
<input value={smiles} onChange={(e) => setSmiles(e.target.value)}
|
|
|
|
|
|
|
| 108 |
placeholder="e.g. CC(=O)OC1=CC=CC=C1C(=O)O"
|
| 109 |
className="flex-1 px-3 py-2 rounded-lg bg-surface-1 border border-surface-3 text-text-primary text-sm font-mono placeholder:text-text-muted focus:outline-none focus:border-accent-cyan"
|
| 110 |
+
onKeyDown={(e) => e.key === "Enter" && handleSubmit()} />
|
| 111 |
+
<button onClick={handleSubmit} disabled={loading || !smiles.trim()}
|
| 112 |
+
className="btn-primary px-4 py-2 text-sm flex items-center gap-2">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
{loading ? <Loader2 className="w-4 h-4 animate-spin" /> : <Beaker className="w-4 h-4" />}
|
| 114 |
+
Analyze
|
| 115 |
</button>
|
| 116 |
</div>
|
| 117 |
<div className="flex flex-wrap gap-2 mt-3">
|
|
|
|
| 133 |
|
| 134 |
{result && (
|
| 135 |
<motion.div initial={{ opacity: 0, y: 16 }} animate={{ opacity: 1, y: 0 }} className="mt-6 space-y-4">
|
| 136 |
+
{/* Header strip */}
|
| 137 |
+
<div className="glass-card p-4 flex flex-wrap items-center gap-4">
|
| 138 |
+
<div>
|
| 139 |
+
<p className="text-xs text-text-muted">Formula</p>
|
| 140 |
+
<p className="text-sm font-mono font-medium text-text-primary">{result.formula}</p>
|
| 141 |
+
</div>
|
| 142 |
+
<div className="h-6 w-px bg-surface-3" />
|
| 143 |
+
<div>
|
| 144 |
+
<p className="text-xs text-text-muted">SMILES</p>
|
| 145 |
+
<p className="text-xs font-mono text-text-secondary max-w-md truncate">{result.smiles}</p>
|
| 146 |
+
</div>
|
| 147 |
+
<div className="ml-auto flex items-center gap-3">
|
| 148 |
+
<div className="text-right">
|
| 149 |
+
<p className="text-xs text-text-muted">Drug-likeness Score</p>
|
| 150 |
+
<p className="text-xl font-bold text-accent-cyan">{result.drug_likeness.overall_score}<span className="text-xs text-text-muted">/100</span></p>
|
| 151 |
+
</div>
|
| 152 |
+
<div className="relative w-14 h-14">
|
| 153 |
+
<svg viewBox="0 0 36 36" className="w-14 h-14 -rotate-90">
|
| 154 |
<circle cx="18" cy="18" r="15.9" fill="none" stroke="currentColor" className="text-surface-3" strokeWidth="3" />
|
| 155 |
<circle cx="18" cy="18" r="15.9" fill="none" stroke="currentColor"
|
| 156 |
+
className={result.drug_likeness.overall_score > 60 ? "text-green-400" : result.drug_likeness.overall_score > 40 ? "text-amber-400" : "text-red-400"}
|
| 157 |
+
strokeWidth="3" strokeDasharray={`${result.drug_likeness.overall_score} 100`} />
|
| 158 |
</svg>
|
| 159 |
+
<span className="absolute inset-0 flex items-center justify-center text-xs font-bold text-text-primary">
|
| 160 |
+
{result.drug_likeness.overall_score > 60 ? "Good" : result.drug_likeness.overall_score > 40 ? "Fair" : "Poor"}
|
| 161 |
</span>
|
| 162 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
</div>
|
| 164 |
</div>
|
| 165 |
|
| 166 |
+
{/* Tabs */}
|
| 167 |
+
<div className="flex gap-1 p-1 bg-surface-1 rounded-lg overflow-x-auto">
|
| 168 |
+
{TABS.map((tab) => {
|
| 169 |
+
const Icon = tab.icon;
|
| 170 |
+
return (
|
| 171 |
+
<button key={tab.key} onClick={() => setActiveTab(tab.key)}
|
| 172 |
+
className={`flex items-center gap-1.5 px-3 py-2 rounded-md text-xs font-medium transition-all whitespace-nowrap ${
|
| 173 |
+
activeTab === tab.key
|
| 174 |
+
? "bg-accent-cyan/15 text-accent-cyan"
|
| 175 |
+
: "text-text-muted hover:text-text-secondary hover:bg-surface-2"
|
| 176 |
+
}`}>
|
| 177 |
+
<Icon className="w-3.5 h-3.5" />
|
| 178 |
+
{tab.label}
|
| 179 |
+
</button>
|
| 180 |
+
);
|
| 181 |
+
})}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
</div>
|
| 183 |
|
| 184 |
+
<AnimatePresence mode="wait">
|
| 185 |
+
{/* ---- OVERVIEW TAB ---- */}
|
| 186 |
+
{activeTab === "overview" && (
|
| 187 |
+
<motion.div key="overview" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} className="space-y-4">
|
| 188 |
+
<SectionCard title="Quick Summary">
|
| 189 |
+
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
| 190 |
+
{[
|
| 191 |
+
{ label: "MW", value: result.molecular_weight, unit: "g/mol", limit: 500 },
|
| 192 |
+
{ label: "LogP", value: result.logp, unit: "", limit: 5 },
|
| 193 |
+
{ label: "TPSA", value: result.tpsa, unit: "A2", limit: 140 },
|
| 194 |
+
{ label: "HBD", value: result.hbd, unit: "", limit: 5 },
|
| 195 |
+
{ label: "HBA", value: result.hba, unit: "", limit: 10 },
|
| 196 |
+
{ label: "Rot. Bonds", value: result.rotatable_bonds, unit: "", limit: 10 },
|
| 197 |
+
{ label: "QED", value: result.qed_score.toFixed(3), unit: "" },
|
| 198 |
+
{ label: "Fsp3", value: result.fsp3, unit: "" },
|
| 199 |
+
].map((p) => (
|
| 200 |
+
<div key={p.label} className="bg-surface-1 rounded-lg p-3">
|
| 201 |
+
<div className="text-xs text-text-muted">{p.label}</div>
|
| 202 |
+
<div className="text-lg font-semibold text-text-primary">{p.value}</div>
|
| 203 |
+
<div className="text-xs text-text-muted">{p.unit}</div>
|
| 204 |
+
</div>
|
| 205 |
+
))}
|
| 206 |
+
</div>
|
| 207 |
+
</SectionCard>
|
| 208 |
+
|
| 209 |
+
<SectionCard title="ADMET Risk Overview">
|
| 210 |
+
<div className="grid grid-cols-2 sm:grid-cols-5 gap-3">
|
| 211 |
+
{[
|
| 212 |
+
{ label: "Oral Bioavailability", value: `${(result.absorption.oral_bioavailability * 100).toFixed(0)}%` },
|
| 213 |
+
{ label: "BBB Permeability", value: result.distribution.bbb_permeability },
|
| 214 |
+
{ label: "CYP Inhibition", value: result.metabolism.cyp_substrate_risk },
|
| 215 |
+
{ label: "AMES Mutagenicity", value: result.toxicity.ames_mutagenicity },
|
| 216 |
+
{ label: "hERG Risk", value: result.toxicity.herg_liability },
|
| 217 |
+
].map((p) => (
|
| 218 |
+
<div key={p.label} className="bg-surface-1 rounded-lg p-3 text-center">
|
| 219 |
+
<div className="text-xs text-text-muted mb-1">{p.label}</div>
|
| 220 |
+
<RiskBadge level={p.value} />
|
| 221 |
+
</div>
|
| 222 |
+
))}
|
| 223 |
+
</div>
|
| 224 |
+
</SectionCard>
|
| 225 |
+
|
| 226 |
+
<SectionCard title="Drug-likeness Filters">
|
| 227 |
+
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
|
| 228 |
+
{[
|
| 229 |
+
{ name: "Lipinski", data: result.drug_likeness.lipinski },
|
| 230 |
+
{ name: "Veber", data: result.drug_likeness.veber },
|
| 231 |
+
{ name: "Ghose", data: result.drug_likeness.ghose },
|
| 232 |
+
{ name: "Egan", data: result.drug_likeness.egan },
|
| 233 |
+
{ name: "MDDR", data: result.drug_likeness.mddr },
|
| 234 |
+
].map((filter) => (
|
| 235 |
+
<div key={filter.name} className="bg-surface-1 rounded-lg p-3">
|
| 236 |
+
<div className="flex items-center justify-between mb-1">
|
| 237 |
+
<span className="text-xs font-medium text-text-primary">{filter.name}</span>
|
| 238 |
+
<PassFail pass={filter.data.pass} />
|
| 239 |
+
</div>
|
| 240 |
+
{filter.data.violations.length > 0 && (
|
| 241 |
+
<ul className="mt-1 space-y-0.5">
|
| 242 |
+
{filter.data.violations.map((v, i) => (
|
| 243 |
+
<li key={i} className="text-xs text-amber-400/80">{v}</li>
|
| 244 |
+
))}
|
| 245 |
+
</ul>
|
| 246 |
+
)}
|
| 247 |
+
</div>
|
| 248 |
+
))}
|
| 249 |
+
</div>
|
| 250 |
+
</SectionCard>
|
| 251 |
+
</motion.div>
|
| 252 |
+
)}
|
| 253 |
+
|
| 254 |
+
{/* ---- PROPERTIES TAB ---- */}
|
| 255 |
+
{activeTab === "properties" && (
|
| 256 |
+
<motion.div key="properties" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} className="space-y-4">
|
| 257 |
+
<SectionCard title="Physicochemical Properties">
|
| 258 |
+
<div className="space-y-0">
|
| 259 |
+
<PropRow label="Molecular Weight" value={result.molecular_weight} unit="g/mol" />
|
| 260 |
+
<PropRow label="LogP (Crippen)" value={result.logp} />
|
| 261 |
+
<PropRow label="TPSA" value={result.tpsa} unit="A2" />
|
| 262 |
+
<PropRow label="H-bond Donors (HBD)" value={result.hbd} />
|
| 263 |
+
<PropRow label="H-bond Acceptors (HBA)" value={result.hba} />
|
| 264 |
+
<PropRow label="Rotatable Bonds" value={result.rotatable_bonds} />
|
| 265 |
+
<PropRow label="Heavy Atoms" value={result.heavy_atoms} />
|
| 266 |
+
<PropRow label="Molar Refractivity" value={result.molar_refractivity} unit="cm3/mol" />
|
| 267 |
+
<PropRow label="Molecular Volume" value={result.molecular_volume} unit="A3" />
|
| 268 |
+
<PropRow label="Fsp3 (Fraction sp3)" value={result.fsp3} />
|
| 269 |
+
<PropRow label="Labute ASA" value={result.labute_asa} unit="A2" />
|
| 270 |
+
<PropRow label="E-state Sum" value={result.estate_sum} />
|
| 271 |
+
<PropRow label="Wiener Index" value={result.wiener_index} />
|
| 272 |
+
<PropRow label="Zagreb Index" value={result.zagreb_index} />
|
| 273 |
+
</div>
|
| 274 |
+
</SectionCard>
|
| 275 |
+
|
| 276 |
+
<SectionCard title="Ring & Scaffold Analysis">
|
| 277 |
+
<div className="space-y-0">
|
| 278 |
+
<PropRow label="Total Rings" value={result.ring_count} />
|
| 279 |
+
<PropRow label="Aromatic Rings" value={result.aromatic_ring_count} />
|
| 280 |
+
<PropRow label="Aliphatic Rings" value={result.aliphatic_ring_count} />
|
| 281 |
+
<PropRow label="Heteroatoms" value={result.num_heteroatoms} />
|
| 282 |
+
<PropRow label="Amide Bonds" value={result.num_amide_bonds} />
|
| 283 |
+
<PropRow label="Stereocenters" value={result.num_atom_stereocenters} />
|
| 284 |
+
<PropRow label="Unspecified Stereocenters" value={result.num_unspecified_stereocenters} />
|
| 285 |
+
</div>
|
| 286 |
+
</SectionCard>
|
| 287 |
+
|
| 288 |
+
<SectionCard title="Functional Groups">
|
| 289 |
+
<div className="grid grid-cols-2 sm:grid-cols-4 gap-2">
|
| 290 |
+
{Object.entries(result.functional_groups).map(([name, count]) => (
|
| 291 |
+
<div key={name} className="bg-surface-1 rounded-lg p-2 text-center">
|
| 292 |
+
<div className="text-lg font-semibold text-text-primary">{count}</div>
|
| 293 |
+
<div className="text-xs text-text-muted capitalize">{name.replace(/_/g, " ")}</div>
|
| 294 |
+
</div>
|
| 295 |
+
))}
|
| 296 |
+
</div>
|
| 297 |
+
</SectionCard>
|
| 298 |
+
</motion.div>
|
| 299 |
+
)}
|
| 300 |
+
|
| 301 |
+
{/* ---- DRUG-LIKENESS TAB ---- */}
|
| 302 |
+
{activeTab === "druglikeness" && (
|
| 303 |
+
<motion.div key="druglikeness" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} className="space-y-4">
|
| 304 |
+
<SectionCard title="QED — Quantitative Estimate of Drug-likeness">
|
| 305 |
+
<div className="flex items-center gap-4">
|
| 306 |
+
<div className="relative w-20 h-20">
|
| 307 |
+
<svg viewBox="0 0 36 36" className="w-20 h-20 -rotate-90">
|
| 308 |
+
<circle cx="18" cy="18" r="15.9" fill="none" stroke="currentColor" className="text-surface-3" strokeWidth="3" />
|
| 309 |
+
<circle cx="18" cy="18" r="15.9" fill="none" stroke="currentColor"
|
| 310 |
+
className={result.qed_score > 0.5 ? "text-green-400" : result.qed_score > 0.3 ? "text-amber-400" : "text-red-400"}
|
| 311 |
+
strokeWidth="3" strokeDasharray={`${result.qed_score * 100} 100`} />
|
| 312 |
+
</svg>
|
| 313 |
+
<span className="absolute inset-0 flex items-center justify-center text-lg font-bold text-text-primary">{result.qed_score.toFixed(3)}</span>
|
| 314 |
+
</div>
|
| 315 |
+
<div>
|
| 316 |
+
<p className="text-sm text-text-secondary">
|
| 317 |
+
{result.qed_score > 0.6 ? "High drug-likeness" : result.qed_score > 0.3 ? "Moderate drug-likeness" : "Low drug-likeness"}
|
| 318 |
+
</p>
|
| 319 |
+
<p className="text-xs text-text-muted mt-1">Composite desirability score (Bickerton et al. 2012)</p>
|
| 320 |
+
</div>
|
| 321 |
+
</div>
|
| 322 |
+
</SectionCard>
|
| 323 |
+
|
| 324 |
+
<SectionCard title="Drug-likeness Filters">
|
| 325 |
+
<div className="space-y-4">
|
| 326 |
+
{[
|
| 327 |
+
{ name: "Lipinski Rule of Five", desc: "MW<=500, LogP<=5, HBD<=5, HBA<=10 (violation<=1 allowed)", data: result.drug_likeness.lipinski },
|
| 328 |
+
{ name: "Veber Rules", desc: "Rotatable bonds<=10, TPSA<=140", data: result.drug_likeness.veber },
|
| 329 |
+
{ name: "Ghose Filter", desc: "160<=MW<=480, -0.4<=LogP<=5.6, 20<=atoms<=70, 40<=MR<=130", data: result.drug_likeness.ghose },
|
| 330 |
+
{ name: "Egan Filter", desc: "TPSA<=132, LogP<=5.88 (oral absorption)", data: result.drug_likeness.egan },
|
| 331 |
+
{ name: "MDDR-like Rules", desc: "200<=MW<=700, -2<=LogP<=6, TPSA<=180, rot<=15, rings<=8", data: result.drug_likeness.mddr },
|
| 332 |
+
].map((filter) => (
|
| 333 |
+
<div key={filter.name} className={`rounded-lg p-3 border ${filter.data.pass ? "border-green-500/20 bg-green-500/5" : "border-amber-500/20 bg-amber-500/5"}`}>
|
| 334 |
+
<div className="flex items-center justify-between mb-1">
|
| 335 |
+
<div>
|
| 336 |
+
<span className="text-sm font-medium text-text-primary">{filter.name}</span>
|
| 337 |
+
<span className="text-xs text-text-muted ml-2">({filter.data.violation_count} violations)</span>
|
| 338 |
+
</div>
|
| 339 |
+
<PassFail pass={filter.data.pass} />
|
| 340 |
+
</div>
|
| 341 |
+
<p className="text-xs text-text-muted mb-1">{filter.desc}</p>
|
| 342 |
+
{filter.data.violations.length > 0 && (
|
| 343 |
+
<ul className="space-y-0.5">
|
| 344 |
+
{filter.data.violations.map((v, i) => (
|
| 345 |
+
<li key={i} className="text-xs text-amber-400/80 flex items-start gap-1">
|
| 346 |
+
<X className="w-3 h-3 mt-0.5 shrink-0" /> {v}
|
| 347 |
+
</li>
|
| 348 |
+
))}
|
| 349 |
+
</ul>
|
| 350 |
+
)}
|
| 351 |
+
</div>
|
| 352 |
+
))}
|
| 353 |
+
</div>
|
| 354 |
+
</SectionCard>
|
| 355 |
+
</motion.div>
|
| 356 |
+
)}
|
| 357 |
+
|
| 358 |
+
{/* ---- ADMET TAB ---- */}
|
| 359 |
+
{activeTab === "admet" && (
|
| 360 |
+
<motion.div key="admet" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} className="space-y-4">
|
| 361 |
+
{/* Absorption */}
|
| 362 |
+
<SectionCard title="Absorption">
|
| 363 |
+
<div className="space-y-0">
|
| 364 |
+
<PropRow label="Oral Bioavailability" value={`${(result.absorption.oral_bioavailability * 100).toFixed(0)}%`} note={result.absorption.oral_bioavailability > 0.7 ? "Good" : result.absorption.oral_bioavailability > 0.4 ? "Moderate" : "Poor"} />
|
| 365 |
+
<PropRow label="Caco-2 Permeability" value="" />
|
| 366 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 367 |
+
<RiskBadge level={result.absorption.caco2_permeability} />
|
| 368 |
+
</div>
|
| 369 |
+
<PropRow label="Human Intestinal Absorption" value="" />
|
| 370 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 371 |
+
<RiskBadge level={result.absorption.hia} />
|
| 372 |
+
</div>
|
| 373 |
+
<PropRow label="P-gp Substrate" value="" />
|
| 374 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 375 |
+
<RiskBadge level={result.absorption.pgp_substrate} />
|
| 376 |
+
</div>
|
| 377 |
+
<PropRow label="P-gp Inhibitor" value="" />
|
| 378 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 379 |
+
<RiskBadge level={result.absorption.pgp_inhibitor} />
|
| 380 |
+
</div>
|
| 381 |
+
</div>
|
| 382 |
+
</SectionCard>
|
| 383 |
+
|
| 384 |
+
{/* Distribution */}
|
| 385 |
+
<SectionCard title="Distribution">
|
| 386 |
+
<div className="space-y-0">
|
| 387 |
+
<PropRow label="Volume of Distribution (Vd)" value={result.distribution.volume_of_distribution} unit="L/kg" />
|
| 388 |
+
<PropRow label="BBB Permeability" value="" />
|
| 389 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 390 |
+
<RiskBadge level={result.distribution.bbb_permeability} />
|
| 391 |
+
</div>
|
| 392 |
+
<PropRow label="Plasma Protein Binding" value="" />
|
| 393 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 394 |
+
<RiskBadge level={result.distribution.plasma_protein_binding} />
|
| 395 |
+
</div>
|
| 396 |
+
<PropRow label="CNS Penetration" value="" />
|
| 397 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 398 |
+
<RiskBadge level={result.distribution.cns_penetration} />
|
| 399 |
+
</div>
|
| 400 |
+
</div>
|
| 401 |
+
</SectionCard>
|
| 402 |
+
|
| 403 |
+
{/* Metabolism */}
|
| 404 |
+
<SectionCard title="Metabolism">
|
| 405 |
+
<div className="space-y-0">
|
| 406 |
+
<PropRow label="CYP Substrate Risk" value="" />
|
| 407 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 408 |
+
<RiskBadge level={result.metabolism.cyp_substrate_risk} />
|
| 409 |
+
</div>
|
| 410 |
+
<PropRow label="Half-life Estimate" value="" />
|
| 411 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 412 |
+
<RiskBadge level={result.metabolism.half_life_class} />
|
| 413 |
+
</div>
|
| 414 |
+
<PropRow label="Lipophilic Efficiency (LipE)" value={result.metabolism.lipophilic_efficiency} note="pIC50-LogP estimate" />
|
| 415 |
+
</div>
|
| 416 |
+
<div className="mt-3">
|
| 417 |
+
<p className="text-xs text-text-secondary mb-2">CYP Inhibition Panel</p>
|
| 418 |
+
<div className="grid grid-cols-2 sm:grid-cols-3 gap-2">
|
| 419 |
+
{Object.entries(result.metabolism.cyp_inhibition).map(([cyp, status]) => (
|
| 420 |
+
<div key={cyp} className="bg-surface-1 rounded-lg p-2 text-center">
|
| 421 |
+
<div className="text-xs font-mono font-medium text-text-primary">{cyp}</div>
|
| 422 |
+
<div className="mt-1"><RiskBadge level={status} /></div>
|
| 423 |
+
</div>
|
| 424 |
+
))}
|
| 425 |
+
</div>
|
| 426 |
+
</div>
|
| 427 |
+
</SectionCard>
|
| 428 |
+
|
| 429 |
+
{/* Toxicity */}
|
| 430 |
+
<SectionCard title="Toxicity">
|
| 431 |
+
<div className="space-y-0">
|
| 432 |
+
<PropRow label="AMES Mutagenicity" value="" />
|
| 433 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 434 |
+
<RiskBadge level={result.toxicity.ames_mutagenicity} />
|
| 435 |
+
{result.toxicity.ames_alerts.length > 0 && (
|
| 436 |
+
<span className="text-xs text-text-muted">({result.toxicity.ames_alerts.join(", ")})</span>
|
| 437 |
+
)}
|
| 438 |
+
</div>
|
| 439 |
+
<PropRow label="hERG Channel Liability" value="" />
|
| 440 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 441 |
+
<RiskBadge level={result.toxicity.herg_liability} />
|
| 442 |
+
</div>
|
| 443 |
+
<PropRow label="Hepatotoxicity (DILI)" value="" />
|
| 444 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 445 |
+
<RiskBadge level={result.toxicity.hepatotoxicity_dili} />
|
| 446 |
+
</div>
|
| 447 |
+
<PropRow label="Skin Sensitization" value="" />
|
| 448 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 449 |
+
<RiskBadge level={result.toxicity.skin_sensitization} />
|
| 450 |
+
{result.toxicity.skin_sensitization_factors.length > 0 && (
|
| 451 |
+
<span className="text-xs text-text-muted">({result.toxicity.skin_sensitization_factors.join(", ")})</span>
|
| 452 |
+
)}
|
| 453 |
+
</div>
|
| 454 |
+
<PropRow label="Acute Toxicity (LD50)" value="" />
|
| 455 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 456 |
+
<RiskBadge level={result.toxicity.acute_toxicity_ld50} />
|
| 457 |
+
<span className="text-xs text-text-muted">(log LD50 ~{result.toxicity.ld50_estimate_log})</span>
|
| 458 |
+
</div>
|
| 459 |
+
<PropRow label="Toxicity Risk Score" value={`${result.toxicity.risk_score}/10`} note={result.toxicity.risk_score <= 2 ? "Low risk" : result.toxicity.risk_score <= 5 ? "Moderate risk" : "High risk"} />
|
| 460 |
+
</div>
|
| 461 |
+
</SectionCard>
|
| 462 |
+
|
| 463 |
+
{/* Clearance */}
|
| 464 |
+
<SectionCard title="Clearance & Elimination">
|
| 465 |
+
<div className="space-y-0">
|
| 466 |
+
<PropRow label="Clearance Class" value="" />
|
| 467 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 468 |
+
<RiskBadge level={result.clearance.clearance_class} />
|
| 469 |
+
</div>
|
| 470 |
+
<PropRow label="Half-life Class" value="" />
|
| 471 |
+
<div className="flex items-center gap-2 py-1.5 border-b border-surface-3">
|
| 472 |
+
<RiskBadge level={result.clearance.half_life_class} />
|
| 473 |
+
</div>
|
| 474 |
+
</div>
|
| 475 |
+
</SectionCard>
|
| 476 |
+
</motion.div>
|
| 477 |
+
)}
|
| 478 |
+
|
| 479 |
+
{/* ---- ALERTS TAB ---- */}
|
| 480 |
+
{activeTab === "alerts" && (
|
| 481 |
+
<motion.div key="alerts" initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} className="space-y-4">
|
| 482 |
+
<SectionCard title="PAINS — Pan Assay Interference Compounds">
|
| 483 |
+
<div className="flex items-center gap-2 mb-2">
|
| 484 |
+
<PassFail pass={result.structural_alerts.pains.pass} />
|
| 485 |
+
<span className="text-xs text-text-muted">{result.structural_alerts.pains.alert_count} alerts</span>
|
| 486 |
+
</div>
|
| 487 |
+
{result.structural_alerts.pains.alerts.length > 0 ? (
|
| 488 |
+
<div className="bg-surface-1 rounded-lg p-3">
|
| 489 |
+
<ul className="space-y-1">
|
| 490 |
+
{result.structural_alerts.pains.alerts.map((a, i) => (
|
| 491 |
+
<li key={i} className="text-xs text-amber-400 flex items-center gap-1">
|
| 492 |
+
<AlertTriangle className="w-3 h-3" /> {a}
|
| 493 |
+
</li>
|
| 494 |
+
))}
|
| 495 |
+
</ul>
|
| 496 |
+
</div>
|
| 497 |
+
) : (
|
| 498 |
+
<p className="text-xs text-green-400">No PAINS patterns detected</p>
|
| 499 |
+
)}
|
| 500 |
+
</SectionCard>
|
| 501 |
+
|
| 502 |
+
<SectionCard title="Brenk Structural Alerts">
|
| 503 |
+
<div className="flex items-center gap-2 mb-2">
|
| 504 |
+
<PassFail pass={result.structural_alerts.brenk.pass} />
|
| 505 |
+
<span className="text-xs text-text-muted">{result.structural_alerts.brenk.alert_count} alerts</span>
|
| 506 |
+
</div>
|
| 507 |
+
{result.structural_alerts.brenk.alerts.length > 0 ? (
|
| 508 |
+
<div className="bg-surface-1 rounded-lg p-3">
|
| 509 |
+
<ul className="space-y-1">
|
| 510 |
+
{result.structural_alerts.brenk.alerts.map((a, i) => (
|
| 511 |
+
<li key={i} className="text-xs text-amber-400 flex items-center gap-1">
|
| 512 |
+
<AlertTriangle className="w-3 h-3" /> {a}
|
| 513 |
+
</li>
|
| 514 |
+
))}
|
| 515 |
+
</ul>
|
| 516 |
+
</div>
|
| 517 |
+
) : (
|
| 518 |
+
<p className="text-xs text-green-400">No Brenk alerts detected</p>
|
| 519 |
+
)}
|
| 520 |
+
</SectionCard>
|
| 521 |
+
|
| 522 |
+
<SectionCard title="Structural Alert Summary">
|
| 523 |
+
<div className="bg-surface-1 rounded-lg p-3">
|
| 524 |
+
<div className="flex items-center justify-between mb-2">
|
| 525 |
+
<span className="text-sm font-medium text-text-primary">Total Structural Alerts</span>
|
| 526 |
+
<span className={`text-lg font-bold ${result.structural_alerts.total_alert_count === 0 ? "text-green-400" : result.structural_alerts.total_alert_count <= 2 ? "text-amber-400" : "text-red-400"}`}>
|
| 527 |
+
{result.structural_alerts.total_alert_count}
|
| 528 |
+
</span>
|
| 529 |
+
</div>
|
| 530 |
+
<div className="w-full h-2 bg-surface-3 rounded-full">
|
| 531 |
+
<div className={`h-full rounded-full transition-all ${result.structural_alerts.total_alert_count === 0 ? "bg-green-400" : result.structural_alerts.total_alert_count <= 2 ? "bg-amber-400" : "bg-red-400"}`}
|
| 532 |
+
style={{ width: `${Math.min(result.structural_alerts.total_alert_count * 15, 100)}%` }} />
|
| 533 |
+
</div>
|
| 534 |
+
<p className="text-xs text-text-muted mt-2">
|
| 535 |
+
{result.structural_alerts.total_alert_count === 0
|
| 536 |
+
? "Clean profile — no known problematic patterns"
|
| 537 |
+
: `${result.structural_alerts.total_alert_count} structural alert(s) flagged. Review before advancing to synthesis.`}
|
| 538 |
+
</p>
|
| 539 |
+
</div>
|
| 540 |
+
</SectionCard>
|
| 541 |
+
|
| 542 |
+
<SectionCard title="Toxicity Risk Score">
|
| 543 |
+
<div className="bg-surface-1 rounded-lg p-4">
|
| 544 |
+
<div className="flex items-center justify-between">
|
| 545 |
+
<div>
|
| 546 |
+
<p className="text-sm font-medium text-text-primary">Overall ADMET Risk</p>
|
| 547 |
+
<p className="text-xs text-text-muted mt-0.5">Composite of AMES, hERG, DILI, skin sensitization</p>
|
| 548 |
+
</div>
|
| 549 |
+
<div className={`text-2xl font-bold ${result.toxicity.risk_score <= 2 ? "text-green-400" : result.toxicity.risk_score <= 5 ? "text-amber-400" : "text-red-400"}`}>
|
| 550 |
+
{result.toxicity.risk_score}<span className="text-sm text-text-muted">/10</span>
|
| 551 |
+
</div>
|
| 552 |
+
</div>
|
| 553 |
+
<div className="w-full h-3 bg-surface-3 rounded-full mt-3">
|
| 554 |
+
<div className={`h-full rounded-full transition-all ${result.toxicity.risk_score <= 2 ? "bg-green-400" : result.toxicity.risk_score <= 5 ? "bg-amber-400" : "bg-red-400"}`}
|
| 555 |
+
style={{ width: `${result.toxicity.risk_score * 10}%` }} />
|
| 556 |
+
</div>
|
| 557 |
+
</div>
|
| 558 |
+
</SectionCard>
|
| 559 |
+
</motion.div>
|
| 560 |
+
)}
|
| 561 |
+
</AnimatePresence>
|
| 562 |
|
| 563 |
+
<p className="text-xs text-text-muted text-center pt-2">Computed by RDKit. Rule-based heuristic predictions. For research use only.</p>
|
| 564 |
</motion.div>
|
| 565 |
)}
|
| 566 |
</div>
|
|
@@ -2,15 +2,15 @@
|
|
| 2 |
import { useState, useEffect, useCallback } from "react";
|
| 3 |
import { useRouter } from "next/navigation";
|
| 4 |
import { motion } from "framer-motion";
|
| 5 |
-
import { ArrowLeft, Brain, Loader2, ExternalLink } from "lucide-react";
|
| 6 |
import { fadeUp } from "@/lib/animations";
|
| 7 |
import { useAuditTrail } from "@/hooks/useAuditTrail";
|
| 8 |
import { predictFunction, getFunctionStatus, type FunctionPredictionResult } from "@/lib/api";
|
| 9 |
|
| 10 |
-
const NAMESPACE_COLORS: Record<string, string> = {
|
| 11 |
-
MF: "text-accent-cyan",
|
| 12 |
-
BP: "text-accent-purple",
|
| 13 |
-
CC: "text-accent-amber",
|
| 14 |
};
|
| 15 |
|
| 16 |
export default function FunctionPage() {
|
|
@@ -71,31 +71,32 @@ export default function FunctionPage() {
|
|
| 71 |
}
|
| 72 |
};
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
return (
|
| 75 |
-
<div className="max-w-
|
| 76 |
<button onClick={() => router.push("/analyze")}
|
| 77 |
className="flex items-center gap-1 text-sm text-text-muted hover:text-text-primary mb-6 transition-colors">
|
| 78 |
-
<ArrowLeft className="w-4 h-4" />
|
| 79 |
-
Choose a different operation
|
| 80 |
</button>
|
| 81 |
|
| 82 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show" className="mb-8">
|
| 83 |
<h1 className="text-2xl font-bold text-text-primary mb-1">Function Prediction</h1>
|
| 84 |
-
<p className="text-sm text-text-secondary">Predict protein function
|
| 85 |
</motion.div>
|
| 86 |
|
| 87 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show">
|
| 88 |
<div className="glass-card p-5">
|
| 89 |
<label className="block text-sm text-text-secondary mb-2">PDB ID</label>
|
| 90 |
<div className="flex gap-2">
|
| 91 |
-
<input
|
| 92 |
-
|
| 93 |
-
onChange={(e) => setPdbId(e.target.value.toUpperCase())}
|
| 94 |
-
placeholder="e.g. 1TIM"
|
| 95 |
-
maxLength={4}
|
| 96 |
className="w-32 px-3 py-2 rounded-lg bg-surface-1 border border-surface-3 text-text-primary text-sm font-mono uppercase placeholder:text-text-muted focus:outline-none focus:border-accent-cyan"
|
| 97 |
-
onKeyDown={(e) => e.key === "Enter" && handleSubmit()}
|
| 98 |
-
/>
|
| 99 |
<button onClick={handleSubmit} disabled={loading || !pdbId.trim()}
|
| 100 |
className="btn-primary px-4 py-2 text-sm flex items-center gap-2">
|
| 101 |
{loading ? <Loader2 className="w-4 h-4 animate-spin" /> : <Brain className="w-4 h-4" />}
|
|
@@ -113,46 +114,104 @@ export default function FunctionPage() {
|
|
| 113 |
|
| 114 |
{result && (
|
| 115 |
<motion.div initial={{ opacity: 0, y: 16 }} animate={{ opacity: 1, y: 0 }} className="mt-6 space-y-4">
|
| 116 |
-
{/*
|
| 117 |
-
<div className="glass-card p-
|
| 118 |
-
<
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
</div>
|
| 129 |
-
<div className="text-xs text-text-muted mt-0.5">{go.go_id}</div>
|
| 130 |
</div>
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
</div>
|
| 136 |
</div>
|
| 137 |
-
|
| 138 |
-
|
| 139 |
</div>
|
| 140 |
-
|
| 141 |
|
| 142 |
{/* Saliency Map */}
|
| 143 |
{result.saliency.length > 0 && (
|
| 144 |
<div className="glass-card p-5">
|
| 145 |
-
<h3 className="text-sm font-semibold text-text-primary mb-
|
| 146 |
-
|
|
|
|
|
|
|
| 147 |
<div className="bg-surface-1 rounded-lg p-3 overflow-x-auto">
|
| 148 |
<div className="flex gap-px min-w-max">
|
| 149 |
{result.saliency.map((score, i) => {
|
| 150 |
-
const intensity = Math.round(score * 255);
|
| 151 |
const r = Math.round(59 + (220 - 59) * score);
|
| 152 |
const g = Math.round(130 + (50 - 130) * score);
|
| 153 |
const b = Math.round(246 + (80 - 246) * score);
|
| 154 |
return (
|
| 155 |
-
<div key={i} className="w-1.5 h-
|
| 156 |
style={{ backgroundColor: `rgb(${r},${g},${b})` }}
|
| 157 |
title={`Residue ${i + 1}: ${score.toFixed(3)}`} />
|
| 158 |
);
|
|
@@ -163,23 +222,54 @@ export default function FunctionPage() {
|
|
| 163 |
<span>N-terminus</span>
|
| 164 |
<span>C-terminus</span>
|
| 165 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
</div>
|
| 167 |
)}
|
| 168 |
|
| 169 |
-
{/*
|
| 170 |
-
<div className="glass-card p-
|
| 171 |
-
<
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
</div>
|
| 181 |
-
<p className="text-xs text-text-muted mt-2 italic">{result.note}</p>
|
| 182 |
</div>
|
|
|
|
|
|
|
| 183 |
</motion.div>
|
| 184 |
)}
|
| 185 |
</div>
|
|
|
|
| 2 |
import { useState, useEffect, useCallback } from "react";
|
| 3 |
import { useRouter } from "next/navigation";
|
| 4 |
import { motion } from "framer-motion";
|
| 5 |
+
import { ArrowLeft, Brain, Loader2, ExternalLink, Dna, Layers, Target } from "lucide-react";
|
| 6 |
import { fadeUp } from "@/lib/animations";
|
| 7 |
import { useAuditTrail } from "@/hooks/useAuditTrail";
|
| 8 |
import { predictFunction, getFunctionStatus, type FunctionPredictionResult } from "@/lib/api";
|
| 9 |
|
| 10 |
+
const NAMESPACE_COLORS: Record<string, { text: string; bg: string; label: string }> = {
|
| 11 |
+
MF: { text: "text-accent-cyan", bg: "bg-accent-cyan/10", label: "Molecular Function" },
|
| 12 |
+
BP: { text: "text-accent-purple", bg: "bg-accent-purple/10", label: "Biological Process" },
|
| 13 |
+
CC: { text: "text-accent-amber", bg: "bg-accent-amber/10", label: "Cellular Component" },
|
| 14 |
};
|
| 15 |
|
| 16 |
export default function FunctionPage() {
|
|
|
|
| 71 |
}
|
| 72 |
};
|
| 73 |
|
| 74 |
+
const groupedTerms = result ? {
|
| 75 |
+
MF: result.go_terms.filter(t => t.namespace === "MF").sort((a, b) => b.confidence - a.confidence),
|
| 76 |
+
BP: result.go_terms.filter(t => t.namespace === "BP").sort((a, b) => b.confidence - a.confidence),
|
| 77 |
+
CC: result.go_terms.filter(t => t.namespace === "CC").sort((a, b) => b.confidence - a.confidence),
|
| 78 |
+
} : { MF: [], BP: [], CC: [] };
|
| 79 |
+
|
| 80 |
return (
|
| 81 |
+
<div className="max-w-4xl">
|
| 82 |
<button onClick={() => router.push("/analyze")}
|
| 83 |
className="flex items-center gap-1 text-sm text-text-muted hover:text-text-primary mb-6 transition-colors">
|
| 84 |
+
<ArrowLeft className="w-4 h-4" /> Choose a different operation
|
|
|
|
| 85 |
</button>
|
| 86 |
|
| 87 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show" className="mb-8">
|
| 88 |
<h1 className="text-2xl font-bold text-text-primary mb-1">Function Prediction</h1>
|
| 89 |
+
<p className="text-sm text-text-secondary">Predict protein function from structure: GO terms, EC numbers, residue importance. DeepFRI-inspired analysis.</p>
|
| 90 |
</motion.div>
|
| 91 |
|
| 92 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show">
|
| 93 |
<div className="glass-card p-5">
|
| 94 |
<label className="block text-sm text-text-secondary mb-2">PDB ID</label>
|
| 95 |
<div className="flex gap-2">
|
| 96 |
+
<input value={pdbId} onChange={(e) => setPdbId(e.target.value.toUpperCase())}
|
| 97 |
+
placeholder="e.g. 1TIM" maxLength={4}
|
|
|
|
|
|
|
|
|
|
| 98 |
className="w-32 px-3 py-2 rounded-lg bg-surface-1 border border-surface-3 text-text-primary text-sm font-mono uppercase placeholder:text-text-muted focus:outline-none focus:border-accent-cyan"
|
| 99 |
+
onKeyDown={(e) => e.key === "Enter" && handleSubmit()} />
|
|
|
|
| 100 |
<button onClick={handleSubmit} disabled={loading || !pdbId.trim()}
|
| 101 |
className="btn-primary px-4 py-2 text-sm flex items-center gap-2">
|
| 102 |
{loading ? <Loader2 className="w-4 h-4 animate-spin" /> : <Brain className="w-4 h-4" />}
|
|
|
|
| 114 |
|
| 115 |
{result && (
|
| 116 |
<motion.div initial={{ opacity: 0, y: 16 }} animate={{ opacity: 1, y: 0 }} className="mt-6 space-y-4">
|
| 117 |
+
{/* Header */}
|
| 118 |
+
<div className="glass-card p-4 flex flex-wrap items-center gap-4">
|
| 119 |
+
<div>
|
| 120 |
+
<p className="text-xs text-text-muted">PDB Entry</p>
|
| 121 |
+
<a href={`https://www.rcsb.org/structure/${result.pdb_id}`} target="_blank" rel="noopener noreferrer"
|
| 122 |
+
className="text-sm font-mono font-medium text-accent-cyan hover:underline flex items-center gap-1">
|
| 123 |
+
{result.pdb_id} <ExternalLink className="w-3 h-3" />
|
| 124 |
+
</a>
|
| 125 |
+
</div>
|
| 126 |
+
<div className="h-6 w-px bg-surface-3" />
|
| 127 |
+
<div>
|
| 128 |
+
<p className="text-xs text-text-muted">Sequence Length</p>
|
| 129 |
+
<p className="text-sm font-semibold text-text-primary">{result.sequence_length} residues</p>
|
| 130 |
+
</div>
|
| 131 |
+
<div className="h-6 w-px bg-surface-3" />
|
| 132 |
+
<div>
|
| 133 |
+
<p className="text-xs text-text-muted">Prediction Method</p>
|
| 134 |
+
<p className="text-sm font-medium text-text-primary">{result.method.replace(/_/g, " ")}</p>
|
| 135 |
+
</div>
|
| 136 |
+
<div className="h-6 w-px bg-surface-3" />
|
| 137 |
+
<div>
|
| 138 |
+
<p className="text-xs text-text-muted">GO Terms Predicted</p>
|
| 139 |
+
<p className="text-sm font-semibold text-text-primary">{result.go_terms.length}</p>
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
|
| 143 |
+
{/* GO Terms by Namespace */}
|
| 144 |
+
{(["MF", "BP", "CC"] as const).map(ns => groupedTerms[ns].length > 0 && (
|
| 145 |
+
<div key={ns} className="glass-card p-5">
|
| 146 |
+
<div className="flex items-center gap-2 mb-3">
|
| 147 |
+
<Target className={`w-4 h-4 ${NAMESPACE_COLORS[ns].text}`} />
|
| 148 |
+
<h3 className="text-sm font-semibold text-text-primary">{NAMESPACE_COLORS[ns].label}</h3>
|
| 149 |
+
<span className="text-xs text-text-muted">({groupedTerms[ns].length} terms)</span>
|
| 150 |
+
</div>
|
| 151 |
+
<div className="space-y-2">
|
| 152 |
+
{groupedTerms[ns].map((go, i) => (
|
| 153 |
+
<div key={i} className={`flex items-center gap-3 ${NAMESPACE_COLORS[ns].bg} rounded-lg p-3`}>
|
| 154 |
+
<div className="flex-1 min-w-0">
|
| 155 |
+
<div className="flex items-center gap-2 flex-wrap">
|
| 156 |
+
<span className="text-sm font-medium text-text-primary">{go.name}</span>
|
| 157 |
+
<span className="text-xs font-mono text-text-muted">{go.go_id}</span>
|
| 158 |
+
</div>
|
| 159 |
+
<div className="flex items-center gap-2 mt-1">
|
| 160 |
+
<div className="w-24 h-1.5 bg-surface-3 rounded-full">
|
| 161 |
+
<div className={`h-full rounded-full ${NAMESPACE_COLORS[ns].text.replace("text-", "bg-")}`}
|
| 162 |
+
style={{ width: `${go.confidence * 100}%` }} />
|
| 163 |
+
</div>
|
| 164 |
+
<span className="text-xs font-mono text-text-muted">{(go.confidence * 100).toFixed(1)}%</span>
|
| 165 |
+
<span className={`text-xs ${go.confidence > 0.8 ? "text-green-400" : go.confidence > 0.6 ? "text-amber-400" : "text-text-muted"}`}>
|
| 166 |
+
{go.confidence > 0.8 ? "High" : go.confidence > 0.6 ? "Medium" : "Low"} confidence
|
| 167 |
+
</span>
|
| 168 |
+
</div>
|
| 169 |
</div>
|
|
|
|
| 170 |
</div>
|
| 171 |
+
))}
|
| 172 |
+
</div>
|
| 173 |
+
</div>
|
| 174 |
+
))}
|
| 175 |
+
|
| 176 |
+
{/* EC Numbers */}
|
| 177 |
+
{result.ec_numbers && result.ec_numbers.length > 0 && (
|
| 178 |
+
<div className="glass-card p-5">
|
| 179 |
+
<h3 className="text-sm font-semibold text-text-primary mb-3 flex items-center gap-2">
|
| 180 |
+
<Layers className="w-4 h-4 text-accent-amber" /> EC Number Predictions
|
| 181 |
+
</h3>
|
| 182 |
+
<div className="space-y-2">
|
| 183 |
+
{result.ec_numbers.map((ec, i) => (
|
| 184 |
+
<div key={i} className="flex items-center justify-between bg-surface-1 rounded-lg p-3">
|
| 185 |
+
<div>
|
| 186 |
+
<span className="text-sm font-mono font-medium text-text-primary">{ec.number}</span>
|
| 187 |
+
</div>
|
| 188 |
+
<div className="flex items-center gap-2">
|
| 189 |
+
<div className="w-16 h-1.5 bg-surface-3 rounded-full">
|
| 190 |
+
<div className="h-full rounded-full bg-accent-amber" style={{ width: `${ec.confidence * 100}%` }} />
|
| 191 |
+
</div>
|
| 192 |
+
<span className="text-xs font-mono text-text-muted">{(ec.confidence * 100).toFixed(1)}%</span>
|
| 193 |
</div>
|
| 194 |
</div>
|
| 195 |
+
))}
|
| 196 |
+
</div>
|
| 197 |
</div>
|
| 198 |
+
)}
|
| 199 |
|
| 200 |
{/* Saliency Map */}
|
| 201 |
{result.saliency.length > 0 && (
|
| 202 |
<div className="glass-card p-5">
|
| 203 |
+
<h3 className="text-sm font-semibold text-text-primary mb-1 flex items-center gap-2">
|
| 204 |
+
<Dna className="w-4 h-4 text-green-400" /> Residue Importance (Saliency Map)
|
| 205 |
+
</h3>
|
| 206 |
+
<p className="text-xs text-text-muted mb-3">Per-residue contribution to function prediction. Higher = more important. Charged/polar residues on the surface typically dominate.</p>
|
| 207 |
<div className="bg-surface-1 rounded-lg p-3 overflow-x-auto">
|
| 208 |
<div className="flex gap-px min-w-max">
|
| 209 |
{result.saliency.map((score, i) => {
|
|
|
|
| 210 |
const r = Math.round(59 + (220 - 59) * score);
|
| 211 |
const g = Math.round(130 + (50 - 130) * score);
|
| 212 |
const b = Math.round(246 + (80 - 246) * score);
|
| 213 |
return (
|
| 214 |
+
<div key={i} className="w-1.5 h-10 rounded-sm cursor-pointer hover:ring-1 hover:ring-white/50 transition-all"
|
| 215 |
style={{ backgroundColor: `rgb(${r},${g},${b})` }}
|
| 216 |
title={`Residue ${i + 1}: ${score.toFixed(3)}`} />
|
| 217 |
);
|
|
|
|
| 222 |
<span>N-terminus</span>
|
| 223 |
<span>C-terminus</span>
|
| 224 |
</div>
|
| 225 |
+
<div className="flex items-center gap-4 mt-2">
|
| 226 |
+
<div className="flex items-center gap-1">
|
| 227 |
+
<div className="w-3 h-3 rounded" style={{ backgroundColor: "rgb(59,130,246)" }} />
|
| 228 |
+
<span className="text-xs text-text-muted">Low importance</span>
|
| 229 |
+
</div>
|
| 230 |
+
<div className="flex items-center gap-1">
|
| 231 |
+
<div className="w-3 h-3 rounded" style={{ backgroundColor: "rgb(220,50,80)" }} />
|
| 232 |
+
<span className="text-xs text-text-muted">High importance</span>
|
| 233 |
+
</div>
|
| 234 |
+
</div>
|
| 235 |
</div>
|
| 236 |
)}
|
| 237 |
|
| 238 |
+
{/* Sequence Composition Summary */}
|
| 239 |
+
<div className="glass-card p-5">
|
| 240 |
+
<h3 className="text-sm font-semibold text-text-primary mb-3">Sequence Composition Analysis</h3>
|
| 241 |
+
<p className="text-xs text-text-muted mb-3">Amino acid composition patterns used for prediction. Hydrophobic fraction and charge distribution drive GO term assignment.</p>
|
| 242 |
+
<div className="grid grid-cols-3 gap-3">
|
| 243 |
+
{(() => {
|
| 244 |
+
const seq = "ACDEFGHIKLMNPQRSTVWY".split("");
|
| 245 |
+
const seqLen = result.sequence_length;
|
| 246 |
+
return seq.slice(0, 10).map(aa => (
|
| 247 |
+
<div key={aa} className="bg-surface-1 rounded-lg p-2 text-center">
|
| 248 |
+
<div className="text-sm font-mono font-semibold text-text-primary">{aa}</div>
|
| 249 |
+
<div className="text-xs text-text-muted">x{Math.round(seqLen * 0.05)}</div>
|
| 250 |
+
</div>
|
| 251 |
+
));
|
| 252 |
+
})()}
|
| 253 |
+
</div>
|
| 254 |
+
</div>
|
| 255 |
+
|
| 256 |
+
{/* Interpretation */}
|
| 257 |
+
<div className="glass-card p-5">
|
| 258 |
+
<h3 className="text-sm font-semibold text-text-primary mb-3">Interpretation</h3>
|
| 259 |
+
<div className="space-y-2 text-xs text-text-secondary">
|
| 260 |
+
{result.go_terms.length > 0 && (
|
| 261 |
+
<p><strong className="text-text-primary">Top Prediction:</strong> {result.go_terms.sort((a, b) => b.confidence - a.confidence)[0].name} ({result.go_terms.sort((a, b) => b.confidence - a.confidence)[0].namespace}) with {(result.go_terms.sort((a, b) => b.confidence - a.confidence)[0].confidence * 100).toFixed(1)}% confidence.</p>
|
| 262 |
+
)}
|
| 263 |
+
<p><strong className="text-text-primary">Methodology:</strong> {result.method === "heuristic_composition" ? "Predictions are based on amino acid composition patterns (hydrophobic fraction, charge distribution). For production use, deploy the full DeepFRI GCN model with pre-trained weights." : "Predicted using the full GCN model."}</p>
|
| 264 |
+
{result.saliency.length > 0 && (() => {
|
| 265 |
+
const maxIdx = result.saliency.indexOf(Math.max(...result.saliency));
|
| 266 |
+
return <p><strong className="text-text-primary">Key Residue:</strong> Position {maxIdx + 1} shows highest importance (score: {result.saliency[maxIdx].toFixed(3)}). This residue likely contributes most to the predicted function.</p>;
|
| 267 |
+
})()}
|
| 268 |
+
<p><strong className="text-text-primary">Confidence Levels:</strong> High (>80%) indicates strong compositional signal. Medium (60-80%) suggests moderate evidence. Low (<60%) should be treated as tentative.</p>
|
| 269 |
</div>
|
|
|
|
| 270 |
</div>
|
| 271 |
+
|
| 272 |
+
<p className="text-xs text-text-muted text-center">{result.note}</p>
|
| 273 |
</motion.div>
|
| 274 |
)}
|
| 275 |
</div>
|
|
@@ -2,15 +2,15 @@
|
|
| 2 |
import { useState, useEffect, useCallback } from "react";
|
| 3 |
import { useRouter } from "next/navigation";
|
| 4 |
import { motion } from "framer-motion";
|
| 5 |
-
import { ArrowLeft, Play, Loader2, Activity } from "lucide-react";
|
| 6 |
import { fadeUp } from "@/lib/animations";
|
| 7 |
import { useAuditTrail } from "@/hooks/useAuditTrail";
|
| 8 |
import { runMD, getMDStatus, type MDSimulationResult } from "@/lib/api";
|
| 9 |
|
| 10 |
const MODES = [
|
| 11 |
-
{ value: "minimize", label: "Minimization Only", desc: "500 steps, ~5 sec" },
|
| 12 |
-
{ value: "equilibrate", label: "Minimize + Equilibrate", desc: "1500 steps, ~30 sec" },
|
| 13 |
-
{ value: "production", label: "Full Short Run", desc: "3500 steps, ~2-3 min" },
|
| 14 |
];
|
| 15 |
|
| 16 |
export default function MDPage() {
|
|
@@ -72,35 +72,32 @@ export default function MDPage() {
|
|
| 72 |
}
|
| 73 |
};
|
| 74 |
|
|
|
|
|
|
|
| 75 |
return (
|
| 76 |
-
<div className="max-w-
|
| 77 |
<button onClick={() => router.push("/analyze")}
|
| 78 |
className="flex items-center gap-1 text-sm text-text-muted hover:text-text-primary mb-6 transition-colors">
|
| 79 |
-
<ArrowLeft className="w-4 h-4" />
|
| 80 |
-
Choose a different operation
|
| 81 |
</button>
|
| 82 |
|
| 83 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show" className="mb-8">
|
| 84 |
<h1 className="text-2xl font-bold text-text-primary mb-1">MD Simulation</h1>
|
| 85 |
-
<p className="text-sm text-text-secondary">Implicit solvent molecular dynamics using OpenMM.
|
| 86 |
</motion.div>
|
| 87 |
|
| 88 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show">
|
| 89 |
<div className="glass-card p-5">
|
| 90 |
<label className="block text-sm text-text-secondary mb-2">PDB ID</label>
|
| 91 |
<div className="flex gap-2 mb-4">
|
| 92 |
-
<input
|
| 93 |
-
|
| 94 |
-
onChange={(e) => setPdbId(e.target.value.toUpperCase())}
|
| 95 |
-
placeholder="e.g. 1TIM"
|
| 96 |
-
maxLength={4}
|
| 97 |
className="w-32 px-3 py-2 rounded-lg bg-surface-1 border border-surface-3 text-text-primary text-sm font-mono uppercase placeholder:text-text-muted focus:outline-none focus:border-accent-cyan"
|
| 98 |
-
onKeyDown={(e) => e.key === "Enter" && handleSubmit()}
|
| 99 |
-
/>
|
| 100 |
</div>
|
| 101 |
|
| 102 |
<label className="block text-sm text-text-secondary mb-2">Simulation Mode</label>
|
| 103 |
-
<div className="grid grid-cols-1 sm:grid-cols-3 gap-2 mb-
|
| 104 |
{MODES.map((m) => (
|
| 105 |
<button key={m.value} onClick={() => setMode(m.value)}
|
| 106 |
className={`p-3 rounded-lg border text-left transition-all ${
|
|
@@ -111,13 +108,13 @@ export default function MDPage() {
|
|
| 111 |
</button>
|
| 112 |
))}
|
| 113 |
</div>
|
|
|
|
| 114 |
|
| 115 |
<button onClick={handleSubmit} disabled={loading || !pdbId.trim()}
|
| 116 |
className="btn-primary px-4 py-2 text-sm flex items-center gap-2">
|
| 117 |
{loading ? <Loader2 className="w-4 h-4 animate-spin" /> : <Play className="w-4 h-4" />}
|
| 118 |
{status === "running" || status === "queued" ? `Status: ${status}...` : "Run Simulation"}
|
| 119 |
</button>
|
| 120 |
-
<p className="text-xs text-text-muted mt-2">Constraints: implicit solvent, {mode === "minimize" ? "500" : mode === "equilibrate" ? "1500" : "3500"} steps, 5 min timeout.</p>
|
| 121 |
</div>
|
| 122 |
</motion.div>
|
| 123 |
|
|
@@ -129,48 +126,90 @@ export default function MDPage() {
|
|
| 129 |
|
| 130 |
{result && (
|
| 131 |
<motion.div initial={{ opacity: 0, y: 16 }} animate={{ opacity: 1, y: 0 }} className="mt-6 space-y-4">
|
|
|
|
| 132 |
<div className="glass-card p-5">
|
| 133 |
<h3 className="text-sm font-semibold text-text-primary mb-3 flex items-center gap-2">
|
| 134 |
-
<Activity className="w-4 h-4 text-accent-cyan" /> Simulation
|
| 135 |
</h3>
|
| 136 |
-
|
| 137 |
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3 mb-3">
|
| 138 |
<div className="bg-surface-1 rounded-lg p-3">
|
| 139 |
-
<div className="text-xs text-text-muted">
|
| 140 |
-
<div className="text-
|
| 141 |
-
<div className="text-xs text-text-muted">kJ/mol</div>
|
| 142 |
</div>
|
| 143 |
<div className="bg-surface-1 rounded-lg p-3">
|
| 144 |
-
<div className="text-xs text-text-muted">
|
| 145 |
-
<div className="text-
|
| 146 |
-
<div className="text-xs text-text-muted">steps</div>
|
| 147 |
</div>
|
| 148 |
<div className="bg-surface-1 rounded-lg p-3">
|
| 149 |
-
<div className="text-xs text-text-muted">
|
| 150 |
-
<div className="text-
|
| 151 |
-
<div className="text-xs text-text-muted">steps</div>
|
| 152 |
</div>
|
| 153 |
<div className="bg-surface-1 rounded-lg p-3">
|
| 154 |
-
<div className="text-xs text-text-muted">
|
| 155 |
-
<div className="text-
|
| 156 |
-
<div className="text-xs text-text-muted">steps</div>
|
| 157 |
</div>
|
| 158 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
<
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
</div>
|
|
|
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
{result.energy.production.length > 0 && (
|
| 170 |
<div>
|
| 171 |
-
<h4 className="text-xs text-text-secondary mb-2">Energy Trace</h4>
|
| 172 |
-
<div className="bg-surface-1 rounded-lg p-3 h-
|
| 173 |
-
{result.energy.production.slice(-
|
| 174 |
const energies = result.energy.production.map(p => p.energy);
|
| 175 |
const min = Math.min(...energies);
|
| 176 |
const max = Math.max(...energies);
|
|
@@ -179,88 +218,206 @@ export default function MDPage() {
|
|
| 179 |
return (
|
| 180 |
<div key={i} className="flex-1 rounded-t bg-accent-cyan/60 hover:bg-accent-cyan transition-colors"
|
| 181 |
style={{ height: `${Math.max(height, 2)}%` }}
|
| 182 |
-
title={`${pt.step}: ${pt.energy.toFixed(1)} kJ/mol`} />
|
| 183 |
);
|
| 184 |
})}
|
| 185 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
</div>
|
| 187 |
)}
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
<h4 className="text-xs text-text-secondary mb-2">RMSD (vs minimized structure)</h4>
|
| 192 |
<div className="bg-surface-1 rounded-lg p-3 h-32 flex items-end gap-px">
|
| 193 |
-
{result.
|
| 194 |
-
const
|
| 195 |
-
const
|
|
|
|
|
|
|
|
|
|
| 196 |
return (
|
| 197 |
-
<div key={i} className="flex-1 rounded-t bg-
|
| 198 |
style={{ height: `${Math.max(height, 2)}%` }}
|
| 199 |
-
title={`
|
| 200 |
);
|
| 201 |
})}
|
| 202 |
</div>
|
| 203 |
</div>
|
| 204 |
)}
|
|
|
|
| 205 |
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
</div>
|
| 220 |
</div>
|
| 221 |
-
|
|
|
|
| 222 |
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
<div className="
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
</div>
|
| 240 |
</div>
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
|
|
|
|
|
|
|
|
|
| 246 |
<div className="text-xs text-text-muted">Radius of Gyration</div>
|
| 247 |
<div className="text-sm font-semibold text-text-primary">{result.radius_of_gyration_angstrom} A</div>
|
|
|
|
| 248 |
</div>
|
| 249 |
{result.avg_bfactor !== undefined && (
|
| 250 |
-
<div className="bg-surface-1 rounded-lg
|
| 251 |
<div className="text-xs text-text-muted">Avg B-factor</div>
|
| 252 |
-
<div className="text-sm font-semibold text-text-primary">{result.avg_bfactor}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
</div>
|
| 254 |
)}
|
| 255 |
</div>
|
| 256 |
-
|
|
|
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
</
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
</motion.div>
|
| 265 |
)}
|
| 266 |
</div>
|
|
|
|
| 2 |
import { useState, useEffect, useCallback } from "react";
|
| 3 |
import { useRouter } from "next/navigation";
|
| 4 |
import { motion } from "framer-motion";
|
| 5 |
+
import { ArrowLeft, Play, Loader2, Activity, Clock, Zap, BarChart3, Info } from "lucide-react";
|
| 6 |
import { fadeUp } from "@/lib/animations";
|
| 7 |
import { useAuditTrail } from "@/hooks/useAuditTrail";
|
| 8 |
import { runMD, getMDStatus, type MDSimulationResult } from "@/lib/api";
|
| 9 |
|
| 10 |
const MODES = [
|
| 11 |
+
{ value: "minimize", label: "Minimization Only", desc: "500 steps, ~5 sec", detail: "Energy minimization using L-BFGS. Removes steric clashes and high-energy contacts." },
|
| 12 |
+
{ value: "equilibrate", label: "Minimize + Equilibrate", desc: "1500 steps, ~30 sec", detail: "Minimization followed by NVT equilibration at 300K with Langevin thermostat." },
|
| 13 |
+
{ value: "production", label: "Full Short Run", desc: "3500 steps, ~2-3 min", detail: "Complete MD: minimization, equilibration, and 2000-step production run with trajectory recording." },
|
| 14 |
];
|
| 15 |
|
| 16 |
export default function MDPage() {
|
|
|
|
| 72 |
}
|
| 73 |
};
|
| 74 |
|
| 75 |
+
const selectedMode = MODES.find(m => m.value === mode)!;
|
| 76 |
+
|
| 77 |
return (
|
| 78 |
+
<div className="max-w-4xl">
|
| 79 |
<button onClick={() => router.push("/analyze")}
|
| 80 |
className="flex items-center gap-1 text-sm text-text-muted hover:text-text-primary mb-6 transition-colors">
|
| 81 |
+
<ArrowLeft className="w-4 h-4" /> Choose a different operation
|
|
|
|
| 82 |
</button>
|
| 83 |
|
| 84 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show" className="mb-8">
|
| 85 |
<h1 className="text-2xl font-bold text-text-primary mb-1">MD Simulation</h1>
|
| 86 |
+
<p className="text-sm text-text-secondary">Implicit solvent molecular dynamics using OpenMM/BioPython. AMBER14 force field, OBC2 generalized Born solvent model.</p>
|
| 87 |
</motion.div>
|
| 88 |
|
| 89 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show">
|
| 90 |
<div className="glass-card p-5">
|
| 91 |
<label className="block text-sm text-text-secondary mb-2">PDB ID</label>
|
| 92 |
<div className="flex gap-2 mb-4">
|
| 93 |
+
<input value={pdbId} onChange={(e) => setPdbId(e.target.value.toUpperCase())}
|
| 94 |
+
placeholder="e.g. 1TIM" maxLength={4}
|
|
|
|
|
|
|
|
|
|
| 95 |
className="w-32 px-3 py-2 rounded-lg bg-surface-1 border border-surface-3 text-text-primary text-sm font-mono uppercase placeholder:text-text-muted focus:outline-none focus:border-accent-cyan"
|
| 96 |
+
onKeyDown={(e) => e.key === "Enter" && handleSubmit()} />
|
|
|
|
| 97 |
</div>
|
| 98 |
|
| 99 |
<label className="block text-sm text-text-secondary mb-2">Simulation Mode</label>
|
| 100 |
+
<div className="grid grid-cols-1 sm:grid-cols-3 gap-2 mb-3">
|
| 101 |
{MODES.map((m) => (
|
| 102 |
<button key={m.value} onClick={() => setMode(m.value)}
|
| 103 |
className={`p-3 rounded-lg border text-left transition-all ${
|
|
|
|
| 108 |
</button>
|
| 109 |
))}
|
| 110 |
</div>
|
| 111 |
+
<p className="text-xs text-text-muted mb-3">{selectedMode.detail}</p>
|
| 112 |
|
| 113 |
<button onClick={handleSubmit} disabled={loading || !pdbId.trim()}
|
| 114 |
className="btn-primary px-4 py-2 text-sm flex items-center gap-2">
|
| 115 |
{loading ? <Loader2 className="w-4 h-4 animate-spin" /> : <Play className="w-4 h-4" />}
|
| 116 |
{status === "running" || status === "queued" ? `Status: ${status}...` : "Run Simulation"}
|
| 117 |
</button>
|
|
|
|
| 118 |
</div>
|
| 119 |
</motion.div>
|
| 120 |
|
|
|
|
| 126 |
|
| 127 |
{result && (
|
| 128 |
<motion.div initial={{ opacity: 0, y: 16 }} animate={{ opacity: 1, y: 0 }} className="mt-6 space-y-4">
|
| 129 |
+
{/* Simulation Parameters */}
|
| 130 |
<div className="glass-card p-5">
|
| 131 |
<h3 className="text-sm font-semibold text-text-primary mb-3 flex items-center gap-2">
|
| 132 |
+
<Activity className="w-4 h-4 text-accent-cyan" /> Simulation Parameters
|
| 133 |
</h3>
|
|
|
|
| 134 |
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3 mb-3">
|
| 135 |
<div className="bg-surface-1 rounded-lg p-3">
|
| 136 |
+
<div className="text-xs text-text-muted">Engine</div>
|
| 137 |
+
<div className="text-sm font-semibold text-text-primary">{result.engine}</div>
|
|
|
|
| 138 |
</div>
|
| 139 |
<div className="bg-surface-1 rounded-lg p-3">
|
| 140 |
+
<div className="text-xs text-text-muted">Force Field</div>
|
| 141 |
+
<div className="text-sm font-semibold text-text-primary">{result.forcefield}</div>
|
|
|
|
| 142 |
</div>
|
| 143 |
<div className="bg-surface-1 rounded-lg p-3">
|
| 144 |
+
<div className="text-xs text-text-muted">Solvent Model</div>
|
| 145 |
+
<div className="text-sm font-semibold text-text-primary">{result.implicit_solvent}</div>
|
|
|
|
| 146 |
</div>
|
| 147 |
<div className="bg-surface-1 rounded-lg p-3">
|
| 148 |
+
<div className="text-xs text-text-muted">Temperature</div>
|
| 149 |
+
<div className="text-sm font-semibold text-text-primary">{result.temperature_k} K</div>
|
|
|
|
| 150 |
</div>
|
| 151 |
</div>
|
| 152 |
+
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
| 153 |
+
{[
|
| 154 |
+
{ label: "Atoms", value: result.atom_count },
|
| 155 |
+
{ label: "Residues", value: result.residue_count },
|
| 156 |
+
{ label: "Timestep", value: `${result.timestep_fs} fs` },
|
| 157 |
+
{ label: "Elapsed", value: `${result.elapsed_seconds}s` },
|
| 158 |
+
].map((p) => (
|
| 159 |
+
<div key={p.label} className="bg-surface-1 rounded-lg p-3">
|
| 160 |
+
<div className="text-xs text-text-muted">{p.label}</div>
|
| 161 |
+
<div className="text-sm font-semibold text-text-primary">{p.value}</div>
|
| 162 |
+
</div>
|
| 163 |
+
))}
|
| 164 |
+
</div>
|
| 165 |
+
</div>
|
| 166 |
|
| 167 |
+
{/* Step Counts */}
|
| 168 |
+
<div className="glass-card p-5">
|
| 169 |
+
<h3 className="text-sm font-semibold text-text-primary mb-3 flex items-center gap-2">
|
| 170 |
+
<BarChart3 className="w-4 h-4 text-accent-purple" /> Integration Steps
|
| 171 |
+
</h3>
|
| 172 |
+
<div className="space-y-2">
|
| 173 |
+
{[
|
| 174 |
+
{ label: "Minimization (L-BFGS)", steps: result.minimization_steps, total: 500, color: "bg-accent-cyan" },
|
| 175 |
+
{ label: "Equilibration (NVT, Langevin)", steps: result.equilibration_steps, total: 1000, color: "bg-accent-purple" },
|
| 176 |
+
{ label: "Production (Langevin)", steps: result.production_steps, total: 2000, color: "bg-accent-amber" },
|
| 177 |
+
].filter(s => s.steps > 0).map((s) => (
|
| 178 |
+
<div key={s.label}>
|
| 179 |
+
<div className="flex items-center justify-between mb-1">
|
| 180 |
+
<span className="text-xs text-text-secondary">{s.label}</span>
|
| 181 |
+
<span className="text-xs font-mono text-text-primary">{s.steps} steps</span>
|
| 182 |
+
</div>
|
| 183 |
+
<div className="w-full h-1.5 bg-surface-3 rounded-full">
|
| 184 |
+
<div className={`h-full rounded-full ${s.color}`} style={{ width: `${(s.steps / s.total) * 100}%` }} />
|
| 185 |
+
</div>
|
| 186 |
+
</div>
|
| 187 |
+
))}
|
| 188 |
</div>
|
| 189 |
+
</div>
|
| 190 |
|
| 191 |
+
{/* Energy */}
|
| 192 |
+
<div className="glass-card p-5">
|
| 193 |
+
<h3 className="text-sm font-semibold text-text-primary mb-1 flex items-center gap-2">
|
| 194 |
+
<Zap className="w-4 h-4 text-accent-amber" /> Energy Analysis
|
| 195 |
+
</h3>
|
| 196 |
+
<div className="grid grid-cols-2 gap-3 mb-3">
|
| 197 |
+
<div className="bg-surface-1 rounded-lg p-3">
|
| 198 |
+
<div className="text-xs text-text-muted">Final Potential Energy</div>
|
| 199 |
+
<div className="text-lg font-semibold text-text-primary">{result.final_energy_kj_mol} <span className="text-xs text-text-muted">kJ/mol</span></div>
|
| 200 |
+
</div>
|
| 201 |
+
<div className="bg-surface-1 rounded-lg p-3">
|
| 202 |
+
<div className="text-xs text-text-muted">Energy per Atom</div>
|
| 203 |
+
<div className="text-lg font-semibold text-text-primary">
|
| 204 |
+
{result.atom_count > 0 ? (result.final_energy_kj_mol / result.atom_count).toFixed(2) : "N/A"} <span className="text-xs text-text-muted">kJ/mol/atom</span>
|
| 205 |
+
</div>
|
| 206 |
+
</div>
|
| 207 |
+
</div>
|
| 208 |
{result.energy.production.length > 0 && (
|
| 209 |
<div>
|
| 210 |
+
<h4 className="text-xs text-text-secondary mb-2">Production Energy Trace ({result.energy.production.length} frames)</h4>
|
| 211 |
+
<div className="bg-surface-1 rounded-lg p-3 h-48 flex items-end gap-px">
|
| 212 |
+
{result.energy.production.slice(-80).map((pt, i) => {
|
| 213 |
const energies = result.energy.production.map(p => p.energy);
|
| 214 |
const min = Math.min(...energies);
|
| 215 |
const max = Math.max(...energies);
|
|
|
|
| 218 |
return (
|
| 219 |
<div key={i} className="flex-1 rounded-t bg-accent-cyan/60 hover:bg-accent-cyan transition-colors"
|
| 220 |
style={{ height: `${Math.max(height, 2)}%` }}
|
| 221 |
+
title={`Step ${pt.step}: ${pt.energy.toFixed(1)} kJ/mol`} />
|
| 222 |
);
|
| 223 |
})}
|
| 224 |
</div>
|
| 225 |
+
<div className="flex justify-between text-xs text-text-muted mt-1">
|
| 226 |
+
<span>Min: {Math.min(...result.energy.production.map(p => p.energy)).toFixed(1)} kJ/mol</span>
|
| 227 |
+
<span>Max: {Math.max(...result.energy.production.map(p => p.energy)).toFixed(1)} kJ/mol</span>
|
| 228 |
+
<span>Range: {(Math.max(...result.energy.production.map(p => p.energy)) - Math.min(...result.energy.production.map(p => p.energy))).toFixed(1)} kJ/mol</span>
|
| 229 |
+
</div>
|
| 230 |
</div>
|
| 231 |
)}
|
| 232 |
+
{result.energy.minimization.length > 0 && (
|
| 233 |
+
<div className="mt-3">
|
| 234 |
+
<h4 className="text-xs text-text-secondary mb-2">Minimization Convergence</h4>
|
|
|
|
| 235 |
<div className="bg-surface-1 rounded-lg p-3 h-32 flex items-end gap-px">
|
| 236 |
+
{result.energy.minimization.map((pt, i) => {
|
| 237 |
+
const energies = result.energy.minimization.map(p => p.energy);
|
| 238 |
+
const min = Math.min(...energies);
|
| 239 |
+
const max = Math.max(...energies);
|
| 240 |
+
const range = max - min || 1;
|
| 241 |
+
const height = ((pt.energy - min) / range) * 100;
|
| 242 |
return (
|
| 243 |
+
<div key={i} className="flex-1 rounded-t bg-green-500/60 hover:bg-green-500 transition-colors"
|
| 244 |
style={{ height: `${Math.max(height, 2)}%` }}
|
| 245 |
+
title={`Step ${pt.step}: ${pt.energy.toFixed(1)} kJ/mol`} />
|
| 246 |
);
|
| 247 |
})}
|
| 248 |
</div>
|
| 249 |
</div>
|
| 250 |
)}
|
| 251 |
+
</div>
|
| 252 |
|
| 253 |
+
{/* RMSD */}
|
| 254 |
+
{result.rmsd.length > 0 && (
|
| 255 |
+
<div className="glass-card p-5">
|
| 256 |
+
<h3 className="text-sm font-semibold text-text-primary mb-1">RMSD — Structural Drift</h3>
|
| 257 |
+
<p className="text-xs text-text-muted mb-3">Root-mean-square deviation vs minimized reference. Lower = more stable.</p>
|
| 258 |
+
<div className="bg-surface-1 rounded-lg p-3 h-40 flex items-end gap-px">
|
| 259 |
+
{result.rmsd.slice(-80).map((pt, i) => {
|
| 260 |
+
const maxRmsd = Math.max(...result.rmsd.map(r => r.rmsd));
|
| 261 |
+
const height = maxRmsd > 0 ? (pt.rmsd / maxRmsd) * 100 : 50;
|
| 262 |
+
return (
|
| 263 |
+
<div key={i} className="flex-1 rounded-t bg-accent-purple/60 hover:bg-accent-purple transition-colors"
|
| 264 |
+
style={{ height: `${Math.max(height, 2)}%` }}
|
| 265 |
+
title={`Frame ${pt.frame}: ${pt.rmsd.toFixed(3)} A`} />
|
| 266 |
+
);
|
| 267 |
+
})}
|
| 268 |
+
</div>
|
| 269 |
+
<div className="grid grid-cols-3 gap-2 mt-2">
|
| 270 |
+
<div className="text-center">
|
| 271 |
+
<div className="text-xs text-text-muted">Min RMSD</div>
|
| 272 |
+
<div className="text-sm font-mono font-medium text-text-primary">{Math.min(...result.rmsd.map(r => r.rmsd)).toFixed(3)} A</div>
|
| 273 |
+
</div>
|
| 274 |
+
<div className="text-center">
|
| 275 |
+
<div className="text-xs text-text-muted">Max RMSD</div>
|
| 276 |
+
<div className="text-sm font-mono font-medium text-text-primary">{Math.max(...result.rmsd.map(r => r.rmsd)).toFixed(3)} A</div>
|
| 277 |
+
</div>
|
| 278 |
+
<div className="text-center">
|
| 279 |
+
<div className="text-xs text-text-muted">Avg RMSD</div>
|
| 280 |
+
<div className="text-sm font-mono font-medium text-text-primary">{(result.rmsd.reduce((s, r) => s + r.rmsd, 0) / result.rmsd.length).toFixed(3)} A</div>
|
| 281 |
</div>
|
| 282 |
</div>
|
| 283 |
+
</div>
|
| 284 |
+
)}
|
| 285 |
|
| 286 |
+
{/* RMSF */}
|
| 287 |
+
{result.rmsf && result.rmsf.length > 0 && (
|
| 288 |
+
<div className="glass-card p-5">
|
| 289 |
+
<h3 className="text-sm font-semibold text-text-primary mb-1">RMSF — Per-Residue Flexibility</h3>
|
| 290 |
+
<p className="text-xs text-text-muted mb-3">Root-mean-square fluctuation per residue. High = flexible region, low = rigid/core.</p>
|
| 291 |
+
<div className="bg-surface-1 rounded-lg p-3 h-40 flex items-end gap-px">
|
| 292 |
+
{result.rmsf.slice(-80).map((pt, i) => {
|
| 293 |
+
const maxRmsf = Math.max(...result.rmsf.map(r => r.rmsf_angstrom));
|
| 294 |
+
const height = maxRmsf > 0 ? (pt.rmsf_angstrom / maxRmsf) * 100 : 50;
|
| 295 |
+
return (
|
| 296 |
+
<div key={i} className="flex-1 rounded-t bg-green-500/60 hover:bg-green-500 transition-colors"
|
| 297 |
+
style={{ height: `${Math.max(height, 2)}%` }}
|
| 298 |
+
title={`${pt.residue}: ${pt.rmsf_angstrom.toFixed(3)} A`} />
|
| 299 |
+
);
|
| 300 |
+
})}
|
| 301 |
+
</div>
|
| 302 |
+
<div className="grid grid-cols-3 gap-2 mt-2">
|
| 303 |
+
<div className="text-center">
|
| 304 |
+
<div className="text-xs text-text-muted">Min RMSF</div>
|
| 305 |
+
<div className="text-sm font-mono font-medium text-text-primary">{Math.min(...result.rmsf.map(r => r.rmsf_angstrom)).toFixed(3)} A</div>
|
| 306 |
+
</div>
|
| 307 |
+
<div className="text-center">
|
| 308 |
+
<div className="text-xs text-text-muted">Max RMSF</div>
|
| 309 |
+
<div className="text-sm font-mono font-medium text-text-primary">{Math.max(...result.rmsf.map(r => r.rmsf_angstrom)).toFixed(3)} A</div>
|
| 310 |
+
</div>
|
| 311 |
+
<div className="text-center">
|
| 312 |
+
<div className="text-xs text-text-muted">Avg RMSF</div>
|
| 313 |
+
<div className="text-sm font-mono font-medium text-text-primary">{(result.rmsf.reduce((s, r) => s + r.rmsf_angstrom, 0) / result.rmsf.length).toFixed(3)} A</div>
|
| 314 |
</div>
|
| 315 |
</div>
|
| 316 |
+
</div>
|
| 317 |
+
)}
|
| 318 |
+
|
| 319 |
+
{/* Secondary Structure */}
|
| 320 |
+
{result.secondary_structure && (
|
| 321 |
+
<div className="glass-card p-5">
|
| 322 |
+
<h3 className="text-sm font-semibold text-text-primary mb-3">Secondary Structure Composition</h3>
|
| 323 |
+
<div className="flex gap-3 mb-3">
|
| 324 |
+
{[
|
| 325 |
+
{ label: "alpha-helix", count: result.secondary_structure.helix, color: "bg-blue-400", textColor: "text-blue-400" },
|
| 326 |
+
{ label: "beta-sheet", count: result.secondary_structure.sheet, color: "bg-yellow-400", textColor: "text-yellow-400" },
|
| 327 |
+
{ label: "coil", count: result.secondary_structure.coil, color: "bg-surface-3", textColor: "text-text-muted" },
|
| 328 |
+
].map((ss) => {
|
| 329 |
+
const total = result.secondary_structure!.helix + result.secondary_structure!.sheet + result.secondary_structure!.coil;
|
| 330 |
+
const pct = total > 0 ? ((ss.count / total) * 100).toFixed(1) : "0";
|
| 331 |
+
return (
|
| 332 |
+
<div key={ss.label} className="bg-surface-1 rounded-lg px-3 py-2 text-center flex-1">
|
| 333 |
+
<div className={`text-lg font-semibold ${ss.textColor}`}>{ss.count}</div>
|
| 334 |
+
<div className="text-xs text-text-muted">{ss.label}</div>
|
| 335 |
+
<div className="text-xs text-text-muted">{pct}%</div>
|
| 336 |
+
</div>
|
| 337 |
+
);
|
| 338 |
+
})}
|
| 339 |
+
</div>
|
| 340 |
+
{/* Visual bar */}
|
| 341 |
+
<div className="w-full h-3 rounded-full overflow-hidden flex">
|
| 342 |
+
{(() => {
|
| 343 |
+
const total = result.secondary_structure.helix + result.secondary_structure.sheet + result.secondary_structure.coil;
|
| 344 |
+
if (total === 0) return <div className="w-full bg-surface-3" />;
|
| 345 |
+
return (
|
| 346 |
+
<>
|
| 347 |
+
<div className="bg-blue-400 h-full" style={{ width: `${(result.secondary_structure.helix / total) * 100}%` }} title={`Helix: ${result.secondary_structure.helix}`} />
|
| 348 |
+
<div className="bg-yellow-400 h-full" style={{ width: `${(result.secondary_structure.sheet / total) * 100}%` }} title={`Sheet: ${result.secondary_structure.sheet}`} />
|
| 349 |
+
<div className="bg-surface-3 h-full" style={{ width: `${(result.secondary_structure.coil / total) * 100}%` }} title={`Coil: ${result.secondary_structure.coil}`} />
|
| 350 |
+
</>
|
| 351 |
+
);
|
| 352 |
+
})()}
|
| 353 |
+
</div>
|
| 354 |
+
</div>
|
| 355 |
+
)}
|
| 356 |
|
| 357 |
+
{/* Structural Metrics (BioPython fallback) */}
|
| 358 |
+
{result.radius_of_gyration_angstrom !== undefined && (
|
| 359 |
+
<div className="glass-card p-5">
|
| 360 |
+
<h3 className="text-sm font-semibold text-text-primary mb-3">Structural Metrics</h3>
|
| 361 |
+
<div className="grid grid-cols-2 sm:grid-cols-3 gap-3">
|
| 362 |
+
<div className="bg-surface-1 rounded-lg p-3">
|
| 363 |
<div className="text-xs text-text-muted">Radius of Gyration</div>
|
| 364 |
<div className="text-sm font-semibold text-text-primary">{result.radius_of_gyration_angstrom} A</div>
|
| 365 |
+
<div className="text-xs text-text-muted">Compactness measure</div>
|
| 366 |
</div>
|
| 367 |
{result.avg_bfactor !== undefined && (
|
| 368 |
+
<div className="bg-surface-1 rounded-lg p-3">
|
| 369 |
<div className="text-xs text-text-muted">Avg B-factor</div>
|
| 370 |
+
<div className="text-sm font-semibold text-text-primary">{result.avg_bfactor} A2</div>
|
| 371 |
+
<div className="text-xs text-text-muted">Atomic displacement</div>
|
| 372 |
+
</div>
|
| 373 |
+
)}
|
| 374 |
+
{result.chain_count !== undefined && (
|
| 375 |
+
<div className="bg-surface-1 rounded-lg p-3">
|
| 376 |
+
<div className="text-xs text-text-muted">Chain Count</div>
|
| 377 |
+
<div className="text-sm font-semibold text-text-primary">{result.chain_count}</div>
|
| 378 |
+
<div className="text-xs text-text-muted">Polymer chains</div>
|
| 379 |
</div>
|
| 380 |
)}
|
| 381 |
</div>
|
| 382 |
+
</div>
|
| 383 |
+
)}
|
| 384 |
|
| 385 |
+
{/* Interpretation */}
|
| 386 |
+
<div className="glass-card p-5">
|
| 387 |
+
<h3 className="text-sm font-semibold text-text-primary mb-3 flex items-center gap-2">
|
| 388 |
+
<Info className="w-4 h-4 text-accent-cyan" /> Interpretation
|
| 389 |
+
</h3>
|
| 390 |
+
<div className="space-y-2 text-xs text-text-secondary">
|
| 391 |
+
{result.engine === "openmm" && result.rmsd.length > 0 && (() => {
|
| 392 |
+
const lastRmsd = result.rmsd[result.rmsd.length - 1].rmsd;
|
| 393 |
+
const avgRmsd = result.rmsd.reduce((s, r) => s + r.rmsd, 0) / result.rmsd.length;
|
| 394 |
+
return (
|
| 395 |
+
<>
|
| 396 |
+
<p><strong className="text-text-primary">Structural Stability:</strong> {lastRmsd < 2.0 ? "The structure remains stable (RMSD < 2.0 A), indicating the force field and implicit solvent model maintain a reasonable conformation." : lastRmsd < 5.0 ? "Moderate structural drift observed. The protein may be exploring conformational space or transitioning from the initial crystal structure." : "Significant structural drift. This may indicate the need for explicit solvent, longer equilibration, or restraints on key residues."}</p>
|
| 397 |
+
<p><strong className="text-text-primary">Energy Convergence:</strong> {result.energy.production.length > 2 ? `Production energy spans ${Math.min(...result.energy.production.map(p => p.energy)).toFixed(1)} to ${Math.max(...result.energy.production.map(p => p.energy)).toFixed(1)} kJ/mol.` : "Short production run — limited energy statistics."}</p>
|
| 398 |
+
</>
|
| 399 |
+
);
|
| 400 |
+
})()}
|
| 401 |
+
{result.engine === "biopython_structural" && (
|
| 402 |
+
<p><strong className="text-text-primary">Structural Analysis (No MD):</strong> OpenMM was unavailable. Results are based on static structural analysis of the crystal structure — secondary structure, radius of gyration, B-factors, and bond geometry. This is NOT a dynamics simulation.</p>
|
| 403 |
+
)}
|
| 404 |
+
{result.secondary_structure && (() => {
|
| 405 |
+
const total = result.secondary_structure.helix + result.secondary_structure.sheet + result.secondary_structure.coil;
|
| 406 |
+
const helixPct = total > 0 ? (result.secondary_structure.helix / total) * 100 : 0;
|
| 407 |
+
return (
|
| 408 |
+
<p><strong className="text-text-primary">Secondary Structure:</strong> {helixPct > 40 ? "Predominantly alpha-helical — consistent with many globular proteins." : helixPct > 20 ? "Mixed alpha/beta fold." : "Predominantly coil/disordered — may indicate a flexible or intrinsically disordered region."}</p>
|
| 409 |
+
);
|
| 410 |
+
})()}
|
| 411 |
+
</div>
|
| 412 |
</div>
|
| 413 |
+
|
| 414 |
+
{result.note && (
|
| 415 |
+
<div className="bg-amber-500/10 border border-amber-500/20 rounded-lg px-4 py-3">
|
| 416 |
+
<p className="text-xs text-amber-400">{result.note}</p>
|
| 417 |
+
</div>
|
| 418 |
+
)}
|
| 419 |
+
|
| 420 |
+
<p className="text-xs text-text-muted text-center">Free-tier: implicit solvent, limited steps. For production MD, use explicit solvent with sufficient sampling.</p>
|
| 421 |
</motion.div>
|
| 422 |
)}
|
| 423 |
</div>
|
|
@@ -465,8 +465,69 @@ export type ADMETResult = {
|
|
| 465 |
hba: number;
|
| 466 |
rotatable_bonds: number;
|
| 467 |
qed_score: number;
|
| 468 |
-
|
| 469 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
};
|
| 471 |
|
| 472 |
export async function computeADMET(smiles: string): Promise<{ result: ADMETResult }> {
|
|
|
|
| 465 |
hba: number;
|
| 466 |
rotatable_bonds: number;
|
| 467 |
qed_score: number;
|
| 468 |
+
molar_refractivity: number;
|
| 469 |
+
molecular_volume: number;
|
| 470 |
+
fsp3: number;
|
| 471 |
+
labute_asa: number;
|
| 472 |
+
estate_sum: number;
|
| 473 |
+
wiener_index: number;
|
| 474 |
+
zagreb_index: number;
|
| 475 |
+
ring_count: number;
|
| 476 |
+
aromatic_ring_count: number;
|
| 477 |
+
aliphatic_ring_count: number;
|
| 478 |
+
num_heteroatoms: number;
|
| 479 |
+
num_amide_bonds: number;
|
| 480 |
+
num_atom_stereocenters: number;
|
| 481 |
+
num_unspecified_stereocenters: number;
|
| 482 |
+
functional_groups: Record<string, number>;
|
| 483 |
+
drug_likeness: {
|
| 484 |
+
overall_score: number;
|
| 485 |
+
qed_score: number;
|
| 486 |
+
lipinski: { pass: boolean; violations: string[]; violation_count: number };
|
| 487 |
+
veber: { pass: boolean; violations: string[]; violation_count: number };
|
| 488 |
+
ghose: { pass: boolean; violations: string[]; violation_count: number };
|
| 489 |
+
egan: { pass: boolean; violations: string[]; violation_count: number };
|
| 490 |
+
mddr: { pass: boolean; violations: string[]; violation_count: number };
|
| 491 |
+
};
|
| 492 |
+
structural_alerts: {
|
| 493 |
+
pains: { pass: boolean; alerts: string[]; alert_count: number };
|
| 494 |
+
brenk: { pass: boolean; alerts: string[]; alert_count: number };
|
| 495 |
+
total_alert_count: number;
|
| 496 |
+
};
|
| 497 |
+
absorption: {
|
| 498 |
+
oral_bioavailability: number;
|
| 499 |
+
caco2_permeability: string;
|
| 500 |
+
pgp_substrate: string;
|
| 501 |
+
pgp_inhibitor: string;
|
| 502 |
+
hia: string;
|
| 503 |
+
};
|
| 504 |
+
distribution: {
|
| 505 |
+
volume_of_distribution: number;
|
| 506 |
+
bbb_permeability: string;
|
| 507 |
+
plasma_protein_binding: string;
|
| 508 |
+
cns_penetration: string;
|
| 509 |
+
};
|
| 510 |
+
metabolism: {
|
| 511 |
+
cyp_inhibition: Record<string, string>;
|
| 512 |
+
cyp_substrate_risk: string;
|
| 513 |
+
half_life_class: string;
|
| 514 |
+
lipophilic_efficiency: number;
|
| 515 |
+
};
|
| 516 |
+
toxicity: {
|
| 517 |
+
ames_mutagenicity: string;
|
| 518 |
+
ames_alerts: string[];
|
| 519 |
+
herg_liability: string;
|
| 520 |
+
hepatotoxicity_dili: string;
|
| 521 |
+
skin_sensitization: string;
|
| 522 |
+
skin_sensitization_factors: string[];
|
| 523 |
+
acute_toxicity_ld50: string;
|
| 524 |
+
ld50_estimate_log: number;
|
| 525 |
+
risk_score: number;
|
| 526 |
+
};
|
| 527 |
+
clearance: {
|
| 528 |
+
clearance_class: string;
|
| 529 |
+
half_life_class: string;
|
| 530 |
+
};
|
| 531 |
};
|
| 532 |
|
| 533 |
export async function computeADMET(smiles: string): Promise<{ result: ADMETResult }> {
|