Spaces:
Paused
Paused
Deploy Seqcolyte Studio
Browse filesFiles changed (3)
99 unmodified lines10010110210310410510699 unmodified lines};/** Resolve per-check knowledge, handling the spec-driven dynamic ids (r1/r2 adapter, anchor_*). */function knowledgeFor(checkId: string): CheckKnowledge | undefined {if (CHECK_KNOWLEDGE[checkId]) return CHECK_KNOWLEDGE[checkId];if (checkId.endsWith("_adapter_readthrough")) return CHECK_KNOWLEDGE.adapter_readthrough;if (checkId.startsWith("anchor_")) return CHECK_KNOWLEDGE.anchor;99 unmodified lines10010110210310410510699 unmodified lines};/** Resolve per-check knowledge, handling the spec-driven dynamic ids (r1/r2 adapter, anchor_*). */export function knowledgeFor(checkId: string): CheckKnowledge | undefined {if (CHECK_KNOWLEDGE[checkId]) return CHECK_KNOWLEDGE[checkId];if (checkId.endsWith("_adapter_readthrough")) return CHECK_KNOWLEDGE.adapter_readthrough;if (checkId.startsWith("anchor_")) return CHECK_KNOWLEDGE.anchor;
4 unmodified lines5678910265 unmodified lines2762772782792802812822832842852862872882892902912922932942952962972982993003014 unmodified linesimport { allocateRun, getProject, getRun, updateRun } from "./store";import { killGroup, spawnLogged } from "./spawn";import { generateAllFixes } from "./remediate";import type { QcReport, RunRecord, StepName, StepStatus } from "./types";async function fileExists(p: string): Promise<boolean> {265 unmodified lines}}async function finalize(projectId: string, runId: string, status: StepStatus): Promise<void> {const run = await updateRun(projectId, runId, (r) => ({...r,overallStatus: status,finishedAt: now(),}));// Eager remediation: after a first-pass QC run (not a re-QC on cleaned reads) succeeds, auto-author// fix scripts for every solvable finding in the background so they're waiting in Files.if (status === "succeeded" && run.options.fastqSource !== "remediated") {void (async () => {try {const report = JSON.parse(await fs.readFile(path.join(runDir(projectId, runId), "qc_report.json"), "utf8"),) as QcReport;generateAllFixes(projectId, report);} catch {/* best effort — remediation is optional */}})();}}/** Fire-and-forget launcher. The HTTP request returns immediately; this drives to completion. */4 unmodified lines56789101112265 unmodified lines2782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323334 unmodified linesimport { allocateRun, getProject, getRun, updateRun } from "./store";import { killGroup, spawnLogged } from "./spawn";import { generateAllFixes } from "./remediate";import { appendConversation } from "./chat";import { knowledgeFor } from "./reportHtml";import type { QcReport, RunRecord, StepName, StepStatus } from "./types";async function fileExists(p: string): Promise<boolean> {265 unmodified lines}}/** A conversational diagnosis + suggested-fix summary from the report (posted after each QC run). */function buildDiagnosisMessage(report: QcReport): string {const issues = (report.findings ?? []).filter((f) => f.verdict === "fail" || f.verdict === "warn");const verdict = (report.overall ?? "").toUpperCase();const lines: string[] = [`**QC complete — overall ${verdict || "done"}.**`];const plan = report.plan;if (plan?.diagnosis) lines.push(plan.diagnosis);else if (plan?.root_cause) lines.push(`Likely root cause: ${plan.root_cause}.`);if (issues.length) {lines.push("", "**Issues & suggested fixes:**");for (const f of issues.slice(0, 6)) {const inlineFix = /Fix:/i.test(f.detail);const fix = inlineFix ? null : knowledgeFor(f.check_id)?.fix ?? null;lines.push(`- **${f.title}** — ${f.detail}${fix ? `\n _Suggested fix:_ ${fix}` : ""}`);}} else {lines.push("", "All checks passed — the reads are consistent with the expected structure.");}lines.push("","The full report (root cause + suggested fix per issue) is open in the viewer. Any " +"computationally-fixable issue also appears in the **Computational fixes** panel below — tick " +"them and Apply to clean the reads and re-score.",);return lines.join("\n");}async function finalize(projectId: string, runId: string, status: StepStatus): Promise<void> {if (status === "succeeded") {try {const report = JSON.parse(await fs.readFile(path.join(runDir(projectId, runId), "qc_report.json"), "utf8"),) as QcReport;// Post the diagnosis + suggested fixes into the conversation (not only in the report). Awaited// BEFORE the status flips so the client's post-run hydrate always sees it.await appendConversation(projectId, [{ role: "assistant", text: buildDiagnosisMessage(report), ts: now() },]);// Eager remediation (fire-and-forget): only for a first-pass run, not a re-QC on cleaned reads.const cur = await getRun(projectId, runId);if (cur.options.fastqSource !== "remediated") generateAllFixes(projectId, report);} catch {/* best effort — diagnosis/remediation are optional */}}await updateRun(projectId, runId, (r) => ({...r,overallStatus: status,finishedAt: now(),}));}/** Fire-and-forget launcher. The HTTP request returns immediately; this drives to completion. */
studio/src/lib/reportHtml.ts+1-1
studio/src/lib/runner.ts+47-15
studio/tsconfig.tsbuildinfo