frontend: the Rugnux live page as one control-room screen
The live page no longer scrolls on a desktop screen: a dark stage the height of the window holds, top to bottom, the phase (collecting, processing, done with the verdict's colour) with the two progress bars - the detector's images against the collection and the step rugnux is on against its own pass - and the clock the run is judged by (since the first image while it runs, last image to all written when it is over, with the deadline counting down in between); one row of eight hero numbers (resolution, CC1/2, I/sigma, completeness, R_meas or R_split, ISa or the serial indexing rate, space group with the cell, the model's R-free); and the stage proper - the placed model in Mol* on the left, filling its panel, the triage list and the merging statistics by shell on the right. While there is no model the left half lists the run's steps with the running one's progress. Serial data put the pre-pass's decisions where rotation data put the lattice probe. The hero numbers come out of the summary's Signal and Completeness rows, which is where the status carries them. The timeline, the steps with their notes, the summary rows, the warnings, the model scores and the serial pre-pass geometry move under a "Details" fold below the stage, on the page's light background; the settings stay below that. The shell plots take the colours of the enclosing theme and a height, the structure viewer can fill its parent, and the wide page may use up to 3400 px so a 4k screen is not left half empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
This commit is contained in:
1 parent
d5ec4920a1
commit
2ce722d1ec
5 files changed
+444
-228
No files matched your search
@@ -313,7 +313,7 @@ function App() {
|
||||
<Box component="main" sx={{ flexGrow: 1, p: 3, pb: '84px', minWidth: 0 }}>
|
||||
<Toolbar/>
|
||||
<ErrorMessage s={s.broker}/>
|
||||
<Box sx={{ maxWidth: activeItem.wide ? 2400 : 1300, mx: 'auto', mt: 2 }}>
|
||||
<Box sx={{ maxWidth: activeItem.wide ? 3400 : 1300, mx: 'auto', mt: 2 }}>
|
||||
{activeItem.render?.()}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import {Box, Paper, Tooltip, Typography} from "@mui/material";
|
||||
import {green, grey, indigo, red} from "@mui/material/colors";
|
||||
import {Box, Tooltip, Typography} from "@mui/material";
|
||||
import {green, red} from "@mui/material/colors";
|
||||
import {keyframes} from "@mui/system";
|
||||
import {rugnux_live_status} from "../client";
|
||||
|
||||
// The headline of a rugnux live run as big numbers, as jfjoch_viewer's merge-statistics window opens:
|
||||
// resolution, ISa, space group, and whether the model was placed. "—" until the run is over.
|
||||
// The headline of a rugnux live run as one row of big numbers, read left to right the way a crystallographer
|
||||
// reads a merge: how far, how clean, how complete, in what symmetry, and whether the model fits. "—" until
|
||||
// the merge the numbers are of exists (the end of a rotation run, each provisional merge of a serial one).
|
||||
|
||||
const fadeIn = keyframes`
|
||||
from { opacity: 0; transform: scale(.94); }
|
||||
@@ -13,7 +14,7 @@ const fadeIn = keyframes`
|
||||
|
||||
// The short Hermann-Mauguin symbol with screw axes subscripted and rotoinversions overlined, as the viewer
|
||||
// writes it: "P 1 21 1" -> P2₁, "P 41 21 2" -> P4₁2₁2, "R 3 :H" -> H3.
|
||||
function SpaceGroup({hm}: { hm: string }) {
|
||||
export function SpaceGroup({hm}: { hm: string }) {
|
||||
const [symbol, setting] = hm.split(":").map(x => x.trim());
|
||||
let s = symbol;
|
||||
// the monoclinic shortening: "P 1 21 1" -> "P 21"
|
||||
@@ -31,107 +32,135 @@ function SpaceGroup({hm}: { hm: string }) {
|
||||
})}</>;
|
||||
}
|
||||
|
||||
type Tone = "plain" | "pending" | "good" | "bad" | "neutral";
|
||||
type Tone = "plain" | "pending" | "good" | "bad";
|
||||
|
||||
const TONE: Record<Tone, { bg: string, border: string, value: string }> = {
|
||||
plain: {bg: "#fff", border: indigo[100], value: indigo[900]},
|
||||
pending: {bg: grey[50], border: grey[200], value: indigo[200]},
|
||||
good: {bg: green[50], border: green[400], value: green[800]},
|
||||
bad: {bg: red[50], border: red[300], value: red[800]},
|
||||
neutral: {bg: grey[100], border: grey[300], value: grey[600]},
|
||||
};
|
||||
const VALUE_COLOUR: Record<Tone, string> = {plain: "text.primary", pending: "text.disabled", good: green[300], bad: red[300]};
|
||||
|
||||
function Card({value, caption, sub, tip, tone}:
|
||||
function Tile({value, caption, sub, tip, tone}:
|
||||
{ value: React.ReactNode, caption: string, sub?: string, tip: React.ReactNode, tone: Tone }) {
|
||||
const c = TONE[tone];
|
||||
return (
|
||||
<Tooltip title={tip} arrow placement="bottom">
|
||||
<Paper variant="outlined" sx={{px: 2, py: 1.5, textAlign: "center", minWidth: 0, bgcolor: c.bg,
|
||||
borderColor: c.border, borderWidth: tone === "good" || tone === "bad" ? 2 : 1}}>
|
||||
<Box sx={{px: 1.5, py: 1, minWidth: 0, borderLeft: "3px solid",
|
||||
borderColor: tone === "good" ? green[400] : tone === "bad" ? red[400] : "divider"}}>
|
||||
<Typography sx={{fontSize: "0.7rem", fontWeight: 700, letterSpacing: ".1em", textTransform: "uppercase",
|
||||
color: "text.secondary", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis"}}>
|
||||
{caption}
|
||||
</Typography>
|
||||
<Typography key={String(value)} component="div"
|
||||
sx={{fontSize: "clamp(1.4rem, 2.4vw, 2.75rem)", lineHeight: 1.15, fontWeight: 800, color: c.value,
|
||||
fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap", overflow: "hidden",
|
||||
textOverflow: "ellipsis", animation: `${fadeIn} 500ms ease-out`,
|
||||
sx={{fontSize: "clamp(1.5rem, 1.9vw, 3.4rem)", lineHeight: 1.15, fontWeight: 800,
|
||||
color: VALUE_COLOUR[tone], fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap",
|
||||
overflow: "hidden", textOverflow: "ellipsis", animation: `${fadeIn} 500ms ease-out`,
|
||||
"@media (prefers-reduced-motion: reduce)": {animation: "none"}}}>
|
||||
{value}
|
||||
</Typography>
|
||||
<Typography sx={{fontSize: "0.8rem", fontWeight: 700, letterSpacing: ".08em", textTransform: "uppercase",
|
||||
color: "text.secondary"}}>
|
||||
{caption}
|
||||
</Typography>
|
||||
<Typography sx={{fontSize: "0.85rem", color: "text.secondary", minHeight: "1.3em", whiteSpace: "nowrap",
|
||||
<Typography sx={{fontSize: "0.78rem", color: "text.secondary", minHeight: "1.3em", whiteSpace: "nowrap",
|
||||
overflow: "hidden", textOverflow: "ellipsis"}}>
|
||||
{sub ?? ""}
|
||||
</Typography>
|
||||
</Paper>
|
||||
</Box>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
// The run-wide merging statistics exist only as the words of the report's Signal and Completeness rows
|
||||
// ("I/sigma 35.2 R_meas 4.8 % CC1/2 1.000 ISa 30.2", "85.7 % over the full written range"); they are
|
||||
// read back out of them here. A status that carried them as numbers would make this go away.
|
||||
function summaryNumber(s: rugnux_live_status, row: RegExp, key: RegExp): number | undefined {
|
||||
const text = s.summary.find(r => row.test(r.label))?.value;
|
||||
const m = text?.match(key);
|
||||
return m ? parseFloat(m[1]) : undefined;
|
||||
}
|
||||
|
||||
const FIT_TIP = "Fit over random: how far the placed model's R-work stands below that of the same model refitted "
|
||||
+ "in random orientations, in standard deviations of those. It is the test rugnux places a model by, for "
|
||||
+ "molecular replacement and for a model that fits where it is alike. Green: rugnux placed the model; "
|
||||
+ "red: it did not.";
|
||||
+ "in random orientations, in standard deviations of those. It is the test rugnux places a model by. "
|
||||
+ "Green: rugnux placed the model; red: it did not.";
|
||||
|
||||
const REFINED_TIP = "R-work and R-free of the placed model after rugnux refined it against these data (rigid bodies "
|
||||
+ "and grouped B, then every atom restrained by the dictionary), R-free on the merge's own free set.";
|
||||
|
||||
// The model card: green where rugnux placed the model (by molecular replacement or where it was), red where it
|
||||
// did not, grey where there was no model to place; once refined, the refined R-free is its context line.
|
||||
// modelLoaded: a model is uploaded now.
|
||||
function ModelCard({s, modelLoaded}: { s: rugnux_live_status, modelLoaded: boolean }) {
|
||||
// The model tile: green where rugnux placed the model, red where it did not, plain where there was none.
|
||||
// Once refined, the refined R-work / R-free are the number. modelLoaded: a model is uploaded now.
|
||||
function ModelTile({s, modelLoaded}: { s: rugnux_live_status, modelLoaded: boolean }) {
|
||||
const m = s.model;
|
||||
const fit = m?.fit_sigma != null ? `${m.fit_sigma >= 0 ? "+" : ""}${m.fit_sigma.toFixed(1)} σ` : undefined;
|
||||
if (m && m.placement !== "NOT_PLACED") {
|
||||
const how = m.placement === "MR"
|
||||
? `MR · ${m.copies ?? 1} ${m.copies === 1 || m.copies === undefined ? "copy" : "copies"}`
|
||||
: "fits where it is";
|
||||
// Refined: its R-work / R-free are the headline, the card's green still says the model was placed
|
||||
const rf = m.refinement?.performed ? m.refinement : undefined;
|
||||
if (rf && rf.r_work != null && rf.r_free != null)
|
||||
return <Card value={`${rf.r_work.toFixed(2)} / ${rf.r_free.toFixed(2)}`} caption="R-work / R-free, refined"
|
||||
sub={`placed: ${how}${fit ? ` · fit ${fit}` : ""}`} tone="good"
|
||||
tip={<>{REFINED_TIP}{rf.cancelled && " The deadline cut the refinement short."}<br/><br/>{FIT_TIP}</>}/>;
|
||||
return <Card value={fit ?? "Placed"} caption="Model placed" sub={how} tone="good" tip={FIT_TIP}/>;
|
||||
return <Tile value={rf.r_free.toFixed(3)} caption="R-free · refined"
|
||||
sub={`R-work ${rf.r_work.toFixed(3)} · ${how}${fit ? ` · fit ${fit}` : ""}`} tone="good"
|
||||
tip={<>R-work and R-free of the placed model after rugnux refined it against these data, R-free
|
||||
on the merge's own free set.{rf.cancelled && " The deadline cut the refinement short."}
|
||||
<br/><br/>{FIT_TIP}</>}/>;
|
||||
if (m.r_work != null && m.r_free != null)
|
||||
return <Tile value={m.r_free.toFixed(3)} caption="R-free · as placed"
|
||||
sub={`R-work ${m.r_work.toFixed(3)} · ${how}${fit ? ` · fit ${fit}` : ""}`} tone="good" tip={FIT_TIP}/>;
|
||||
return <Tile value={fit ?? "Placed"} caption="Model" sub={how} tone="good" tip={FIT_TIP}/>;
|
||||
}
|
||||
if (m) {
|
||||
// "NOT_PLACED: no group of ..." -> "no group of ..."
|
||||
const why = m.reason || m.mr_decision.replace(/^[A-Z_]+: /, "");
|
||||
return <Card value={fit ?? "Not placed"} caption="Model not placed" sub={why} tone="bad"
|
||||
return <Tile value={fit ?? "Not placed"} caption="Model" sub={why} tone="bad"
|
||||
tip={<>{FIT_TIP}{why && <><br/><br/>{why}</>}</>}/>;
|
||||
}
|
||||
if (s.state === "Running" && modelLoaded) {
|
||||
const step = s.steps.length > 0 ? s.steps[s.steps.length - 1].title : "";
|
||||
const sub = step === "Molecular replacement" ? "searching…" : step === "Refinement" ? "refining…"
|
||||
: "placed after merging";
|
||||
return <Card value="—" caption="Model" sub={sub} tone="pending" tip={FIT_TIP}/>;
|
||||
: "placed after the merge";
|
||||
return <Tile value="—" caption="Model" sub={sub} tone="pending" tip={FIT_TIP}/>;
|
||||
}
|
||||
if (s.state === "Running" || !modelLoaded)
|
||||
return <Card value="No model" caption="Model" sub="upload one below" tone="neutral"
|
||||
tip="No model was uploaded for this run, so none was placed. Molecular replacement runs on the next collection after a model is uploaded below."/>;
|
||||
return <Card value="—" caption="Model" sub="not used in this run" tone="neutral"
|
||||
return <Tile value="none" caption="Model" sub="upload one in the settings" tone="plain"
|
||||
tip="No model was uploaded for this run, so none was placed. Molecular replacement runs on the next collection after a model is uploaded."/>;
|
||||
return <Tile value="—" caption="Model" sub="not used in this run" tone="plain"
|
||||
tip="The run ended without placing the model - the steps and warnings say why."/>;
|
||||
}
|
||||
|
||||
function RugnuxHero({s, modelLoaded}: { s: rugnux_live_status, modelLoaded: boolean }) {
|
||||
const pending = s.state === "Running";
|
||||
const later = pending ? "when the run is over" : undefined;
|
||||
const tone: Tone = pending ? "pending" : "plain";
|
||||
// the numbers are of a merge that exists: rotation - the run is over; serial - a provisional merge is in
|
||||
const merged = s.d_min !== undefined || (s.shells !== undefined && s.shells.length > 0);
|
||||
const pending: Tone = merged ? "plain" : "pending";
|
||||
const later = merged ? undefined : s.stills ? "at the first provisional merge" : "when the run is over";
|
||||
const num = (v: number | undefined, fmt: (x: number) => string) => v !== undefined ? fmt(v) : "—";
|
||||
const pct = (x: number) => `${x.toFixed(1)} %`;
|
||||
|
||||
const ccHalf = summaryNumber(s, /^signal/i, /CC1\/2\s+([\d.]+)/);
|
||||
const iSigma = summaryNumber(s, /^signal/i, /I\/sigma\s+([\d.]+)/);
|
||||
const rMeas = summaryNumber(s, /^signal/i, /R_meas\s+([\d.]+)\s*%/);
|
||||
const rSplit = summaryNumber(s, /^signal/i, /R_split\s+([\d.]+)\s*%/);
|
||||
const completeness = summaryNumber(s, /^completeness/i, /([\d.]+)\s*%/);
|
||||
const cell = s.summary.find(r => /^unit cell/i.test(r.label))?.value;
|
||||
const mrGroup = s.model?.mr_space_group;
|
||||
const indexed = s.stills && s.stills.images_analysed > 0
|
||||
? 100 * s.stills.images_indexed / s.stills.images_analysed : undefined;
|
||||
|
||||
return (
|
||||
<Box sx={{display: "grid", gap: 2, gridTemplateColumns: {xs: "repeat(2, minmax(0, 1fr))", md: "repeat(4, minmax(0, 1fr))"}}}>
|
||||
<Card value={s.d_min !== undefined ? `${s.d_min.toFixed(2)} Å` : "—"} caption="Resolution" sub={later}
|
||||
tone={s.d_min !== undefined ? "plain" : tone}
|
||||
<Box sx={{display: "grid", gap: 1, gridTemplateColumns: {xs: "repeat(2, minmax(0, 1fr))", md: "repeat(4, minmax(0, 1fr))",
|
||||
lg: "repeat(8, minmax(0, 1fr))"}}}>
|
||||
<Tile value={num(s.d_min, x => `${x.toFixed(2)} Å`)} caption="Resolution" sub={later} tone={pending}
|
||||
tip="High-resolution limit of the merge (d_min); the Resolution row of the result says where the CC½ fall-off is fitted."/>
|
||||
<Card value={s.isa !== undefined ? s.isa.toFixed(1) : "—"} caption="ISa"
|
||||
sub={later ?? (s.isa === undefined ? "not determined" : undefined)}
|
||||
tone={s.isa !== undefined ? "plain" : tone}
|
||||
tip="ISa: the I/σ the strongest reflections level off at, from the error model (XDS's meaning). It measures the crystal and the instrument, not the exposure."/>
|
||||
<Card value={s.space_group ? <SpaceGroup hm={s.space_group}/> : "—"} caption="Space group"
|
||||
sub={later ?? (mrGroup && s.space_group && mrGroup !== s.space_group ? `model placed in ${mrGroup}` : s.space_group)}
|
||||
tone={s.space_group ? "plain" : tone}
|
||||
tip="Space group rugnux determined from the data. Where molecular replacement placed the model in another group, the card says which."/>
|
||||
<ModelCard s={s} modelLoaded={modelLoaded}/>
|
||||
<Tile value={num(ccHalf, x => x.toFixed(3))} caption="CC½" sub={later ?? "all reflections"} tone={pending}
|
||||
tip="CC½ of the whole merge, the half-dataset correlation; the plot on the right has it by shell."/>
|
||||
<Tile value={num(iSigma, x => x.toFixed(1))} caption="I/σ" sub={later ?? "mean over the merge"} tone={pending}
|
||||
tip="Mean I/σ of the merged reflections over the whole written range."/>
|
||||
<Tile value={num(completeness, pct)} caption="Completeness" sub={later ?? "full written range"} tone={pending}
|
||||
tip="Completeness of the merge over the full written resolution range."/>
|
||||
{s.stills
|
||||
? <Tile value={num(rSplit, pct)} caption="R split" sub={later ?? "half-set agreement"} tone={pending}
|
||||
tip="R_split between the two half-sets of the serial merge."/>
|
||||
: <Tile value={num(rMeas, pct)} caption="R meas" sub={later ?? "all reflections"} tone={pending}
|
||||
tip="R_meas of the whole merge, the multiplicity-independent merging R."/>}
|
||||
{s.stills
|
||||
? <Tile value={num(indexed, pct)} caption="Indexed" tone={indexed !== undefined ? "plain" : "pending"}
|
||||
sub={`${s.stills.images_indexed.toLocaleString()} of ${s.stills.images_analysed.toLocaleString()} images`}
|
||||
tip="Images the GPU analysis indexed, of those analysed since the pre-pass."/>
|
||||
: <Tile value={num(s.isa, x => x.toFixed(1))} caption="ISa" sub={later ?? (s.isa === undefined ? "not determined" : "error model")}
|
||||
tone={pending}
|
||||
tip="ISa: the I/σ the strongest reflections level off at, from the error model (XDS's meaning). It measures the crystal and the instrument, not the exposure."/>}
|
||||
<Tile value={s.space_group ? <SpaceGroup hm={s.space_group}/> : "—"} caption="Space group" tone={s.space_group ? "plain" : pending}
|
||||
sub={later ?? (mrGroup && s.space_group && mrGroup !== s.space_group ? `model placed in ${mrGroup}` : cell)}
|
||||
tip={<>Space group rugnux determined from the data{cell && <>, unit cell {cell}</>}. Where molecular
|
||||
replacement placed the model in another group, the tile says which.</>}/>
|
||||
<ModelTile s={s} modelLoaded={modelLoaded}/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import {Alert, Box, LinearProgress, Paper, Stack, Typography} from "@mui/material";
|
||||
import {indigo, lime, grey} from "@mui/material/colors";
|
||||
import {Alert, Box, Button, Collapse, Paper, Stack, ThemeProvider, Typography, createTheme} from "@mui/material";
|
||||
import {green, indigo, lime, orange, red, grey} from "@mui/material/colors";
|
||||
import {keyframes} from "@mui/system";
|
||||
import {useQuery} from "@tanstack/react-query";
|
||||
import {getConfigRugnuxOptions, getRugnuxStatusOptions} from "../client/@tanstack/react-query.gen";
|
||||
import {rugnux_live_status} from "../client";
|
||||
import {rugnux_live_status, rugnux_live_step, rugnux_live_stills} from "../client";
|
||||
import {useTokenRequired} from "../auth";
|
||||
import EmptyState from "./EmptyState";
|
||||
import RugnuxTriage from "./RugnuxTriage";
|
||||
@@ -11,28 +12,183 @@ import RugnuxSettings from "./RugnuxSettings";
|
||||
import RugnuxHero from "./RugnuxHero";
|
||||
import RugnuxStills from "./RugnuxStills";
|
||||
import RugnuxShellPlots from "./RugnuxShellPlots";
|
||||
import {CutAlert, lastImageTime, ModelScores, ProbeAlert, RunMessage, StateChip, StepTable, VerdictAlert} from "./RugnuxParts";
|
||||
import {lastImageTime, ModelScores, StepTable, VerdictAlert} from "./RugnuxParts";
|
||||
import BoltIcon from "@mui/icons-material/Bolt";
|
||||
import {lazy, Suspense} from "react";
|
||||
import {keyframes} from "@mui/system";
|
||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||
import CheckIcon from "@mui/icons-material/Check";
|
||||
import {lazy, Suspense, useEffect, useRef, useState} from "react";
|
||||
|
||||
// The live page as one control-room screen: a dark stage that holds, top to bottom, the state and the two
|
||||
// progress bars (the detector's and rugnux's), the hero numbers of the merge, and the stage proper - the placed
|
||||
// model in Mol* on the left, the triage list and the merging statistics by shell on the right. While there is
|
||||
// no model the left half shows the run's steps. Everything else - the timeline, step notes, summary rows,
|
||||
// warnings, the serial pre-pass geometry - sits under a "Details" fold below the stage, and the settings
|
||||
// under that, on the page's ordinary light background.
|
||||
|
||||
// Mol* is large: loaded only when there is a model to show.
|
||||
const RugnuxStructureViewer = lazy(() => import("./RugnuxStructureViewer"));
|
||||
|
||||
// The summary rows rugnux writes; the ones a crystallographer looks at first get a stronger tile.
|
||||
const KEY_ROW = /unit cell|space group|resolution|signal|r-?free|model/i;
|
||||
// The dark room: the app's indigo/lime, on a navy stage the viewer's black blends into.
|
||||
const liveTheme = createTheme({
|
||||
palette: {
|
||||
mode: "dark",
|
||||
primary: {main: indigo[300]},
|
||||
secondary: {main: lime[500]},
|
||||
background: {default: "#0c1122", paper: "#151c33"},
|
||||
text: {primary: "#e9edf7", secondary: "#9aa5c4", disabled: "#596483"},
|
||||
divider: "rgba(154,165,196,.22)",
|
||||
},
|
||||
shape: {borderRadius: 8},
|
||||
});
|
||||
|
||||
// The model section's entrance under the timeline, once the run has placed a model
|
||||
const slideIn = keyframes`
|
||||
from { opacity: 0; transform: translateY(24px); }
|
||||
to { opacity: 1; transform: none; }
|
||||
const stripes = keyframes`
|
||||
from { background-position: 0 0; }
|
||||
to { background-position: 40px 0; }
|
||||
`;
|
||||
const pulse = keyframes`
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: .45; }
|
||||
`;
|
||||
|
||||
function Section({title, children, sx}: { title: string, children: React.ReactNode, sx?: object }) {
|
||||
const runningSx = {
|
||||
backgroundImage: "linear-gradient(135deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, "
|
||||
+ "rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%, transparent)",
|
||||
backgroundSize: "40px 40px",
|
||||
animation: `${stripes} 1s linear infinite`,
|
||||
"@media (prefers-reduced-motion: reduce)": {animation: "none"},
|
||||
};
|
||||
|
||||
// What the run is doing, in one word, with the colour the rest of the screen takes from it.
|
||||
function phase(s: rugnux_live_status): { label: string, colour: string } {
|
||||
if (s.state === "Running")
|
||||
return lastImageTime(s) === undefined
|
||||
? {label: "Collecting", colour: lime[500]} : {label: "Processing", colour: indigo[300]};
|
||||
if (s.state === "Done")
|
||||
return s.verdict === "OK" ? {label: "Done", colour: green[400]}
|
||||
: s.verdict === "WARNINGS" ? {label: "Done · warnings", colour: orange[400]}
|
||||
: {label: `Done · ${s.verdict.toLowerCase()}`, colour: red[400]};
|
||||
if (s.state === "Failed")
|
||||
return {label: "Failed", colour: red[400]};
|
||||
return {label: s.state, colour: grey[500]};
|
||||
}
|
||||
|
||||
// The serial pre-pass in one line: its state, and what it decided for the whole collection
|
||||
function prepassLine(st: rugnux_live_stills) {
|
||||
if (st.prepass === "Holding")
|
||||
return `Pre-pass: holding ${st.images_held} / ${st.images_needed} images`;
|
||||
if (st.prepass === "Running")
|
||||
return `Pre-pass on the first ${st.images_held} images`;
|
||||
if (st.prepass === "Failed")
|
||||
return "Pre-pass failed: the stated beam centre and mask are used";
|
||||
const shift = st.beam_x_pxl !== undefined && st.beam_y_pxl !== undefined
|
||||
? Math.hypot(st.beam_x_pxl - st.file_beam_x_pxl, st.beam_y_pxl - st.file_beam_y_pxl) : undefined;
|
||||
return `Pre-pass on ${st.images_held} images in ${st.prepass_s?.toFixed(1)} s`
|
||||
+ (shift !== undefined ? ` · beam centre moved ${shift.toFixed(1)} px` : "")
|
||||
+ (st.distance_mm !== undefined ? ` · distance ${(st.distance_mm - st.file_distance_mm) >= 0 ? "+" : ""}${(st.distance_mm - st.file_distance_mm).toFixed(2)} mm` : "")
|
||||
+ (st.analysis_rate_hz !== undefined ? ` · GPU analysis ${st.analysis_rate_hz.toFixed(0)} Hz` : "");
|
||||
}
|
||||
|
||||
// A progress bar with its caption inside: fraction undefined = busy without a measure (striped, full).
|
||||
function Bar({caption, detail, fraction, colour, busy}:
|
||||
{ caption: string, detail: string, fraction?: number, colour: string, busy: boolean }) {
|
||||
const width = fraction === undefined ? (busy ? 100 : 0) : 100 * Math.min(1, Math.max(0, fraction));
|
||||
return (
|
||||
<Paper sx={{p: 3, height: "100%", ...sx}}>
|
||||
<Typography sx={{fontSize: "0.8rem", fontWeight: 700, letterSpacing: ".08em", textTransform: "uppercase",
|
||||
color: "primary.dark", mb: 2}}>
|
||||
<Box sx={{position: "relative", height: 30, borderRadius: 1.5, bgcolor: "rgba(255,255,255,.07)", overflow: "hidden"}}>
|
||||
<Box sx={{position: "absolute", left: 0, top: 0, bottom: 0, width: `${width}%`, bgcolor: colour,
|
||||
transition: "width 400ms ease-out", opacity: fraction === undefined && busy ? 0.5 : 1,
|
||||
...(busy && runningSx)}}/>
|
||||
<Box sx={{position: "absolute", inset: 0, display: "flex", alignItems: "center", px: 1.5, gap: 2,
|
||||
mixBlendMode: "screen"}}>
|
||||
<Typography sx={{fontWeight: 800, fontSize: "0.95rem", letterSpacing: ".04em", whiteSpace: "nowrap", color: "#fff"}}>
|
||||
{caption}
|
||||
</Typography>
|
||||
<Typography sx={{fontSize: "0.9rem", color: "#fff", whiteSpace: "nowrap", overflow: "hidden",
|
||||
textOverflow: "ellipsis", ml: "auto", fontVariantNumeric: "tabular-nums"}}>
|
||||
{detail}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
// Phase, the two bars and the clock: images against the collection on the detector's bar, the step rugnux is
|
||||
// on against its own pass on rugnux's - the second chases the first while collecting - and, at the right,
|
||||
// the number the run is judged by: seconds since the first image while it runs, from the last image to all
|
||||
// results written once it is over.
|
||||
function Header({s, deadline_s}: { s: rugnux_live_status, deadline_s: number }) {
|
||||
const p = phase(s);
|
||||
const running = s.state === "Running";
|
||||
const lastImage = lastImageTime(s);
|
||||
const collecting = running && lastImage === undefined;
|
||||
const rate = s.images_received > 1 && s.elapsed_s > 0 ? (s.images_received - 1) / (lastImage ?? s.elapsed_s) : 0;
|
||||
const remaining = collecting && rate > 0 ? (s.images_expected - s.images_received) / rate : undefined;
|
||||
const detectorDetail = `${s.images_received.toLocaleString()} / ${s.images_expected.toLocaleString()} images`
|
||||
+ (rate > 0 ? ` · ${rate.toFixed(0)} Hz` : "")
|
||||
+ (remaining !== undefined ? ` · ${remaining.toFixed(0)} s to go` : lastImage !== undefined ? ` · collected in ${lastImage.toFixed(1)} s` : "");
|
||||
|
||||
const step = s.steps.length > 0 ? s.steps[s.steps.length - 1] : undefined;
|
||||
let rugnuxDetail: string, rugnuxFraction: number | undefined;
|
||||
if (running && step) {
|
||||
rugnuxDetail = `${step.title} · step ${s.steps.length}` + (s.step_progress !== undefined ? ` · ${(100 * s.step_progress).toFixed(0)} %` : "");
|
||||
rugnuxFraction = s.step_progress;
|
||||
} else if (running) {
|
||||
rugnuxDetail = "waiting for images";
|
||||
rugnuxFraction = 0;
|
||||
} else {
|
||||
rugnuxDetail = s.cut ? `cut (${s.cut}) after ${s.steps.length} steps` : `${s.steps.length} steps · ${s.elapsed_s.toFixed(1)} s`;
|
||||
rugnuxFraction = 1;
|
||||
}
|
||||
|
||||
const latency = s.last_image_to_written_s;
|
||||
const clock = latency !== undefined
|
||||
? {caption: "last image → all written", value: latency, colour: p.colour}
|
||||
: lastImage !== undefined
|
||||
? {caption: "since the last image", value: s.elapsed_s - lastImage, colour: indigo[200]}
|
||||
: {caption: "since the first image", value: s.elapsed_s, colour: "text.primary"};
|
||||
const deadline = running && lastImage !== undefined && deadline_s > 0 ? lastImage + deadline_s - s.elapsed_s : undefined;
|
||||
|
||||
return (
|
||||
<Box sx={{display: "grid", gridTemplateColumns: {xs: "1fr", md: "minmax(0, 1fr) auto"}, gap: 3, alignItems: "center"}}>
|
||||
<Stack spacing={1} sx={{minWidth: 0}}>
|
||||
<Stack direction="row" spacing={2} alignItems="baseline" sx={{minWidth: 0}}>
|
||||
<Typography sx={{fontSize: "1.35rem", fontWeight: 900, letterSpacing: ".08em", textTransform: "uppercase",
|
||||
color: p.colour, whiteSpace: "nowrap", ...(running && {animation: `${pulse} 2.4s ease-in-out infinite`,
|
||||
"@media (prefers-reduced-motion: reduce)": {animation: "none"}})}}>
|
||||
{p.label}
|
||||
</Typography>
|
||||
<Typography noWrap sx={{color: "text.secondary", minWidth: 0}}>
|
||||
{s.message || s.verdict_text || (s.stills ? prepassLine(s.stills) : s.probe) || "Rugnux live"}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Bar caption="Detector" detail={detectorDetail} colour={lime[700]} busy={collecting}
|
||||
fraction={s.images_expected > 0 ? s.images_received / s.images_expected : undefined}/>
|
||||
<Bar caption="Rugnux" detail={rugnuxDetail} busy={running} fraction={rugnuxFraction}
|
||||
colour={s.state === "Failed" ? red[700] : s.state === "Done" ? green[700] : indigo[500]}/>
|
||||
</Stack>
|
||||
<Box sx={{textAlign: "right", minWidth: 240}}>
|
||||
<Typography sx={{fontSize: "0.75rem", fontWeight: 700, letterSpacing: ".1em", textTransform: "uppercase",
|
||||
color: "text.secondary"}}>
|
||||
{clock.caption}
|
||||
</Typography>
|
||||
<Typography sx={{fontSize: "4rem", lineHeight: 1, fontWeight: 900, color: clock.colour,
|
||||
fontVariantNumeric: "tabular-nums"}}>
|
||||
{clock.value.toFixed(1)}<Box component="span" sx={{fontSize: "1.6rem", ml: 0.5, color: "text.secondary"}}>s</Box>
|
||||
</Typography>
|
||||
<Typography sx={{fontSize: "0.85rem", color: deadline !== undefined && deadline < 10 ? orange[300] : "text.secondary", minHeight: "1.3em"}}>
|
||||
{deadline !== undefined ? `deadline in ${Math.max(0, deadline).toFixed(0)} s`
|
||||
: s.cut ? `analysis cut (${s.cut})${s.cut_s !== undefined ? ` at ${s.cut_s.toFixed(1)} s` : ""}`
|
||||
: s.start_to_first_image_s !== undefined ? `START → first image ${s.start_to_first_image_s.toFixed(1)} s` : ""}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function Panel({title, children, sx}: { title: React.ReactNode, children: React.ReactNode, sx?: object }) {
|
||||
return (
|
||||
<Paper elevation={0} sx={{p: 2, display: "flex", flexDirection: "column", minHeight: 0, minWidth: 0, ...sx}}>
|
||||
<Typography sx={{fontSize: "0.72rem", fontWeight: 700, letterSpacing: ".1em", textTransform: "uppercase",
|
||||
color: "text.secondary", mb: 1}}>
|
||||
{title}
|
||||
</Typography>
|
||||
{children}
|
||||
@@ -40,104 +196,152 @@ function Section({title, children, sx}: { title: string, children: React.ReactNo
|
||||
);
|
||||
}
|
||||
|
||||
function Header({s}: { s: rugnux_live_status }) {
|
||||
const latency = s.last_image_to_written_s;
|
||||
const lastImage = lastImageTime(s);
|
||||
return (
|
||||
<Paper sx={{p: 3, background: `linear-gradient(90deg, ${indigo[50]} 0%, #fff 70%)`}}>
|
||||
<Box sx={{display: "flex", alignItems: "center", gap: 3, flexWrap: "wrap"}}>
|
||||
<Box sx={{flexGrow: 1, minWidth: 280}}>
|
||||
<Stack direction="row" spacing={2} alignItems="center">
|
||||
<Typography variant="h4" sx={{fontWeight: 700, color: "primary.dark"}}>Rugnux live</Typography>
|
||||
<StateChip state={s.state} large/>
|
||||
</Stack>
|
||||
<Typography sx={{mt: 1, color: "text.secondary", fontSize: "1.1rem"}}>
|
||||
{s.images_received} / {s.images_expected} images
|
||||
{lastImage !== undefined && ` · collected in ${lastImage.toFixed(1)} s`}
|
||||
{` · ${s.elapsed_s.toFixed(1)} s since the first image`}
|
||||
{s.start_to_first_image_s !== undefined && ` · START → first image ${s.start_to_first_image_s.toFixed(1)} s`}
|
||||
</Typography>
|
||||
function Later({text}: { text: string }) {
|
||||
return <Typography sx={{color: "text.disabled", m: "auto", textAlign: "center"}}>{text}</Typography>;
|
||||
}
|
||||
|
||||
// The run's steps as a sequence, the running one with its progress: what fills the stage while there is no
|
||||
// model to show.
|
||||
function StepSequence({s}: { s: rugnux_live_status }) {
|
||||
const running = s.state === "Running";
|
||||
const row = (step: rugnux_live_step, i: number) => {
|
||||
const open = step.duration_s === undefined;
|
||||
return (
|
||||
<Box key={i} sx={{display: "grid", gridTemplateColumns: "28px 1fr auto", alignItems: "center", gap: 1.5,
|
||||
py: 0.75, borderBottom: "1px solid", borderColor: "divider", opacity: open && !running ? 0.6 : 1}}>
|
||||
{open && running
|
||||
? <Box sx={{width: 14, height: 14, borderRadius: "50%", bgcolor: indigo[300], mx: "auto",
|
||||
animation: `${pulse} 1.2s ease-in-out infinite`, "@media (prefers-reduced-motion: reduce)": {animation: "none"}}}/>
|
||||
: <CheckIcon sx={{fontSize: 18, color: open ? "text.disabled" : green[400], mx: "auto"}}/>}
|
||||
<Box sx={{minWidth: 0}}>
|
||||
<Typography sx={{fontWeight: open && running ? 800 : 600}}>{step.title}</Typography>
|
||||
{step.notes.length > 0 &&
|
||||
<Typography noWrap sx={{fontSize: "0.82rem", color: "text.secondary"}}>{step.notes[step.notes.length - 1]}</Typography>}
|
||||
</Box>
|
||||
<Box sx={{textAlign: "right", ml: "auto"}}>
|
||||
<Typography sx={{fontSize: "0.85rem", fontWeight: 700, letterSpacing: ".08em",
|
||||
textTransform: "uppercase", color: "text.secondary"}}>
|
||||
{latency !== undefined ? "Last image → all results written" : "Processing for"}
|
||||
</Typography>
|
||||
<Typography sx={{fontSize: "4.5rem", lineHeight: 1.05, fontWeight: 800,
|
||||
color: latency === undefined ? indigo[300] : s.state === 'Done' ? lime[900] : indigo[700]}}>
|
||||
{(latency ?? s.elapsed_s).toFixed(1)} s
|
||||
</Typography>
|
||||
<Typography sx={{fontVariantNumeric: "tabular-nums", color: "text.secondary", whiteSpace: "nowrap"}}>
|
||||
{open ? (running && s.step_progress !== undefined ? `${(100 * s.step_progress).toFixed(0)} %` : "") : `${step.duration_s!.toFixed(1)} s`}
|
||||
</Typography>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
return (
|
||||
<Box sx={{overflowY: "auto", minHeight: 0}}>
|
||||
{s.steps.length === 0 && <Later text={running ? "Rugnux starts on the first images" : "No steps ran"}/>}
|
||||
{s.steps.map(row)}
|
||||
{s.probe && <Typography sx={{mt: 1.5, fontSize: "0.9rem", color: s.probe.startsWith("no lattice") ? orange[300] : "text.secondary"}}>
|
||||
Lattice probe{s.probe_s !== undefined && ` at ${s.probe_s.toFixed(1)} s`}: {s.probe}
|
||||
</Typography>}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function Stage({s}: { s: rugnux_live_status }) {
|
||||
const m = s.model;
|
||||
// The model shows once a rotation run is over; serial data place it on each provisional merge, and the viewer
|
||||
// reloads when the model step has a new result, not every time the status is polled.
|
||||
if (m && s.placed_model && (s.state !== "Running" || s.stills)) {
|
||||
const resultKey = s.stills
|
||||
? `${m.placement} ${m.r_work} ${m.r_free} ${m.refinement?.r_free} ${s.refined_model}`
|
||||
: `${s.elapsed_s}`;
|
||||
return (
|
||||
<Panel title={<>{m.placement === "MR" ? "Molecular replacement" : "Model"}{m.predicted && " · predicted model"}
|
||||
{s.refined_model && " · refined"} · {m.model_name}</>} sx={{flexGrow: 1}}>
|
||||
<Box sx={{flexGrow: 1, minHeight: 0}}>
|
||||
<Suspense fallback={<Later text="Loading viewer..."/>}>
|
||||
<RugnuxStructureViewer resultKey={resultKey} anomalous={s.anomalous_map} fill
|
||||
anomalousSignal={s.anomalous_signal} refined={s.refined_model}
|
||||
blobs={s.refined_model ? m.refinement?.blobs ?? [] : []}/>
|
||||
</Suspense>
|
||||
</Box>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Panel title="Run" sx={{flexGrow: 1}}>
|
||||
<StepSequence s={s}/>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
|
||||
// Height of an element in px, kept up to date as the page resizes: the shell plots need theirs in pixels.
|
||||
function useHeight() {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const [height, setHeight] = useState(0);
|
||||
useEffect(() => {
|
||||
if (!ref.current)
|
||||
return;
|
||||
const observer = new ResizeObserver(entries => setHeight(entries[0].contentRect.height));
|
||||
observer.observe(ref.current);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
return [ref, height] as const;
|
||||
}
|
||||
|
||||
function Dashboard({s, deadline_s, modelLoaded}: { s: rugnux_live_status, deadline_s: number, modelLoaded: boolean }) {
|
||||
const [plotsRef, plotsHeight] = useHeight();
|
||||
const attention = s.triage?.filter(i => i.severity === "serious" || i.severity === "attention").length ?? 0;
|
||||
const later = s.stills ? "at the first provisional merge" : "when the run is over";
|
||||
return (
|
||||
<Box sx={{display: "grid", gridTemplateRows: "auto auto minmax(0, 1fr)", gap: 2, height: "100%", minHeight: 0}}>
|
||||
<Header s={s} deadline_s={deadline_s}/>
|
||||
<RugnuxHero s={s} modelLoaded={modelLoaded}/>
|
||||
<Box sx={{display: "grid", gap: 2, minHeight: 0,
|
||||
gridTemplateColumns: {xs: "1fr", lg: "minmax(0, 11fr) minmax(0, 9fr)"},
|
||||
gridTemplateRows: {xs: "auto", lg: "minmax(0, 1fr)"}}}>
|
||||
<Box sx={{minHeight: {xs: 480, lg: 0}, display: "flex", flexDirection: "column"}}>
|
||||
<Stage s={s}/>
|
||||
</Box>
|
||||
<Box sx={{display: "flex", flexDirection: "column", gap: 2, minHeight: 0}}>
|
||||
<Panel title={<>Triage{attention > 0 && <Box component="span" sx={{color: orange[300]}}> · {attention} need attention</Box>}</>}
|
||||
sx={{flex: "0 1 auto", maxHeight: "45%", overflowY: "auto", "& > *": {flexShrink: 0}}}>
|
||||
{s.triage && s.triage.length > 0 ? <RugnuxTriage items={s.triage}/> : <Later text={`Checked ${later}`}/>}
|
||||
</Panel>
|
||||
<Panel title={<>By resolution{s.shells_merge && ` · merge of ${s.shells_merge}`}</>} sx={{flex: "1 1 0"}}>
|
||||
<Box ref={plotsRef} sx={{flexGrow: 1, minHeight: {xs: 400, lg: 0}, display: "flex"}}>
|
||||
{s.shells && s.shells.length > 0
|
||||
? <Box sx={{width: "100%"}}>
|
||||
<RugnuxShellPlots shells={s.shells} height={Math.max(170, (plotsHeight - 16) / 2)}/>
|
||||
</Box>
|
||||
: <Later text={`Merging statistics ${later}`}/>}
|
||||
</Box>
|
||||
</Panel>
|
||||
</Box>
|
||||
</Box>
|
||||
<RunMessage s={s} sx={{mt: 2}}/>
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
|
||||
function CurrentStep({s}: { s: rugnux_live_status }) {
|
||||
const current = s.state === 'Running' && s.steps.length > 0 ? s.steps[s.steps.length - 1] : undefined;
|
||||
if (!current)
|
||||
return null;
|
||||
return (
|
||||
<Box sx={{mb: 2}}>
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="baseline">
|
||||
<Typography sx={{fontWeight: 700, fontSize: "1.25rem"}}>{current.title}</Typography>
|
||||
{s.step_progress !== undefined &&
|
||||
<Typography sx={{fontWeight: 700, color: "primary.main"}}>{(s.step_progress * 100).toFixed(0)} %</Typography>}
|
||||
</Stack>
|
||||
<LinearProgress variant={s.step_progress !== undefined ? "determinate" : "indeterminate"}
|
||||
value={(s.step_progress ?? 0) * 100} sx={{height: 10, borderRadius: 5, mt: 1}}/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function SummaryTiles({s}: { s: rugnux_live_status }) {
|
||||
if (s.summary.length === 0)
|
||||
return null;
|
||||
return (
|
||||
<Box sx={{display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))", gap: 1.5, mt: 2}}>
|
||||
{s.summary.map((row, i) => {
|
||||
const key = KEY_ROW.test(row.label);
|
||||
const short = row.value.length <= 24;
|
||||
return (
|
||||
<Box key={i} sx={{p: 1.5, borderRadius: 2,
|
||||
bgcolor: key ? indigo[50] : grey[50],
|
||||
border: "1px solid", borderColor: key ? indigo[100] : grey[200]}}>
|
||||
<Typography sx={{fontSize: "0.75rem", fontWeight: 700, letterSpacing: ".06em",
|
||||
textTransform: "uppercase", color: key ? "primary.main" : "text.secondary"}}>
|
||||
{row.label}
|
||||
</Typography>
|
||||
<Typography sx={{fontSize: key && short ? "1.2rem" : "0.95rem", fontWeight: key ? 700 : 400,
|
||||
color: key ? "primary.dark" : "text.primary", wordBreak: "break-word"}}>
|
||||
{row.value}
|
||||
</Typography>
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function ModelSection({s}: { s: rugnux_live_status }) {
|
||||
const m = s.model!;
|
||||
// What the stage leaves out, on the light page: the timeline, the steps with their notes, the summary rows
|
||||
// and warnings, the model's scores, and the serial pre-pass geometry.
|
||||
function Details({s, deadline_s}: { s: rugnux_live_status, deadline_s: number }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const mrSeconds = s.steps.find(step => step.title === "Molecular replacement")?.duration_s;
|
||||
// Serial data place the model on each provisional merge while collecting: the viewer reloads when the model
|
||||
// step has a new result, not every time the status is polled.
|
||||
const resultKey = s.stills
|
||||
? `${m.placement} ${m.r_work} ${m.r_free} ${m.refinement?.r_free} ${s.refined_model}`
|
||||
: `${s.elapsed_s}`;
|
||||
return (
|
||||
<Section title={(m.placement === "MR" ? "Molecular replacement" : "Model") + (m.predicted ? " · predicted model" : "")}
|
||||
sx={{animation: `${slideIn} 700ms ease-out`, "@media (prefers-reduced-motion: reduce)": {animation: "none"}}}>
|
||||
<ModelScores m={m} mrSeconds={mrSeconds} anomalousSignal={s.anomalous_signal}/>
|
||||
{s.placed_model && <Box sx={{mt: 2}}>
|
||||
<Suspense fallback={<Typography color="text.secondary">Loading viewer...</Typography>}>
|
||||
<RugnuxStructureViewer resultKey={resultKey} anomalous={s.anomalous_map}
|
||||
anomalousSignal={s.anomalous_signal} refined={s.refined_model}
|
||||
blobs={s.refined_model ? m.refinement?.blobs ?? [] : []}/>
|
||||
</Suspense>
|
||||
</Box>}
|
||||
</Section>
|
||||
<Paper sx={{p: 2}}>
|
||||
<Button onClick={() => setOpen(o => !o)} size="large"
|
||||
endIcon={<ExpandMoreIcon sx={{transform: open ? "rotate(180deg)" : "none", transition: "transform 200ms"}}/>}>
|
||||
Details - timeline, steps, result rows{s.warnings.length > 0 && `, ${s.warnings.length} warning${s.warnings.length > 1 ? "s" : ""}`}
|
||||
</Button>
|
||||
<Collapse in={open} unmountOnExit>
|
||||
<Stack spacing={3} sx={{mt: 2}}>
|
||||
<RugnuxTimeline s={s} deadline_s={deadline_s}/>
|
||||
{s.stills && <RugnuxStills st={s.stills}/>}
|
||||
{s.model && <ModelScores m={s.model} mrSeconds={mrSeconds} anomalousSignal={s.anomalous_signal}/>}
|
||||
<Box sx={{display: "grid", gridTemplateColumns: {xs: "1fr", lg: "1fr 1fr"}, gap: 3, alignItems: "start"}}>
|
||||
<StepTable steps={s.steps}/>
|
||||
<Stack spacing={2}>
|
||||
<VerdictAlert s={s}/>
|
||||
{s.summary.length > 0 &&
|
||||
<Box component="table" sx={{borderCollapse: "collapse", "& td": {py: 0.5, pr: 2, verticalAlign: "top"},
|
||||
"& td:first-of-type": {fontWeight: 600, whiteSpace: "nowrap"}}}>
|
||||
<tbody>{s.summary.map((row, i) => <tr key={i}><td>{row.label}</td><td>{row.value}</td></tr>)}</tbody>
|
||||
</Box>}
|
||||
{s.warnings.map((w, i) => <Alert key={i} severity="warning">{w}</Alert>)}
|
||||
</Stack>
|
||||
</Box>
|
||||
</Stack>
|
||||
</Collapse>
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -151,58 +355,29 @@ function RugnuxPage({measuring}: { measuring: boolean }) {
|
||||
});
|
||||
const tokenRequired = useTokenRequired();
|
||||
|
||||
let live;
|
||||
let empty;
|
||||
if (settings !== undefined && !enabled)
|
||||
live = <Paper><EmptyState icon={<BoltIcon fontSize="inherit"/>}
|
||||
text="Rugnux live mode is off - enable it below"/></Paper>;
|
||||
empty = "Rugnux live mode is off - enable it below";
|
||||
else if (isError && tokenRequired)
|
||||
live = <Paper><EmptyState icon={<BoltIcon fontSize="inherit"/>}
|
||||
text="Dataset token required (key button in the top bar)"/></Paper>;
|
||||
empty = "Dataset token required (key button in the top bar)";
|
||||
else if (isError || s === undefined || s.state === 'Idle')
|
||||
live = <Paper><EmptyState icon={<BoltIcon fontSize="inherit"/>}
|
||||
text="No rugnux run yet - start a collection with live processing enabled"/></Paper>;
|
||||
else
|
||||
live = (
|
||||
<Stack spacing={2}>
|
||||
<Header s={s}/>
|
||||
{s.stills
|
||||
? <Section title="Serial · pre-pass and GPU analysis"><RugnuxStills st={s.stills}/></Section>
|
||||
: <RugnuxHero s={s} modelLoaded={settings?.model_loaded === true}/>}
|
||||
<CutAlert s={s}/>
|
||||
<ProbeAlert s={s} large/>
|
||||
{s.triage && s.triage.length > 0 && <Section title="Triage"><RugnuxTriage items={s.triage}/></Section>}
|
||||
<Section title="Timeline">
|
||||
<RugnuxTimeline s={s} deadline_s={settings?.deadline_s ?? 0}/>
|
||||
</Section>
|
||||
{s.model && (s.state !== 'Running' || s.stills) && <ModelSection s={s}/>}
|
||||
{s.shells && s.shells.length > 0 &&
|
||||
<Section title="Merging statistics by resolution">
|
||||
<RugnuxShellPlots shells={s.shells} merge={s.shells_merge}/>
|
||||
</Section>}
|
||||
<Box sx={{display: "grid", gridTemplateColumns: {xs: "1fr", lg: s.stills ? "1fr" : "minmax(400px, 1fr) 2fr"}, gap: 2,
|
||||
alignItems: "start"}}>
|
||||
<Section title="Processing">
|
||||
<CurrentStep s={s}/>
|
||||
<StepTable steps={s.steps}/>
|
||||
</Section>
|
||||
{!s.stills && <Section title="Result">
|
||||
{s.verdict
|
||||
? <VerdictAlert s={s}/>
|
||||
: <Typography color="text.secondary">
|
||||
{s.state === 'Running' ? "Results appear when the run is over." : "No result."}
|
||||
</Typography>}
|
||||
<SummaryTiles s={s}/>
|
||||
<Stack spacing={1} sx={{mt: s.warnings.length > 0 ? 2 : 0}}>
|
||||
{s.warnings.map((w, i) => <Alert key={i} severity="warning">{w}</Alert>)}
|
||||
</Stack>
|
||||
</Section>}
|
||||
</Box>
|
||||
</Stack>
|
||||
);
|
||||
empty = "No rugnux run yet - start a collection with live processing enabled";
|
||||
|
||||
// The stage is the height of the window less the app's bars, so the essentials never scroll on a desktop
|
||||
// screen; below the lg breakpoint it flows.
|
||||
return (
|
||||
<Stack spacing={2}>
|
||||
{live}
|
||||
<ThemeProvider theme={liveTheme}>
|
||||
<Box sx={{bgcolor: "background.default", color: "text.primary", borderRadius: 2, p: 2,
|
||||
height: {lg: "calc(100vh - 196px)"}, minHeight: {lg: 720}, overflow: "hidden"}}>
|
||||
{empty || !s
|
||||
? <Box sx={{height: "100%", display: "flex", "& .MuiSvgIcon-root, & p": {color: "text.secondary"}}}>
|
||||
<Box sx={{m: "auto"}}><EmptyState icon={<BoltIcon fontSize="inherit"/>} text={empty ?? ""}/></Box>
|
||||
</Box>
|
||||
: <Dashboard s={s} deadline_s={settings?.deadline_s ?? 0} modelLoaded={settings?.model_loaded === true}/>}
|
||||
</Box>
|
||||
</ThemeProvider>
|
||||
{s && !empty && <Details s={s} deadline_s={settings?.deadline_s ?? 0}/>}
|
||||
<RugnuxSettings measuring={measuring}/>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Box, Typography} from "@mui/material";
|
||||
import {Box, Typography, useTheme} from "@mui/material";
|
||||
import {rugnux_live_shell} from "../client";
|
||||
import Plot from "./Plot";
|
||||
|
||||
@@ -24,7 +24,12 @@ const PANELS: { title: string, percent: boolean, legendLeft?: boolean, series: S
|
||||
]},
|
||||
];
|
||||
|
||||
function RugnuxShellPlots({shells, merge}: { shells: rugnux_live_shell[], merge?: string }) {
|
||||
// height: of each panel in px. The plots take the colours of the enclosing MUI theme, so they read the
|
||||
// same on the light dashboard card and on the dark live page.
|
||||
function RugnuxShellPlots({shells, merge, height = 300}: { shells: rugnux_live_shell[], merge?: string, height?: number }) {
|
||||
const theme = useTheme();
|
||||
const dark = theme.palette.mode === "dark";
|
||||
const grid = dark ? "rgba(255,255,255,.12)" : "#eee";
|
||||
const x = shells.map(sh => 1 / (sh.d_min * sh.d_min));
|
||||
// At most six d labels, the finest shell always among them
|
||||
const step = Math.ceil(shells.length / 6);
|
||||
@@ -51,22 +56,27 @@ function RugnuxShellPlots({shells, merge}: { shells: rugnux_live_shell[], merge?
|
||||
return null;
|
||||
return (
|
||||
<Plot key={panel.title}
|
||||
style={{width: "100%", height: 300}}
|
||||
style={{width: "100%", height}}
|
||||
data={data}
|
||||
layout={{
|
||||
title: {text: panel.title},
|
||||
margin: {t: 40, b: 50, l: 60, r: 20},
|
||||
title: {text: panel.title, font: {size: 14}},
|
||||
height,
|
||||
margin: {t: 32, b: 40, l: 50, r: 12},
|
||||
paper_bgcolor: "rgba(0,0,0,0)",
|
||||
plot_bgcolor: "rgba(0,0,0,0)",
|
||||
font: {color: theme.palette.text.secondary, size: 11},
|
||||
showlegend: data.length > 1,
|
||||
legend: panel.legendLeft ? {x: 0, xanchor: "left", y: 1} : {x: 1, xanchor: "right", y: 1},
|
||||
xaxis: {
|
||||
title: {text: "d [Å]"},
|
||||
title: {text: "d [Å]", standoff: 4},
|
||||
gridcolor: grid, zerolinecolor: grid,
|
||||
tickvals: ticks.map(sh => 1 / (sh.d_min * sh.d_min)),
|
||||
ticktext: ticks.map(sh => sh.d_min.toFixed(2)),
|
||||
},
|
||||
yaxis: {rangemode: "tozero"},
|
||||
yaxis: {rangemode: "tozero", gridcolor: grid, zerolinecolor: grid},
|
||||
uirevision: "shells",
|
||||
}}
|
||||
config={{responsive: true}}/>
|
||||
config={{responsive: true, displayModeBar: false}}/>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
|
||||
@@ -74,10 +74,11 @@ const BLOB_LABELS: [string, string][] = [['LIGAND', 'ligand'], ['WATER', 'water'
|
||||
|
||||
// resultKey: changes when a new result is there to load; anomalous: it has an anomalous difference map;
|
||||
// anomalousSignal: the data carry usable anomalous signal, so that map is worth showing from the start;
|
||||
// refined: the broker serves the refined model and its maps; blobs: what the refined model leaves unexplained.
|
||||
function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, refined, blobs}:
|
||||
// refined: the broker serves the refined model and its maps; blobs: what the refined model leaves unexplained;
|
||||
// fill: take the parent's height (the live page's stage) instead of the viewer's own.
|
||||
function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, refined, blobs, fill}:
|
||||
{ resultKey: string, anomalous: boolean, anomalousSignal: boolean,
|
||||
refined: boolean, blobs: Blob[] }) {
|
||||
refined: boolean, blobs: Blob[], fill?: boolean }) {
|
||||
const pluginRef = useRef<PluginContext | null>(null);
|
||||
const [pluginReady, setPluginReady] = useState(0);
|
||||
const [error, setError] = useState<string>();
|
||||
@@ -220,8 +221,9 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, refined,
|
||||
const mapsDisabled = mapsLoading;
|
||||
return (
|
||||
<Box sx={{display: 'grid', gridTemplateColumns: {xs: '1fr', md: '1fr 300px'}, border: '1px solid',
|
||||
borderColor: 'divider', borderRadius: 1, overflow: 'hidden'}}>
|
||||
<Box sx={{position: 'relative', bgcolor: '#000', height: {xs: '55vh', md: 'clamp(520px, 64vh, 820px)'}}}>
|
||||
borderColor: 'divider', borderRadius: 1, overflow: 'hidden', height: fill ? '100%' : undefined}}>
|
||||
<Box sx={{position: 'relative', bgcolor: '#000',
|
||||
height: fill ? '100%' : {xs: '55vh', md: 'clamp(520px, 64vh, 820px)'}, minHeight: fill ? 0 : undefined}}>
|
||||
<Box sx={{position: 'absolute', inset: 0, opacity: revealed ? 1 : 0,
|
||||
transition: 'opacity 900ms ease-out', '@media (prefers-reduced-motion: reduce)': {transition: 'none'}}}>
|
||||
<MolstarCanvas onReady={onPluginReady}/>
|
||||
@@ -232,7 +234,7 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, refined,
|
||||
{modelLoading ? 'loading model…' : 'computing density maps…'}</Typography>
|
||||
</Box>}
|
||||
</Box>
|
||||
<Box sx={{borderLeft: {md: '1px solid'}, borderColor: {md: 'divider'}, p: 1.75}}>
|
||||
<Box sx={{borderLeft: {md: '1px solid'}, borderColor: {md: 'divider'}, p: 1.75, overflowY: 'auto', minHeight: 0}}>
|
||||
{error && <Alert severity="warning" sx={{mb: 1}}>{error}</Alert>}
|
||||
<SectionTitle>{refined ? 'Model · refined' : 'Model'}</SectionTitle>
|
||||
<Box sx={{display: 'flex', gap: 0.75, flexWrap: 'wrap', alignItems: 'center', mb: 0.75}}>
|
||||
|
||||
Reference in new issue
Block a user