Spaces:
Running
Running
feat(seq-tools): wire motif scanner into BLAST, structure, alignment and dot-plot workflows
Browse files
bioai-platform/frontend/src/app/(dashboard)/analyze/motif/page.tsx
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
| 9 |
MagnifyingGlass as Search,
|
| 10 |
X as Close,
|
| 11 |
Atom,
|
|
|
|
|
|
|
| 12 |
} from '@phosphor-icons/react';
|
| 13 |
import { fadeUp } from '@/lib/animations';
|
| 14 |
import { fetchMotifCategories, fetchMotifPatterns, fetchSequence, scanMotifLibrary, scanMotifPattern } from '@/lib/api';
|
|
@@ -119,11 +121,25 @@ export default function MotifScannerPage() {
|
|
| 119 |
fetchMotifCategories().then(setCategories).catch(() => {});
|
| 120 |
}, []);
|
| 121 |
|
| 122 |
-
// Prefill the sequence from a deep link
|
|
|
|
| 123 |
useEffect(() => {
|
| 124 |
-
const
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
}
|
| 128 |
}, []);
|
| 129 |
|
|
@@ -197,6 +213,20 @@ export default function MotifScannerPage() {
|
|
| 197 |
[accession, router],
|
| 198 |
);
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
const groupedPresets = useMemo(() => {
|
| 201 |
const groups = new Map<string, MotifLibraryPattern[]>();
|
| 202 |
for (const p of patterns) {
|
|
@@ -350,6 +380,30 @@ export default function MotifScannerPage() {
|
|
| 350 |
</CriticalButton>
|
| 351 |
</div>
|
| 352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 353 |
{error && (
|
| 354 |
<div className="rounded-lg bg-error/10 border border-error/30 px-4 py-3 text-sm text-error">
|
| 355 |
<strong>Scan failed:</strong> {error}
|
|
|
|
| 9 |
MagnifyingGlass as Search,
|
| 10 |
X as Close,
|
| 11 |
Atom,
|
| 12 |
+
ArrowsLeftRight as ArrowSwap,
|
| 13 |
+
ChartScatter as Scatter,
|
| 14 |
} from '@phosphor-icons/react';
|
| 15 |
import { fadeUp } from '@/lib/animations';
|
| 16 |
import { fetchMotifCategories, fetchMotifPatterns, fetchSequence, scanMotifLibrary, scanMotifPattern } from '@/lib/api';
|
|
|
|
| 121 |
fetchMotifCategories().then(setCategories).catch(() => {});
|
| 122 |
}, []);
|
| 123 |
|
| 124 |
+
// Prefill the sequence / accession from a deep link
|
| 125 |
+
// (e.g. "scan for motifs" on a BLAST hit carries ?sequence=...&uniprot=...).
|
| 126 |
useEffect(() => {
|
| 127 |
+
const params = new URLSearchParams(globalThis.location?.search ?? '');
|
| 128 |
+
const seqParam = params.get('sequence');
|
| 129 |
+
const accParam = params.get('uniprot');
|
| 130 |
+
if (seqParam) setSequence(seqParam);
|
| 131 |
+
if (accParam) {
|
| 132 |
+
const clean = accParam.trim().split('.')[0];
|
| 133 |
+
if (extractAccession(`>${clean}`)) {
|
| 134 |
+
setAccession(clean);
|
| 135 |
+
} else {
|
| 136 |
+
// Non-UniProt identifier (e.g. a RefSeq id) — best-effort resolve.
|
| 137 |
+
fetchSequence(clean, 'uniprot')
|
| 138 |
+
.then(res => {
|
| 139 |
+
if (res.sequence && res.accession) setAccession(res.accession.split('.')[0]);
|
| 140 |
+
})
|
| 141 |
+
.catch(() => {});
|
| 142 |
+
}
|
| 143 |
}
|
| 144 |
}, []);
|
| 145 |
|
|
|
|
| 213 |
[accession, router],
|
| 214 |
);
|
| 215 |
|
| 216 |
+
const goBlast = () => {
|
| 217 |
+
sessionStorage.setItem('blast_sequence', sequence);
|
| 218 |
+
router.push('/analyze/blast');
|
| 219 |
+
};
|
| 220 |
+
|
| 221 |
+
const goPairwise = () => {
|
| 222 |
+
sessionStorage.setItem('pairwise_sequence_a', sequence);
|
| 223 |
+
router.push('/analyze/pairwise');
|
| 224 |
+
};
|
| 225 |
+
|
| 226 |
+
const goDotPlot = () => {
|
| 227 |
+
router.push(`/analyze/dotplot?seq_a=${encodeURIComponent(sequence.replace(/[^A-Za-z]/g, '').toUpperCase())}&self=1`);
|
| 228 |
+
};
|
| 229 |
+
|
| 230 |
const groupedPresets = useMemo(() => {
|
| 231 |
const groups = new Map<string, MotifLibraryPattern[]>();
|
| 232 |
for (const p of patterns) {
|
|
|
|
| 380 |
</CriticalButton>
|
| 381 |
</div>
|
| 382 |
|
| 383 |
+
{canRun && (
|
| 384 |
+
<div className="flex items-center gap-2 flex-wrap">
|
| 385 |
+
<span className="text-[10px] uppercase tracking-wider text-text-muted mr-1">Continue in:</span>
|
| 386 |
+
<button
|
| 387 |
+
onClick={goBlast}
|
| 388 |
+
className="inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded border border-glass-border bg-surface-1 text-text-secondary hover:text-accent-cyan transition"
|
| 389 |
+
>
|
| 390 |
+
<Search className="w-3.5 h-3.5" /> BLAST
|
| 391 |
+
</button>
|
| 392 |
+
<button
|
| 393 |
+
onClick={goPairwise}
|
| 394 |
+
className="inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded border border-glass-border bg-surface-1 text-text-secondary hover:text-accent-cyan transition"
|
| 395 |
+
>
|
| 396 |
+
<ArrowSwap className="w-3.5 h-3.5" /> Pairwise align
|
| 397 |
+
</button>
|
| 398 |
+
<button
|
| 399 |
+
onClick={goDotPlot}
|
| 400 |
+
className="inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded border border-glass-border bg-surface-1 text-text-secondary hover:text-accent-cyan transition"
|
| 401 |
+
>
|
| 402 |
+
<Scatter className="w-3.5 h-3.5" /> Dot plot
|
| 403 |
+
</button>
|
| 404 |
+
</div>
|
| 405 |
+
)}
|
| 406 |
+
|
| 407 |
{error && (
|
| 408 |
<div className="rounded-lg bg-error/10 border border-error/30 px-4 py-3 text-sm text-error">
|
| 409 |
<strong>Scan failed:</strong> {error}
|
bioai-platform/frontend/src/app/(dashboard)/analyze/pairwise/page.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
'use client';
|
| 2 |
|
| 3 |
-
import { useState } from 'react';
|
| 4 |
import { motion } from 'framer-motion';
|
| 5 |
import { ArrowsLeftRight as ArrowSwap, CircleNotch as LoaderCircle } from '@phosphor-icons/react';
|
| 6 |
import { fadeUp } from '@/lib/animations';
|
|
@@ -44,6 +44,14 @@ export default function PairwiseAlignPage() {
|
|
| 44 |
const [error, setError] = useState<string | null>(null);
|
| 45 |
const audit = useAuditTrail();
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
const lenA = cleanLength(seqA);
|
| 48 |
const lenB = cleanLength(seqB);
|
| 49 |
const canRun = lenA >= 2 && lenB >= 2 && !loading;
|
|
|
|
| 1 |
'use client';
|
| 2 |
|
| 3 |
+
import { useState, useEffect } from 'react';
|
| 4 |
import { motion } from 'framer-motion';
|
| 5 |
import { ArrowsLeftRight as ArrowSwap, CircleNotch as LoaderCircle } from '@phosphor-icons/react';
|
| 6 |
import { fadeUp } from '@/lib/animations';
|
|
|
|
| 44 |
const [error, setError] = useState<string | null>(null);
|
| 45 |
const audit = useAuditTrail();
|
| 46 |
|
| 47 |
+
useEffect(() => {
|
| 48 |
+
const stored = sessionStorage.getItem('pairwise_sequence_a');
|
| 49 |
+
if (stored) {
|
| 50 |
+
sessionStorage.removeItem('pairwise_sequence_a');
|
| 51 |
+
setSeqA(stored);
|
| 52 |
+
}
|
| 53 |
+
}, []);
|
| 54 |
+
|
| 55 |
const lenA = cleanLength(seqA);
|
| 56 |
const lenB = cleanLength(seqB);
|
| 57 |
const canRun = lenA >= 2 && lenB >= 2 && !loading;
|
bioai-platform/frontend/src/app/(dashboard)/analyze/structure/page.tsx
CHANGED
|
@@ -115,7 +115,19 @@ export default function StructurePage() {
|
|
| 115 |
</div>
|
| 116 |
</motion.div>
|
| 117 |
|
| 118 |
-
{error &&
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
{result && (
|
| 121 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show" className="space-y-4">
|
|
|
|
| 115 |
</div>
|
| 116 |
</motion.div>
|
| 117 |
|
| 118 |
+
{error && (
|
| 119 |
+
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show" className="glass-card p-4 border border-error/20">
|
| 120 |
+
<p className="text-sm text-error">{error}</p>
|
| 121 |
+
{linkHighlight && (
|
| 122 |
+
<div className="mt-2 text-xs text-text-muted">
|
| 123 |
+
Couldn't find a structure for{' '}
|
| 124 |
+
<code className="font-mono text-text-secondary">{linkHighlight.acc}</code>. AlphaFold and PDB may not
|
| 125 |
+
cover this accession. Search with a UniProt accession (e.g. P04637) or a PDB ID (e.g. 1TIM) to continue,
|
| 126 |
+
then use the motif scanner's highlight again.
|
| 127 |
+
</div>
|
| 128 |
+
)}
|
| 129 |
+
</motion.div>
|
| 130 |
+
)}
|
| 131 |
|
| 132 |
{result && (
|
| 133 |
<motion.div variants={fadeUp} initial={{ y: 24 }} animate="show" className="space-y-4">
|
bioai-platform/frontend/src/components/results/BlastPanel.tsx
CHANGED
|
@@ -100,7 +100,7 @@ export function BlastPanel({ hits, count, source, querySequence }: BlastPanelPro
|
|
| 100 |
<Scatter className="w-3.5 h-3.5" /> Dot plot vs query
|
| 101 |
</a>
|
| 102 |
<a
|
| 103 |
-
href={`/analyze/motif?sequence=${encodeURIComponent((hit.hit_alignment || hit.midline || '').replace(/-/g, ''))}`}
|
| 104 |
className="inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded border border-glass-border bg-surface-1 text-text-secondary hover:text-accent-purple transition"
|
| 105 |
>
|
| 106 |
<Target className="w-3.5 h-3.5" /> Scan for motifs
|
|
|
|
| 100 |
<Scatter className="w-3.5 h-3.5" /> Dot plot vs query
|
| 101 |
</a>
|
| 102 |
<a
|
| 103 |
+
href={`/analyze/motif?sequence=${encodeURIComponent((hit.hit_alignment || hit.midline || '').replace(/-/g, ''))}&uniprot=${encodeURIComponent(hit.accession)}`}
|
| 104 |
className="inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded border border-glass-border bg-surface-1 text-text-secondary hover:text-accent-purple transition"
|
| 105 |
>
|
| 106 |
<Target className="w-3.5 h-3.5" /> Scan for motifs
|