jbrowse-plugin-graphgenomeviewer 5.0.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +3 -4
  2. package/dist/chunks/GbzBaseSyntenyAdapter-TQVDD3OC.js +8 -0
  3. package/dist/chunks/GbzBaseSyntenyAdapter-TQVDD3OC.js.map +7 -0
  4. package/dist/chunks/{GraphGenomeView-YYP4IFSI.js → GraphGenomeView-AY2FO4P2.js} +2 -2
  5. package/dist/chunks/{GraphTrackSettingsDialog-2WPJRAJC.js → GraphTrackSettingsDialog-QJXPMWYG.js} +2 -2
  6. package/dist/chunks/LinearGraphDisplay-GKVG72J4.js +2 -0
  7. package/dist/chunks/LinearGraphDisplay-GKVG72J4.js.map +7 -0
  8. package/dist/chunks/chunk-2V27PV25.js +3 -0
  9. package/dist/chunks/chunk-2V27PV25.js.map +7 -0
  10. package/dist/chunks/chunk-FNHKEAKB.js +5 -0
  11. package/dist/chunks/{chunk-LGFKHSVJ.js.map → chunk-FNHKEAKB.js.map} +3 -3
  12. package/dist/chunks/chunk-K5Z47YVI.js +2 -0
  13. package/dist/chunks/chunk-K5Z47YVI.js.map +7 -0
  14. package/dist/chunks/{chunk-SJNG2XK7.js → chunk-LJZDHT2C.js} +2 -2
  15. package/dist/chunks/chunk-NWJN4C4V.js +2 -0
  16. package/dist/chunks/chunk-NWJN4C4V.js.map +7 -0
  17. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +5 -5
  18. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  19. package/package.json +2 -2
  20. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +20 -38
  21. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +14 -65
  22. package/src/GraphGenomeView/components/GenePins.tsx +25 -80
  23. package/src/GraphGenomeView/components/usePaneGestures.ts +1 -0
  24. package/src/GraphGenomeView/genes/geneFeatures.ts +46 -7
  25. package/src/GraphGenomeView/genes/genes.test.ts +88 -1
  26. package/src/GraphGenomeView/model.test.ts +1 -1
  27. package/src/GraphGenomeView/pane/fitViews.ts +1 -0
  28. package/src/GraphGenomeView/pane/graphViews.ts +39 -5
  29. package/src/GraphGenomeView/pane/loadActions.ts +5 -5
  30. package/src/GraphGenomeView/pane/paneBase.ts +3 -2
  31. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +160 -92
  32. package/src/LinearGraphDisplay/components/LinearGraphDisplay.tsx +2 -12
  33. package/src/LinearGraphDisplay/denseWindow.ts +40 -0
  34. package/src/LinearGraphDisplay/model.ts +34 -94
  35. package/src/index.ts +0 -2
  36. package/src/version.ts +1 -1
  37. package/dist/chunks/GbzBaseSyntenyAdapter-CKKVHC2R.js +0 -4
  38. package/dist/chunks/GbzBaseSyntenyAdapter-CKKVHC2R.js.map +0 -7
  39. package/dist/chunks/LinearGraphDisplay-7YE624D5.js +0 -2
  40. package/dist/chunks/LinearGraphDisplay-7YE624D5.js.map +0 -7
  41. package/dist/chunks/chunk-2H7GDQ3R.js +0 -6
  42. package/dist/chunks/chunk-2H7GDQ3R.js.map +0 -7
  43. package/dist/chunks/chunk-BZOIENU5.js +0 -2
  44. package/dist/chunks/chunk-BZOIENU5.js.map +0 -7
  45. package/dist/chunks/chunk-H54W6OQQ.js +0 -2
  46. package/dist/chunks/chunk-H54W6OQQ.js.map +0 -7
  47. package/dist/chunks/chunk-LGFKHSVJ.js +0 -5
  48. package/dist/chunks/chunk-O4XV3K35.js +0 -2
  49. package/dist/chunks/chunk-O4XV3K35.js.map +0 -7
  50. package/dist/chunks/chunk-WKVVIDCS.js +0 -3
  51. package/dist/chunks/chunk-WKVVIDCS.js.map +0 -7
  52. package/src/GetHaplotypeOverview.ts +0 -77
  53. package/src/HaplotypeOverview/HaplotypeOverviewCanvas.tsx +0 -203
  54. package/src/HaplotypeOverview/draw.test.ts +0 -136
  55. package/src/HaplotypeOverview/draw.ts +0 -433
  56. package/src/HaplotypeOverview/model.ts +0 -163
  57. /package/dist/chunks/{GraphGenomeView-YYP4IFSI.js.map → GraphGenomeView-AY2FO4P2.js.map} +0 -0
  58. /package/dist/chunks/{GraphTrackSettingsDialog-2WPJRAJC.js.map → GraphTrackSettingsDialog-QJXPMWYG.js.map} +0 -0
  59. /package/dist/chunks/{chunk-SJNG2XK7.js.map → chunk-LJZDHT2C.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/core/src/gbzJoin.ts", "../../packages/core/src/reference.ts", "../../packages/core/src/gbzWindow.ts"],
4
- "sourcesContent": ["// One GFA from gbz-base cuts of consecutive reference fragments. A haplotype\n// bridging the gap between two fragments comes back from both cuts, each piece\n// the run inside its own cut's nodes, so the two can overlap without matching.\n\ninterface Walk {\n fields: string[]\n name: string\n start: number\n end: number\n}\n\nconst UNKNOWN_SAMPLE = 'unknown'\n\nfunction parseWalk(line: string): Walk {\n const fields = line.split('\\t')\n return {\n fields,\n name: fields.slice(1, 4).join('\\t'),\n start: +fields[4]!,\n end: +fields[5]!,\n }\n}\n\nconst stepsOf = (walk: Walk) => walk.fields[6]!.match(/[<>][^<>]+/g) ?? []\n\nfunction segmentLengths(lines: string[]) {\n const lengths = new Map<string, number>()\n for (const line of lines) {\n if (line.startsWith('S\\t')) {\n const [, id, sequence, ...tags] = line.split('\\t')\n const ln = tags.find(tag => tag.startsWith('LN:i:'))\n lengths.set(\n id!,\n sequence === '*' && ln ? +ln.slice('LN:i:'.length) : sequence!.length,\n )\n }\n }\n return lengths\n}\n\n// `a` carried on by the steps of `b` past `a.end`, where `b` starts inside or\n// at the end of `a`; undefined when no step of `b` starts exactly at `a.end`,\n// which two pieces of one walk always share\nfunction extend(a: Walk, b: Walk, lengths: Map<string, number>) {\n if (b.end <= a.end) {\n return a\n }\n const steps = stepsOf(b)\n let pos = b.start\n for (const [i, step] of steps.entries()) {\n if (pos === a.end) {\n const fields = [...a.fields]\n fields[5] = String(b.end)\n fields[6] = a.fields[6]! + steps.slice(i).join('')\n return { ...a, fields, end: b.end }\n }\n const length = lengths.get(step.slice(1))\n if (pos > a.end || length === undefined) {\n return undefined\n }\n pos += length\n }\n return undefined\n}\n\n// Whether one of a haplotype's own paths starts at `at` on its contig\nexport type StartsPath = (\n sample: string,\n haplotype: number,\n contig: string,\n at: number,\n) => boolean\n\n// Pieces of one walk, by start, with each pair that overlaps or meets joined\n// into one. Pieces that meet where one of the haplotype's own paths starts are\n// two paths, whether or not the graph links them; a walk a cut split never\n// has a path starting at the seam.\nfunction joinPieces(\n pieces: Walk[],\n lengths: Map<string, number>,\n startsPath: StartsPath,\n) {\n const joined: Walk[] = []\n for (const piece of pieces.sort((a, b) => a.start - b.start)) {\n const last = joined.at(-1)\n const [, sample, haplotype, contig] = piece.fields\n const joins =\n last !== undefined &&\n (piece.start < last.end ||\n (piece.start === last.end &&\n !startsPath(sample!, +haplotype!, contig!, piece.start)))\n const extended = joins ? extend(last, piece, lengths) : undefined\n if (extended) {\n joined[joined.length - 1] = extended\n } else {\n joined.push(piece)\n }\n }\n return joined\n}\n\nconst flip = (sign: string) => (sign === '+' ? '-' : '+')\n\n// The link each step of a walk takes, in both of the ways an L line can write\n// it. Where two pieces met in no cut's nodes, no cut wrote the link between\n// them.\nfunction* stepLinks(walk: Walk) {\n const steps = stepsOf(walk).map(step => ({\n id: step.slice(1),\n sign: step.startsWith('>') ? '+' : '-',\n }))\n for (let i = 1; i < steps.length; i++) {\n const a = steps[i - 1]!\n const b = steps[i]!\n yield {\n forward: `L\\t${a.id}\\t${a.sign}\\t${b.id}\\t${b.sign}\\t0M`,\n reverse: `L\\t${b.id}\\t${flip(b.sign)}\\t${a.id}\\t${flip(a.sign)}\\t0M`,\n }\n }\n}\n\n// Each segment and link once, every cut's reference walk (its first W line)\n// ahead of the haplotype walks, the pieces of each walk joined, the\n// reference's among them since a cut's context can reach the other fragment,\n// and each cut's `unknown#N` walks numbered on from the cut before's, since\n// gbz-base numbers them per cut. Unnamed walks start every cut at 0, so their\n// pieces cannot be joined.\nexport function joinCuts(gfas: string[], startsPath: StartsPath) {\n if (gfas.length <= 1) {\n return gfas[0] ?? ''\n }\n const cuts = gfas.map(gfa => gfa.split('\\n').filter(line => line !== ''))\n const ofType = (cut: string[], type: string) =>\n cut.filter(line => line.startsWith(`${type}\\t`))\n const lengths = segmentLengths(cuts.flat())\n let unknownOffset = 0\n const walksByCut = cuts.map(cut => {\n const walks = ofType(cut, 'W').map(parseWalk)\n const offset = unknownOffset\n for (const walk of walks.filter(w => w.fields[1] === UNKNOWN_SAMPLE)) {\n const haplotype = +walk.fields[2]! + offset\n walk.fields[2] = String(haplotype)\n walk.name = walk.fields.slice(1, 4).join('\\t')\n unknownOffset = Math.max(unknownOffset, haplotype)\n }\n return walks\n })\n const byName = new Map<string, Walk[]>()\n for (const walk of [\n ...walksByCut.flatMap(walks => walks.slice(0, 1)),\n ...walksByCut.flatMap(walks => walks.slice(1)),\n ]) {\n const pieces = byName.get(walk.name)\n if (pieces) {\n pieces.push(walk)\n } else {\n byName.set(walk.name, [walk])\n }\n }\n const walks = [...byName.values()].flatMap(pieces =>\n joinPieces(pieces, lengths, startsPath),\n )\n const links = new Set(cuts.flatMap(cut => ofType(cut, 'L')))\n for (const walk of walks) {\n for (const link of stepLinks(walk)) {\n if (!links.has(link.forward) && !links.has(link.reverse)) {\n links.add(link.forward)\n }\n }\n }\n const lines = new Set([\n ...ofType(cuts[0]!, 'H'),\n ...cuts.flatMap(cut => ofType(cut, 'S')),\n ...links,\n ...walks.map(walk => walk.fields.join('\\t')),\n ])\n return `${[...lines].join('\\n')}\\n`\n}\n", "import { isBackbone } from './anchoredNodes'\nimport {\n isGenericSample,\n panSNContig,\n panSNHaplotype,\n panSNSample,\n} from './pansn'\n\nimport type { Graph, PathOrigin } from './types'\n\n// A graph's backbone names the sample it lies on (`GRCh38#0#chr6`), not an\n// assembly, and a bare contig (`chr6`) is in every human assembly at once. A\n// backbone binds to an assembly where its PanSN prefix is that assembly's name,\n// one of its aliases, or its well-known sample. One that names no sample binds\n// only where the host knows the assembly otherwise, as a track's config does.\n\nexport interface BackboneContig {\n // as the graph names it, `GRCh38#0#chr6`\n refName: string\n // as an assembly names it, `chr6`\n contig: string\n start: number\n end: number\n}\n\nexport interface Backbone {\n contigs: BackboneContig[]\n // The PanSN prefixes that name the backbone, sample then haplotype:\n // `GRCh38`, `GRCh38#0`. The sample drops out where the graph walks another\n // haplotype of it, as a diploid's `HG002` names `HG002#1` and `HG002#2`.\n prefixes: string[]\n // Whether the contigs name one real sample: false where every contig is bare\n // (`chr6`) or generic (`_gbwt_ref#0#chr6`), or where the samples differ\n named: boolean\n}\n\nexport interface AssemblyNames {\n name: string\n aliases?: string[]\n}\n\n// The sample a reference assembly's graphs name it by, keyed by the assembly's\n// name in lower case: HPRC writes `CHM13` where UCSC's assembly is `hs1`.\nexport const WELL_KNOWN_SAMPLES: ReadonlyMap<string, string> = new Map([\n ['hg38', 'GRCh38'],\n ['hg19', 'GRCh37'],\n ['hs1', 'CHM13'],\n ['t2t-chm13', 'CHM13'],\n ['chm13v2', 'CHM13'],\n])\n\nexport function wellKnownSample(assemblyName: string) {\n return WELL_KNOWN_SAMPLES.get(assemblyName.toLowerCase())\n}\n\nfunction sampleOf(refName: string) {\n const sample = refName.includes('#') ? panSNSample(refName) : undefined\n return sample === undefined || isGenericSample(sample) ? undefined : sample\n}\n\n// `HG002#1`, or the sample of a two-part name, which states no haplotype\nfunction haplotypeOf(refName: string) {\n return panSNHaplotype(refName) ?? panSNSample(refName)\n}\n\n// Each sample's haplotypes among the graph's walks and node refNames\nfunction graphHaplotypes(graph: Graph) {\n const refNames = new Set((graph.anchorPaths ?? []).map(p => p.name))\n for (const node of graph.nodes) {\n if (node.stable) {\n refNames.add(node.stable.refName)\n }\n }\n const bySample = new Map<string, Set<string>>()\n for (const refName of refNames) {\n const sample = sampleOf(refName)\n if (sample !== undefined) {\n const haplotypes =\n bySample.get(sample) ?? bySample.set(sample, new Set()).get(sample)!\n haplotypes.add(haplotypeOf(refName))\n }\n }\n return bySample\n}\n\nfunction backboneFrom(\n contigs: BackboneContig[],\n haplotypes: Map<string, Set<string>>,\n): Backbone {\n const samples = new Set(contigs.map(c => sampleOf(c.refName)))\n const [sample] = samples\n if (samples.size !== 1 || sample === undefined) {\n return { contigs, prefixes: [], named: false }\n }\n const own = new Set(contigs.map(c => haplotypeOf(c.refName)))\n const unique = [...(haplotypes.get(sample) ?? [])].every(h => own.has(h))\n const shared = new Set(contigs.map(c => panSNHaplotype(c.refName)))\n const [haplotype] = shared\n return {\n contigs,\n prefixes: [\n ...(unique ? [sample] : []),\n ...(shared.size === 1 && haplotype ? [haplotype] : []),\n ],\n named: true,\n }\n}\n\n// The rank-0 nodes' refNames and the span each covers\nexport function graphBackbone(graph: Graph): Backbone | undefined {\n const spans = new Map<string, BackboneContig>()\n for (const node of graph.nodes) {\n if (isBackbone(node)) {\n const { refName, start } = node.stable\n const end = start + node.length\n const span = spans.get(refName)\n if (span) {\n span.start = Math.min(span.start, start)\n span.end = Math.max(span.end, end)\n } else {\n spans.set(refName, {\n refName,\n contig: panSNContig(refName),\n start,\n end,\n })\n }\n }\n }\n const contigs = [...spans.values()]\n return contigs.length\n ? backboneFrom(contigs, graphHaplotypes(graph))\n : undefined\n}\n\n// The assembly the backbone's haplotype names by its name or an alias, else\n// the one its sample names, else the one whose well-known sample it is. A\n// backbone with no prefix binds to none.\nexport function backboneAssembly<T extends AssemblyNames>(\n backbone: Backbone | undefined,\n assemblies: T[],\n): T | undefined {\n const names = (a: T) => [a.name, ...(a.aliases ?? [])]\n const naming = (prefix: string) => (a: T) =>\n names(a).some(n => n.toLowerCase() === prefix.toLowerCase())\n const prefixes = [...(backbone?.prefixes ?? [])].reverse()\n const sample = backbone?.prefixes.find(p => !p.includes('#'))?.toLowerCase()\n for (const prefix of prefixes) {\n const assembly = assemblies.find(naming(prefix))\n if (assembly) {\n return assembly\n }\n }\n return sample === undefined\n ? undefined\n : assemblies.find(a =>\n names(a).some(n => wellKnownSample(n)?.toLowerCase() === sample),\n )\n}\n\n// The first of the graph's walks that a backbone along it would bind to\n// `assembly`, for putting x on the assembly a cut was made for\nexport function assemblyWalk(\n graph: Graph,\n assembly: AssemblyNames,\n): PathOrigin | undefined {\n const haplotypes = graphHaplotypes(graph)\n return graph.anchorPaths?.find(walk =>\n backboneAssembly(\n backboneFrom(\n [\n {\n refName: walk.name,\n contig: panSNContig(walk.name),\n start: walk.start,\n end: walk.start + walk.length,\n },\n ],\n haplotypes,\n ),\n [assembly],\n ),\n )\n}\n\n// The names a file from outside the graph may give a contig: its own, and the\n// same with or without UCSC's `chr`, the mitochondrion as M or MT either way\nexport function contigNames(contig: string) {\n const bare = contig.replace(/^chr/i, '')\n const forms = !bare ? [] : /^(M|MT)$/i.test(bare) ? ['M', 'MT'] : [bare]\n return [...new Set([contig, ...forms.flatMap(f => [f, `chr${f}`])])]\n}\n\n// Which of `refNames` a feature's refName names: the one it equals, else the\n// only one whose contig it names, by any of contigNames or the name `aliases`\n// gives that contig (`{ chr6: 'NC_000006.12' }`). A name two refNames share\n// names neither.\nexport function refNameBinding(\n refNames: Iterable<string>,\n aliases: Record<string, string> = {},\n) {\n const exact = new Set(refNames)\n const byName = new Map<string, string | undefined>()\n for (const refName of exact) {\n const contig = panSNContig(refName)\n const alias = aliases[contig]\n for (const name of new Set([\n ...contigNames(contig),\n ...(alias ? [alias] : []),\n ])) {\n byName.set(name, byName.has(name) ? undefined : refName)\n }\n }\n return (name: string) => (exact.has(name) ? name : byName.get(name))\n}\n\n// An assembly's features on a backbone that binds to it, each renamed to the\n// backbone's refName for it, so the assembly's `chr6` becomes the graph's\n// `GRCh38#0#chr6`. genePins and tubeMapGenes take only the renamed.\nexport function featuresOnBackbone<T extends { refName: string }>(\n features: readonly T[],\n backbone: Backbone,\n aliases?: Record<string, string>,\n): T[] {\n const bind = refNameBinding(\n backbone.contigs.map(c => c.refName),\n aliases,\n )\n return features.flatMap(f => {\n const refName = bind(f.refName)\n return refName === undefined\n ? []\n : [refName === f.refName ? f : { ...f, refName }]\n })\n}\n", "import { joinCuts } from './gbzJoin.ts'\nimport { panSNMatchesPrefix, panSNSample } from './pansn.ts'\nimport { wellKnownSample } from './reference.ts'\n\nimport type { GBZBase, PathName, PathQuery, SnarlOutput } from '@gmod/gbz-base'\n\n// A window of a gbz-base graph cut to GFA, with no host in it: the adapter\n// and a standalone page open the database their own way and share this.\n\nexport class NoReferenceSampleError extends Error {\n override name = 'NoReferenceSampleError'\n\n constructor(anchor: string, referenceSamples: string[]) {\n super(\n referenceSamples.length === 0\n ? `the graph names no reference sample (gbwt_reference_samples) and the anchor \"${anchor}\" maps to none; set referenceSample`\n : `the anchor \"${anchor}\" is none of the graph's reference samples (${referenceSamples.join(', ')}); set referenceSample or map it through assemblyNameToPanSN`,\n )\n }\n}\n\nexport class NodeLimitError extends Error {\n override name = 'NodeLimitError'\n\n constructor(limit: number, windowBp: number, fitsBp: number) {\n super(\n `this ${windowBp.toLocaleString()} bp window reads more than nodeLimit (${limit.toLocaleString()}) graph nodes; zoom in to about ${fitsBp.toLocaleString()} bp or raise nodeLimit`,\n )\n }\n}\n\nexport function haplotypePrefix(name: Pick<PathName, 'sample' | 'haplotype'>) {\n return `${name.sample}#${name.haplotype}`\n}\n\n// Whether a walk is one of the haplotypes asked for, by PanSN prefix at sample\n// (`HG002`) or haplotype (`HG002#1`) depth; undefined wants every one.\nexport function haplotypeWanted(name: PathName, wanted: string[] | undefined) {\n const prefix = haplotypePrefix(name)\n return (\n wanted === undefined ||\n wanted.some(candidate => panSNMatchesPrefix(prefix, candidate))\n )\n}\n\nexport async function referenceSamplesOf(db: GBZBase) {\n return ((await db.tag('gbwt_reference_samples')) ?? '')\n .split(/\\s+/)\n .filter(sample => sample !== '')\n}\n\nfunction aliasedSample(anchorSample: string, referenceSamples: string[]) {\n const lower = anchorSample.toLowerCase()\n const alias = wellKnownSample(anchorSample)?.toLowerCase()\n return (\n referenceSamples.find(s => s === anchorSample) ??\n referenceSamples.find(s => s.toLowerCase() === lower) ??\n referenceSamples.find(s => s.toLowerCase() === alias)\n )\n}\n\nexport function resolveReferenceSample({\n configured,\n anchorPrefix,\n referenceSamples,\n}: {\n configured: string\n anchorPrefix: string\n referenceSamples: string[]\n}) {\n if (configured !== '') {\n return configured\n }\n const sample =\n aliasedSample(panSNSample(anchorPrefix), referenceSamples) ??\n (referenceSamples.length === 1 ? referenceSamples[0] : undefined)\n if (sample === undefined) {\n throw new NoReferenceSampleError(anchorPrefix, referenceSamples)\n }\n return sample\n}\n\n// The indexed reference path a window on `refName` resolves against, or\n// undefined when the reference sample has no indexed path by that contig.\nexport async function referencePathQuery(\n db: GBZBase,\n referenceSample: string,\n refName: string,\n): Promise<PathQuery | undefined> {\n const path = (await db.paths()).find(\n p =>\n p.isIndexed &&\n p.name.sample === referenceSample &&\n p.name.contig === refName,\n )\n return path\n ? {\n sample: path.name.sample,\n contig: refName,\n haplotype: path.name.haplotype,\n }\n : undefined\n}\n\n// gbz-base reports the node limit with how far along the reference the walk\n// had got when it tripped, counted from the window's start; a window that fits\n// is that far, with a margin, or half the window when the limit tripped past\n// the reference.\nexport function nodeLimitError(\n error: unknown,\n limit: number,\n windowBp: number,\n) {\n const isLimit =\n error instanceof Error &&\n (error.name === 'SubgraphLimitError' ||\n /^Subgraph size limit of \\d+ nodes exceeded/.test(error.message))\n if (!isLimit) {\n return undefined\n } else {\n const walked = (error as { walkedBp?: unknown }).walkedBp\n const fits =\n typeof walked === 'number' && walked > 0\n ? Math.floor(walked * 0.8)\n : Math.floor(windowBp / 2)\n return new NodeLimitError(limit, windowBp, Math.max(fits, 1))\n }\n}\n\nexport interface GbzWindowOptions {\n context: number\n snarls: SnarlOutput\n limit: number\n keep?: ((name: PathName) => boolean) | undefined\n signal?: AbortSignal | undefined\n}\n\n// A cut's context and snarls unless told otherwise, and the nodes past which a\n// window fails rather than read a whole chromosome: what a gbz-base track's\n// slots default to, so a page or a script cuts the window the viewer would.\n// gbz-base counts every node it walks, which runs well past the nodes a cut\n// keeps.\nexport const GBZ_CUT_DEFAULTS = {\n context: 1000,\n snarls: 'contained',\n limit: 100_000,\n} as const satisfies Pick<GbzWindowOptions, 'context' | 'snarls' | 'limit'>\n\n// The reference walk, the snarls in the window, and one W line per haplotype\n// walk (the reference walk first), PanSN-named when the database carries the\n// haplotype index. Empty when the query names no indexed path.\nexport async function cutWindowGFA(\n db: GBZBase,\n query: PathQuery | undefined,\n start: number,\n end: number,\n opts: GbzWindowOptions,\n) {\n if (!query) {\n return ''\n }\n const subgraphs = await db\n .getSubgraphs({ ...opts, path: query, start, end, haplotypes: 'all' })\n .catch((error: unknown) => {\n throw nodeLimitError(error, opts.limit, end - start) ?? error\n })\n const paths = await db.paths()\n return joinCuts(\n await Promise.all(subgraphs.map(subgraph => subgraph.toGFA())),\n (sample, haplotype, contig, at) =>\n paths.some(\n ({ name }) =>\n name.sample === sample &&\n name.haplotype === haplotype &&\n name.contig === contig &&\n name.fragment === at,\n ),\n )\n}\n"],
5
- "mappings": "4GAWA,IAAMA,EAAiB,UAEvB,SAASC,EAAUC,EAAoB,CACrC,IAAMC,EAASD,EAAK,MAAM,GAAI,EAC9B,MAAO,CACL,OAAAC,EACA,KAAMA,EAAO,MAAM,EAAG,CAAC,EAAE,KAAK,GAAI,EAClC,MAAO,CAACA,EAAO,CAAC,EAChB,IAAK,CAACA,EAAO,CAAC,CAChB,CACF,CAEA,IAAMC,EAAWC,GAAeA,EAAK,OAAO,CAAC,EAAG,MAAM,aAAa,GAAK,CAAC,EAEzE,SAASC,EAAeC,EAAiB,CACvC,IAAMC,EAAU,IAAI,IACpB,QAAWN,KAAQK,EACjB,GAAIL,EAAK,WAAW,IAAK,EAAG,CAC1B,GAAM,CAAC,CAAEO,EAAIC,EAAU,GAAGC,CAAI,EAAIT,EAAK,MAAM,GAAI,EAC3CU,EAAKD,EAAK,KAAKE,GAAOA,EAAI,WAAW,OA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MAAM1B,EACrB,aAAa,CAAE,GAAGyB,EAAM,KAAMH,EAAO,MAAAC,EAAO,IAAAC,EAAK,WAAY,KAAM,CAAC,EACpE,MAAOP,GAAmB,CACzB,MAAMD,EAAeC,EAAOQ,EAAK,MAAOD,EAAMD,CAAK,GAAKN,CAC1D,CAAC,EACGU,EAAQ,MAAM3B,EAAG,MAAM,EAC7B,OAAO4B,EACL,MAAM,QAAQ,IAAIF,EAAU,IAAIG,GAAYA,EAAS,MAAM,CAAC,CAAC,EAC7D,CAAC5B,EAAQ6B,EAAWC,EAAQC,IAC1BL,EAAM,KACJ,CAAC,CAAE,KAAAlC,CAAK,IACNA,EAAK,SAAWQ,GAChBR,EAAK,YAAcqC,GACnBrC,EAAK,SAAWsC,GAChBtC,EAAK,WAAauC,CACtB,CACJ,CACF",
6
- "names": ["UNKNOWN_SAMPLE", "parseWalk", "line", "fields", "stepsOf", "walk", "segmentLengths", "lines", "lengths", "id", "sequence", "tags", "ln", "tag", "extend", "a", "b", "steps", "pos", "step", "length", "joinPieces", "pieces", "startsPath", "joined", "piece", "last", "sample", "haplotype", "contig", "extended", "flip", "sign", "stepLinks", "i", "joinCuts", "gfas", "cuts", "gfa", "ofType", "cut", "type", "unknownOffset", "walksByCut", "walks", "offset", "w", "byName", "links", "link", "WELL_KNOWN_SAMPLES", "wellKnownSample", "assemblyName", "sampleOf", "refName", "sample", "panSNSample", "isGenericSample", "haplotypeOf", "panSNHaplotype", "graphHaplotypes", "graph", "refNames", "p", "node", "bySample", "backboneFrom", "contigs", "haplotypes", "samples", "c", "own", "unique", "h", "shared", "haplotype", "graphBackbone", "spans", "isBackbone", "start", "end", "span", "panSNContig", "backboneAssembly", "backbone", "assemblies", "names", "naming", "prefix", "a", "n", "prefixes", "assembly", "assemblyWalk", "walk", "contigNames", "contig", "bare", "forms", "f", "refNameBinding", "aliases", "exact", "byName", "alias", "name", "featuresOnBackbone", "features", "bind", "NoReferenceSampleError", "anchor", "referenceSamples", "NodeLimitError", "limit", "windowBp", "fitsBp", "haplotypePrefix", "name", "haplotypeWanted", "wanted", "prefix", "candidate", "panSNMatchesPrefix", "referenceSamplesOf", "db", "sample", "aliasedSample", "anchorSample", "lower", "alias", "wellKnownSample", "resolveReferenceSample", "configured", "anchorPrefix", "panSNSample", "referencePathQuery", "referenceSample", "refName", "path", "p", "nodeLimitError", "error", "walked", "fits", "GBZ_CUT_DEFAULTS", "cutWindowGFA", "query", "start", "end", "opts", "subgraphs", "paths", "joinCuts", "subgraph", "haplotype", "contig", "at"]
4
+ "sourcesContent": ["// One GFA from gbz-base cuts of consecutive reference fragments. A haplotype\n// bridging the gap between two fragments comes back from both cuts, each piece\n// the run inside its own cut's nodes, so the two can overlap without matching.\n\ninterface Walk {\n fields: string[]\n name: string\n start: number\n end: number\n}\n\nconst UNKNOWN_SAMPLE = 'unknown'\n\nfunction parseWalk(line: string): Walk {\n const fields = line.split('\\t')\n return {\n fields,\n name: fields.slice(1, 4).join('\\t'),\n start: +fields[4]!,\n end: +fields[5]!,\n }\n}\n\nconst stepsOf = (walk: Walk) => walk.fields[6]!.match(/[<>][^<>]+/g) ?? []\n\nfunction segmentLengths(lines: string[]) {\n const lengths = new Map<string, number>()\n for (const line of lines) {\n if (line.startsWith('S\\t')) {\n const [, id, sequence, ...tags] = line.split('\\t')\n const ln = tags.find(tag => tag.startsWith('LN:i:'))\n lengths.set(\n id!,\n sequence === '*' && ln ? +ln.slice('LN:i:'.length) : sequence!.length,\n )\n }\n }\n return lengths\n}\n\n// `a` carried on by the steps of `b` past `a.end`, where `b` starts inside or\n// at the end of `a`; undefined when no step of `b` starts exactly at `a.end`,\n// which two pieces of one walk always share\nfunction extend(a: Walk, b: Walk, lengths: Map<string, number>) {\n if (b.end <= a.end) {\n return a\n }\n const steps = stepsOf(b)\n let pos = b.start\n for (const [i, step] of steps.entries()) {\n if (pos === a.end) {\n const fields = [...a.fields]\n fields[5] = String(b.end)\n fields[6] = a.fields[6]! + steps.slice(i).join('')\n return { ...a, fields, end: b.end }\n }\n const length = lengths.get(step.slice(1))\n if (pos > a.end || length === undefined) {\n return undefined\n }\n pos += length\n }\n return undefined\n}\n\n// Whether one of a haplotype's own paths starts at `at` on its contig\nexport type StartsPath = (\n sample: string,\n haplotype: number,\n contig: string,\n at: number,\n) => boolean\n\n// Pieces of one walk, by start, with each pair that overlaps or meets joined\n// into one. Pieces that meet where one of the haplotype's own paths starts are\n// two paths, whether or not the graph links them; a walk a cut split never\n// has a path starting at the seam.\nfunction joinPieces(\n pieces: Walk[],\n lengths: Map<string, number>,\n startsPath: StartsPath,\n) {\n const joined: Walk[] = []\n for (const piece of pieces.sort((a, b) => a.start - b.start)) {\n const last = joined.at(-1)\n const [, sample, haplotype, contig] = piece.fields\n const joins =\n last !== undefined &&\n (piece.start < last.end ||\n (piece.start === last.end &&\n !startsPath(sample!, +haplotype!, contig!, piece.start)))\n const extended = joins ? extend(last, piece, lengths) : undefined\n if (extended) {\n joined[joined.length - 1] = extended\n } else {\n joined.push(piece)\n }\n }\n return joined\n}\n\nconst flip = (sign: string) => (sign === '+' ? '-' : '+')\n\n// The link each step of a walk takes, in both of the ways an L line can write\n// it. Where two pieces met in no cut's nodes, no cut wrote the link between\n// them.\nfunction* stepLinks(walk: Walk) {\n const steps = stepsOf(walk).map(step => ({\n id: step.slice(1),\n sign: step.startsWith('>') ? '+' : '-',\n }))\n for (let i = 1; i < steps.length; i++) {\n const a = steps[i - 1]!\n const b = steps[i]!\n yield {\n forward: `L\\t${a.id}\\t${a.sign}\\t${b.id}\\t${b.sign}\\t0M`,\n reverse: `L\\t${b.id}\\t${flip(b.sign)}\\t${a.id}\\t${flip(a.sign)}\\t0M`,\n }\n }\n}\n\n// Each segment and link once, every cut's reference walk (its first W line)\n// ahead of the haplotype walks, the pieces of each walk joined, the\n// reference's among them since a cut's context can reach the other fragment,\n// and each cut's `unknown#N` walks numbered on from the cut before's, since\n// gbz-base numbers them per cut. Unnamed walks start every cut at 0, so their\n// pieces cannot be joined.\nexport function joinCuts(gfas: string[], startsPath: StartsPath) {\n if (gfas.length <= 1) {\n return gfas[0] ?? ''\n }\n const cuts = gfas.map(gfa => gfa.split('\\n').filter(line => line !== ''))\n const ofType = (cut: string[], type: string) =>\n cut.filter(line => line.startsWith(`${type}\\t`))\n const lengths = segmentLengths(cuts.flat())\n let unknownOffset = 0\n const walksByCut = cuts.map(cut => {\n const walks = ofType(cut, 'W').map(parseWalk)\n const offset = unknownOffset\n for (const walk of walks.filter(w => w.fields[1] === UNKNOWN_SAMPLE)) {\n const haplotype = +walk.fields[2]! + offset\n walk.fields[2] = String(haplotype)\n walk.name = walk.fields.slice(1, 4).join('\\t')\n unknownOffset = Math.max(unknownOffset, haplotype)\n }\n return walks\n })\n const byName = new Map<string, Walk[]>()\n for (const walk of [\n ...walksByCut.flatMap(walks => walks.slice(0, 1)),\n ...walksByCut.flatMap(walks => walks.slice(1)),\n ]) {\n const pieces = byName.get(walk.name)\n if (pieces) {\n pieces.push(walk)\n } else {\n byName.set(walk.name, [walk])\n }\n }\n const walks = [...byName.values()].flatMap(pieces =>\n joinPieces(pieces, lengths, startsPath),\n )\n const links = new Set(cuts.flatMap(cut => ofType(cut, 'L')))\n for (const walk of walks) {\n for (const link of stepLinks(walk)) {\n if (!links.has(link.forward) && !links.has(link.reverse)) {\n links.add(link.forward)\n }\n }\n }\n const lines = new Set([\n ...ofType(cuts[0]!, 'H'),\n ...cuts.flatMap(cut => ofType(cut, 'S')),\n ...links,\n ...walks.map(walk => walk.fields.join('\\t')),\n ])\n return `${[...lines].join('\\n')}\\n`\n}\n", "import { isBackbone } from './anchoredNodes'\nimport {\n isGenericSample,\n panSNContig,\n panSNHaplotype,\n panSNSample,\n} from './pansn'\n\nimport type { Graph, PathOrigin } from './types'\n\n// A graph's backbone names the sample it lies on (`GRCh38#0#chr6`), not an\n// assembly, and a bare contig (`chr6`) is in every human assembly at once. A\n// backbone binds to an assembly where its PanSN prefix is that assembly's name,\n// one of its aliases, or its well-known sample. One that names no sample binds\n// only where the host knows the assembly otherwise, as a track's config does.\n\nexport interface BackboneContig {\n // as the graph names it, `GRCh38#0#chr6`\n refName: string\n // as an assembly names it, `chr6`\n contig: string\n start: number\n end: number\n}\n\nexport interface Backbone {\n contigs: BackboneContig[]\n // The PanSN prefixes that name the backbone, sample then haplotype:\n // `GRCh38`, `GRCh38#0`. The sample drops out where the graph walks another\n // haplotype of it, as a diploid's `HG002` names `HG002#1` and `HG002#2`.\n prefixes: string[]\n // Whether the contigs name one real sample: false where every contig is bare\n // (`chr6`) or generic (`_gbwt_ref#0#chr6`), or where the samples differ\n named: boolean\n}\n\nexport interface AssemblyNames {\n name: string\n aliases?: string[]\n}\n\n// The sample a reference assembly's graphs name it by, keyed by the assembly's\n// name in lower case: HPRC writes `CHM13` where UCSC's assembly is `hs1`.\nexport const WELL_KNOWN_SAMPLES: ReadonlyMap<string, string> = new Map([\n ['hg38', 'GRCh38'],\n ['hg19', 'GRCh37'],\n ['hs1', 'CHM13'],\n ['t2t-chm13', 'CHM13'],\n ['chm13v2', 'CHM13'],\n])\n\nexport function wellKnownSample(assemblyName: string) {\n return WELL_KNOWN_SAMPLES.get(assemblyName.toLowerCase())\n}\n\nfunction sampleOf(refName: string) {\n const sample = refName.includes('#') ? panSNSample(refName) : undefined\n return sample === undefined || isGenericSample(sample) ? undefined : sample\n}\n\n// `HG002#1`, or the sample of a two-part name, which states no haplotype\nfunction haplotypeOf(refName: string) {\n return panSNHaplotype(refName) ?? panSNSample(refName)\n}\n\n// Each sample's haplotypes among the graph's walks and node refNames\nfunction graphHaplotypes(graph: Graph) {\n const refNames = new Set((graph.anchorPaths ?? []).map(p => p.name))\n for (const node of graph.nodes) {\n if (node.stable) {\n refNames.add(node.stable.refName)\n }\n }\n const bySample = new Map<string, Set<string>>()\n for (const refName of refNames) {\n const sample = sampleOf(refName)\n if (sample !== undefined) {\n const haplotypes =\n bySample.get(sample) ?? bySample.set(sample, new Set()).get(sample)!\n haplotypes.add(haplotypeOf(refName))\n }\n }\n return bySample\n}\n\nfunction backboneFrom(\n contigs: BackboneContig[],\n haplotypes: Map<string, Set<string>>,\n): Backbone {\n const samples = new Set(contigs.map(c => sampleOf(c.refName)))\n const [sample] = samples\n if (samples.size !== 1 || sample === undefined) {\n return { contigs, prefixes: [], named: false }\n }\n const own = new Set(contigs.map(c => haplotypeOf(c.refName)))\n const unique = [...(haplotypes.get(sample) ?? [])].every(h => own.has(h))\n const shared = new Set(contigs.map(c => panSNHaplotype(c.refName)))\n const [haplotype] = shared\n return {\n contigs,\n prefixes: [\n ...(unique ? [sample] : []),\n ...(shared.size === 1 && haplotype ? [haplotype] : []),\n ],\n named: true,\n }\n}\n\n// The rank-0 nodes' refNames and the span each covers\nexport function graphBackbone(graph: Graph): Backbone | undefined {\n const spans = new Map<string, BackboneContig>()\n for (const node of graph.nodes) {\n if (isBackbone(node)) {\n const { refName, start } = node.stable\n const end = start + node.length\n const span = spans.get(refName)\n if (span) {\n span.start = Math.min(span.start, start)\n span.end = Math.max(span.end, end)\n } else {\n spans.set(refName, {\n refName,\n contig: panSNContig(refName),\n start,\n end,\n })\n }\n }\n }\n const contigs = [...spans.values()]\n return contigs.length\n ? backboneFrom(contigs, graphHaplotypes(graph))\n : undefined\n}\n\n// `GRCh38 chr6`: the window's contig, else the backbone's one contig, after the\n// sample a named backbone lies on. Undefined where there is no one contig, so\n// a range never follows a bare sample.\nexport function referenceLabel(graph: Graph, region?: { refName: string }) {\n const backbone = graphBackbone(graph)\n const contig = region\n ? panSNContig(region.refName)\n : backbone?.contigs.length === 1\n ? backbone.contigs[0]!.contig\n : undefined\n const sample = backbone?.named\n ? panSNSample(backbone.contigs[0]!.refName)\n : undefined\n return contig && (sample ? `${sample} ${contig}` : contig)\n}\n\n// The assembly the backbone's haplotype names by its name or an alias, else\n// the one its sample names, else the one whose well-known sample it is. A\n// backbone with no prefix binds to none.\nexport function backboneAssembly<T extends AssemblyNames>(\n backbone: Backbone | undefined,\n assemblies: T[],\n): T | undefined {\n const names = (a: T) => [a.name, ...(a.aliases ?? [])]\n const naming = (prefix: string) => (a: T) =>\n names(a).some(n => n.toLowerCase() === prefix.toLowerCase())\n const prefixes = [...(backbone?.prefixes ?? [])].reverse()\n const sample = backbone?.prefixes.find(p => !p.includes('#'))?.toLowerCase()\n for (const prefix of prefixes) {\n const assembly = assemblies.find(naming(prefix))\n if (assembly) {\n return assembly\n }\n }\n return sample === undefined\n ? undefined\n : assemblies.find(a =>\n names(a).some(n => wellKnownSample(n)?.toLowerCase() === sample),\n )\n}\n\n// The first of the graph's walks that a backbone along it would bind to\n// `assembly`, for putting x on the assembly a cut was made for\nexport function assemblyWalk(\n graph: Graph,\n assembly: AssemblyNames,\n): PathOrigin | undefined {\n const haplotypes = graphHaplotypes(graph)\n return graph.anchorPaths?.find(walk =>\n backboneAssembly(\n backboneFrom(\n [\n {\n refName: walk.name,\n contig: panSNContig(walk.name),\n start: walk.start,\n end: walk.start + walk.length,\n },\n ],\n haplotypes,\n ),\n [assembly],\n ),\n )\n}\n\n// The names a file from outside the graph may give a contig: its own, and the\n// same with or without UCSC's `chr`, the mitochondrion as M or MT either way\nexport function contigNames(contig: string) {\n const bare = contig.replace(/^chr/i, '')\n const forms = !bare ? [] : /^(M|MT)$/i.test(bare) ? ['M', 'MT'] : [bare]\n return [...new Set([contig, ...forms.flatMap(f => [f, `chr${f}`])])]\n}\n\n// Which of `refNames` a feature's refName names: the one it equals, else the\n// only one whose contig it names, by any of contigNames or the name `aliases`\n// gives that contig (`{ chr6: 'NC_000006.12' }`). A name two refNames share\n// names neither.\nexport function refNameBinding(\n refNames: Iterable<string>,\n aliases: Record<string, string> = {},\n) {\n const exact = new Set(refNames)\n const byName = new Map<string, string | undefined>()\n for (const refName of exact) {\n const contig = panSNContig(refName)\n const alias = aliases[contig]\n for (const name of new Set([\n ...contigNames(contig),\n ...(alias ? [alias] : []),\n ])) {\n byName.set(name, byName.has(name) ? undefined : refName)\n }\n }\n return (name: string) => (exact.has(name) ? name : byName.get(name))\n}\n\n// An assembly's features on a backbone that binds to it, each renamed to the\n// backbone's refName for it, so the assembly's `chr6` becomes the graph's\n// `GRCh38#0#chr6`. genePins and tubeMapGenes take only the renamed.\nexport function featuresOnBackbone<T extends { refName: string }>(\n features: readonly T[],\n backbone: Backbone,\n aliases?: Record<string, string>,\n): T[] {\n const bind = refNameBinding(\n backbone.contigs.map(c => c.refName),\n aliases,\n )\n return features.flatMap(f => {\n const refName = bind(f.refName)\n return refName === undefined\n ? []\n : [refName === f.refName ? f : { ...f, refName }]\n })\n}\n", "import { joinCuts } from './gbzJoin.ts'\nimport { panSNMatchesPrefix, panSNSample } from './pansn.ts'\nimport { wellKnownSample } from './reference.ts'\n\nimport type { GBZBase, PathName, PathQuery, SnarlOutput } from '@gmod/gbz-base'\n\n// A window of a gbz-base graph cut to GFA, with no host in it: the adapter\n// and a standalone page open the database their own way and share this.\n\nexport class NoReferenceSampleError extends Error {\n override name = 'NoReferenceSampleError'\n\n constructor(anchor: string, referenceSamples: string[]) {\n super(\n referenceSamples.length === 0\n ? `the graph names no reference sample (gbwt_reference_samples) and the anchor \"${anchor}\" maps to none; set referenceSample`\n : `the anchor \"${anchor}\" is none of the graph's reference samples (${referenceSamples.join(', ')}); set referenceSample or map it through assemblyNameToPanSN`,\n )\n }\n}\n\nexport class NodeLimitError extends Error {\n override name = 'NodeLimitError'\n readonly regionTooLarge = true\n\n constructor(\n limit: number,\n windowBp: number,\n readonly fitsBp: number,\n ) {\n super(\n `this ${windowBp.toLocaleString()} bp window reads more than nodeLimit (${limit.toLocaleString()}) graph nodes; zoom in to about ${fitsBp.toLocaleString()} bp or raise nodeLimit`,\n )\n }\n}\n\nexport function haplotypePrefix(name: Pick<PathName, 'sample' | 'haplotype'>) {\n return `${name.sample}#${name.haplotype}`\n}\n\n// Whether a walk is one of the haplotypes asked for, by PanSN prefix at sample\n// (`HG002`) or haplotype (`HG002#1`) depth; undefined wants every one.\nexport function haplotypeWanted(name: PathName, wanted: string[] | undefined) {\n const prefix = haplotypePrefix(name)\n return (\n wanted === undefined ||\n wanted.some(candidate => panSNMatchesPrefix(prefix, candidate))\n )\n}\n\nexport async function referenceSamplesOf(db: GBZBase) {\n return ((await db.tag('gbwt_reference_samples')) ?? '')\n .split(/\\s+/)\n .filter(sample => sample !== '')\n}\n\nfunction aliasedSample(anchorSample: string, referenceSamples: string[]) {\n const lower = anchorSample.toLowerCase()\n const alias = wellKnownSample(anchorSample)?.toLowerCase()\n return (\n referenceSamples.find(s => s === anchorSample) ??\n referenceSamples.find(s => s.toLowerCase() === lower) ??\n referenceSamples.find(s => s.toLowerCase() === alias)\n )\n}\n\nexport function resolveReferenceSample({\n configured,\n anchorPrefix,\n referenceSamples,\n}: {\n configured: string\n anchorPrefix: string\n referenceSamples: string[]\n}) {\n if (configured !== '') {\n return configured\n }\n const sample =\n aliasedSample(panSNSample(anchorPrefix), referenceSamples) ??\n (referenceSamples.length === 1 ? referenceSamples[0] : undefined)\n if (sample === undefined) {\n throw new NoReferenceSampleError(anchorPrefix, referenceSamples)\n }\n return sample\n}\n\n// The indexed reference path a window on `refName` resolves against, or\n// undefined when the reference sample has no indexed path by that contig.\nexport async function referencePathQuery(\n db: GBZBase,\n referenceSample: string,\n refName: string,\n): Promise<PathQuery | undefined> {\n const path = (await db.paths()).find(\n p =>\n p.isIndexed &&\n p.name.sample === referenceSample &&\n p.name.contig === refName,\n )\n return path\n ? {\n sample: path.name.sample,\n contig: refName,\n haplotype: path.name.haplotype,\n }\n : undefined\n}\n\n// gbz-base reports the node limit with how far along the reference the walk\n// had got when it tripped, counted from the window's start; a window that fits\n// is that far, with a margin, or half the window when the limit tripped past\n// the reference.\nexport function nodeLimitError(\n error: unknown,\n limit: number,\n windowBp: number,\n) {\n const isLimit =\n error instanceof Error &&\n (error.name === 'SubgraphLimitError' ||\n /^Subgraph size limit of \\d+ nodes exceeded/.test(error.message))\n if (!isLimit) {\n return undefined\n } else {\n const walked = (error as { walkedBp?: unknown }).walkedBp\n const fits =\n typeof walked === 'number' && walked > 0\n ? Math.floor(walked * 0.8)\n : Math.floor(windowBp / 2)\n return new NodeLimitError(limit, windowBp, Math.max(fits, 1))\n }\n}\n\nexport interface GbzWindowOptions {\n context: number\n snarls: SnarlOutput\n limit: number\n keep?: ((name: PathName) => boolean) | undefined\n signal?: AbortSignal | undefined\n}\n\n// A cut's context and snarls unless told otherwise, and the nodes past which a\n// window fails rather than read a whole chromosome: what a gbz-base track's\n// slots default to, so a page or a script cuts the window the viewer would.\n// gbz-base counts every node it walks, which runs well past the nodes a cut\n// keeps.\nexport const GBZ_CUT_DEFAULTS = {\n context: 1000,\n snarls: 'contained',\n limit: 100_000,\n} as const satisfies Pick<GbzWindowOptions, 'context' | 'snarls' | 'limit'>\n\n// The reference walk, the snarls in the window, and one W line per haplotype\n// walk (the reference walk first), PanSN-named when the database carries the\n// haplotype index. Empty when the query names no indexed path.\nexport async function cutWindowGFA(\n db: GBZBase,\n query: PathQuery | undefined,\n start: number,\n end: number,\n opts: GbzWindowOptions,\n) {\n if (!query) {\n return ''\n }\n const subgraphs = await db\n .getSubgraphs({ ...opts, path: query, start, end, haplotypes: 'all' })\n .catch((error: unknown) => {\n throw nodeLimitError(error, opts.limit, end - start) ?? error\n })\n const paths = await db.paths()\n return joinCuts(\n await Promise.all(subgraphs.map(subgraph => subgraph.toGFA())),\n (sample, haplotype, contig, at) =>\n paths.some(\n ({ name }) =>\n name.sample === sample &&\n name.haplotype === haplotype &&\n name.contig === contig &&\n name.fragment === at,\n ),\n )\n}\n"],
5
+ "mappings": "4GAWA,IAAMA,EAAiB,UAEvB,SAASC,EAAUC,EAAoB,CACrC,IAAMC,EAASD,EAAK,MAAM,GAAI,EAC9B,MAAO,CACL,OAAAC,EACA,KAAMA,EAAO,MAAM,EAAG,CAAC,EAAE,KAAK,GAAI,EAClC,MAAO,CAACA,EAAO,CAAC,EAChB,IAAK,CAACA,EAAO,CAAC,CAChB,CACF,CAEA,IAAMC,EAAWC,GAAeA,EAAK,OAAO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ence", "tags", "ln", "tag", "extend", "a", "b", "steps", "pos", "step", "length", "joinPieces", "pieces", "startsPath", "joined", "piece", "last", "sample", "haplotype", "contig", "extended", "flip", "sign", "stepLinks", "i", "joinCuts", "gfas", "cuts", "gfa", "ofType", "cut", "type", "unknownOffset", "walksByCut", "walks", "offset", "w", "byName", "links", "link", "WELL_KNOWN_SAMPLES", "wellKnownSample", "assemblyName", "sampleOf", "refName", "sample", "panSNSample", "isGenericSample", "haplotypeOf", "panSNHaplotype", "graphHaplotypes", "graph", "refNames", "p", "node", "bySample", "backboneFrom", "contigs", "haplotypes", "samples", "c", "own", "unique", "h", "shared", "haplotype", "graphBackbone", "spans", "isBackbone", "start", "end", "span", "panSNContig", "referenceLabel", "region", "backbone", "contig", "backboneAssembly", "assemblies", "names", "naming", "prefix", "a", "n", "prefixes", "assembly", "assemblyWalk", "walk", "contigNames", "bare", "forms", "f", "refNameBinding", "aliases", "exact", "byName", "alias", "name", "featuresOnBackbone", "features", "bind", "NoReferenceSampleError", "anchor", "referenceSamples", "NodeLimitError", "limit", "windowBp", "fitsBp", "haplotypePrefix", "name", "haplotypeWanted", "wanted", "prefix", "candidate", "panSNMatchesPrefix", "referenceSamplesOf", "db", "sample", "aliasedSample", "anchorSample", "lower", "alias", "wellKnownSample", "s", "resolveReferenceSample", "configured", "anchorPrefix", "panSNSample", "referencePathQuery", "referenceSample", "refName", "path", "p", "nodeLimitError", "error", "walked", "fits", "GBZ_CUT_DEFAULTS", "cutWindowGFA", "query", "start", "end", "opts", "subgraphs", "paths", "joinCuts", "subgraph", "haplotype", "contig", "at"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import{b as T,g as de}from"./chunk-7BKUWQE5.js";import{a as ie,b as ue}from"./chunk-KULNKXPT.js";import{a as We}from"./chunk-FY3BTKY4.js";var Zt=We((no,ke)=>{ke.exports=JBrowseExports["tss-react/mui"]});function nn(e){let t=n=>Math.round(n*100)/100;return e.map((n,o)=>`${o?"L":"M"}${t(n.x)},${t(n.y)}`).join("")}function me(e,t,n,o,s){let r=Math.hypot(o-t,n-e);if(r===0)return[n,o];let a=(n-e)/r,c=(o-t)/r;return[n+s*a,o+s*c]}function q(e,t){let n=1-t,o=n*n*n,s=3*n*n*t,r=3*n*t*t,a=t*t*t;return{x:o*e.x0+s*e.cx0+r*e.cx1+a*e.x1,y:o*e.y0+s*e.cy0+r*e.cy1+a*e.y1}}function ye(e){let t=e[Math.floor(e.length/2)];return t?q(t,.5):void 0}function ge(e){let t=1/0,n=1/0,o=-1/0,s=-1/0;for(let r of e)t=Math.min(t,r.x0,r.cx0,r.cx1,r.x1),o=Math.max(o,r.x0,r.cx0,r.cx1,r.x1),n=Math.min(n,r.y0,r.cy0,r.cy1,r.y1),s=Math.max(s,r.y0,r.cy0,r.cy1,r.y1);return{minX:t,minY:n,maxX:o,maxY:s}}function Ue(e,t,n){let o=q(e,t),s=q(e,n),r=(n-t)/3,a=le(e,t),c=le(e,n);return{x0:o.x,y0:o.y,cx0:o.x+a.x*r,cy0:o.y+a.y*r,cx1:s.x-c.x*r,cy1:s.y-c.y*r,x1:s.x,y1:s.y}}function le(e,t){let n=1-t,o=3*n*n,s=6*n*t,r=3*t*t;return{x:o*(e.cx0-e.x0)+s*(e.cx1-e.cx0)+r*(e.x1-e.cx1),y:o*(e.cy0-e.y0)+s*(e.cy1-e.cy0)+r*(e.y1-e.cy1)}}function on(e,t){let n=e.map(a=>Math.hypot(a.cx0-a.x0,a.cy0-a.y0)+Math.hypot(a.cx1-a.cx0,a.cy1-a.cy0)+Math.hypot(a.x1-a.cx1,a.y1-a.cy1)),o=n.reduce((a,c)=>a+c,0),s=Math.max(3,Math.round(o/t)|1),r=[];for(let a=0;a<s;a+=2){let c=a/s*o,u=(a+1)/s*o,d=[],m=0;e.forEach((h,p)=>{let i=n[p],x=m+i;i>0&&x>c&&m<u&&d.push(Ue(h,Math.max(0,(c-m)/i),Math.min(1,(u-m)/i))),m=x}),d.length&&r.push(d)}return r}function rn(e,t,n){let o=new Array(e.length);for(let s=0;s<e.length;s++){let r=e[s];o[s]={x0:r.x0+t,y0:r.y0+n,cx0:r.cx0+t,cy0:r.cy0+n,cx1:r.cx1+t,cy1:r.cy1+n,x1:r.x1+t,y1:r.y1+n}}return o}function X(e,t){let n=e.length-1;return t==="end"?{at:e[n],inward:e[n-1]}:{at:e[0],inward:e[1]}}var Ve=.5,je=80;function k(e){return e.endsWith("-")?"-":"+"}function z(e){let t=(n,o)=>(o??k(n))===k(n);return{from:t(e.from,e.fromStrand)?"end":"start",to:t(e.to,e.toStrand)?"start":"end"}}function fe(e){let t=1/0,n=-1/0;for(let o of e)t=Math.min(t,o.x),n=Math.max(n,o.x);return{min:t,max:n}}function pe(e,t){return Math.max(0,t.min-e,e-t.max)}function he(e,t,n){let o=pe(e[0].x,t),s=pe(e[e.length-1].x,t);return o===s?n:o<s?"start":"end"}function Je(e,t){return{from:he(e,fe(t),"end"),to:he(t,fe(e),"start")}}var qe=.75,Ke=1.15,Qe=.35,Ze=60;function et(e,t,n,o,s,r){let a=Math.hypot(n-e,o-t),c=a===0?1:(n-e)/a,u=a===0?0:(o-t)/a,d=0,m=1/0,h=-1/0;for(let l of s){let f=l.x-e,y=l.y-t,b=f*-u+y*c;Math.abs(b)>Math.abs(d)&&(d=b);let g=f*c+y*u;m=Math.min(m,g),h=Math.max(h,g)}let p=s.length?h-m:0,i=Math.max(Math.abs(d)*Ke/qe,p*Qe),x=r===void 0?i:Math.min(i,r);return d<0?-x:x}function Ne({scaleX:e,scaleY:t}){return t/e}var tt=3;function j(e,t,n){let o=t.x-e.x,s=(t.y-e.y)*n,r=Math.hypot(o,s);return r===0?void 0:{x:o/r,y:s/r}}function sn(e,t,n,o,s=tt){let r=Ne(o),a=j(e[e.length-1],t[0],r)??j(e[0],e.at(-1),r)??j(t[0],t.at(-1),r)??{x:1,y:0},c=[];for(let u=0;u<n;u++){let d=(u-(n-1)/2)*s;c.push({x:-a.y*d,y:a.x*d/r})}return c}function J(e,t){return e.map(n=>({x:n.x,y:n.y*t}))}function nt(e,t){for(let n of e)n.y0/=t,n.cy0/=t,n.cy1/=t,n.y1/=t;return e}var ot=12,rt=40;function xe(e,t){let n=0;for(let r=1;r<e.length;r++)n+=Math.hypot(e[r].x-e[r-1].x,e[r].y-e[r-1].y);let o=n*t;return Math.min(rt,Math.max(ot,o/2))/Math.max(t,Number.EPSILON)}function st(e){return e.from!==e.to?!1:e.fromStrand&&e.toStrand&&e.fromStrand!==e.toStrand?e.fromStrand==="+"?"end":"start":!0}function Le(e,t=!1){let n=st(e);if(!t)return n;let o=z(e);return n===!1?o:o.from===o.to?o.from:!0}function at(e,t,n,o){let{at:s,inward:r}=e,a=r?s.x-r.x:1,c=r?s.y-r.y:0,u=Math.hypot(a,c)||1,d=a/u,m=c/u,h=s.x+n,p=s.y+o,i=h+d*t/3,x=p+m*t/3,l=h+d*t,f=p+m*t,y=-m*t/2,b=d*t/2;return[{x0:h,y0:p,cx0:i,cy0:x,cx1:l+y,cy1:f+b,x1:l,y1:f},{x0:l,y0:f,cx0:l-y,cy0:f-b,cx1:i,cy1:x,x1:h,y1:p}]}function K(e,t,n,o,s,r,a=[],c){let u=r.scaleX,d=Ne(r),m=c??(r.pixelRows?Ze:void 0);if(d!==1)return nt(K(J(e,d),J(t,d),n,o,s*d,{scaleX:u,scaleY:u},J(a,d),m===void 0?void 0:m*d),d);if(typeof n=="string")return at(X(e,n),xe(e,u),o,s);let h=n===!0,p=h?{from:"end",to:"start"}:n||Je(e,t),i=X(e,p.from),x=X(t,p.to),l=i.at,f=x.at,y=l.x+o,b=l.y+s,g=f.x+o,A=f.y+s;if(h){let M=1,L=0;if(i.inward){let R=l.x-i.inward.x,I=l.y-i.inward.y,O=Math.hypot(R,I);O>0&&(M=R/O,L=I/O)}let N=xe(e,u),_=-L,E=M,S=(l.x+f.x)/2+o+_*N,G=(l.y+f.y)/2+s+E*N,w=y+M*N,C=b+L*N,P=g-M*N,B=A-L*N;return[{x0:y,y0:b,cx0:w,cy0:C,cx1:w+_*N,cy1:C+E*N,x1:S,y1:G},{x0:S,y0:G,cx0:P+_*N,cy0:B+E*N,cx1:P,cy1:B,x1:g,y1:A}]}else{let M=i.inward??{x:l.x-(f.x-l.x),y:l.y-(f.y-l.y)},L=x.inward??{x:f.x-(l.x-f.x),y:f.y-(l.y-f.y)},N=Math.hypot(g-y,A-b),_=(oe,re,ze,Fe)=>{let se=re.x-oe.x,ae=re.y-oe.y,ce=Math.hypot(se,ae),$e=ce===0?0:(ze*se+Fe*ae)/ce;return Math.max(0,Math.min(N*Ve,je,$e*.5))},E=f.x-l.x,S=f.y-l.y,[G,w]=me(M.x,M.y,l.x,l.y,_(M,l,E,S)),[C,P]=me(L.x,L.y,f.x,f.y,_(L,f,-E,-S)),B=a.length?et(y,b,g,A,a,m):0,R=N===0?1:N,I=(g-y)/R,O=(A-b)/R,H=-O*B,ee=I*B,te=I*Math.abs(B),ne=O*Math.abs(B);return[{x0:y,y0:b,cx0:G+o+H-te,cy0:w+s+ee-ne,cx1:C+o+H+te,cy1:P+s+ee+ne,x1:g,y1:A}]}}function be(e,t){let n=e[0],o=e.at(-1);return Math.hypot(n.x-t.x,n.y-t.y)<Math.hypot(o.x-t.x,o.y-t.y)?"start":"end"}function Se(e,t,n,o){let s=X(e,o?.from??be(e,n[0])),r=X(t,o?.to??be(t,n.at(-1))),a=[s.at,...n,r.at],c=d=>{let m=a[d],h=i=>Math.hypot(i.x-m.x,i.y-m.y),p=(i,x)=>{let l=i?h(i):0,f=h(x);return l===0?{x:x.x-m.x,y:x.y-m.y}:{x:(m.x-i.x)/l*f,y:(m.y-i.y)/l*f}};if(d===0)return p(s.inward,a[1]);if(d===a.length-1){let i=p(r.inward,a[d-1]);return{x:-i.x,y:-i.y}}return{x:(a[d+1].x-a[d-1].x)/2,y:(a[d+1].y-a[d-1].y)/2}},u=[];for(let d=0;d<a.length-1;d++){let m=a[d],h=a[d+1],p=c(d),i=c(d+1);u.push({x0:m.x,y0:m.y,cx0:m.x+p.x/3,cy0:m.y+p.y/3,cx1:h.x-i.x/3,cy1:h.y-i.y/3,x1:h.x,y1:h.y})}return u}var ct=1;function it(e,t){return t.flatMap(n=>e[n]??[])}function Ee(e,t,n,o,s=!1){let r=e[t.from],a=e[t.to];if(!(!r?.length||!a?.length))return o?Se(r,a,o,s?z(t):void 0):K(r,a,Le(t,s),0,0,n,it(e,t.bypassed))}function ut(e){let t=new Map;for(let n of e.nodes)if(T(n)){let o=t.get(n.stable.refName);o?o.push(n):t.set(n.stable.refName,[n])}for(let n of t.values())n.sort((o,s)=>o.stable.start-s.stable.start);return t}function dt(e,t,n){let o=[];if(e)for(let s=de(e,t);s<e.length;s++){let r=e[s];if(r.stable.start>=n)break;r.stable.start+r.length<=n&&o.push(r.id)}return o}function mt(e,t,n,o){let{fromStrand:s,toStrand:r}=e;if(s===void 0||r===void 0)return!0;let a=s===(t.stable.strand??"+"),c=r===(n.stable.strand??"+");return o?a&&c:!a&&!c}function dn(e){let t=new Map(e.nodes.map(s=>[s.id,s])),n=ut(e),o=[];for(let s=0;s<e.edges.length;s++){let r=e.edges[s],a=t.get(r.from),c=t.get(r.to);if(a!==void 0&&c!==void 0&&T(a)&&T(c)&&a.stable.refName===c.stable.refName){let u=a.stable.start<=c.stable.start,[d,m]=u?[a,c]:[c,a],h=d.stable.start+d.length,p=m.stable.start,i=p-h;if(i>=ct&&mt(r,a,c,u)){let x=d.stable.refName;o.push({edgeIndex:s,from:r.from,to:r.to,...r.fromStrand?{fromStrand:r.fromStrand}:{},...r.toStrand?{toStrand:r.toStrand}:{},refName:x,start:h,end:p,bp:i,bypassed:dt(n.get(x),h,p)})}}}return o}function Me(e){return e==="+"?"-":"+"}function pn(e,t=new Set){let n=e.edges.map(z),o=new Map,s=(i,x,l)=>{let f=`${i}|${x}`,y=o.get(f);y?y.push(l):o.set(f,[l])};e.edges.forEach((i,x)=>{s(i.from,n[x].from,x),s(i.to,n[x].to,x)});let r=i=>{let x=o.get(`${i}|end`);if(x?.length!==1)return;let l=x[0],f=e.edges[l];return f.from===i&&f.to!==i&&!t.has(i)&&!t.has(f.to)&&n[l].from==="end"&&n[l].to==="start"&&o.get(`${f.to}|start`)?.length===1?l:void 0},a=new Set,c=new Map,u=new Map;for(let i of e.nodes){let x=o.get(`${i.id}|start`),l=x?.length===1?e.edges[x[0]].from:void 0;if(c.has(i.id)||l!==void 0&&r(l)===x[0])continue;let f=[i.id];for(;;){let y=r(f.at(-1)),b=y===void 0?void 0:e.edges[y].to;if(b===void 0||c.has(b))break;a.add(y),f.push(b)}for(let y of f)c.set(y,i.id);f.length>1&&u.set(i.id,f)}for(let i of e.nodes)c.has(i.id)||c.set(i.id,i.id);let d=new Map(e.nodes.map(i=>[i.id,i])),m=[];for(let i of e.nodes){if(c.get(i.id)!==i.id)continue;let x=u.get(i.id);if(!x){m.push(i);continue}let l=x.map(b=>d.get(b)),f=l.filter(T),y=f.length?f.reduce((b,g)=>b.stable.start<=g.stable.start?b:g):l[0];m.push({id:i.id,name:i.name,length:l.reduce((b,g)=>b+g.length,0),depth:i.depth,stable:y.stable})}let h=new Set,p=[];return e.edges.forEach((i,x)=>{let l=c.get(i.from),f=c.get(i.to),y=n[x],b=`${l}|${y.from}>${f}|${y.to}`;a.has(x)||h.has(b)||(h.add(b),p.push({from:l,to:f,...y.from==="start"?{fromStrand:Me(k(l))}:{},...y.to==="end"?{toStrand:Me(k(f))}:{}}))}),{graph:{...e,nodes:m,edges:p,paths:void 0,pathVisits:void 0},runs:u}}function hn(e,t,n){let o={...e};for(let[s,r]of t){let a=e[s];if(!a?.length)continue;delete o[s];let c=Z(a),u=c.at(-1),d=r.map(p=>Math.max(n(p),0)),m=d.reduce((p,i)=>p+i,0)||r.length,h=0;r.forEach((p,i)=>{let x=m?d[i]/m*u:u/r.length,l=i===r.length-1?u:h+x;o[p]=_e(a,c,h,l),h=l})}return o}function xn(e,t,n){if(e.length===0)return[];let o=Z(e),s=o.at(-1);return _e(e,o,t*s,n*s)}function Ae(e){let t=Z(e);return Q(e,t,t.at(-1)/2)}function Z(e){let t=[0];for(let n=1;n<e.length;n++)t.push(t[n-1]+Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y));return t}function Q(e,t,n){if(n<=0)return{...e[0]};let o=1;for(;o<t.length&&t[o]<n;)o++;if(o>=t.length)return{...e.at(-1)};let s=t[o]-t[o-1],r=s>0?(n-t[o-1])/s:0,a=e[o-1],c=e[o];return{x:a.x+(c.x-a.x)*r,y:a.y+(c.y-a.y)*r}}function _e(e,t,n,o){let s=[Q(e,t,n)];for(let r=0;r<e.length;r++)t[r]>n&&t[r]<o&&s.push({...e[r]});return s.push(Q(e,t,o)),s}function lt(e){return e.length*6.2+8}function ft(e,t){return e.x0<t.x1&&e.x1>t.x0&&e.y0<t.y1&&e.y1>t.y0}function Be(e,t){return e.x1<=0||e.x0>=t.width||e.y1<=0||e.y0>=t.height}function pt(e,t){return e.x0>=0&&e.x1<=t.width&&e.y0>=0&&e.y1<=t.height}function ht(e,t=[]){let n=[...t];return o=>Be(o,e)||n.some(s=>ft(s,o))?!1:(n.push(o),!0)}function yn(e,t,n){let o=[],r=(a,c)=>{let u=lt(c),d=a.y>t.height/2?-1:1;for(let m=0;m<=(a.stack??0);m++){let h=a.y+d*m*19,p={x0:a.x-u/2,x1:a.x+u/2,y0:h-11-4,y1:h+4};if(Be(p,t))return;if(pt(p,t)&&(a.fits?.(p)??!0)&&n(p))return{...a,text:c,y:h,w:u}}};for(let a of e){let c=r(a,a.text)??(a.fallback===void 0?void 0:r(a,a.fallback));c&&o.push(c)}return o}var xt=26,bt=4e4,yt=8,gt=8,Nt=5.7,Lt=6,St=13,F=3,$=2;function U(e){return(e.length*Nt+Lt+F)/2}var v=(St+F)/2,Et=U("1 bp");function W(e,t,n){return{x0:t-e,x1:t+e,y0:n-v,y1:n+v}}function Mn(e,t){return{x0:6,x1:6+e.length*6.2+8+F,y0:t-8-F/2,y1:t+8+F/2}}function Y(e,t,n){return n<t?e:Math.min(Math.max(e,t),n)}function Oe(e){return String(e).replace(/\B(?=(\d{3})+$)/g,",")}function Ce(e){return e>=1e6?`${+(e/1e6).toFixed(1)} Mb`:e>=1e3?`${+(e/1e3).toFixed(1)} kb`:`${e} bp`}function we(e){return`${Ce(e)} del`}function Mt(e,t,n,o){let s=e[0],r=e[e.length-1],a=(t.x-(s.x0+r.x1)/2)*n,c=(t.y-(s.y0+r.y1)/2)*o,u=Math.hypot(a,c);return u===0?{x:0,y:-1}:{x:a/u,y:c/u}}function At(e,t){return Math.abs(t.x)*(e.x1-e.x0)/2+Math.abs(t.y)*(e.y1-e.y0)/2}function _t(e,t){let n=(e.x1-e.x0)/2,o=(e.y1-e.y0)/2;return Math.min(t.x===0?1/0:n/Math.abs(t.x),t.y===0?1/0:o/Math.abs(t.y))}function Bt(e,t,n){let o=0;for(let s=1;s<e.length;s++){let r=e[s-1],a=e[s];o+=Math.hypot((a.x-r.x)*t,(a.y-r.y)*n)}return o}function wt(e,t){let n=1/0,o=1/0,s=-1/0,r=-1/0;for(let a of e)for(let c of t[a]??[])n=Math.min(n,c.x),s=Math.max(s,c.x),o=Math.min(o,c.y),r=Math.max(r,c.y);return n===1/0?void 0:{minX:n,minY:o,maxX:s,maxY:r}}var Ge=new WeakMap;function Gt(e,t){let n=Ge.get(e);if(n?.nodeLengths===t)return n.order;let o=Object.entries(e).filter(([s,r])=>r.length>0&&t.has(s)).sort(([s],[r])=>t.get(r)-t.get(s));return Ge.set(e,{nodeLengths:t,order:o}),o}var Pe=new WeakMap;function Pt(e,t,n,o,s,r){let{scaleX:a,scaleY:c}=n,u=Pe.get(e);if(u?.deletions===t&&u.routes===s&&u.stranded===r&&u.scaleX===a&&u.scaleY===c&&u.version===o)return u.arcs;let d=[];for(let m of[...t].sort((h,p)=>p.bp-h.bp)){let h=Ee(e,m,n,s?.[m.edgeIndex],r),p=h?ye(h):void 0;if(h&&p){let{minX:i,minY:x,maxX:l,maxY:f}=ge(h);d.push({deletion:m,curves:h,apex:p,extent:Math.max((l-i)*a,(f-x)*c)})}}return Pe.set(e,{deletions:t,routes:s,stranded:r,scaleX:a,scaleY:c,version:o,arcs:d}),d}function An({nodePositions:e,nodeLengths:t,deletions:n,deletionRoutes:o,stranded:s=!1,alleleDeletions:r,axis:a,translateX:c,translateY:u,width:d,height:m,version:h=0}){let{scaleX:p,scaleY:i}=a,x=[],l=[];for(let{deletion:b,curves:g,apex:A,extent:M}of Pt(e,n,a,h,o,s))if(M>=xt){let L=we(b.bp),N=U(L),_=W(N,0,0),E=A.x*p+c,S=A.y*i+u,G=M>=N*2/$,w=Mt(g,A,p,i),C=At(_,w)+gt,P=G?E:Y(E+w.x*C,N,d-N),B=G?S:Y(S+w.y*C,v,m-v),R=Math.hypot(P-E,B-S),I;if(R>0){let O={x:(P-E)/R,y:(B-S)/R},H=_t(_,O);I={arcX:E,arcY:S,labelX:P-O.x*H,labelY:B-O.y*H}}x.push({label:{key:`del:${b.edgeIndex}`,text:L,x:P,y:B,kind:"deletion",leader:I},box:W(N,P,B)})}let f=new Set,y=[...r??[]].sort((b,g)=>g.bp-b.bp);for(let b of y){let g=wt(b.nodeIds,e);if(!g)continue;let A=Math.max(g.minX*p+c,0),M=Math.min(g.maxX*p+c,d),L=Math.max(g.minY*i+u,0),N=Math.min(g.maxY*i+u,m);if(M<A||N<L)continue;let _=Math.max(M-A,N-L),E=we(b.bp),S=U(E);if(_>=S*2/$){for(let C of b.nodeIds)f.add(C);let G=Y((A+M)/2,S,d-S),w=Y((L+N)/2,v,m-v);x.push({label:{key:`alleledel:${b.nodeIds.join(",")}`,text:E,x:G,y:w,kind:"deletion"},box:W(S,G,w)})}}for(let[b,g]of Gt(e,t)){if(f.has(b))continue;let{x:A,y:M}=Ae(g),L=M*i+u;if(L+v<=0||L-v>=m)continue;let N=Bt(g,p,i);if(N<Et*2/$)continue;let _=Ce(t.get(b)),E=U(_);if(N>=E*2/$){let S=A*p+c;l.push({label:{key:`node:${b}`,text:_,x:S,y:L,kind:"node"},box:W(E,S,L)})}}return{deletions:x,nodes:l}}function _n(e,t){return Math.max(yt,Math.floor(e*t/bt))}function Bn(e,t,n=1/0){let o=[];for(let{label:s,box:r}of e){if(o.length>=n)break;t(r)&&o.push(s)}return o}var Ct=/:(\d+)-\d+$/;function V(e){let t=Ct.exec(e);return t?{name:e.slice(0,t.index),start:+t[1]}:{name:e,start:0}}function On(e,t){let n=[],o=new Map;for(let s of e){let r=ie(s.name),a=s.start;for(let c of s.steps){let u={path:s.name,sample:r,start:a,strand:c.strand},d=o.get(c.id);d?d.push(u):o.set(c.id,[u]),a+=t(c.id)}n.push({name:s.name,sample:r,start:s.start,length:a-s.start})}return{anchorPaths:n,pathVisits:o}}function Rt(e,t){return e.find(o=>o.sample===t||o.name===t)??e[0]}var It=1;function vt(e,t,n){let o=e;if(t&&t.length>0){let s=t.find(r=>r.path===n)??t[0];o={...e,stable:{refName:s.path,start:s.start,rank:s.path===n?0:It,strand:s.strand},samples:[...new Set(t.map(r=>r.sample))].sort()}}return o}function Tt(e,t){let{anchorPaths:n,pathVisits:o}=e,s=n&&o?Rt(n,t):void 0;return s&&o?{...e,nodes:e.nodes.map(r=>vt(r,o.get(r.name),s.name)),anchoredBy:"paths",referencePath:s.name}:e}function Cn(e,t){return e.anchoredBy==="tags"?e:Tt(e,t)}function Rn(e,t){if(!e.anchorPaths)return;let n=new Map(e.nodes.map(r=>[r.id,r.length])),o=(r,a=r.length)=>{let c=0;for(let u=0;u<a;u++)c+=n.get(r[u])??0;return c},s=new Map;for(let r of e.paths??[]){let a=V(r.name).name;s.set(a,[...s.get(a)??[],r])}return e.anchorPaths.map(r=>{let a=s.get(r.name),c=a?.length===1?a[0]:void 0,u=c&&t.get(c.name);return c&&u?{...r,start:r.start+o(c.nodeIds,u.first),length:o(u.nodeIds)}:r})}function Hn(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Math.abs(t%360)}function Dt(e,t){return e*360/t}var Ht=.7,Xt=.5,kt=16;function Xn(e){return e>0&&e<=kt}function zt(e,t){return`hsl(${Dt(e,t)}, ${Ht*100}%, ${Xt*100}%)`}function kn(e,t){return`hsl(0, 0%, ${t>1?25+45*e/(t-1):45}%)`}function Ft(e){let t=V(e).name.split("#"),n=t.join("#");if(t.length>=3&&ue(t[0])){let o=t.slice(2).join("#");return[o,o,n]}return[t[0],t.slice(0,2).join("#"),n]}function $t(e,t){let{start:n}=V(e);return t.map(o=>`${o} @${Oe(n)}`)}function zn(e,t){let n=new Map;e.forEach((u,d)=>{n.has(u.name)||n.set(u.name,d)});let o=[...n].map(([u,d])=>({name:u,i:d})),s=o.map(u=>Ft(u.name)),r=[0,1,2].flatMap(u=>[o.map((d,m)=>s[m][u]),o.map((d,m)=>$t(d.name,s[m])[u])]),c=r.find(u=>new Set(u).size===o.length)??r.at(-1);return o.map(({name:u,i:d},m)=>({name:u,label:c[m],color:t?.[d]??zt(d,e.length)}))}var Wt=[{value:"auto",label:"Auto"},{value:"uniform",label:"Uniform"},{value:"random",label:"Random"},{value:"rainbow",label:"Rainbow"},{value:"depth",label:"Depth"},{value:"node-length",label:"Node length"},{value:"stable-rank",label:"Stable rank"},{value:"reference-position",label:"Reference position"},{value:"grey",label:"Grey"}],$n=Wt.map(e=>e.value);function Wn(e,t){return e!=="auto"?e:t?.anchoredBy?"reference-position":"uniform"}var Yt=[{value:"depth",label:"By depth",description:"Thicker the more paths carry a node, on the square root of its depth against the mean. A graph with one depth everywhere draws uniform."},{value:"uniform",label:"Uniform",description:"Every node the same thickness."}],Un=Yt.map(e=>e.value),Ut=.3,Re=3;function Vt(e){let t=0,n=0;for(let o of e.nodes)t+=o.depth*o.length,n+=o.length;return n>0?t/n:0}function jt(e,t){return!(t>0)||!(e.depth>0)?1:Math.min(Re,Math.max(Ut,Math.sqrt(e.depth/t)))}function Jt(e,t,n,o){return t*(n==="depth"?jt(e,o):1)}function qt(e,t){return e*(t==="depth"?Re:1)}function Vn(e,t,n,o){let s=e?Vt(e):0;return{maxHalfWidthPx:qt(n,o)/2,halfWidthPx:r=>{let a=t?.get(r);return a?Jt(a,n,o,s)/2:n/2}}}function Kt(e,t){return Math.max(e.nodeLengthPerMegabase*t/1e6,e.minimumNodeLength)}function ve(e,t=5){let o=e.nodes.reduce((r,a)=>r+a.length,0)/1e6,s=Math.max(e.nodes.length*40,500);return{nodeLengthPerMegabase:o>0?s/o:1e4,minimumNodeLength:Math.max(5,t),edgeLength:5,nodeSegmentLength:20}}var D={power:1,effect:1};function Te(e){return e.power===1&&e.effect===1}function De(e,t){let n=e.nodes.length,o=e.nodes.reduce((a,c)=>a+c.length,0),s=n>0?o/n:0,r=n>0?Math.max(n*40,500)/n:40;return a=>{if(s<=0)return r;let c=(a/s)**t.power;return Math.max(r*((c-1)*t.effect+1),5)}}var Ie=1e3,He={law:D,minNodeLength:0};function Jn(e,t=He){let{law:n,minNodeLength:o}=t,s=ve(e,o);if(Te(n))return{nodes:e.nodes,opts:s};let r=De(e,n);return{nodes:e.nodes.map(a=>({...a,length:Math.round(r(a.length)*Ie)})),opts:{...s,nodeLengthPerMegabase:1e6/Ie,minimumNodeLength:5}}}function qn(e,t=He){if(Te(t.law)){let n=ve(e,t.minNodeLength);return o=>Kt(n,o)}return De(e,t.law)}var Xe=[{value:"auto",label:"Proportional",description:"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.",law:D,minNodeFactor:0},{value:"open",label:"Open bubbles",description:"Give every allele a drawn length, so a bubble reads as two arms rather than a knot.",law:D,minNodeFactor:2.5},{value:"wide",label:"Wide bubbles",description:"As open, spread further. Best on a window of a dozen bubbles.",law:D,minNodeFactor:10},{value:"compress",label:"Compress lengths",description:"Pull the longest and shortest nodes towards the graph\u2019s mean, so a cut spanning kb and bp fits one pane.",law:{power:.5,effect:.5},minNodeFactor:0}],Zn=Xe.map(e=>e.value);function eo(e){let t=Xe.find(n=>n.value===e);return{law:t?.law??D,minNodeLength:(t?.minNodeFactor??0)*40}}export{V as a,On as b,Rt as c,Tt as d,Cn as e,Rn as f,nn as g,ge as h,on as i,rn as j,z as k,Ne as l,sn as m,Le as n,K as o,Se as p,it as q,dn as r,pn as s,hn as t,xn as u,ht as v,yn as w,Mn as x,Oe as y,Ce as z,An as A,_n as B,Bn as C,Hn as D,Dt as E,Ht as F,Xt as G,kt as H,Xn as I,zt as J,kn as K,zn as L,Wt as M,$n as N,Wn as O,Yt as P,Un as Q,Vt as R,Jt as S,Vn as T,Kt as U,Jn as V,qn as W,Xe as X,Zn as Y,eo as Z,Zt as _};
2
+ //# sourceMappingURL=chunk-K5Z47YVI.js.map