Spaces:
Running
Running
fix(seq-tools): stop auto-scrolling on job completion, fix structure highlight & AlphaFold viewer loading
Browse files- bioai-platform/frontend/src/app/(dashboard)/analyze/docking/page.tsx +0 -5
- bioai-platform/frontend/src/app/(dashboard)/analyze/function/page.tsx +0 -3
- bioai-platform/frontend/src/app/(dashboard)/analyze/phylo/page.tsx +0 -5
- bioai-platform/frontend/src/app/(dashboard)/analyze/sequencing/page.tsx +0 -5
- bioai-platform/frontend/src/app/(dashboard)/analyze/structure/page.tsx +14 -2
- bioai-platform/frontend/src/components/DockingViewer.tsx +48 -27
bioai-platform/frontend/src/app/(dashboard)/analyze/docking/page.tsx
CHANGED
|
@@ -235,11 +235,6 @@ export default function DockingPage() {
|
|
| 235 |
if (status.status === 'complete' || status.status === 'completed' || status.status === 'failed') {
|
| 236 |
setPolling(false);
|
| 237 |
}
|
| 238 |
-
if (status.status === 'complete' || status.status === 'completed') {
|
| 239 |
-
requestAnimationFrame(() => {
|
| 240 |
-
document.getElementById('docking-results')?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 241 |
-
});
|
| 242 |
-
}
|
| 243 |
} catch {
|
| 244 |
setPolling(false);
|
| 245 |
setError('Failed to check docking status');
|
|
|
|
| 235 |
if (status.status === 'complete' || status.status === 'completed' || status.status === 'failed') {
|
| 236 |
setPolling(false);
|
| 237 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
} catch {
|
| 239 |
setPolling(false);
|
| 240 |
setError('Failed to check docking status');
|
bioai-platform/frontend/src/app/(dashboard)/analyze/function/page.tsx
CHANGED
|
@@ -31,9 +31,6 @@ export default function FunctionPage() {
|
|
| 31 |
if (res.status === "complete" && res.result) {
|
| 32 |
setResult(res.result);
|
| 33 |
setLoading(false);
|
| 34 |
-
requestAnimationFrame(() => {
|
| 35 |
-
document.getElementById('function-results')?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 36 |
-
});
|
| 37 |
} else if (res.status === "failed") {
|
| 38 |
setError(res.error || "Prediction failed");
|
| 39 |
setLoading(false);
|
|
|
|
| 31 |
if (res.status === "complete" && res.result) {
|
| 32 |
setResult(res.result);
|
| 33 |
setLoading(false);
|
|
|
|
|
|
|
|
|
|
| 34 |
} else if (res.status === "failed") {
|
| 35 |
setError(res.error || "Prediction failed");
|
| 36 |
setLoading(false);
|
bioai-platform/frontend/src/app/(dashboard)/analyze/phylo/page.tsx
CHANGED
|
@@ -161,11 +161,6 @@ export default function PhyloPage() {
|
|
| 161 |
const data: PhyloJobStatus = await res.json()
|
| 162 |
setJob(data)
|
| 163 |
if (data.phase === 'complete' || data.phase === 'error') stopPoll()
|
| 164 |
-
if (data.phase === 'complete') {
|
| 165 |
-
requestAnimationFrame(() => {
|
| 166 |
-
document.getElementById('phylo-results')?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
| 167 |
-
})
|
| 168 |
-
}
|
| 169 |
} catch { }
|
| 170 |
}, [stopPoll])
|
| 171 |
|
|
|
|
| 161 |
const data: PhyloJobStatus = await res.json()
|
| 162 |
setJob(data)
|
| 163 |
if (data.phase === 'complete' || data.phase === 'error') stopPoll()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
} catch { }
|
| 165 |
}, [stopPoll])
|
| 166 |
|
bioai-platform/frontend/src/app/(dashboard)/analyze/sequencing/page.tsx
CHANGED
|
@@ -72,11 +72,6 @@ export default function SequencingPage() {
|
|
| 72 |
if (status.status === 'complete' || status.status === 'failed') {
|
| 73 |
setPolling(false);
|
| 74 |
}
|
| 75 |
-
if (status.status === 'complete') {
|
| 76 |
-
requestAnimationFrame(() => {
|
| 77 |
-
document.getElementById('sequencing-results')?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
| 78 |
-
});
|
| 79 |
-
}
|
| 80 |
} catch {
|
| 81 |
setPolling(false);
|
| 82 |
setError('Failed to check pipeline status');
|
|
|
|
| 72 |
if (status.status === 'complete' || status.status === 'failed') {
|
| 73 |
setPolling(false);
|
| 74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
} catch {
|
| 76 |
setPolling(false);
|
| 77 |
setError('Failed to check pipeline status');
|
bioai-platform/frontend/src/app/(dashboard)/analyze/structure/page.tsx
CHANGED
|
@@ -79,6 +79,10 @@ export default function StructurePage() {
|
|
| 79 |
|
| 80 |
const pdbId = result?.pdb_id || result?.pdb_url?.match(/view\/(\w+)\.pdb$/)?.[1] || '';
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
const highlightApplied =
|
| 83 |
linkHighlight &&
|
| 84 |
result &&
|
|
@@ -148,8 +152,16 @@ export default function StructurePage() {
|
|
| 148 |
</a>
|
| 149 |
)}
|
| 150 |
</div>
|
| 151 |
-
{pdbId ? (
|
| 152 |
-
<DockingViewer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
) : (
|
| 154 |
<div className="w-full h-96 rounded-xl bg-surface-0 flex items-center justify-center">
|
| 155 |
<p className="text-sm text-text-muted">3D view not available</p>
|
|
|
|
| 79 |
|
| 80 |
const pdbId = result?.pdb_id || result?.pdb_url?.match(/view\/(\w+)\.pdb$/)?.[1] || '';
|
| 81 |
|
| 82 |
+
// AlphaFold results don't carry a PDB id — render them by file URL instead.
|
| 83 |
+
const viewerUrl = result?.source === 'alphafold' ? result.cif_url || result.pdb_url : undefined;
|
| 84 |
+
const viewerUrlFormat = result?.source === 'alphafold' ? (result.cif_url ? 'cif' : 'pdb') : undefined;
|
| 85 |
+
|
| 86 |
const highlightApplied =
|
| 87 |
linkHighlight &&
|
| 88 |
result &&
|
|
|
|
| 152 |
</a>
|
| 153 |
)}
|
| 154 |
</div>
|
| 155 |
+
{pdbId || viewerUrl ? (
|
| 156 |
+
<DockingViewer
|
| 157 |
+
pdbId={pdbId}
|
| 158 |
+
pdbUrl={viewerUrl}
|
| 159 |
+
pdbUrlFormat={viewerUrlFormat}
|
| 160 |
+
ligandPdb=""
|
| 161 |
+
chains={inventory?.chains}
|
| 162 |
+
ligands={inventory?.ligands}
|
| 163 |
+
highlightRange={highlightApplied}
|
| 164 |
+
/>
|
| 165 |
) : (
|
| 166 |
<div className="w-full h-96 rounded-xl bg-surface-0 flex items-center justify-center">
|
| 167 |
<p className="text-sm text-text-muted">3D view not available</p>
|
bioai-platform/frontend/src/components/DockingViewer.tsx
CHANGED
|
@@ -8,6 +8,8 @@ import { ArrowCounterClockwise as RotateCcw, ArrowClockwise as RotateCw, Camera,
|
|
| 8 |
interface DockingViewerProps {
|
| 9 |
pdbId: string;
|
| 10 |
ligandPdb: string;
|
|
|
|
|
|
|
| 11 |
interactions?: DockingInteraction;
|
| 12 |
height?: number | string;
|
| 13 |
backgroundColor?: string;
|
|
@@ -79,6 +81,8 @@ interface PDBeElement extends HTMLElement {
|
|
| 79 |
export function DockingViewer({
|
| 80 |
pdbId,
|
| 81 |
ligandPdb,
|
|
|
|
|
|
|
| 82 |
interactions,
|
| 83 |
height = 480,
|
| 84 |
backgroundColor = '#0B0C14',
|
|
@@ -109,18 +113,24 @@ export function DockingViewer({
|
|
| 109 |
if (!viewer) return;
|
| 110 |
|
| 111 |
try {
|
| 112 |
-
|
| 113 |
-
moleculeId: pdbId.toLowerCase(),
|
| 114 |
visualStyle: {
|
| 115 |
polymer: { type: rep, color: { name: COLOR_MAP[color].name } },
|
| 116 |
het: 'ball-and-stick',
|
| 117 |
water: 'spacefill',
|
| 118 |
},
|
| 119 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
} catch {
|
| 121 |
// Best-effort
|
| 122 |
}
|
| 123 |
-
}, [pdbId]);
|
| 124 |
|
| 125 |
const loadLigand = useCallback(async () => {
|
| 126 |
const viewer = viewerRef.current?.viewerInstance;
|
|
@@ -264,9 +274,9 @@ export function DockingViewer({
|
|
| 264 |
setTimeout(() => cam.spin(false), 1500);
|
| 265 |
}, []);
|
| 266 |
|
| 267 |
-
// Initialize viewer ONCE per pdbId
|
| 268 |
useEffect(() => {
|
| 269 |
-
if (!pdbId) {
|
| 270 |
setStatus('error');
|
| 271 |
setError('Missing structure identifier');
|
| 272 |
return;
|
|
@@ -283,10 +293,15 @@ export function DockingViewer({
|
|
| 283 |
container.innerHTML = '';
|
| 284 |
|
| 285 |
const el = document.createElement('pdbe-molstar') as PDBeElement;
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
el.setAttribute('hide-controls', '');
|
| 288 |
el.setAttribute('background-color', backgroundColor);
|
| 289 |
-
el.id = `pdbe-docking-${pdbId.toLowerCase()}`;
|
| 290 |
container.appendChild(el);
|
| 291 |
viewerRef.current = el;
|
| 292 |
|
|
@@ -338,16 +353,35 @@ export function DockingViewer({
|
|
| 338 |
if (checkInterval) clearInterval(checkInterval);
|
| 339 |
el.removeEventListener('molstar-models-loaded', onModelsLoaded);
|
| 340 |
};
|
| 341 |
-
}, [pdbId, ligandPdb, backgroundColor]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
|
| 343 |
// Representation + color changes
|
| 344 |
useEffect(() => {
|
| 345 |
if (status === 'ready' && (representation !== representationRef.current || colorScheme !== colorSchemeRef.current)) {
|
| 346 |
representationRef.current = representation;
|
| 347 |
colorSchemeRef.current = colorScheme;
|
| 348 |
-
applyVisualization(representation, colorScheme);
|
| 349 |
}
|
| 350 |
-
}, [representation, colorScheme, status, applyVisualization]);
|
| 351 |
|
| 352 |
// Interaction updates
|
| 353 |
useEffect(() => {
|
|
@@ -356,24 +390,11 @@ export function DockingViewer({
|
|
| 356 |
}
|
| 357 |
}, [interactions, status, drawInteractions, visibleInteractions]);
|
| 358 |
|
| 359 |
-
// Highlight a residue range (deep-linked from motif scan on the structure page)
|
| 360 |
useEffect(() => {
|
| 361 |
-
if (status
|
| 362 |
-
|
| 363 |
-
if (!viewer) return;
|
| 364 |
-
const { start, end } = highlightRange;
|
| 365 |
-
if (!Number.isFinite(start) || !Number.isFinite(end) || end < start) return;
|
| 366 |
-
try {
|
| 367 |
-
void viewer.visual.select({
|
| 368 |
-
data: [{ auth_seq_id: [start, end], color: '#fbbf24' }],
|
| 369 |
-
nonSelectedColor: '#334155',
|
| 370 |
-
keepRepresentations: true,
|
| 371 |
-
});
|
| 372 |
-
void viewer.visual.focus([{ auth_seq_id: [start, end] }]);
|
| 373 |
-
} catch {
|
| 374 |
-
// Best-effort viewer enhancement; the tabular residue data remains available.
|
| 375 |
}
|
| 376 |
-
}, [status,
|
| 377 |
|
| 378 |
// Spin
|
| 379 |
useEffect(() => {
|
|
|
|
| 8 |
interface DockingViewerProps {
|
| 9 |
pdbId: string;
|
| 10 |
ligandPdb: string;
|
| 11 |
+
pdbUrl?: string;
|
| 12 |
+
pdbUrlFormat?: 'pdb' | 'cif';
|
| 13 |
interactions?: DockingInteraction;
|
| 14 |
height?: number | string;
|
| 15 |
backgroundColor?: string;
|
|
|
|
| 81 |
export function DockingViewer({
|
| 82 |
pdbId,
|
| 83 |
ligandPdb,
|
| 84 |
+
pdbUrl,
|
| 85 |
+
pdbUrlFormat,
|
| 86 |
interactions,
|
| 87 |
height = 480,
|
| 88 |
backgroundColor = '#0B0C14',
|
|
|
|
| 113 |
if (!viewer) return;
|
| 114 |
|
| 115 |
try {
|
| 116 |
+
const options: Record<string, unknown> = {
|
|
|
|
| 117 |
visualStyle: {
|
| 118 |
polymer: { type: rep, color: { name: COLOR_MAP[color].name } },
|
| 119 |
het: 'ball-and-stick',
|
| 120 |
water: 'spacefill',
|
| 121 |
},
|
| 122 |
+
};
|
| 123 |
+
if (pdbUrl) {
|
| 124 |
+
options.customDataUrl = pdbUrl;
|
| 125 |
+
options.customDataFormat = pdbUrlFormat || 'pdb';
|
| 126 |
+
} else {
|
| 127 |
+
options.moleculeId = pdbId.toLowerCase();
|
| 128 |
+
}
|
| 129 |
+
await viewer.visual.update(options, true);
|
| 130 |
} catch {
|
| 131 |
// Best-effort
|
| 132 |
}
|
| 133 |
+
}, [pdbId, pdbUrl, pdbUrlFormat]);
|
| 134 |
|
| 135 |
const loadLigand = useCallback(async () => {
|
| 136 |
const viewer = viewerRef.current?.viewerInstance;
|
|
|
|
| 274 |
setTimeout(() => cam.spin(false), 1500);
|
| 275 |
}, []);
|
| 276 |
|
| 277 |
+
// Initialize viewer ONCE per pdbId / pdbUrl
|
| 278 |
useEffect(() => {
|
| 279 |
+
if (!pdbId && !pdbUrl) {
|
| 280 |
setStatus('error');
|
| 281 |
setError('Missing structure identifier');
|
| 282 |
return;
|
|
|
|
| 293 |
container.innerHTML = '';
|
| 294 |
|
| 295 |
const el = document.createElement('pdbe-molstar') as PDBeElement;
|
| 296 |
+
if (pdbUrl) {
|
| 297 |
+
el.setAttribute('custom-data-url', pdbUrl);
|
| 298 |
+
el.setAttribute('custom-data-format', pdbUrlFormat || 'pdb');
|
| 299 |
+
} else {
|
| 300 |
+
el.setAttribute('molecule-id', pdbId.toLowerCase());
|
| 301 |
+
}
|
| 302 |
el.setAttribute('hide-controls', '');
|
| 303 |
el.setAttribute('background-color', backgroundColor);
|
| 304 |
+
el.id = `pdbe-docking-${(pdbId || pdbUrl || 'structure').toLowerCase().replace(/[^a-z0-9]/gi, '')}`;
|
| 305 |
container.appendChild(el);
|
| 306 |
viewerRef.current = el;
|
| 307 |
|
|
|
|
| 353 |
if (checkInterval) clearInterval(checkInterval);
|
| 354 |
el.removeEventListener('molstar-models-loaded', onModelsLoaded);
|
| 355 |
};
|
| 356 |
+
}, [pdbId, pdbUrl, ligandPdb, backgroundColor]); // eslint-disable-line react-hooks/exhaustive-deps
|
| 357 |
+
|
| 358 |
+
// Highlight a residue range (deep-linked from motif scan on the structure page).
|
| 359 |
+
// Uses PDBe Molstar's visual.select range format so the residues actually get
|
| 360 |
+
// colored and focused on the canvas.
|
| 361 |
+
const applyHighlight = useCallback(async () => {
|
| 362 |
+
const viewer = viewerRef.current?.viewerInstance;
|
| 363 |
+
if (!viewer || !highlightRange) return;
|
| 364 |
+
const { start, end } = highlightRange;
|
| 365 |
+
if (!Number.isFinite(start) || !Number.isFinite(end) || end < start) return;
|
| 366 |
+
try {
|
| 367 |
+
await viewer.visual.select({
|
| 368 |
+
data: [{ start_residue_number: start, end_residue_number: end, color: '#fbbf24', focus: true }],
|
| 369 |
+
nonSelectedColor: '#1e2436',
|
| 370 |
+
keepRepresentations: true,
|
| 371 |
+
});
|
| 372 |
+
} catch {
|
| 373 |
+
// Best-effort viewer enhancement; the tabular residue data remains available.
|
| 374 |
+
}
|
| 375 |
+
}, [highlightRange]);
|
| 376 |
|
| 377 |
// Representation + color changes
|
| 378 |
useEffect(() => {
|
| 379 |
if (status === 'ready' && (representation !== representationRef.current || colorScheme !== colorSchemeRef.current)) {
|
| 380 |
representationRef.current = representation;
|
| 381 |
colorSchemeRef.current = colorScheme;
|
| 382 |
+
void applyVisualization(representation, colorScheme).then(() => applyHighlight());
|
| 383 |
}
|
| 384 |
+
}, [representation, colorScheme, status, applyVisualization, applyHighlight]);
|
| 385 |
|
| 386 |
// Interaction updates
|
| 387 |
useEffect(() => {
|
|
|
|
| 390 |
}
|
| 391 |
}, [interactions, status, drawInteractions, visibleInteractions]);
|
| 392 |
|
|
|
|
| 393 |
useEffect(() => {
|
| 394 |
+
if (status === 'ready') {
|
| 395 |
+
void applyHighlight();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
}
|
| 397 |
+
}, [status, applyHighlight]);
|
| 398 |
|
| 399 |
// Spin
|
| 400 |
useEffect(() => {
|