jbrowse-plugin-graphgenomeviewer 4.1.0 → 4.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.
- package/README.md +4 -4
- package/dist/chunks/{GraphGenomeView-UV5XDD7W.js → GraphGenomeView-QOBHGMLE.js} +2 -2
- package/dist/chunks/{LinearGraphDisplay-P2POSPXV.js → LinearGraphDisplay-TPXW6POY.js} +2 -2
- package/dist/chunks/{RgfaTabixAdapter-5MD2ZZ2F.js → RgfaTabixAdapter-QPKEJZXA.js} +3 -3
- package/dist/chunks/{RgfaTabixAdapter-5MD2ZZ2F.js.map → RgfaTabixAdapter-QPKEJZXA.js.map} +2 -2
- package/dist/chunks/{chunk-32XXMGET.js → chunk-HW55QCJG.js} +2 -2
- package/dist/chunks/{chunk-32XXMGET.js.map → chunk-HW55QCJG.js.map} +1 -1
- package/dist/chunks/{chunk-OJOZ5YAL.js → chunk-SIP5IHWK.js} +2 -2
- package/dist/chunks/{chunk-OJOZ5YAL.js.map → chunk-SIP5IHWK.js.map} +2 -2
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +4 -4
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +2 -2
- package/package.json +2 -2
- package/src/GraphGenomeView/components/WalkRowsOverlay.tsx +2 -2
- package/src/GraphGenomeView/model.test.ts +1 -1
- package/src/GraphGenomeView/model.ts +4 -6
- package/src/RgfaTabixAdapter/RgfaTabixAdapter.test.ts +8 -8
- package/src/RgfaTabixAdapter/RgfaTabixAdapter.ts +5 -6
- package/src/RgfaTabixAdapter/rgfaBed.test.ts +7 -7
- package/src/version.ts +1 -1
- /package/dist/chunks/{GraphGenomeView-UV5XDD7W.js.map → GraphGenomeView-QOBHGMLE.js.map} +0 -0
- /package/dist/chunks/{LinearGraphDisplay-P2POSPXV.js.map → LinearGraphDisplay-TPXW6POY.js.map} +0 -0
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ above it.
|
|
|
22
22
|
|
|
23
23
|
- **Copy number off a bar.** Walk rows tile each haplotype by the 5,548 bp
|
|
24
24
|
kringle: GRCh38's six units are the six LPA exon pairs above, and HG00133
|
|
25
|
-
|
|
25
|
+
has 27.
|
|
26
26
|
|
|
27
27
|

|
|
28
28
|
|
|
@@ -49,9 +49,9 @@ node in the view bands its bp in the linear view:
|
|
|
49
49
|
- Genes from the session's annotation track, drawn on the graph
|
|
50
50
|
- Hovering a callset or MAF row in the same view lifts that haplotype's walk
|
|
51
51
|
- Bubbles from `gfatools bubble` or the graph itself, opened level by level
|
|
52
|
-
- gbz-base haplotypes as walks:
|
|
53
|
-
metro-map lanes or side by side, a panel per
|
|
54
|
-
shading from its start to its end
|
|
52
|
+
- gbz-base haplotypes as walks: the number of walks through a node as its
|
|
53
|
+
thickness, walks lifted out as metro-map lanes or side by side, a panel per
|
|
54
|
+
walk or a row per sample, each shading from its start to its end
|
|
55
55
|
- GAF reads in the tube map, with their mismatches, from a gbz-base track
|
|
56
56
|
- Figures as SVG, from the view's Export SVG or from a JSON spec with no browser
|
|
57
57
|
([docs/figures.md](docs/figures.md))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as x}from"./chunk-
|
|
1
|
+
import{a as x}from"./chunk-HW55QCJG.js";import"./chunk-SIP5IHWK.js";import"./chunk-UQEPPJEO.js";import"./chunk-SCMIJAAX.js";import"./chunk-FCWXYIFC.js";import"./chunk-4C4CMI6K.js";import{X as L}from"./chunk-ECKLYJWP.js";import"./chunk-7BKUWQE5.js";import"./chunk-KULNKXPT.js";import{a as s,b as g,c as v,d as G,e as B}from"./chunk-XEJ47DLD.js";import{b as a}from"./chunk-FY3BTKY4.js";var S=a(g(),1);var m=a(G(),1),n=a(v(),1),C=a(g(),1),P=a(L(),1),o=a(s(),1),I=(0,P.makeStyles)()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}}),b=(0,C.observer)(function({model:e}){let{classes:r}=I();return e.isLoading?(0,o.jsxs)(n.Paper,{className:r.paper,"data-testid":"graph-genome-loading",children:[(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(m.LoadingEllipses,{variant:"h6",message:e.statusMessage}),(0,o.jsx)(n.Button,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{e.cancelLoad()},children:"Cancel"})]}),(0,o.jsx)(n.LinearProgress,{variant:"indeterminate"})]}):e.error?(0,o.jsx)(n.Paper,{className:r.paper,children:(0,o.jsx)(m.ErrorBanner,{error:e.error,onReset:()=>{e.retryLoad()}})}):(0,o.jsx)(n.Paper,{className:r.paper,"data-testid":"graph-genome-load-canceled",children:(0,o.jsxs)("div",{className:r.row,children:[(0,o.jsx)(n.Typography,{variant:"h6",children:"Loading canceled"}),(0,o.jsx)(n.Button,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{e.retryLoad()},children:"Retry"})]})})}),h=b;var M=a(B(),1),N=a(G(),1),i=a(v(),1),w=a(g(),1),E=a(L(),1),t=a(s(),1),k=`H VN:Z:1.0
|
|
2
2
|
S 1 ACGT
|
|
3
3
|
S 2 GGCC
|
|
4
4
|
S 3 TTAA
|
|
@@ -7,4 +7,4 @@ L 1 + 2 + 0M
|
|
|
7
7
|
L 1 + 3 + 0M
|
|
8
8
|
L 2 + 4 + 0M
|
|
9
9
|
L 3 + 4 + 0M`,z=(0,E.makeStyles)()({column:{display:"flex",flexDirection:"column",gap:8},rowEnd:{display:"flex",gap:8,alignItems:"flex-end"},rowCenter:{display:"flex",gap:8,alignItems:"center"},flex1:{flex:1},paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto"},header:{marginBottom:12},footer:{marginTop:12,display:"flex",justifyContent:"flex-end"}}),R=(0,w.observer)(function({model:e}){let{classes:r}=z(),[d,T]=(0,M.useState)("");function y(){d.trim()&&e.loadGFAFromLocation({uri:d,locationType:"UriLocation"})}function A(p){let c=p.target.files?.[0];c&&c.text().then(f=>e.loadGFA(f,c.name)).catch(f=>{e.setError(f)})}return(0,t.jsxs)(i.Paper,{className:r.paper,children:[(0,t.jsx)("div",{className:r.header,children:(0,t.jsx)(i.Typography,{variant:"h6",children:"Load a GFA graph"})}),(0,t.jsxs)("div",{className:r.column,children:[(0,t.jsxs)("div",{className:r.rowCenter,children:[(0,t.jsxs)(i.Button,{variant:"outlined",component:"label",size:"small",children:["Choose file",(0,t.jsx)("input",{type:"file",accept:".gfa,.gfa1,.gfa2",hidden:!0,onChange:p=>{A(p)}})]}),(0,t.jsx)(i.Typography,{variant:"caption",color:"text.secondary",children:"Whole-file GFA; best for small/medium graphs."})]}),(0,t.jsxs)("div",{className:r.rowEnd,children:[(0,t.jsx)(i.TextField,{size:"small",label:"URL",placeholder:"https://example.com/graph.gfa",value:d,onChange:p=>{T(p.target.value)},onKeyDown:p=>{p.key==="Enter"&&y()},className:r.flex1}),(0,t.jsx)(i.Button,{variant:"contained",onClick:()=>{y()},disabled:!d.trim(),children:"Open"})]})]}),(0,t.jsx)("div",{className:r.footer,children:(0,t.jsx)(i.Button,{size:"small",onClick:()=>{e.loadGFA(k,"Example graph")},children:"Load 4-node example"})}),e.error?(0,t.jsx)(N.ErrorBanner,{error:e.error}):null]})}),F=R;var l=a(s(),1),U=(0,S.observer)(function({model:e}){return e.hasGraph?(0,l.jsx)(x,{model:e}):e.canRetryLoad&&(e.error||e.loadCanceled)?(0,l.jsx)(h,{model:e}):(0,l.jsxs)(l.Fragment,{children:[e.isLoading?(0,l.jsx)(h,{model:e}):null,(0,l.jsx)("div",{hidden:e.isLoading,children:(0,l.jsx)(F,{model:e})})]})}),O=U;export{O as default};
|
|
10
|
-
//# sourceMappingURL=GraphGenomeView-
|
|
10
|
+
//# sourceMappingURL=GraphGenomeView-QOBHGMLE.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=LinearGraphDisplay-
|
|
1
|
+
import{a as i}from"./chunk-HW55QCJG.js";import"./chunk-SIP5IHWK.js";import"./chunk-UQEPPJEO.js";import"./chunk-SCMIJAAX.js";import"./chunk-FCWXYIFC.js";import"./chunk-4C4CMI6K.js";import"./chunk-ECKLYJWP.js";import"./chunk-7BKUWQE5.js";import"./chunk-KULNKXPT.js";import{a as e,b as d}from"./chunk-XEJ47DLD.js";import{a as h,b as t}from"./chunk-FY3BTKY4.js";var p=h((l,o)=>{o.exports=JBrowseExports["@jbrowse/display-kit/DisplayChrome"]});var s=t(p(),1),n=t(d(),1);var r=t(e(),1),y=(0,n.observer)(function({model:a}){return(0,r.jsx)(s.DisplayStatusChrome,{model:a,phase:a.displayPhase,drawn:a.painted&&a.geometryPainted,testid:"linear-graph-display","data-layout":a.chosenLayoutMode,"data-cut-tier":a.cutTier,"data-recuts":a.recuts,"data-node-count":a.hasGraph?a.nodeCount:void 0,"data-loading":a.isLoading?"":void 0,style:{width:a.paneWidth,height:a.height,overflow:"hidden"},children:(0,r.jsx)(i,{model:a,ownChrome:!1})})}),c=y;export{c as default};
|
|
2
|
+
//# sourceMappingURL=LinearGraphDisplay-TPXW6POY.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as O,b as P,d as h,e as L}from"./chunk-KDIBFGZM.js";import"./chunk-KWAXLUPQ.js";import{a as B}from"./chunk-J4OLMLS5.js";import"./chunk-KULNKXPT.js";import{b as S}from"./chunk-FY3BTKY4.js";var
|
|
2
|
-
`)}function
|
|
3
|
-
//# sourceMappingURL=RgfaTabixAdapter-
|
|
1
|
+
import{a as O,b as P,d as h,e as L}from"./chunk-KDIBFGZM.js";import"./chunk-KWAXLUPQ.js";import{a as B}from"./chunk-J4OLMLS5.js";import"./chunk-KULNKXPT.js";import{b as S}from"./chunk-FY3BTKY4.js";var F=S(O(),1),l=S(B(),1),M=S(P(),1);function x(t){let e=t.split(" ");return{refName:e[0],start:+e[1],end:+e[2],id:e[3],rank:+e[4],tags:e[5]??""}}function $(t){let e=t.tags.split(" ").find(a=>a.startsWith("SM:Z:"));if(e===void 0)return;let n=e.slice(5).split(",").map(a=>a.trim()).filter(Boolean);return n.length>0?n:void 0}function w(t){return{id:t.slice(0,-1),strand:t.slice(-1)}}function A(t){let e=t.split(" "),n=w(e[3]),a=w(e[4]);return{source:n.id,sourceStrand:n.strand,target:a.id,targetStrand:a.strand,sourceSegment:{id:n.id,refName:e[5],start:+e[6],end:+e[7],rank:+e[8],tags:e[13]??""},targetSegment:{id:a.id,refName:e[9],start:+e[10],end:+e[11],rank:+e[12],tags:e[14]??""}}}function I(t){return`${t.source}${t.sourceStrand}${t.target}${t.targetStrand}`}var j=/^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/;function G(t){let{id:e,refName:n,start:a,end:r,rank:s,tags:m}=t,o=m.split(" ").filter(g=>j.test(g)),i=o.length===0?"":` ${o.join(" ")}`;return`S ${e} * LN:i:${r-a} SN:Z:${n} SO:i:${a} SR:i:${s}${i}`}function Z(t){let{source:e,sourceStrand:n,target:a,targetStrand:r}=t;return`L ${e} ${n} ${a} ${r} 0M`}function b(t,e){return t<e?-1:t>e?1:0}function T(t,e){let n=[...t.values()].sort((r,s)=>b(r.refName,s.refName)||r.start-s.start||b(r.id,s.id)),a=[...e.keys()].sort((r,s)=>b(r,s));return["H VN:Z:1.0",...n.map(r=>G(r)),...a.map(r=>Z(e.get(r)))].join(`
|
|
2
|
+
`)}function C(t){return t.filter(e=>e.rank>0)}var N=class extends F.BaseFeatureDataAdapter{static{this.capabilities=["getFeatures","getRefNames"]}constructor(e,n,a){super(e,n,a),this.fine=this.openIndex([])}openIndex(e){let n=h(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]);return{segments:n,links:h(this,[...e,"linksLocation"],[...e,"linksIndex"]),refNames:new L(n,this)}}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async hasDataForRefName(){return!0}getFeatures(e,n={}){let{signal:a,statusCallback:r}=n;return(0,M.ObservableCreate)(async s=>{let m=await this.fine.refNames.resolve(e,n);m!==void 0&&await(0,l.updateStatus)("Downloading segments",r,()=>this.fine.segments.getLines(m,e.start,e.end,{signal:a,lineCallback:o=>{let i=x(o),g=$(i);s.next(new l.SimpleFeature({uniqueId:i.id,refName:e.refName,start:i.start,end:i.end,name:i.id,type:"segment",rank:i.rank,stableName:i.refName,...g&&{samples:g,sampleCount:g.length}}))}})),s.complete()},a)}async getSubgraph(e,n={}){let{hops:a=0,signal:r,tier:s}=n,m=this.index(s),o=new Map,i=new Map,g=await m.refNames.resolve(e,{signal:r}),R=async(f,p,d)=>{let y=[];return await m.links.getLines(f,p,d,{signal:r,lineCallback:v=>{let c=A(v);i.set(I(c),c);for(let u of[c.sourceSegment,c.targetSegment])o.has(u.id)||(o.set(u.id,u),y.push(u))}}),y};if(g===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${e.assemblyName} mapped to its prefix in assemblyNameToPanSN`);await m.segments.getLines(g,e.start,e.end,{signal:r,lineCallback:f=>{let p=x(f);o.set(p.id,p)}});let k=C(await R(g,e.start,e.end));for(let f=0;f<a;f++){let p=await Promise.all(k.map(d=>R(d.refName,d.start,d.end)));k=C(p.flat())}return T(o,i)}};export{N as default};
|
|
3
|
+
//# sourceMappingURL=RgfaTabixAdapter-QPKEJZXA.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/RgfaTabixAdapter/RgfaTabixAdapter.ts", "../../src/RgfaTabixAdapter/rgfaBed.ts"],
|
|
4
|
-
"sourcesContent": ["import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { SimpleFeature, updateStatus } from '@jbrowse/core/util'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\n\nimport { PanSNRefNames, openTabixSlot } from '../panSNTabix.ts'\nimport {\n formatSubgraph,\n linkKey,\n parseLinkLine,\n parseSegmentLine,\n segmentSamples,\n} from './rgfaBed.ts'\n\nimport type { RgfaTabixAdapterConfig } from './configSchema.ts'\nimport type { SubgraphAdapterOptions, SubgraphTier } from '../GetSubgraph.ts'\nimport type { RgfaLink, RgfaSegment } from './rgfaBed.ts'\nimport type { TabixIndexedFile } from '@gmod/tabix'\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { Region } from '@jbrowse/core/util/types'\n\n// What a hop follows: alleles, never the backbone. A rank-0 segment reached\n// through a link is flanking backbone, usually outside the window, so querying\n// its links walks the reference away from the region, brings back more backbone,\n// and closes nothing. Every segment that closes a bubble is an allele interior,\n// and an allele interior is rank > 0 in both index formats (rGFA's SR tag, and\n// pggb's rank 0-or-1 against the anchor path). Reached backbone still becomes a\n// node and its edge still draws; it is only not walked through.\n//\n// This is gfabase's rule, arrived at from the other end. `gfabase sub` expands\n// from a seed either to the whole connected component (`--connected`, which its\n// own README calls overkill) or with `--cutpoints 1`, which takes the biconnected\n// component by *stopping at cutpoints*, the segments every end-to-end walk of\n// the chromosome must traverse. In a reference-anchored pangenome the cutpoints\n// are the backbone, and rank is what the index already states about it, so\n// `rank > 0` is that stopping rule without a connectivity index to build. The\n// third tool is the same shape again: `gfatools view -R` maps the region onto its\n// precomputed bubble decomposition and returns whole overlapping bubbles\n// (gfa_query_by_reg), which is complete for the same reason. Bandage's own\n// `--distance` is a node-step radius, but Bandage holds the entire graph in\n// memory, so its scope is a drawing filter rather than a fetch strategy.\n//\n// Measured with this rule: the E. coli paa window converges at one hop (17\n// segments at 1 and at 2), so the cut closes and stays closed. HPRC's amylase\n// window keeps growing (63 at 0, 78 at 1, 92 at 2) because its alleles have\n// alleles, and wall-clock is flat across all three, since a hop's queries go out\n// together and the remote index dominates.\n//\n// The exact version, when a graph ships a bubble index beside its segments:\n// gfatools' bubble rows carry the member segment ids of every bubble, so the\n// bubbles overlapping the region state which segments a complete cut must\n// contain. That turns the hop count into a termination condition rather than a\n// setting, and MinigraphBubbleAdapter already parses those rows.\nfunction offReference(segments: RgfaSegment[]) {\n return segments.filter(segment => segment.rank > 0)\n}\n\ninterface GraphIndex {\n segments: TabixIndexedFile\n links: TabixIndexedFile\n refNames: PanSNRefNames\n}\n\nexport default class RgfaTabixAdapter extends BaseFeatureDataAdapter<RgfaTabixAdapterConfig> {\n public static capabilities = ['getFeatures', 'getRefNames']\n\n private readonly fine\n private coarse: GraphIndex | undefined\n\n public constructor(\n config: RgfaTabixAdapterConfig,\n getSubAdapter?: getSubAdapterType,\n pluginManager?: PluginManager,\n ) {\n super(config, getSubAdapter, pluginManager)\n this.fine = this.openIndex([])\n }\n\n // refNames off the SEGMENT index: it is the one that names every stable\n // sequence the graph is anchored to, where the link index only names those a\n // link touches.\n private openIndex(under: string[]): GraphIndex {\n const segments = openTabixSlot(\n this,\n [...under, 'segmentsLocation'],\n [...under, 'segmentsIndex'],\n )\n return {\n segments,\n links: openTabixSlot(\n this,\n [...under, 'linksLocation'],\n [...under, 'linksIndex'],\n ),\n refNames: new PanSNRefNames(segments, this),\n }\n }\n\n private index(tier: SubgraphTier = 'fine') {\n if (tier === 'fine') {\n return this.fine\n }\n this.coarse ??= this.openIndex(['coarse'])\n return this.coarse\n }\n\n async getRefNames(opts: BaseOptions = {}) {\n return this.fine.refNames.assemblyRefNames(opts)\n }\n\n public async hasDataForRefName() {\n return true\n }\n\n getFeatures(query: Region, opts: BaseOptions = {}) {\n const { signal, statusCallback } = opts\n return ObservableCreate<Feature>(async observer => {\n const tabixRefName = await this.fine.refNames.resolve(query, opts)\n if (tabixRefName !== undefined) {\n await updateStatus('Downloading segments', statusCallback, () =>\n this.fine.segments.getLines(tabixRefName, query.start, query.end, {\n signal,\n lineCallback: line => {\n const segment = parseSegmentLine(line)\n // `samples` is who, `carriers` is how many, and the second is not\n // just a convenience: a lane colored by carriage is a jexl\n // expression in a config, where counting a list means relying on\n // jexl resolving `.length` through a member access on an array.\n // The count is the axis the color reads, so the index states it.\n const samples = segmentSamples(segment)\n observer.next(\n new SimpleFeature({\n uniqueId: segment.id,\n refName: query.refName,\n start: segment.start,\n end: segment.end,\n name: segment.id,\n type: 'segment',\n rank: segment.rank,\n stableName: segment.refName,\n ...(samples && { samples, carriers: samples.length }),\n }),\n )\n },\n }),\n )\n }\n observer.complete()\n }, signal)\n }\n\n // Extract the graph around a region as GFA text, for GraphGenomeView. The\n // region's own segments come from segs.bed.gz; links.bed.gz supplies the edges\n // incident to them *and* the coordinates of the segments on the other end,\n // which typically sit on a different stable sequence (a rank>0 bubble) and so\n // are not reachable by any coordinate query on this region.\n //\n // `hops` is extra rounds of link-following past the region's own segments\n // and their immediate neighbours, each costing one tabix query per\n // off-reference segment newly reached. One round is what closes a bubble, so\n // it is the default the view asks for; see the frontier below. `signal` goes\n // to every one of those queries, so a cut the view has replaced stops.\n // `tier: 'coarse'` reads the `coarse` pair instead, the same way.\n async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {\n const { hops = 0, signal, tier } = opts\n const index = this.index(tier)\n const segments = new Map<string, RgfaSegment>()\n const links = new Map<string, RgfaLink>()\n const tabixRefName = await index.refNames.resolve(region, { signal })\n\n const addLinksOver = async (\n refName: string,\n start: number,\n end: number,\n ) => {\n const reached: RgfaSegment[] = []\n await index.links.getLines(refName, start, end, {\n signal,\n lineCallback: line => {\n const link = parseLinkLine(line)\n links.set(linkKey(link), link)\n for (const segment of [link.sourceSegment, link.targetSegment]) {\n if (!segments.has(segment.id)) {\n segments.set(segment.id, segment)\n reached.push(segment)\n }\n }\n },\n })\n return reached\n }\n\n if (tabixRefName === undefined) {\n throw new Error(\n `${region.assemblyName} ${region.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${region.assemblyName} mapped to its prefix in assemblyNameToPanSN`,\n )\n }\n await index.segments.getLines(tabixRefName, region.start, region.end, {\n signal,\n lineCallback: line => {\n const segment = parseSegmentLine(line)\n segments.set(segment.id, segment)\n },\n })\n let frontier = offReference(\n await addLinksOver(tabixRefName, region.start, region.end),\n )\n for (let hop = 0; hop < hops; hop++) {\n // One hop's queries are independent of each other, so they go out\n // together rather than one round-trip at a time. Their callbacks share\n // the segment and link maps, which is safe because only one of them runs\n // at a time, and the output is sorted at the end regardless of the order\n // they arrive in.\n const reached = await Promise.all(\n frontier.map(segment =>\n addLinksOver(segment.refName, segment.start, segment.end),\n ),\n )\n frontier = offReference(reached.flat())\n }\n\n return formatSubgraph(segments, links)\n }\n}\n", "// A segment as it appears in segs.bed.gz, and as it is repeated inside every\n// links.bed.gz row: `stableName start end segmentId rank [tags]`. The first\n// five are the SN/SO/SR tags rGFA already carries, projected to BED by\n// `gfatools gfa2bed -m`.\n//\n// `tags` is a space-separated list of GFA tags, written verbatim onto the\n// S-line formatSegment synthesizes, where the GFA parser reads them into\n// `GraphNode.tags` with no work here. It is the extension point for everything\n// the five columns cannot say: carriage on a path-derived graph (`SM:Z:`), the\n// collapse summary on a level-of-detail tier (`ct:Z:`, `cn:i:`, ...), a\n// precomputed layout position later. rGFA files have no sixth column at all,\n// so this is empty for them and nothing changes.\nexport interface RgfaSegment {\n refName: string\n start: number\n end: number\n id: string\n rank: number\n tags: string\n}\n\nexport interface RgfaLink {\n source: string\n sourceStrand: string\n target: string\n targetStrand: string\n sourceSegment: RgfaSegment\n targetSegment: RgfaSegment\n}\n\nexport function parseSegmentLine(line: string): RgfaSegment {\n const cols = line.split('\\t')\n return {\n refName: cols[0]!,\n start: +cols[1]!,\n end: +cols[2]!,\n id: cols[3]!,\n rank: +cols[4]!,\n tags: cols[5] ?? '',\n }\n}\n\n// Carriage as an ordinary feature attribute, for the linear track rather than\n// the graph. The tag column reaches the graph view through the synthesized\n// S-line (formatSegment below, then gfaConverter reads SM into\n// `GraphNode.samples`), and that route ends at the graph: `getFeatures` builds\n// its own features and had no way to say who carries a segment, so a lane\n// colored by carriage was not expressible.\n//\n// `SM:Z:` is its own grammar check here. build_pggb_tabix.sh wrote a bare\n// comma-separated list in this column before the tag column existed, and those\n// files are still hosted; a bare list has no prefix to match, so it is dropped\n// rather than read as one sample named `K12,Sakai,CFT073`.\n//\n// Undefined rather than [] when the tag is absent, matching gfaConverter: an\n// rGFA has no sixth column at all, so a segment that says nothing about\n// carriage stays distinguishable from one carried by nobody.\nexport function segmentSamples(segment: RgfaSegment) {\n const tag = segment.tags.split(' ').find(t => t.startsWith('SM:Z:'))\n if (tag === undefined) {\n return undefined\n }\n const samples = tag\n .slice('SM:Z:'.length)\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n return samples.length > 0 ? samples : undefined\n}\n\n// `s322+` \u2014 the L-line's segment id with its orientation appended, mirroring\n// the GFA record it came from.\nfunction parseEndpoint(field: string) {\n return { id: field.slice(0, -1), strand: field.slice(-1) }\n}\n\nexport function parseLinkLine(line: string): RgfaLink {\n const cols = line.split('\\t')\n const source = parseEndpoint(cols[3]!)\n const target = parseEndpoint(cols[4]!)\n return {\n source: source.id,\n sourceStrand: source.strand,\n target: target.id,\n targetStrand: target.strand,\n sourceSegment: {\n id: source.id,\n refName: cols[5]!,\n start: +cols[6]!,\n end: +cols[7]!,\n rank: +cols[8]!,\n tags: cols[13] ?? '',\n },\n targetSegment: {\n id: target.id,\n refName: cols[9]!,\n start: +cols[10]!,\n end: +cols[11]!,\n rank: +cols[12]!,\n tags: cols[14] ?? '',\n },\n }\n}\n\nexport function linkKey(link: RgfaLink) {\n return `${link.source}${link.sourceStrand}${link.target}${link.targetStrand}`\n}\n\n// Both endpoints of a link are written into every row, so the same link is\n// indexed under each endpoint's stable sequence and arrives twice for a region\n// covering both. Callers dedupe on linkKey.\n\n// Segments carry no sequence here \u2014 the BED records only their span \u2014 so every\n// S-line is written with `*` and an LN tag, which is what the GFA spec asks for\n// and what packages/graph-core's parser reads back as the node length.\n// `NM:i:0`, `SM:Z:HG002.1,HG002.2` \u2014 the GFA tag grammar, checked rather than\n// trusted. Files built before the tag column existed put a bare comma-separated\n// sample list here, and passing that through would put a field that is not a\n// tag on an S-line, which is a malformed GFA rather than a missing annotation.\n// Dropping it degrades to the pre-tag behaviour instead.\nconst GFA_TAG = /^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/\n\nfunction formatSegment(segment: RgfaSegment) {\n const { id, refName, start, end, rank, tags } = segment\n const valid = tags.split(' ').filter(t => GFA_TAG.test(t))\n const extra = valid.length === 0 ? '' : `\\t${valid.join('\\t')}`\n return `S\\t${id}\\t*\\tLN:i:${end - start}\\tSN:Z:${refName}\\tSO:i:${start}\\tSR:i:${rank}${extra}`\n}\n\nfunction formatLink(link: RgfaLink) {\n const { source, sourceStrand, target, targetStrand } = link\n return `L\\t${source}\\t${sourceStrand}\\t${target}\\t${targetStrand}\\t0M`\n}\n\n// Codepoint order, not localeCompare: the byte-identical-output guarantee below\n// has to hold across locales.\nfunction compare(a: string, b: string) {\n return a < b ? -1 : a > b ? 1 : 0\n}\n\n// Deterministic ordering: the same region always produces byte-identical GFA,\n// so a layout computed from it is reproducible.\nexport function formatSubgraph(\n segments: Map<string, RgfaSegment>,\n links: Map<string, RgfaLink>,\n) {\n const sortedSegments = [...segments.values()].sort(\n (a, b) =>\n compare(a.refName, b.refName) || a.start - b.start || compare(a.id, b.id),\n )\n const sortedLinks = [...links.keys()].sort((a, b) => compare(a, b))\n return [\n 'H\\tVN:Z:1.0',\n ...sortedSegments.map(s => formatSegment(s)),\n ...sortedLinks.map(k => formatLink(links.get(k)!)),\n ].join('\\n')\n}\n"],
|
|
5
|
-
"mappings": "qMAAA,IAAAA,EAAuC,SACvCC,EAA4C,SAC5CC,EAAiC,SC4B1B,SAASC,EAAiBC,EAA2B,CAC1D,IAAMC,EAAOD,EAAK,MAAM,GAAI,EAC5B,MAAO,CACL,QAASC,EAAK,CAAC,EACf,MAAO,CAACA,EAAK,CAAC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nimport { SimpleFeature, updateStatus } from '@jbrowse/core/util'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\n\nimport { PanSNRefNames, openTabixSlot } from '../panSNTabix.ts'\nimport {\n formatSubgraph,\n linkKey,\n parseLinkLine,\n parseSegmentLine,\n segmentSamples,\n} from './rgfaBed.ts'\n\nimport type { RgfaTabixAdapterConfig } from './configSchema.ts'\nimport type { SubgraphAdapterOptions, SubgraphTier } from '../GetSubgraph.ts'\nimport type { RgfaLink, RgfaSegment } from './rgfaBed.ts'\nimport type { TabixIndexedFile } from '@gmod/tabix'\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { Region } from '@jbrowse/core/util/types'\n\n// What a hop follows: alleles, never the backbone. A rank-0 segment reached\n// through a link is flanking backbone, usually outside the window, so querying\n// its links walks the reference away from the region, brings back more backbone,\n// and closes nothing. Every segment that closes a bubble is an allele interior,\n// and an allele interior is rank > 0 in both index formats (rGFA's SR tag, and\n// pggb's rank 0-or-1 against the anchor path). Reached backbone still becomes a\n// node and its edge still draws; it is only not walked through.\n//\n// This is gfabase's rule, arrived at from the other end. `gfabase sub` expands\n// from a seed either to the whole connected component (`--connected`, which its\n// own README calls overkill) or with `--cutpoints 1`, which takes the biconnected\n// component by *stopping at cutpoints*, the segments every end-to-end walk of\n// the chromosome must traverse. In a reference-anchored pangenome the cutpoints\n// are the backbone, and rank is what the index already states about it, so\n// `rank > 0` is that stopping rule without a connectivity index to build. The\n// third tool is the same shape again: `gfatools view -R` maps the region onto its\n// precomputed bubble decomposition and returns whole overlapping bubbles\n// (gfa_query_by_reg), which is complete for the same reason. Bandage's own\n// `--distance` is a node-step radius, but Bandage holds the entire graph in\n// memory, so its scope is a drawing filter rather than a fetch strategy.\n//\n// Measured with this rule: the E. coli paa window converges at one hop (17\n// segments at 1 and at 2), so the cut closes and stays closed. HPRC's amylase\n// window keeps growing (63 at 0, 78 at 1, 92 at 2) because its alleles have\n// alleles, and wall-clock is flat across all three, since a hop's queries go out\n// together and the remote index dominates.\n//\n// The exact version, when a graph ships a bubble index beside its segments:\n// gfatools' bubble rows carry the member segment ids of every bubble, so the\n// bubbles overlapping the region state which segments a complete cut must\n// contain. That turns the hop count into a termination condition rather than a\n// setting, and MinigraphBubbleAdapter already parses those rows.\nfunction offReference(segments: RgfaSegment[]) {\n return segments.filter(segment => segment.rank > 0)\n}\n\ninterface GraphIndex {\n segments: TabixIndexedFile\n links: TabixIndexedFile\n refNames: PanSNRefNames\n}\n\nexport default class RgfaTabixAdapter extends BaseFeatureDataAdapter<RgfaTabixAdapterConfig> {\n public static capabilities = ['getFeatures', 'getRefNames']\n\n private readonly fine\n private coarse: GraphIndex | undefined\n\n public constructor(\n config: RgfaTabixAdapterConfig,\n getSubAdapter?: getSubAdapterType,\n pluginManager?: PluginManager,\n ) {\n super(config, getSubAdapter, pluginManager)\n this.fine = this.openIndex([])\n }\n\n // refNames off the SEGMENT index: it is the one that names every stable\n // sequence the graph is anchored to, where the link index only names those a\n // link touches.\n private openIndex(under: string[]): GraphIndex {\n const segments = openTabixSlot(\n this,\n [...under, 'segmentsLocation'],\n [...under, 'segmentsIndex'],\n )\n return {\n segments,\n links: openTabixSlot(\n this,\n [...under, 'linksLocation'],\n [...under, 'linksIndex'],\n ),\n refNames: new PanSNRefNames(segments, this),\n }\n }\n\n private index(tier: SubgraphTier = 'fine') {\n if (tier === 'fine') {\n return this.fine\n }\n this.coarse ??= this.openIndex(['coarse'])\n return this.coarse\n }\n\n async getRefNames(opts: BaseOptions = {}) {\n return this.fine.refNames.assemblyRefNames(opts)\n }\n\n public async hasDataForRefName() {\n return true\n }\n\n getFeatures(query: Region, opts: BaseOptions = {}) {\n const { signal, statusCallback } = opts\n return ObservableCreate<Feature>(async observer => {\n const tabixRefName = await this.fine.refNames.resolve(query, opts)\n if (tabixRefName !== undefined) {\n await updateStatus('Downloading segments', statusCallback, () =>\n this.fine.segments.getLines(tabixRefName, query.start, query.end, {\n signal,\n lineCallback: line => {\n const segment = parseSegmentLine(line)\n // `samples` lists the haplotypes whose paths visit the segment and\n // `sampleCount` counts them. A lane's color reads the count, and\n // a count in jexl would otherwise rely on `.length` resolving\n // through a member access on an array.\n const samples = segmentSamples(segment)\n observer.next(\n new SimpleFeature({\n uniqueId: segment.id,\n refName: query.refName,\n start: segment.start,\n end: segment.end,\n name: segment.id,\n type: 'segment',\n rank: segment.rank,\n stableName: segment.refName,\n ...(samples && { samples, sampleCount: samples.length }),\n }),\n )\n },\n }),\n )\n }\n observer.complete()\n }, signal)\n }\n\n // Extract the graph around a region as GFA text, for GraphGenomeView. The\n // region's own segments come from segs.bed.gz; links.bed.gz supplies the edges\n // incident to them *and* the coordinates of the segments on the other end,\n // which typically sit on a different stable sequence (a rank>0 bubble) and so\n // are not reachable by any coordinate query on this region.\n //\n // `hops` is extra rounds of link-following past the region's own segments\n // and their immediate neighbours, each costing one tabix query per\n // off-reference segment newly reached. One round is what closes a bubble, so\n // it is the default the view asks for; see the frontier below. `signal` goes\n // to every one of those queries, so a cut the view has replaced stops.\n // `tier: 'coarse'` reads the `coarse` pair instead, the same way.\n async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {\n const { hops = 0, signal, tier } = opts\n const index = this.index(tier)\n const segments = new Map<string, RgfaSegment>()\n const links = new Map<string, RgfaLink>()\n const tabixRefName = await index.refNames.resolve(region, { signal })\n\n const addLinksOver = async (\n refName: string,\n start: number,\n end: number,\n ) => {\n const reached: RgfaSegment[] = []\n await index.links.getLines(refName, start, end, {\n signal,\n lineCallback: line => {\n const link = parseLinkLine(line)\n links.set(linkKey(link), link)\n for (const segment of [link.sourceSegment, link.targetSegment]) {\n if (!segments.has(segment.id)) {\n segments.set(segment.id, segment)\n reached.push(segment)\n }\n }\n },\n })\n return reached\n }\n\n if (tabixRefName === undefined) {\n throw new Error(\n `${region.assemblyName} ${region.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${region.assemblyName} mapped to its prefix in assemblyNameToPanSN`,\n )\n }\n await index.segments.getLines(tabixRefName, region.start, region.end, {\n signal,\n lineCallback: line => {\n const segment = parseSegmentLine(line)\n segments.set(segment.id, segment)\n },\n })\n let frontier = offReference(\n await addLinksOver(tabixRefName, region.start, region.end),\n )\n for (let hop = 0; hop < hops; hop++) {\n // One hop's queries are independent of each other, so they go out\n // together rather than one round-trip at a time. Their callbacks share\n // the segment and link maps, which is safe because only one of them runs\n // at a time, and the output is sorted at the end regardless of the order\n // they arrive in.\n const reached = await Promise.all(\n frontier.map(segment =>\n addLinksOver(segment.refName, segment.start, segment.end),\n ),\n )\n frontier = offReference(reached.flat())\n }\n\n return formatSubgraph(segments, links)\n }\n}\n", "// A segment as it appears in segs.bed.gz, and as it is repeated inside every\n// links.bed.gz row: `stableName start end segmentId rank [tags]`. The first\n// five are the SN/SO/SR tags rGFA already carries, projected to BED by\n// `gfatools gfa2bed -m`.\n//\n// `tags` is a space-separated list of GFA tags, written verbatim onto the\n// S-line formatSegment synthesizes, where the GFA parser reads them into\n// `GraphNode.tags` with no work here. It is the extension point for everything\n// the five columns cannot say: carriage on a path-derived graph (`SM:Z:`), the\n// collapse summary on a level-of-detail tier (`ct:Z:`, `cn:i:`, ...), a\n// precomputed layout position later. rGFA files have no sixth column at all,\n// so this is empty for them and nothing changes.\nexport interface RgfaSegment {\n refName: string\n start: number\n end: number\n id: string\n rank: number\n tags: string\n}\n\nexport interface RgfaLink {\n source: string\n sourceStrand: string\n target: string\n targetStrand: string\n sourceSegment: RgfaSegment\n targetSegment: RgfaSegment\n}\n\nexport function parseSegmentLine(line: string): RgfaSegment {\n const cols = line.split('\\t')\n return {\n refName: cols[0]!,\n start: +cols[1]!,\n end: +cols[2]!,\n id: cols[3]!,\n rank: +cols[4]!,\n tags: cols[5] ?? '',\n }\n}\n\n// Carriage as an ordinary feature attribute, for the linear track rather than\n// the graph. The tag column reaches the graph view through the synthesized\n// S-line (formatSegment below, then gfaConverter reads SM into\n// `GraphNode.samples`), and that route ends at the graph: `getFeatures` builds\n// its own features and had no way to say who carries a segment, so a lane\n// colored by carriage was not expressible.\n//\n// `SM:Z:` is its own grammar check here. build_pggb_tabix.sh wrote a bare\n// comma-separated list in this column before the tag column existed, and those\n// files are still hosted; a bare list has no prefix to match, so it is dropped\n// rather than read as one sample named `K12,Sakai,CFT073`.\n//\n// Undefined rather than [] when the tag is absent, matching gfaConverter: an\n// rGFA has no sixth column at all, so a segment that says nothing about\n// carriage stays distinguishable from one carried by nobody.\nexport function segmentSamples(segment: RgfaSegment) {\n const tag = segment.tags.split(' ').find(t => t.startsWith('SM:Z:'))\n if (tag === undefined) {\n return undefined\n }\n const samples = tag\n .slice('SM:Z:'.length)\n .split(',')\n .map(s => s.trim())\n .filter(Boolean)\n return samples.length > 0 ? samples : undefined\n}\n\n// `s322+` \u2014 the L-line's segment id with its orientation appended, mirroring\n// the GFA record it came from.\nfunction parseEndpoint(field: string) {\n return { id: field.slice(0, -1), strand: field.slice(-1) }\n}\n\nexport function parseLinkLine(line: string): RgfaLink {\n const cols = line.split('\\t')\n const source = parseEndpoint(cols[3]!)\n const target = parseEndpoint(cols[4]!)\n return {\n source: source.id,\n sourceStrand: source.strand,\n target: target.id,\n targetStrand: target.strand,\n sourceSegment: {\n id: source.id,\n refName: cols[5]!,\n start: +cols[6]!,\n end: +cols[7]!,\n rank: +cols[8]!,\n tags: cols[13] ?? '',\n },\n targetSegment: {\n id: target.id,\n refName: cols[9]!,\n start: +cols[10]!,\n end: +cols[11]!,\n rank: +cols[12]!,\n tags: cols[14] ?? '',\n },\n }\n}\n\nexport function linkKey(link: RgfaLink) {\n return `${link.source}${link.sourceStrand}${link.target}${link.targetStrand}`\n}\n\n// Both endpoints of a link are written into every row, so the same link is\n// indexed under each endpoint's stable sequence and arrives twice for a region\n// covering both. Callers dedupe on linkKey.\n\n// Segments carry no sequence here \u2014 the BED records only their span \u2014 so every\n// S-line is written with `*` and an LN tag, which is what the GFA spec asks for\n// and what packages/graph-core's parser reads back as the node length.\n// `NM:i:0`, `SM:Z:HG002.1,HG002.2` \u2014 the GFA tag grammar, checked rather than\n// trusted. Files built before the tag column existed put a bare comma-separated\n// sample list here, and passing that through would put a field that is not a\n// tag on an S-line, which is a malformed GFA rather than a missing annotation.\n// Dropping it degrades to the pre-tag behaviour instead.\nconst GFA_TAG = /^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/\n\nfunction formatSegment(segment: RgfaSegment) {\n const { id, refName, start, end, rank, tags } = segment\n const valid = tags.split(' ').filter(t => GFA_TAG.test(t))\n const extra = valid.length === 0 ? '' : `\\t${valid.join('\\t')}`\n return `S\\t${id}\\t*\\tLN:i:${end - start}\\tSN:Z:${refName}\\tSO:i:${start}\\tSR:i:${rank}${extra}`\n}\n\nfunction formatLink(link: RgfaLink) {\n const { source, sourceStrand, target, targetStrand } = link\n return `L\\t${source}\\t${sourceStrand}\\t${target}\\t${targetStrand}\\t0M`\n}\n\n// Codepoint order, not localeCompare: the byte-identical-output guarantee below\n// has to hold across locales.\nfunction compare(a: string, b: string) {\n return a < b ? -1 : a > b ? 1 : 0\n}\n\n// Deterministic ordering: the same region always produces byte-identical GFA,\n// so a layout computed from it is reproducible.\nexport function formatSubgraph(\n segments: Map<string, RgfaSegment>,\n links: Map<string, RgfaLink>,\n) {\n const sortedSegments = [...segments.values()].sort(\n (a, b) =>\n compare(a.refName, b.refName) || a.start - b.start || compare(a.id, b.id),\n )\n const sortedLinks = [...links.keys()].sort((a, b) => compare(a, b))\n return [\n 'H\\tVN:Z:1.0',\n ...sortedSegments.map(s => formatSegment(s)),\n ...sortedLinks.map(k => formatLink(links.get(k)!)),\n ].join('\\n')\n}\n"],
|
|
5
|
+
"mappings": "qMAAA,IAAAA,EAAuC,SACvCC,EAA4C,SAC5CC,EAAiC,SC4B1B,SAASC,EAAiBC,EAA2B,CAC1D,I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ACpE,OAAAR,EACA,aAAcI,GAAQ,CACpB,IAAMf,EAAUgB,EAAiBD,CAAI,EACrChB,EAAS,IAAIC,EAAQ,GAAIA,CAAO,CAClC,CACF,CAAC,EACD,IAAI+B,EAAWjC,EACb,MAAMyB,EAAaT,EAAcK,EAAO,MAAOA,EAAO,GAAG,CAC3D,EACA,QAASa,EAAM,EAAGA,EAAMZ,EAAMY,IAAO,CAMnC,IAAML,EAAU,MAAM,QAAQ,IAC5BI,EAAS,IAAI/B,GACXuB,EAAavB,EAAQ,QAASA,EAAQ,MAAOA,EAAQ,GAAG,CAC1D,CACF,EACA+B,EAAWjC,EAAa6B,EAAQ,KAAK,CAAC,CACxC,CAEA,OAAOM,EAAelC,EAAUuB,CAAK,CACvC,CACF",
|
|
6
6
|
"names": ["import_BaseAdapter", "import_util", "import_rxjs", "parseSegmentLine", "line", "cols", "segmentSamples", "segment", "tag", "t", "samples", "s", "parseEndpoint", "field", "parseLinkLine", "source", "target", "linkKey", "link", "GFA_TAG", "formatSegment", "id", "refName", "start", "end", "rank", "tags", "valid", "extra", "formatLink", "sourceStrand", "targetStrand", "compare", "a", "b", "formatSubgraph", "segments", "links", "sortedSegments", "sortedLinks", "k", "offReference", "segments", "segment", "RgfaTabixAdapter", "config", "getSubAdapter", "pluginManager", "under", "openTabixSlot", "PanSNRefNames", "tier", "opts", "query", "signal", "statusCallback", "observer", "tabixRefName", "line", "parseSegmentLine", "samples", "segmentSamples", "region", "hops", "index", "links", "addLinksOver", "refName", "start", "end", "reached", "link", "parseLinkLine", "linkKey", "frontier", "hop", "formatSubgraph"]
|
|
7
7
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{A as be,B as rt,Da as xt,E as at,F as de,Fa as kt,G as st,Ka as Te,L as ye,La as He,M as it,N as lt,Na as Mt,O as ct,Oa as Ct,R as dt,S as pt,U as ut,V as ft,W as ve,a as T,b as Ge,ba as we,da as mt,h as qe,i as Je,ka as ht,m as Qe,na as gt,oa as bt,s as re,sa as yt,t as tt,ua as vt,va as wt,xa as St,z as ot}from"./chunk-OJOZ5YAL.js";import{b as et}from"./chunk-UQEPPJEO.js";import{a as Ie}from"./chunk-FCWXYIFC.js";import{a as Lt}from"./chunk-4C4CMI6K.js";import{P as nt,X as ae,h as je,j as Ue,k as Ne,l as he,x as ge}from"./chunk-ECKLYJWP.js";import{a as v,b as I,c as ee,d as Ze,e as X}from"./chunk-XEJ47DLD.js";import{a as ao,b as i}from"./chunk-FY3BTKY4.js";var Pt=ao((Xr,Rt)=>{Rt.exports=JBrowseExports["@jbrowse/render-core/useRenderingBackend"]});var Ee=i(X(),1);var Q=i(Ze(),1),Ve=i(Ie(),1),no=i(Pt(),1);var Et=i(v(),1),It=(0,T.createSvgIcon)((0,Et.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info");var _=i(I(),1);var _e=i(I(),1);var N={background:"rgba(255,255,255,0.82)",padding:"4px 6px",borderRadius:3,fontSize:11,lineHeight:"15px",whiteSpace:"nowrap"},L={display:"flex",alignItems:"center",gap:5};var B=i(v(),1),so={position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"hidden",zIndex:2},io=(0,_e.observer)(function({model:e}){let{bubbleHalos:n,walkLift:o,hoveredBubble:a}=e;if(n.length===0)return null;let{scaleX:r,scaleY:s,translateX:c,translateY:u,paneWidth:p,canvasHeight:h}=e,d=e.contigThickness*ot,b=m=>o!==void 0&&!m.nodeIds.some(w=>o.nodeIds.has(w));return(0,B.jsx)("svg",{style:so,width:p,height:h,"data-testid":"graph-bubble-halos",children:(0,B.jsx)("g",{transform:`translate(${c} ${u}) scale(${r} ${s})`,children:n.filter(m=>!m.whole).map(m=>(0,B.jsx)("path",{d:m.path,fill:"none",stroke:re[m.kind],strokeOpacity:a&&et(m.bubble,a)?.45:b(m)?.06:.22,strokeWidth:d,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"},`${m.bubble.start}-${m.bubble.end}`))})})}),Gt=io;function lo({color:t}){return(0,B.jsx)("svg",{width:18,height:10,style:{flex:"none"},children:(0,B.jsx)("line",{x1:5,y1:5,x2:13,y2:5,stroke:t,strokeOpacity:.35,strokeWidth:8,strokeLinecap:"round"})})}var Nt=(0,_e.observer)(function({model:e}){let n=new Map;for(let o of e.bubbleHalos)if(!o.whole){let a=re[o.kind],r=n.get(a)??new Set;r.add(tt[o.kind]),n.set(a,r)}return n.size>0?(0,B.jsx)("div",{style:N,"data-testid":"graph-halo-legend",children:[...n].map(([o,a])=>(0,B.jsxs)("div",{style:L,children:[(0,B.jsx)(lo,{color:o}),(0,B.jsxs)("span",{children:["bubble: ",[...a].join(", ")]})]},o))}):null});var Me=i(X(),1);var Ce=i(Ge(),1),Be=i(I(),1);var D=i(v(),1),te={width:18,height:8,borderRadius:2,flex:"none"},co={marginBottom:2},po={...te,width:48};function pe({walk:t,label:e,reference:n,hint:o,at:a}){let r=mt(t,n);return(0,D.jsxs)("div",{style:co,title:[r.hover,o].filter(Boolean).join(" \xB7 ")||void 0,children:[(0,D.jsxs)("div",{style:L,children:[(0,D.jsx)("div",{style:{...r.shades?po:te,background:we(t.encoding)}}),(0,D.jsxs)("span",{children:[(0,D.jsx)("strong",{children:e}),r.delta,r.outside,r.reversed]})]}),a?(0,D.jsx)("div",{"data-testid":"graph-walk-at",children:a}):r.scale?(0,D.jsx)("div",{children:r.scale}):null]})}var W=i(X(),1);var uo=50;function Tt(t,e){return e>0?Math.max(1,t/e):uo}function fo(t){let e=new Set,n=1/0,o=-1/0;for(let a of t)e.add(a.minY),n=Math.min(n,a.minY),o=Math.max(o,a.minY);return e.size>1?(o-n)/(e.size-1):void 0}function mo(t,e,n){let o=Tt(e,t.length);return{x:o,y:n>0?Tt(n,t.length):fo(t)??o}}function Ht(t,e,n,o){return t===void 0?mo(e,n,o):typeof t=="number"?{x:t,y:t}:t}function ho(t,e,n){let o=t.get(e);o||(o=new Map,t.set(e,o));let a=o.get(n);return a||(a=[],o.set(n,a)),a}function _t(t,e,n,o,a,r,s){let c=Math.floor(n/e.x),u=Math.floor(a/e.x),p=Math.floor(o/e.y),h=Math.floor(r/e.y);for(let d=c;d<=u;d++)for(let b=p;b<=h;b++)ho(t,d,b).push(s)}function Bt(t,e,n,o,a,r){let s=Math.floor((n-a)/e.x),c=Math.floor((n+a)/e.x),u=Math.floor((o-r)/e.y),p=Math.floor((o+r)/e.y),h=[],d=new Set;for(let b=s;b<=c;b++){let m=t.get(b);if(m)for(let w=u;w<=p;w++){let y=m.get(w);if(y)for(let f of y)d.has(f)||(d.add(f),h.push(f))}}return h}var Se=class{constructor(e,n){this.cells=new Map;let o=[],a=0,r=0;for(let[s,c]of Object.entries(e))for(let u=0;u<c.length-1;u++){let p=c[u],h=c[u+1],d=Math.min(p.x,h.x),b=Math.min(p.y,h.y),m=Math.max(p.x,h.x),w=Math.max(p.y,h.y);a+=m-d,r+=w-b,o.push({entry:{nodeId:s,segmentIdx:u},minX:d,minY:b,maxX:m,maxY:w})}this.cellSize=Ht(n,o,a,r);for(let s of o)_t(this.cells,this.cellSize,s.minX,s.minY,s.maxX,s.maxY,s.entry)}query(e,n,o,a=o){return Bt(this.cells,this.cellSize,e,n,o,a)}},xe=class{constructor(e,n,o,a,r,s,c=0){this.cells=new Map;this.edgeCurves=at(e,n,a,s,c);let u=[],p=0,h=0;for(let d=0;d<n.edges.length;d++){let b=n.edges[d],m=e[b.from],w=e[b.to],y=this.edgeCurves.get(d);if(m?.length&&w?.length&&y){let{minX:f,minY:R,maxX:G,maxY:$}=je(y),g=b.pathIds?.length??0;if(o&&g>0){let S=0,M=0;for(let x of he(m,w,g,a))S=Math.max(S,Math.abs(x.x)),M=Math.max(M,Math.abs(x.y));f-=S,R-=M,G+=S,$+=M}p+=G-f,h+=$-R,u.push({ei:d,minX:f,minY:R,maxX:G,maxY:$})}}this.cellSize=Ht(r,u,p,h);for(let d of u)_t(this.cells,this.cellSize,d.minX,d.minY,d.maxX,d.maxY,d.ei)}getCurves(e){return this.edgeCurves.get(e)}query(e,n,o,a=o){return Bt(this.cells,this.cellSize,e,n,o,a)}};function At(t,e,n,o,a,r){let s=a-n,c=r-o,u=s*s+c*c;if(u===0)return Math.hypot(t-n,e-o);let p=Math.max(0,Math.min(1,((t-n)*s+(e-o)*c)/u));return Math.hypot(t-(n+p*s),e-(o+p*c))}function go(t,e,n,o,a,r,s,c,u,p){let h=1/0,d=20,b=n,m=o;for(let w=1;w<=d;w++){let y=w/d,f=1-y,R=f*f*f*n+3*f*f*y*a+3*f*y*y*s+y*y*y*u,G=f*f*f*o+3*f*f*y*r+3*f*y*y*c+y*y*y*p;h=Math.min(h,At(t,e,b,m,R,G)),b=R,m=G}return h}function bo(t,e,n){return go(t,e,n.x0,n.y0,n.cx0,n.cy0,n.cx1,n.cy1,n.x1,n.y1)}function zt(t,e,n,o=1){let a=1/0;for(let r of n){let s=bo(t,e,o===1?r:{x0:r.x0,y0:r.y0*o,cx0:r.cx0,cy0:r.cy0*o,cx1:r.cx1,cy1:r.cy1*o,x1:r.x1,y1:r.y1*o});s<a&&(a=s)}return a}var Wt=new WeakMap;function yo(t,e){let n=Wt.get(t);if(n?.version===e)return n.index;let o=new Se(t);return Wt.set(t,{version:e,index:o}),o}var Ot=new WeakMap;function vo(t,e,n,o,a,r){let s=Ot.get(t);if(s?.graph===e&&s.drawPaths===n&&s.scaleX===o.scaleX&&s.scaleY===o.scaleY&&s.version===a&&s.deletions===r)return s.index;let c=new xe(t,e,n,o,void 0,r,a);return Ot.set(t,{graph:e,drawPaths:n,scaleX:o.scaleX,scaleY:o.scaleY,version:a,index:c,deletions:r}),c}var wo=5;function Xt(t,e,n,o,a=0,r){let s=Ne(o),c=yo(t,a),u=m=>Math.max(wo,m)/o.scaleX,p=u(r?.maxHalfWidthPx??0),h=c.query(e,n,p,p/s),d=null,b=1/0;for(let{nodeId:m,segmentIdx:w}of h){let y=t[m],f=At(e,n*s,y[w].x,y[w].y*s,y[w+1].x,y[w+1].y*s);f<b&&f<u(r?.halfWidthPx(m)??0)&&(b=f,d=m)}return d}function Dt(t,e,n,o,a,r,s=0,c,u){let p=Ne(a),h=10/a.scaleX,d=vo(t,e,r,a,s,c),b=d.query(n,o,h,h/p),m=null,w=h;for(let y of b){let f=e.edges[y],R=t[f.from],G=t[f.to];if(!R?.length||!G?.length||u?.has(y))continue;let $=f.pathIds?.length??0,g=d.getCurves(y);if(!g)continue;let S;if(!r||$===0)S=zt(n,o*p,g,p);else{let M=1/0;for(let x of he(R,G,$,a)){let z=x.x===0&&x.y===0?g:Ue(g,x.x,x.y),ce=zt(n,o*p,z,p);ce<M&&(M=ce)}S=M}S<w&&(w=S,m=y)}return m}function Yt(t){let e=t.deltaY*(t.deltaMode===1?40:t.deltaMode===2?800:1),n=(t.ctrlKey?10:1)*e/100;return 1.1**-Math.max(-2,Math.min(2,n))}var $t=i(Ie(),1);function ke(t,e){(0,W.useEffect)(()=>{if(!t)return;let n=t;function o(a){if(e.hostPlacesX)return;e.host&&a.stopPropagation(),a.preventDefault();let r=n.getBoundingClientRect();e.zoom(Yt(a),a.clientX-r.left,a.clientY-r.top)}return n.addEventListener("wheel",o,{passive:!1}),()=>{n.removeEventListener("wheel",o)}},[t,e])}function Ft(t){let e=(0,W.useRef)({x:0,y:0}),n=(0,W.useRef)(!1),o=(0,W.useRef)({frame:0,pan:null,hover:null});(0,W.useEffect)(()=>()=>{cancelAnimationFrame(o.current.frame)},[]);let[a,r]=(0,W.useState)(void 0),[s,c]=(0,W.useState)(void 0);function u(g,S){return{x:(g-t.translateX)/t.scaleX,y:(S-t.translateY)/t.scaleY}}function p(g){let S=g.currentTarget.getBoundingClientRect();return u(g.clientX-S.left,g.clientY-S.top)}function h(g,S){let{nodePositions:M}=t,x=g*t.scaleX+t.translateX,z=S*t.scaleY+t.translateY;if(t.layoutResult?.tubeMap)return t.tubeMapNodeAt(x,z);let ce=t.referenceStripNodeAt(x,z);return ce||(M?Xt(M,g,S,t.axisScale,t.positionsVersion,t.nodeInk):null)}function d(g){if(g.button===0){if(n.current=!1,t.hostPlacesX)return;t.host&&g.stopPropagation();let{x:S,y:M}=p(g),x=t.layoutResult?.tubeMap||g.nativeEvent.offsetY<t.referenceStripZonePx?null:h(S,M);x?t.setDraggingNode(x):t.setPanning(!0),e.current={x:g.clientX,y:g.clientY}}}function b(){let g=o.current;if(g.frame=0,g.pan&&(t.setTransform(t.scale,t.translateX+g.pan.dx,t.translateY+g.pan.dy),g.pan=null),g.hover&&t.nodePositions&&t.graph){let{x:S,y:M}=u(g.hover.x,g.hover.y);g.hover=null;let x=h(S,M);t.setHoveredNode(x),t.setHoveredEdge(x||t.layoutResult?.tubeMap?null:Dt(t.nodePositions,t.graph,S,M,t.axisScale,t.effectiveDrawPaths&&!t.facetPanels,t.positionsVersion,t.deletionEdgeIndexes,t.hiddenEdgeIndexes))}}function m(){o.current.frame||(o.current.frame=requestAnimationFrame(b))}function w(){let g=o.current;cancelAnimationFrame(g.frame),g.frame=0,g.pan=null,g.hover=null}function y(g){let S=g.clientX-e.current.x,M=g.clientY-e.current.y;e.current={x:g.clientX,y:g.clientY},(Math.abs(S)>1||Math.abs(M)>1)&&(n.current=!0);let x=o.current;if(t.draggingNode)t.moveNode(t.draggingNode,S/t.scaleX,M/t.scaleY);else if(t.isPanning)x.pan={dx:(x.pan?.dx??0)+S,dy:(x.pan?.dy??0)+M},m();else{let z=g.currentTarget.getBoundingClientRect();x.hover={x:g.clientX-z.left,y:g.clientY-z.top},m()}}function f(){t.stopDragging()}function R(){w(),(0,$t.isAlive)(t)&&(t.stopDragging(),t.setHoveredNode(null),t.setHoveredEdge(null))}function G(g){let{x:S,y:M}=p(g),x=h(S,M);if(x){g.preventDefault(),r({nodeId:x,top:g.clientY,left:g.clientX});return}let z=t.walkRowAt(S*t.scaleX+t.translateX,M*t.scaleY+t.translateY);z!==void 0&&(g.preventDefault(),c({row:z,top:g.clientY,left:g.clientX}))}function $(g){if(!n.current){let{x:S,y:M}=p(g),x=h(S,M);t.setSelectedNode(x),x&&t.showNodeDetails(x)}}return{handlers:{onMouseDown:d,onMouseMove:y,onMouseUp:f,onMouseLeave:R,onClick:$,onContextMenu:G},contextNode:a,contextRow:s,closeContextMenu:()=>{r(void 0),c(void 0)}}}var F=i(v(),1),ko={position:"absolute",left:0,top:0,zIndex:4,display:"grid",gap:8,lineHeight:"normal"},Mo={height:34,padding:"2px 6px",boxSizing:"border-box",fontFamily:"inherit",fontSize:11,color:"inherit",cursor:"pointer",border:"none",background:"none",textAlign:"left",display:"block"},Co=(0,Be.observer)(function({model:e,lift:n,width:o,height:a,cell:r,handlers:s}){let[c,u]=(0,Me.useState)(null),p=n.walks[0];ke(c,e),(0,Me.useEffect)(()=>{if(!c)return;let d=new ve(c);d.resize(o,a);let b=(0,Ce.computed)(()=>e.buildDrawing(n,!1)),m,w=(0,Ce.autorun)(()=>{let y=b.get();y&&(y!==m&&(d.uploadGeometry(y.batch),m=y),e.applyHighlights(d),e.paint(d))});return()=>{w(),d.dispose()}},[c,e,n,o,a]);let h=e.walkLabel(p.name);return(0,F.jsxs)("div",{style:r,children:[(0,F.jsx)("button",{type:"button",style:Mo,"data-testid":"graph-facet-title",onClick:()=>{e.liftWalks([p.name]),e.setFacet("")},children:(0,F.jsx)(pe,{walk:p,label:h,reference:e.walkReference,hint:`click to lift ${h} alone`,at:e.hoveredOn(p)})}),(0,F.jsx)("canvas",{ref:u,"data-testid":"graph-facet-canvas",style:{width:o,height:a,display:"block",cursor:e.isPanning||e.draggingNode?"grabbing":"grab"},...s})]})}),Lo=(0,Be.observer)(function({model:e,handlers:n}){let o=e.facetPanels,a=e.facetGrid,r=e.facetPlacement;if(!o||!a||!r)return null;let{columns:s,width:c,height:u}=a;return(0,F.jsx)("div",{"data-testid":"graph-facet-panels",style:{...ko,width:e.paneWidth,minHeight:e.canvasHeight,gridTemplateColumns:`repeat(${s}, ${c}px)`,background:e.darkMode?"#1f1f1f":"white"},children:o.map((p,h)=>(0,F.jsx)(Co,{model:e,lift:p,width:c,height:u,cell:{gridRow:Math.floor(r.cells[h]/s)+1,gridColumn:r.cells[h]%s+1},handlers:n},p.walks[0].name))})}),Kt=Lo;var Vt=i(X(),1),Zt=i(I(),1),K=i(v(),1),Ro={position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"hidden",zIndex:2},ue="#daa520",Po=4,Eo=1,Io=2,Go=(0,Zt.observer)(function({model:e}){let n=`exon-outline-${(0,Vt.useId)().replaceAll(/[^\w-]/g,"")}`,{genePins:o,walkLift:a,nodeInk:r}=e;if(o.length===0)return null;let{scaleX:s,scaleY:c,translateX:u,translateY:p,paneWidth:h,canvasHeight:d}=e,b=f=>{let R=r.halfWidthPx(f)*2;return a?.nodeIds.has(f)?Math.max(R,a.walks.length*Po):R},m=o.flatMap(f=>f.exonsByNode.map(({nodeId:R,d:G})=>({key:`${f.gene.name}-${f.gene.start}-${R}`,d:G,inner:b(R)+2*Eo}))),w=`translate(${u} ${p}) scale(${s} ${c})`,y={fill:"none",strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"};return(0,K.jsxs)("svg",{style:Ro,width:h,height:d,"data-testid":"graph-gene-pins",children:[(0,K.jsx)("mask",{id:n,maskUnits:"userSpaceOnUse",x:0,y:0,width:h,height:d,children:(0,K.jsxs)("g",{transform:w,children:[m.map(f=>(0,K.jsx)("path",{d:f.d,stroke:"#fff",strokeWidth:f.inner+2*Io,...y},f.key)),m.map(f=>(0,K.jsx)("path",{d:f.d,stroke:"#000",strokeWidth:f.inner,...y},f.key))]})}),(0,K.jsx)("rect",{width:h,height:d,fill:ue,mask:`url(#${n})`})]})}),jt=Go;var Ut=i(v(),1),qt=(0,T.createSvgIcon)((0,Ut.jsx)("path",{d:"M3 5v4h2V5h4V3H5c-1.1 0-2 .9-2 2m2 10H3v4c0 1.1.9 2 2 2h4v-2H5zm14 4h-4v2h4c1.1 0 2-.9 2-2v-4h-2zm0-16h-4v2h4v4h2V5c0-1.1-.9-2-2-2"}),"CropFree");var ze=i(v(),1),Jt=(0,T.createSvgIcon)([(0,ze.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"},"0"),(0,ze.jsx)("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2z"},"1")],"ZoomIn");var Qt=i(v(),1),en=(0,T.createSvgIcon)((0,Qt.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14M7 9h5v1H7z"}),"ZoomOut");var A=i(ee(),1),Xe=i(I(),1),Cn=i(ae(),1);var V=i(ee(),1),tn=i(I(),1),nn=i(ae(),1),se=i(v(),1),No=(0,nn.makeStyles)()({formControl:{minWidth:100}}),To=(0,tn.observer)(function({model:e}){let{classes:n}=No(),o=e.colorSchemeLock;return(0,se.jsxs)(V.FormControl,{size:"small",className:n.formControl,disabled:o!==void 0,title:o?.why,children:[(0,se.jsx)(V.InputLabel,{children:"Color"}),(0,se.jsx)(V.Select,{value:e.chosenColorScheme,label:"Color",renderValue:o?()=>o.value:void 0,onChange:a=>{e.setColorScheme(a.target.value)},children:nt.map(({value:a,label:r})=>(0,se.jsx)(V.MenuItem,{value:a,children:r},a))})]})}),on=To;var Oe=i(ee(),1),Ae=i(I(),1),rn=i(ae(),1),ie=i(v(),1),an=(0,rn.makeStyles)()({stats:{marginLeft:"auto"},perf:{color:"#888",fontVariantNumeric:"tabular-nums"}});function We(t){return t===void 0?"\u2013":`${Math.round(t)}ms`}var Ho=(0,Ae.observer)(function({model:e}){let{classes:n}=an(),{lastFetchMs:o,lastLayoutMs:a,lastGeometryMs:r}=e,s=o!==void 0||a!==void 0||r!==void 0;return e.showPerf&&s?(0,ie.jsxs)(Oe.Typography,{variant:"caption",className:n.perf,"data-testid":"graph-perf-stats",children:["fetch ",We(o)," \xB7 layout ",We(a)," \xB7 geom"," ",We(r)]}):null}),_o=(0,Ae.observer)(function({model:e}){let{classes:n}=an();return(0,ie.jsxs)("div",{className:n.stats,"data-testid":"graph-stats","data-node-count":e.nodeCount,"data-edge-count":e.edgeCount,"data-path-count":e.pathCount,"data-fetch-ms":e.lastFetchMs??"","data-layout-ms":e.lastLayoutMs??"","data-geometry-ms":e.lastGeometryMs??"","data-geometry-strokes":e.lastGeometryStrokeCount??"",children:[(0,ie.jsxs)(Oe.Typography,{variant:"body2",component:"span",children:[e.nodeCount," nodes, ",e.edgeCount," edges",e.pathCount>0?`, ${e.pathCount} paths`:""]})," ",(0,ie.jsx)(Ho,{model:e})]})}),sn=_o;var O=i(ee(),1),ln=i(I(),1),cn=i(ae(),1),Z=i(v(),1),Bo=(0,cn.makeStyles)()({formControl:{minWidth:150}}),zo=(0,ln.observer)(function({model:e}){let{classes:n}=Bo(),{graph:o}=e;return(0,Z.jsxs)(O.FormControl,{size:"small",className:n.formControl,children:[(0,Z.jsx)(O.InputLabel,{children:"Layout"}),(0,Z.jsx)(O.Select,{value:e.chosenLayoutMode,label:"Layout","data-testid":"graph-layout-select",onChange:a=>{e.switchLayout(a.target.value)},children:Qe.map(({value:a,label:r,description:s,available:c})=>(0,Z.jsx)(O.MenuItem,{value:a,disabled:o?!c(o):!1,children:(0,Z.jsx)(O.Tooltip,{title:s,placement:"right",children:(0,Z.jsx)("span",{children:r})})},a))})]})}),dn=zo;var Y=i(ee(),1),pn=i(I(),1),un=i(ae(),1),j=i(v(),1),Wo=(0,un.makeStyles)()({formControl:{minWidth:130,maxWidth:240}}),Oo=(0,pn.observer)(function({model:e}){let{classes:n}=Wo(),{repeatChoices:o}=e;if(e.chosenLayoutMode!=="walkrows"||o.length===0)return null;let a=new Set(o.map(r=>r.key));return(0,j.jsxs)(Y.FormControl,{size:"small",className:n.formControl,children:[(0,j.jsx)(Y.InputLabel,{children:"Repeat"}),(0,j.jsxs)(Y.Select,{value:a.has(e.repeatKey)?e.repeatKey:"",label:"Repeat","data-testid":"graph-repeat-select",onChange:r=>{e.setRepeatKey(r.target.value)},children:[(0,j.jsx)(Y.MenuItem,{value:"",children:(0,j.jsx)("em",{children:"Whole window"})}),o.map(({key:r,name:s,unit:c})=>(0,j.jsxs)(Y.MenuItem,{value:r,children:[s," \xB7 ",c.toLocaleString()," bp unit"]},r))]})]})}),fn=Oo;var yn=i(X(),1),vn=i(Ze(),1);var mn=i(v(),1),hn=(0,T.createSvgIcon)((0,mn.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"}),"Delete");var gn=i(v(),1),bn=(0,T.createSvgIcon)((0,gn.jsx)("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreVert");var wn=i(I(),1);var U=i(v(),1),Ao=(0,wn.observer)(function({model:e}){let[n,o]=(0,yn.useState)(!1);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(vn.CascadingMenuButton,{size:"small",menuItems:[{type:"checkbox",label:"Linear layout",checked:e.linearLayout,onClick:()=>{e.setLinearLayout(!e.linearLayout),e.recomputeLayout()}},{type:"checkbox",label:"Show deletion edges",checked:e.showDeletionEdges,onClick:()=>{e.setShowDeletionEdges(!e.showDeletionEdges)}},{type:"checkbox",label:"Show timings",checked:e.showPerf,onClick:()=>{e.setShowPerf(!e.showPerf)}},{type:"divider"},{label:"Settings",icon:Ct,onClick:()=>{o(!0)}},{type:"divider"},{label:"Return to import form",icon:hn,onClick:()=>{e.clearGraph()}}],children:(0,U.jsx)(bn,{})}),(0,U.jsx)(Lt,{model:e,open:n,onClose:()=>{o(!1)}})]})}),Sn=Ao;var H=i(ee(),1),xn=i(I(),1),kn=i(ae(),1),q=i(v(),1),Xo=(0,kn.makeStyles)()({formControl:{minWidth:130,maxWidth:260}}),Do=(0,xn.observer)(function({model:e}){let{classes:n}=Xo(),{walkChoices:o}=e;if(o.length===0||!e.liftsWalks)return null;let a=new Set(o.map(c=>c.name)),r=new Map(o.map(c=>[c.name,c.label])),s=e.walkLayers.map(c=>c.walk).filter(c=>a.has(c));return(0,q.jsxs)(H.FormControl,{size:"small",className:n.formControl,children:[(0,q.jsx)(H.InputLabel,{children:"Walks"}),(0,q.jsx)(H.Select,{multiple:!0,value:s,label:"Walks","data-testid":"graph-walk-select",renderValue:c=>c.map(u=>r.get(u)).join(", "),onChange:c=>{let{value:u}=c.target;e.liftWalks(typeof u=="string"?u.split(","):u)},children:o.map(({name:c,label:u})=>(0,q.jsxs)(H.MenuItem,{value:c,dense:!0,children:[(0,q.jsx)(H.Checkbox,{size:"small",checked:s.includes(c)}),(0,q.jsx)(H.ListItemText,{primary:u})]},c))})]})}),Mn=Do;var P=i(v(),1),Yo=(0,Cn.makeStyles)()({toolbar:{display:"flex",alignItems:"center",gap:4,padding:"2px 4px",borderBottom:"1px solid #ddd"}}),$o=(0,Xe.observer)(function({model:e}){return(0,P.jsx)(A.Typography,{variant:"body2",children:e.zoomPercent})}),Fo=(0,Xe.observer)(function({model:e}){let{classes:n}=Yo();return(0,P.jsxs)("div",{className:n.toolbar,children:[(0,P.jsx)(dn,{model:e}),(0,P.jsx)(on,{model:e}),(0,P.jsx)(Mn,{model:e}),(0,P.jsx)(fn,{model:e}),(0,P.jsx)(A.Tooltip,{title:"Zoom in",children:(0,P.jsx)(A.IconButton,{size:"small",onClick:()=>{e.zoom(1.5,e.viewBox.width/2,e.viewBox.height/2)},children:(0,P.jsx)(Jt,{})})}),(0,P.jsx)(A.Tooltip,{title:"Zoom out",children:(0,P.jsx)(A.IconButton,{size:"small",onClick:()=>{e.zoom(1/1.5,e.viewBox.width/2,e.viewBox.height/2)},children:(0,P.jsx)(en,{})})}),(0,P.jsx)(A.Tooltip,{title:"Zoom to fit",children:(0,P.jsx)(A.IconButton,{size:"small",onClick:()=>{e.zoomToFit()},children:(0,P.jsx)(qt,{})})}),(0,P.jsx)($o,{model:e}),(0,P.jsx)(sn,{model:e}),(0,P.jsx)(Sn,{model:e})]})}),Ln=Fo;var En=i(Ie(),1),In=i(I(),1);var ne=i(v(),1);function fe({x:t,y:e,w:n,text:o,note:a,color:r,edge:s=r,italic:c,small:u,dimmed:p,title:h,testId:d,onClick:b,onHover:m}){return(0,ne.jsxs)("g",{style:{pointerEvents:b||m?"auto":"none",cursor:b?"pointer":void 0,opacity:p?.35:1},"data-testid":d,onClick:b,onMouseEnter:()=>{m?.(!0)},onMouseLeave:()=>{m?.(!1)},children:[h?(0,ne.jsx)("title",{children:h}):null,(0,ne.jsx)("rect",{x:t-n/2,y:e-11-4+2,width:n,height:17,rx:3,fill:"rgba(255,255,255,0.85)",stroke:s,strokeWidth:u?.6:1}),(0,ne.jsxs)("text",{x:t,y:e,fontSize:u?10:11,fontFamily:"sans-serif",fontStyle:c?"italic":void 0,fontWeight:c?600:void 0,fill:r,textAnchor:"middle",children:[o,a?(0,ne.jsx)("tspan",{fontStyle:"normal",fontWeight:"normal",children:a}):null]})]})}var J=i(v(),1),Ko={position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"hidden",zIndex:3},Pn="#1c1c22",Vo=(0,In.observer)(function({model:e}){let{bubbles:n,genes:o,routes:a}=e.overlayLabels;if(n.length+o.length+a.length===0)return null;let{walkLift:r,scaleY:s,translateY:c,contigThickness:u}=e,p=d=>r!==void 0&&!d.nodeIds.some(b=>r.nodeIds.has(b)),h=d=>r!==void 0&&!d.route.walks.some(b=>r.names.has(b));return(0,J.jsxs)("svg",{style:Ko,width:e.paneWidth,height:e.canvasHeight,"data-testid":"graph-label-layer",children:[o.map(({item:d,x:b,y:m,w,text:y})=>{let{gene:f}=d,R=rt(d);return(0,J.jsxs)("g",{children:[(0,J.jsx)("line",{x1:b,x2:b,y1:m-11-2,y2:d.at.y*s+c+u/2,stroke:Pn,strokeWidth:.8,strokeOpacity:.6}),(0,J.jsx)(fe,{x:b,y:m,w,text:f.name,note:y.slice(f.name.length)||void 0,color:Pn,edge:ue,italic:!0,title:`${f.name} ${f.refName}:${f.start.toLocaleString()}-${f.end.toLocaleString()}${R?`, ${R} in the cut`:""}`,testId:"graph-gene-pin-label"})]},`${f.name}-${f.start}`)}),a.map(({item:{halo:d,route:b},x:m,y:w,w:y,text:f})=>(0,J.jsx)(fe,{x:m,y:w,w:y,text:f,color:re[d.kind],small:!0,dimmed:h(b),title:`${b.route.walks.length} walk(s): ${b.route.walks.join(", ")}`,testId:"graph-route-label"},`${d.bubble.start}-${d.bubble.end}-${b.route.steps.join(",")}`)),n.map(({item:d,x:b,y:m,w,text:y})=>(0,J.jsx)(fe,{x:b,y:m,w,text:y,color:re[d.kind],dimmed:p(d),title:`${d.label}
|
|
1
|
+
import{A as be,B as rt,Da as xt,E as at,F as de,Fa as kt,G as st,Ka as Te,L as ye,La as He,M as it,N as lt,Na as Mt,O as ct,Oa as Ct,R as dt,S as pt,U as ut,V as ft,W as ve,a as T,b as Ge,ba as we,da as mt,h as qe,i as Je,ka as ht,m as Qe,na as gt,oa as bt,s as re,sa as yt,t as tt,ua as vt,va as wt,xa as St,z as ot}from"./chunk-SIP5IHWK.js";import{b as et}from"./chunk-UQEPPJEO.js";import{a as Ie}from"./chunk-FCWXYIFC.js";import{a as Lt}from"./chunk-4C4CMI6K.js";import{P as nt,X as ae,h as je,j as Ue,k as Ne,l as he,x as ge}from"./chunk-ECKLYJWP.js";import{a as v,b as I,c as ee,d as Ze,e as X}from"./chunk-XEJ47DLD.js";import{a as ao,b as i}from"./chunk-FY3BTKY4.js";var Pt=ao((Xr,Rt)=>{Rt.exports=JBrowseExports["@jbrowse/render-core/useRenderingBackend"]});var Ee=i(X(),1);var Q=i(Ze(),1),Ve=i(Ie(),1),no=i(Pt(),1);var Et=i(v(),1),It=(0,T.createSvgIcon)((0,Et.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z"}),"Info");var _=i(I(),1);var _e=i(I(),1);var N={background:"rgba(255,255,255,0.82)",padding:"4px 6px",borderRadius:3,fontSize:11,lineHeight:"15px",whiteSpace:"nowrap"},L={display:"flex",alignItems:"center",gap:5};var B=i(v(),1),so={position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"hidden",zIndex:2},io=(0,_e.observer)(function({model:e}){let{bubbleHalos:n,walkLift:o,hoveredBubble:a}=e;if(n.length===0)return null;let{scaleX:r,scaleY:s,translateX:c,translateY:u,paneWidth:p,canvasHeight:h}=e,d=e.contigThickness*ot,b=m=>o!==void 0&&!m.nodeIds.some(w=>o.nodeIds.has(w));return(0,B.jsx)("svg",{style:so,width:p,height:h,"data-testid":"graph-bubble-halos",children:(0,B.jsx)("g",{transform:`translate(${c} ${u}) scale(${r} ${s})`,children:n.filter(m=>!m.whole).map(m=>(0,B.jsx)("path",{d:m.path,fill:"none",stroke:re[m.kind],strokeOpacity:a&&et(m.bubble,a)?.45:b(m)?.06:.22,strokeWidth:d,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"},`${m.bubble.start}-${m.bubble.end}`))})})}),Gt=io;function lo({color:t}){return(0,B.jsx)("svg",{width:18,height:10,style:{flex:"none"},children:(0,B.jsx)("line",{x1:5,y1:5,x2:13,y2:5,stroke:t,strokeOpacity:.35,strokeWidth:8,strokeLinecap:"round"})})}var Nt=(0,_e.observer)(function({model:e}){let n=new Map;for(let o of e.bubbleHalos)if(!o.whole){let a=re[o.kind],r=n.get(a)??new Set;r.add(tt[o.kind]),n.set(a,r)}return n.size>0?(0,B.jsx)("div",{style:N,"data-testid":"graph-halo-legend",children:[...n].map(([o,a])=>(0,B.jsxs)("div",{style:L,children:[(0,B.jsx)(lo,{color:o}),(0,B.jsxs)("span",{children:["bubble: ",[...a].join(", ")]})]},o))}):null});var Me=i(X(),1);var Ce=i(Ge(),1),Be=i(I(),1);var D=i(v(),1),te={width:18,height:8,borderRadius:2,flex:"none"},co={marginBottom:2},po={...te,width:48};function pe({walk:t,label:e,reference:n,hint:o,at:a}){let r=mt(t,n);return(0,D.jsxs)("div",{style:co,title:[r.hover,o].filter(Boolean).join(" \xB7 ")||void 0,children:[(0,D.jsxs)("div",{style:L,children:[(0,D.jsx)("div",{style:{...r.shades?po:te,background:we(t.encoding)}}),(0,D.jsxs)("span",{children:[(0,D.jsx)("strong",{children:e}),r.delta,r.outside,r.reversed]})]}),a?(0,D.jsx)("div",{"data-testid":"graph-walk-at",children:a}):r.scale?(0,D.jsx)("div",{children:r.scale}):null]})}var W=i(X(),1);var uo=50;function Tt(t,e){return e>0?Math.max(1,t/e):uo}function fo(t){let e=new Set,n=1/0,o=-1/0;for(let a of t)e.add(a.minY),n=Math.min(n,a.minY),o=Math.max(o,a.minY);return e.size>1?(o-n)/(e.size-1):void 0}function mo(t,e,n){let o=Tt(e,t.length);return{x:o,y:n>0?Tt(n,t.length):fo(t)??o}}function Ht(t,e,n,o){return t===void 0?mo(e,n,o):typeof t=="number"?{x:t,y:t}:t}function ho(t,e,n){let o=t.get(e);o||(o=new Map,t.set(e,o));let a=o.get(n);return a||(a=[],o.set(n,a)),a}function _t(t,e,n,o,a,r,s){let c=Math.floor(n/e.x),u=Math.floor(a/e.x),p=Math.floor(o/e.y),h=Math.floor(r/e.y);for(let d=c;d<=u;d++)for(let b=p;b<=h;b++)ho(t,d,b).push(s)}function Bt(t,e,n,o,a,r){let s=Math.floor((n-a)/e.x),c=Math.floor((n+a)/e.x),u=Math.floor((o-r)/e.y),p=Math.floor((o+r)/e.y),h=[],d=new Set;for(let b=s;b<=c;b++){let m=t.get(b);if(m)for(let w=u;w<=p;w++){let y=m.get(w);if(y)for(let f of y)d.has(f)||(d.add(f),h.push(f))}}return h}var Se=class{constructor(e,n){this.cells=new Map;let o=[],a=0,r=0;for(let[s,c]of Object.entries(e))for(let u=0;u<c.length-1;u++){let p=c[u],h=c[u+1],d=Math.min(p.x,h.x),b=Math.min(p.y,h.y),m=Math.max(p.x,h.x),w=Math.max(p.y,h.y);a+=m-d,r+=w-b,o.push({entry:{nodeId:s,segmentIdx:u},minX:d,minY:b,maxX:m,maxY:w})}this.cellSize=Ht(n,o,a,r);for(let s of o)_t(this.cells,this.cellSize,s.minX,s.minY,s.maxX,s.maxY,s.entry)}query(e,n,o,a=o){return Bt(this.cells,this.cellSize,e,n,o,a)}},xe=class{constructor(e,n,o,a,r,s,c=0){this.cells=new Map;this.edgeCurves=at(e,n,a,s,c);let u=[],p=0,h=0;for(let d=0;d<n.edges.length;d++){let b=n.edges[d],m=e[b.from],w=e[b.to],y=this.edgeCurves.get(d);if(m?.length&&w?.length&&y){let{minX:f,minY:R,maxX:G,maxY:$}=je(y),g=b.pathIds?.length??0;if(o&&g>0){let S=0,M=0;for(let x of he(m,w,g,a))S=Math.max(S,Math.abs(x.x)),M=Math.max(M,Math.abs(x.y));f-=S,R-=M,G+=S,$+=M}p+=G-f,h+=$-R,u.push({ei:d,minX:f,minY:R,maxX:G,maxY:$})}}this.cellSize=Ht(r,u,p,h);for(let d of u)_t(this.cells,this.cellSize,d.minX,d.minY,d.maxX,d.maxY,d.ei)}getCurves(e){return this.edgeCurves.get(e)}query(e,n,o,a=o){return Bt(this.cells,this.cellSize,e,n,o,a)}};function At(t,e,n,o,a,r){let s=a-n,c=r-o,u=s*s+c*c;if(u===0)return Math.hypot(t-n,e-o);let p=Math.max(0,Math.min(1,((t-n)*s+(e-o)*c)/u));return Math.hypot(t-(n+p*s),e-(o+p*c))}function go(t,e,n,o,a,r,s,c,u,p){let h=1/0,d=20,b=n,m=o;for(let w=1;w<=d;w++){let y=w/d,f=1-y,R=f*f*f*n+3*f*f*y*a+3*f*y*y*s+y*y*y*u,G=f*f*f*o+3*f*f*y*r+3*f*y*y*c+y*y*y*p;h=Math.min(h,At(t,e,b,m,R,G)),b=R,m=G}return h}function bo(t,e,n){return go(t,e,n.x0,n.y0,n.cx0,n.cy0,n.cx1,n.cy1,n.x1,n.y1)}function zt(t,e,n,o=1){let a=1/0;for(let r of n){let s=bo(t,e,o===1?r:{x0:r.x0,y0:r.y0*o,cx0:r.cx0,cy0:r.cy0*o,cx1:r.cx1,cy1:r.cy1*o,x1:r.x1,y1:r.y1*o});s<a&&(a=s)}return a}var Wt=new WeakMap;function yo(t,e){let n=Wt.get(t);if(n?.version===e)return n.index;let o=new Se(t);return Wt.set(t,{version:e,index:o}),o}var Ot=new WeakMap;function vo(t,e,n,o,a,r){let s=Ot.get(t);if(s?.graph===e&&s.drawPaths===n&&s.scaleX===o.scaleX&&s.scaleY===o.scaleY&&s.version===a&&s.deletions===r)return s.index;let c=new xe(t,e,n,o,void 0,r,a);return Ot.set(t,{graph:e,drawPaths:n,scaleX:o.scaleX,scaleY:o.scaleY,version:a,index:c,deletions:r}),c}var wo=5;function Xt(t,e,n,o,a=0,r){let s=Ne(o),c=yo(t,a),u=m=>Math.max(wo,m)/o.scaleX,p=u(r?.maxHalfWidthPx??0),h=c.query(e,n,p,p/s),d=null,b=1/0;for(let{nodeId:m,segmentIdx:w}of h){let y=t[m],f=At(e,n*s,y[w].x,y[w].y*s,y[w+1].x,y[w+1].y*s);f<b&&f<u(r?.halfWidthPx(m)??0)&&(b=f,d=m)}return d}function Dt(t,e,n,o,a,r,s=0,c,u){let p=Ne(a),h=10/a.scaleX,d=vo(t,e,r,a,s,c),b=d.query(n,o,h,h/p),m=null,w=h;for(let y of b){let f=e.edges[y],R=t[f.from],G=t[f.to];if(!R?.length||!G?.length||u?.has(y))continue;let $=f.pathIds?.length??0,g=d.getCurves(y);if(!g)continue;let S;if(!r||$===0)S=zt(n,o*p,g,p);else{let M=1/0;for(let x of he(R,G,$,a)){let z=x.x===0&&x.y===0?g:Ue(g,x.x,x.y),ce=zt(n,o*p,z,p);ce<M&&(M=ce)}S=M}S<w&&(w=S,m=y)}return m}function Yt(t){let e=t.deltaY*(t.deltaMode===1?40:t.deltaMode===2?800:1),n=(t.ctrlKey?10:1)*e/100;return 1.1**-Math.max(-2,Math.min(2,n))}var $t=i(Ie(),1);function ke(t,e){(0,W.useEffect)(()=>{if(!t)return;let n=t;function o(a){if(e.hostPlacesX)return;e.host&&a.stopPropagation(),a.preventDefault();let r=n.getBoundingClientRect();e.zoom(Yt(a),a.clientX-r.left,a.clientY-r.top)}return n.addEventListener("wheel",o,{passive:!1}),()=>{n.removeEventListener("wheel",o)}},[t,e])}function Ft(t){let e=(0,W.useRef)({x:0,y:0}),n=(0,W.useRef)(!1),o=(0,W.useRef)({frame:0,pan:null,hover:null});(0,W.useEffect)(()=>()=>{cancelAnimationFrame(o.current.frame)},[]);let[a,r]=(0,W.useState)(void 0),[s,c]=(0,W.useState)(void 0);function u(g,S){return{x:(g-t.translateX)/t.scaleX,y:(S-t.translateY)/t.scaleY}}function p(g){let S=g.currentTarget.getBoundingClientRect();return u(g.clientX-S.left,g.clientY-S.top)}function h(g,S){let{nodePositions:M}=t,x=g*t.scaleX+t.translateX,z=S*t.scaleY+t.translateY;if(t.layoutResult?.tubeMap)return t.tubeMapNodeAt(x,z);let ce=t.referenceStripNodeAt(x,z);return ce||(M?Xt(M,g,S,t.axisScale,t.positionsVersion,t.nodeInk):null)}function d(g){if(g.button===0){if(n.current=!1,t.hostPlacesX)return;t.host&&g.stopPropagation();let{x:S,y:M}=p(g),x=t.layoutResult?.tubeMap||g.nativeEvent.offsetY<t.referenceStripZonePx?null:h(S,M);x?t.setDraggingNode(x):t.setPanning(!0),e.current={x:g.clientX,y:g.clientY}}}function b(){let g=o.current;if(g.frame=0,g.pan&&(t.setTransform(t.scale,t.translateX+g.pan.dx,t.translateY+g.pan.dy),g.pan=null),g.hover&&t.nodePositions&&t.graph){let{x:S,y:M}=u(g.hover.x,g.hover.y);g.hover=null;let x=h(S,M);t.setHoveredNode(x),t.setHoveredEdge(x||t.layoutResult?.tubeMap?null:Dt(t.nodePositions,t.graph,S,M,t.axisScale,t.effectiveDrawPaths&&!t.facetPanels,t.positionsVersion,t.deletionEdgeIndexes,t.hiddenEdgeIndexes))}}function m(){o.current.frame||(o.current.frame=requestAnimationFrame(b))}function w(){let g=o.current;cancelAnimationFrame(g.frame),g.frame=0,g.pan=null,g.hover=null}function y(g){let S=g.clientX-e.current.x,M=g.clientY-e.current.y;e.current={x:g.clientX,y:g.clientY},(Math.abs(S)>1||Math.abs(M)>1)&&(n.current=!0);let x=o.current;if(t.draggingNode)t.moveNode(t.draggingNode,S/t.scaleX,M/t.scaleY);else if(t.isPanning)x.pan={dx:(x.pan?.dx??0)+S,dy:(x.pan?.dy??0)+M},m();else{let z=g.currentTarget.getBoundingClientRect();x.hover={x:g.clientX-z.left,y:g.clientY-z.top},m()}}function f(){t.stopDragging()}function R(){w(),(0,$t.isAlive)(t)&&(t.stopDragging(),t.setHoveredNode(null),t.setHoveredEdge(null))}function G(g){let{x:S,y:M}=p(g),x=h(S,M);if(x){g.preventDefault(),r({nodeId:x,top:g.clientY,left:g.clientX});return}let z=t.walkRowAt(S*t.scaleX+t.translateX,M*t.scaleY+t.translateY);z!==void 0&&(g.preventDefault(),c({row:z,top:g.clientY,left:g.clientX}))}function $(g){if(!n.current){let{x:S,y:M}=p(g),x=h(S,M);t.setSelectedNode(x),x&&t.showNodeDetails(x)}}return{handlers:{onMouseDown:d,onMouseMove:y,onMouseUp:f,onMouseLeave:R,onClick:$,onContextMenu:G},contextNode:a,contextRow:s,closeContextMenu:()=>{r(void 0),c(void 0)}}}var F=i(v(),1),ko={position:"absolute",left:0,top:0,zIndex:4,display:"grid",gap:8,lineHeight:"normal"},Mo={height:34,padding:"2px 6px",boxSizing:"border-box",fontFamily:"inherit",fontSize:11,color:"inherit",cursor:"pointer",border:"none",background:"none",textAlign:"left",display:"block"},Co=(0,Be.observer)(function({model:e,lift:n,width:o,height:a,cell:r,handlers:s}){let[c,u]=(0,Me.useState)(null),p=n.walks[0];ke(c,e),(0,Me.useEffect)(()=>{if(!c)return;let d=new ve(c);d.resize(o,a);let b=(0,Ce.computed)(()=>e.buildDrawing(n,!1)),m,w=(0,Ce.autorun)(()=>{let y=b.get();y&&(y!==m&&(d.uploadGeometry(y.batch),m=y),e.applyHighlights(d),e.paint(d))});return()=>{w(),d.dispose()}},[c,e,n,o,a]);let h=e.walkLabel(p.name);return(0,F.jsxs)("div",{style:r,children:[(0,F.jsx)("button",{type:"button",style:Mo,"data-testid":"graph-facet-title",onClick:()=>{e.liftWalks([p.name]),e.setFacet("")},children:(0,F.jsx)(pe,{walk:p,label:h,reference:e.walkReference,hint:`click to lift ${h} alone`,at:e.hoveredOn(p)})}),(0,F.jsx)("canvas",{ref:u,"data-testid":"graph-facet-canvas",style:{width:o,height:a,display:"block",cursor:e.isPanning||e.draggingNode?"grabbing":"grab"},...s})]})}),Lo=(0,Be.observer)(function({model:e,handlers:n}){let o=e.facetPanels,a=e.facetGrid,r=e.facetPlacement;if(!o||!a||!r)return null;let{columns:s,width:c,height:u}=a;return(0,F.jsx)("div",{"data-testid":"graph-facet-panels",style:{...ko,width:e.paneWidth,minHeight:e.canvasHeight,gridTemplateColumns:`repeat(${s}, ${c}px)`,background:e.darkMode?"#1f1f1f":"white"},children:o.map((p,h)=>(0,F.jsx)(Co,{model:e,lift:p,width:c,height:u,cell:{gridRow:Math.floor(r.cells[h]/s)+1,gridColumn:r.cells[h]%s+1},handlers:n},p.walks[0].name))})}),Kt=Lo;var Vt=i(X(),1),Zt=i(I(),1),K=i(v(),1),Ro={position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"hidden",zIndex:2},ue="#daa520",Po=4,Eo=1,Io=2,Go=(0,Zt.observer)(function({model:e}){let n=`exon-outline-${(0,Vt.useId)().replaceAll(/[^\w-]/g,"")}`,{genePins:o,walkLift:a,nodeInk:r}=e;if(o.length===0)return null;let{scaleX:s,scaleY:c,translateX:u,translateY:p,paneWidth:h,canvasHeight:d}=e,b=f=>{let R=r.halfWidthPx(f)*2;return a?.nodeIds.has(f)?Math.max(R,a.walks.length*Po):R},m=o.flatMap(f=>f.exonsByNode.map(({nodeId:R,d:G})=>({key:`${f.gene.name}-${f.gene.start}-${R}`,d:G,inner:b(R)+2*Eo}))),w=`translate(${u} ${p}) scale(${s} ${c})`,y={fill:"none",strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"};return(0,K.jsxs)("svg",{style:Ro,width:h,height:d,"data-testid":"graph-gene-pins",children:[(0,K.jsx)("mask",{id:n,maskUnits:"userSpaceOnUse",x:0,y:0,width:h,height:d,children:(0,K.jsxs)("g",{transform:w,children:[m.map(f=>(0,K.jsx)("path",{d:f.d,stroke:"#fff",strokeWidth:f.inner+2*Io,...y},f.key)),m.map(f=>(0,K.jsx)("path",{d:f.d,stroke:"#000",strokeWidth:f.inner,...y},f.key))]})}),(0,K.jsx)("rect",{width:h,height:d,fill:ue,mask:`url(#${n})`})]})}),jt=Go;var Ut=i(v(),1),qt=(0,T.createSvgIcon)((0,Ut.jsx)("path",{d:"M3 5v4h2V5h4V3H5c-1.1 0-2 .9-2 2m2 10H3v4c0 1.1.9 2 2 2h4v-2H5zm14 4h-4v2h4c1.1 0 2-.9 2-2v-4h-2zm0-16h-4v2h4v4h2V5c0-1.1-.9-2-2-2"}),"CropFree");var ze=i(v(),1),Jt=(0,T.createSvgIcon)([(0,ze.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"},"0"),(0,ze.jsx)("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2z"},"1")],"ZoomIn");var Qt=i(v(),1),en=(0,T.createSvgIcon)((0,Qt.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14M7 9h5v1H7z"}),"ZoomOut");var A=i(ee(),1),Xe=i(I(),1),Cn=i(ae(),1);var V=i(ee(),1),tn=i(I(),1),nn=i(ae(),1),se=i(v(),1),No=(0,nn.makeStyles)()({formControl:{minWidth:100}}),To=(0,tn.observer)(function({model:e}){let{classes:n}=No(),o=e.colorSchemeLock;return(0,se.jsxs)(V.FormControl,{size:"small",className:n.formControl,disabled:o!==void 0,title:o?.why,children:[(0,se.jsx)(V.InputLabel,{children:"Color"}),(0,se.jsx)(V.Select,{value:e.chosenColorScheme,label:"Color",renderValue:o?()=>o.value:void 0,onChange:a=>{e.setColorScheme(a.target.value)},children:nt.map(({value:a,label:r})=>(0,se.jsx)(V.MenuItem,{value:a,children:r},a))})]})}),on=To;var Oe=i(ee(),1),Ae=i(I(),1),rn=i(ae(),1),ie=i(v(),1),an=(0,rn.makeStyles)()({stats:{marginLeft:"auto"},perf:{color:"#888",fontVariantNumeric:"tabular-nums"}});function We(t){return t===void 0?"\u2013":`${Math.round(t)}ms`}var Ho=(0,Ae.observer)(function({model:e}){let{classes:n}=an(),{lastFetchMs:o,lastLayoutMs:a,lastGeometryMs:r}=e,s=o!==void 0||a!==void 0||r!==void 0;return e.showPerf&&s?(0,ie.jsxs)(Oe.Typography,{variant:"caption",className:n.perf,"data-testid":"graph-perf-stats",children:["fetch ",We(o)," \xB7 layout ",We(a)," \xB7 geom"," ",We(r)]}):null}),_o=(0,Ae.observer)(function({model:e}){let{classes:n}=an();return(0,ie.jsxs)("div",{className:n.stats,"data-testid":"graph-stats","data-node-count":e.nodeCount,"data-edge-count":e.edgeCount,"data-path-count":e.pathCount,"data-fetch-ms":e.lastFetchMs??"","data-layout-ms":e.lastLayoutMs??"","data-geometry-ms":e.lastGeometryMs??"","data-geometry-strokes":e.lastGeometryStrokeCount??"",children:[(0,ie.jsxs)(Oe.Typography,{variant:"body2",component:"span",children:[e.nodeCount," nodes, ",e.edgeCount," edges",e.pathCount>0?`, ${e.pathCount} paths`:""]})," ",(0,ie.jsx)(Ho,{model:e})]})}),sn=_o;var O=i(ee(),1),ln=i(I(),1),cn=i(ae(),1),Z=i(v(),1),Bo=(0,cn.makeStyles)()({formControl:{minWidth:150}}),zo=(0,ln.observer)(function({model:e}){let{classes:n}=Bo(),{graph:o}=e;return(0,Z.jsxs)(O.FormControl,{size:"small",className:n.formControl,children:[(0,Z.jsx)(O.InputLabel,{children:"Layout"}),(0,Z.jsx)(O.Select,{value:e.chosenLayoutMode,label:"Layout","data-testid":"graph-layout-select",onChange:a=>{e.switchLayout(a.target.value)},children:Qe.map(({value:a,label:r,description:s,available:c})=>(0,Z.jsx)(O.MenuItem,{value:a,disabled:o?!c(o):!1,children:(0,Z.jsx)(O.Tooltip,{title:s,placement:"right",children:(0,Z.jsx)("span",{children:r})})},a))})]})}),dn=zo;var Y=i(ee(),1),pn=i(I(),1),un=i(ae(),1),j=i(v(),1),Wo=(0,un.makeStyles)()({formControl:{minWidth:130,maxWidth:240}}),Oo=(0,pn.observer)(function({model:e}){let{classes:n}=Wo(),{repeatChoices:o}=e;if(e.chosenLayoutMode!=="walkrows"||o.length===0)return null;let a=new Set(o.map(r=>r.key));return(0,j.jsxs)(Y.FormControl,{size:"small",className:n.formControl,children:[(0,j.jsx)(Y.InputLabel,{children:"Repeat"}),(0,j.jsxs)(Y.Select,{value:a.has(e.repeatKey)?e.repeatKey:"",label:"Repeat","data-testid":"graph-repeat-select",onChange:r=>{e.setRepeatKey(r.target.value)},children:[(0,j.jsx)(Y.MenuItem,{value:"",children:(0,j.jsx)("em",{children:"Whole window"})}),o.map(({key:r,name:s,unit:c})=>(0,j.jsxs)(Y.MenuItem,{value:r,children:[s," \xB7 ",c.toLocaleString()," bp unit"]},r))]})]})}),fn=Oo;var yn=i(X(),1),vn=i(Ze(),1);var mn=i(v(),1),hn=(0,T.createSvgIcon)((0,mn.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"}),"Delete");var gn=i(v(),1),bn=(0,T.createSvgIcon)((0,gn.jsx)("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreVert");var wn=i(I(),1);var U=i(v(),1),Ao=(0,wn.observer)(function({model:e}){let[n,o]=(0,yn.useState)(!1);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(vn.CascadingMenuButton,{size:"small",menuItems:[{type:"checkbox",label:"Linear layout",checked:e.linearLayout,onClick:()=>{e.setLinearLayout(!e.linearLayout),e.recomputeLayout()}},{type:"checkbox",label:"Show deletion edges",checked:e.showDeletionEdges,onClick:()=>{e.setShowDeletionEdges(!e.showDeletionEdges)}},{type:"checkbox",label:"Show timings",checked:e.showPerf,onClick:()=>{e.setShowPerf(!e.showPerf)}},{type:"divider"},{label:"Settings",icon:Ct,onClick:()=>{o(!0)}},{type:"divider"},{label:"Return to import form",icon:hn,onClick:()=>{e.clearGraph()}}],children:(0,U.jsx)(bn,{})}),(0,U.jsx)(Lt,{model:e,open:n,onClose:()=>{o(!1)}})]})}),Sn=Ao;var H=i(ee(),1),xn=i(I(),1),kn=i(ae(),1),q=i(v(),1),Xo=(0,kn.makeStyles)()({formControl:{minWidth:130,maxWidth:260}}),Do=(0,xn.observer)(function({model:e}){let{classes:n}=Xo(),{walkChoices:o}=e;if(o.length===0||!e.liftsWalks)return null;let a=new Set(o.map(c=>c.name)),r=new Map(o.map(c=>[c.name,c.label])),s=e.walkLayers.map(c=>c.walk).filter(c=>a.has(c));return(0,q.jsxs)(H.FormControl,{size:"small",className:n.formControl,children:[(0,q.jsx)(H.InputLabel,{children:"Walks"}),(0,q.jsx)(H.Select,{multiple:!0,value:s,label:"Walks","data-testid":"graph-walk-select",renderValue:c=>c.map(u=>r.get(u)).join(", "),onChange:c=>{let{value:u}=c.target;e.liftWalks(typeof u=="string"?u.split(","):u)},children:o.map(({name:c,label:u})=>(0,q.jsxs)(H.MenuItem,{value:c,dense:!0,children:[(0,q.jsx)(H.Checkbox,{size:"small",checked:s.includes(c)}),(0,q.jsx)(H.ListItemText,{primary:u})]},c))})]})}),Mn=Do;var P=i(v(),1),Yo=(0,Cn.makeStyles)()({toolbar:{display:"flex",alignItems:"center",gap:4,padding:"2px 4px",borderBottom:"1px solid #ddd"}}),$o=(0,Xe.observer)(function({model:e}){return(0,P.jsx)(A.Typography,{variant:"body2",children:e.zoomPercent})}),Fo=(0,Xe.observer)(function({model:e}){let{classes:n}=Yo();return(0,P.jsxs)("div",{className:n.toolbar,children:[(0,P.jsx)(dn,{model:e}),(0,P.jsx)(on,{model:e}),(0,P.jsx)(Mn,{model:e}),(0,P.jsx)(fn,{model:e}),(0,P.jsx)(A.Tooltip,{title:"Zoom in",children:(0,P.jsx)(A.IconButton,{size:"small",onClick:()=>{e.zoom(1.5,e.viewBox.width/2,e.viewBox.height/2)},children:(0,P.jsx)(Jt,{})})}),(0,P.jsx)(A.Tooltip,{title:"Zoom out",children:(0,P.jsx)(A.IconButton,{size:"small",onClick:()=>{e.zoom(1/1.5,e.viewBox.width/2,e.viewBox.height/2)},children:(0,P.jsx)(en,{})})}),(0,P.jsx)(A.Tooltip,{title:"Zoom to fit",children:(0,P.jsx)(A.IconButton,{size:"small",onClick:()=>{e.zoomToFit()},children:(0,P.jsx)(qt,{})})}),(0,P.jsx)($o,{model:e}),(0,P.jsx)(sn,{model:e}),(0,P.jsx)(Sn,{model:e})]})}),Ln=Fo;var En=i(Ie(),1),In=i(I(),1);var ne=i(v(),1);function fe({x:t,y:e,w:n,text:o,note:a,color:r,edge:s=r,italic:c,small:u,dimmed:p,title:h,testId:d,onClick:b,onHover:m}){return(0,ne.jsxs)("g",{style:{pointerEvents:b||m?"auto":"none",cursor:b?"pointer":void 0,opacity:p?.35:1},"data-testid":d,onClick:b,onMouseEnter:()=>{m?.(!0)},onMouseLeave:()=>{m?.(!1)},children:[h?(0,ne.jsx)("title",{children:h}):null,(0,ne.jsx)("rect",{x:t-n/2,y:e-11-4+2,width:n,height:17,rx:3,fill:"rgba(255,255,255,0.85)",stroke:s,strokeWidth:u?.6:1}),(0,ne.jsxs)("text",{x:t,y:e,fontSize:u?10:11,fontFamily:"sans-serif",fontStyle:c?"italic":void 0,fontWeight:c?600:void 0,fill:r,textAnchor:"middle",children:[o,a?(0,ne.jsx)("tspan",{fontStyle:"normal",fontWeight:"normal",children:a}):null]})]})}var J=i(v(),1),Ko={position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"hidden",zIndex:3},Pn="#1c1c22",Vo=(0,In.observer)(function({model:e}){let{bubbles:n,genes:o,routes:a}=e.overlayLabels;if(n.length+o.length+a.length===0)return null;let{walkLift:r,scaleY:s,translateY:c,contigThickness:u}=e,p=d=>r!==void 0&&!d.nodeIds.some(b=>r.nodeIds.has(b)),h=d=>r!==void 0&&!d.route.walks.some(b=>r.names.has(b));return(0,J.jsxs)("svg",{style:Ko,width:e.paneWidth,height:e.canvasHeight,"data-testid":"graph-label-layer",children:[o.map(({item:d,x:b,y:m,w,text:y})=>{let{gene:f}=d,R=rt(d);return(0,J.jsxs)("g",{children:[(0,J.jsx)("line",{x1:b,x2:b,y1:m-11-2,y2:d.at.y*s+c+u/2,stroke:Pn,strokeWidth:.8,strokeOpacity:.6}),(0,J.jsx)(fe,{x:b,y:m,w,text:f.name,note:y.slice(f.name.length)||void 0,color:Pn,edge:ue,italic:!0,title:`${f.name} ${f.refName}:${f.start.toLocaleString()}-${f.end.toLocaleString()}${R?`, ${R} in the cut`:""}`,testId:"graph-gene-pin-label"})]},`${f.name}-${f.start}`)}),a.map(({item:{halo:d,route:b},x:m,y:w,w:y,text:f})=>(0,J.jsx)(fe,{x:m,y:w,w:y,text:f,color:re[d.kind],small:!0,dimmed:h(b),title:`${b.route.walks.length} walk(s): ${b.route.walks.join(", ")}`,testId:"graph-route-label"},`${d.bubble.start}-${d.bubble.end}-${b.route.steps.join(",")}`)),n.map(({item:d,x:b,y:m,w,text:y})=>(0,J.jsx)(fe,{x:b,y:m,w,text:y,color:re[d.kind],dimmed:p(d),title:`${d.label}
|
|
2
2
|
${d.bubble.segmentCount} segments \xB7 click to open`,testId:"graph-bubble-halo-label",onClick:()=>{e.popBubble(d.bubble)},onHover:f=>{(0,En.isAlive)(e)&&e.setHoveredBubble(f?d.bubble:null)}},`${d.bubble.start}-${d.bubble.end}`))]})}),Gn=Vo;var Le=i(X(),1);var Tn=i(ft(),1),Hn=i(Ge(),1),De=i(I(),1);var E=i(v(),1),Zo={position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:5},jo=(0,De.observer)(function({model:e}){let n=(0,Le.useRef)(null),{referenceStripShown:o,paneWidth:a,canvasHeight:r}=e;return(0,Le.useEffect)(()=>(0,Hn.autorun)(()=>{let s=n.current,c=e.referenceStripFrame,u=s?.getContext("2d");if(s&&u&&c&&e.referenceStripShown){let p=(0,Tn.getDpr)(),h=e.paneWidth,d=e.canvasHeight;s.width=Math.round(h*p),s.height=Math.round(d*p),u.setTransform(p,0,0,p,0,0),u.clearRect(0,0,h,d),ht(u,e.referenceStripBlocks,c,{width:h,lit:e.referenceStripLit,darkMode:e.darkMode,dpr:p})}}),[e]),(0,E.jsx)("canvas",{ref:n,"data-testid":o?"graph-reference-strip":void 0,style:{...Zo,width:a,height:r,display:o?"block":"none"}})}),_n=jo,Bn=18,Uo="linear-gradient(to right, hsl(0, 70%, 50%) 0 33%, hsl(120, 70%, 50%) 33% 61%, hsl(240, 70%, 50%) 61%)",qo=6;function Jo(t){let e=t.filter((a,r)=>a!==t[r-1]),n=Math.min(qo,e.length),o=Array.from({length:n},(a,r)=>e[n>1?Math.round(r*(e.length-1)/(n-1)):0]);return o.length>1?`linear-gradient(to right, ${o.join(", ")})`:o[0]??de}function Nn({rows:t}){return(0,E.jsx)("div",{style:{width:Bn,flex:"none"},children:t.map(({key:e,background:n})=>(0,E.jsx)("div",{style:{height:t.length>1?3:4,background:n}},e))})}function Qo(t){return t.walkLift?.walks.map(e=>({key:e.name,background:we(e.encoding)}))??[{key:"scheme",background:t.effectiveColorScheme==="reference-position"?Uo:Jo(t.referenceStripBlocks.map(e=>e.colors[0]))}]}function er(){return(0,E.jsx)("svg",{width:Bn,height:10,style:{flex:"none"},children:(0,E.jsx)("path",{d:"M0,5 L8,0 L8,10 Z M18,5 L10,0 L10,10 Z",fill:"#18181c"})})}var zn=(0,De.observer)(function({model:e}){let n=(e.walkLift?.walks.length??0)>1;return e.referenceStripShown?(0,E.jsxs)("div",{style:N,"data-testid":"graph-reference-strip-legend",children:[(0,E.jsxs)("div",{style:L,children:[(0,E.jsx)(Nn,{rows:Qo(e)}),(0,E.jsxs)("span",{children:["top strip: reference segments at their bp",n?", a row per walk":""]})]}),e.referenceStripFaded?(0,E.jsxs)("div",{style:L,children:[(0,E.jsx)(Nn,{rows:[{key:"pale",background:de}]}),(0,E.jsxs)("span",{children:["reference not on"," ",n?"that row's walk":e.liftedWalksLabel]})]}):null,e.referenceStripOverhangs?(0,E.jsxs)("div",{style:L,children:[(0,E.jsx)(er,{}),(0,E.jsx)("span",{children:"the graph draws reference past this edge"})]}):null]}):null});var Pe=i(X(),1);var An=i(ft(),1),Xn=i(Ge(),1),Ye=i(I(),1);var k=i(v(),1),tr={position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:1},nr=(0,Ye.observer)(function({model:e}){let n=(0,Pe.useRef)(null),{tubeMapPicture:o,paneWidth:a,canvasHeight:r}=e;return(0,Pe.useEffect)(()=>(0,Xn.autorun)(()=>{let s=n.current,c=e.tubeMapPicture,u=e.tubeMapFrame,p=s?.getContext("2d");if(s&&p&&c&&u){let h=(0,An.getDpr)(),d=e.paneWidth,b=e.canvasHeight;s.width=Math.round(d*h),s.height=Math.round(b*h),p.setTransform(h,0,0,h,0,0),p.clearRect(0,0,d,b);let m={...u,width:d,highlightNode:e.hoveredNode??e.selectedNode,darkMode:e.darkMode,tubeColors:e.tubeMapTubeColors,nodeColors:e.tubeMapNodeColors};St(p,c,m),wt(p,e.tubeMapDeviations,m),yt(p,e.tubeMapConnectors,e.connectorZoneBottom,m);let{bounds:w}=c;xt(p,e.tubeMapGenes,m,u.y(w.minY)-2);let y=e.tubeMapRulerBoxes;y&&bt(p,y,m,u.y(w.maxY)+4,e.layoutResult?.referenceAxis)}}),[e]),(0,k.jsx)("canvas",{ref:n,"data-testid":o?"graph-tube-map":void 0,style:{...tr,width:a,height:r,display:o?"block":"none"}})}),Dn=nr,Re=18;function or(){let t=[[.5,5.5],[8.5,Re-.5]];return(0,k.jsx)("svg",{width:Re,height:7,style:{flex:"none"},children:(0,k.jsx)("path",{d:t.map(([e,n])=>`M${e},6 V1.5 H${n} V6`).join(" "),fill:"none",stroke:gt(),strokeWidth:1})})}var $e={width:Re,height:7,flex:"none"},rr={...$e,display:"flex",justifyContent:"center",backgroundColor:"#b8b8c0"};function ar(){return(0,k.jsx)("div",{style:rr,children:(0,k.jsx)("div",{style:{width:2,backgroundColor:vt()}})})}function Wn({colors:t}){let e=100/t.length,n=t.map((o,a)=>`${o} ${a*e}% ${(a+1)*e}%`);return(0,k.jsx)("div",{style:{...$e,background:`linear-gradient(to right, ${n.join(", ")})`}})}var On={width:Re,flex:"none",textAlign:"center",fontFamily:"monospace",fontSize:12};function sr(){return(0,k.jsx)("div",{style:{...$e,backgroundColor:"grey"}})}function oe({swatch:t,children:e}){return(0,k.jsxs)("div",{style:L,children:[t,(0,k.jsx)("span",{children:e})]})}var Yn=(0,Ye.observer)(function({model:e}){let{logWidths:n,foldBp:o,forwardReads:a,reverseReads:r,mismatches:s}=e.tubeMapKeys,c=[a&&(0,k.jsx)(oe,{swatch:(0,k.jsx)(Wn,{colors:qe}),children:"read on the forward strand"},"fwd"),r&&(0,k.jsx)(oe,{swatch:(0,k.jsx)(Wn,{colors:Je}),children:"read on the reverse strand"},"rev"),s.has("substitution")&&(0,k.jsx)(oe,{swatch:(0,k.jsx)("span",{style:On,children:"A"}),children:"a read's base unlike the node's"},"sub"),s.has("insertion")&&(0,k.jsx)(oe,{swatch:(0,k.jsx)("span",{style:On,children:"*"}),children:"bases a read inserts"},"ins"),s.has("deletion")&&(0,k.jsx)(oe,{swatch:(0,k.jsx)(sr,{}),children:"bases a read skips"},"del"),o!==void 0&&(0,k.jsxs)(oe,{swatch:(0,k.jsx)(ar,{}),children:["a haplotype's variant under ",ge(o)]},"fold"),n&&(0,k.jsx)(oe,{swatch:(0,k.jsx)(or,{}),children:"width grows with log of length"},"log")].filter(Boolean);return c.length>0?(0,k.jsx)("div",{style:N,"data-testid":"graph-tube-map-legend",children:c}):null});var $n=i(ee(),1),Fn=i(I(),1),Vn=i(v(),1),ir={position:"absolute",left:8,zIndex:5,background:"rgba(255,255,255,0.9)",textTransform:"none"},lr=(0,Fn.observer)(function({model:e}){let{poppedFrom:n}=e;return n?(0,Vn.jsxs)($n.Button,{size:"small",variant:"outlined",style:{...ir,...e.facetPanels?{bottom:8}:{top:8}},"data-testid":"graph-unpop-bubble",onClick:()=>{e.unpopBubble()},children:["\u25C0 Back to ",n.label]}):null}),Kn=lr;var qn=i(X(),1);var Ke=i(I(),1);var Zn=i(X(),1);function cr(t){return t==="class"?"className":/^(data|aria)-/.test(t)?t:t.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}function jn(t,e){if(typeof t=="string")return t;let n={key:e};for(let[o,a]of Object.entries(t.attrs))a!==void 0&&(n[cr(o)]=a);return(0,Zn.createElement)(t.tag,n,...t.children.map(jn))}function Fe({el:t}){return jn(t,0)}var C=i(v(),1),pr={position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"visible",zIndex:3},ur="#111",fr="#9e9e9e",me={width:18,height:lt-4,borderRadius:2},mr={...me,display:"flex",justifyContent:"center"};function Un({color:t}){return(0,C.jsx)("div",{style:mr,children:(0,C.jsx)("div",{style:{width:2,backgroundColor:t}})})}function hr({swatch:t}){return t.kind==="gene"?(0,C.jsx)("div",{style:{...me,boxSizing:"border-box",border:`1.5px solid ${it}`,borderRadius:0}}):(0,C.jsx)("div",{style:{...me,height:t.kind==="gap"?ct:me.height,background:t.fill}})}var Jn=(0,Ke.observer)(function({model:e}){let n=e.walkRowBars;if(!n)return null;let o=[n.reference,...n.rows].flatMap(r=>r.call??[]),a=dt(n,{ramp:e.referenceRampDomain,rampCss:ye,genes:e.walkRowGenes?.size?e.walkRowGeneGaps:void 0});return(0,C.jsxs)("div",{style:N,"data-testid":"graph-walk-rows-legend",children:[a.map(r=>r.note?(0,C.jsx)("div",{style:{color:"#666",fontStyle:"italic"},children:r.label},r.label):(0,C.jsxs)("div",{style:L,children:[(0,C.jsx)(hr,{swatch:r.swatch}),(0,C.jsx)("span",{children:r.label})]},r.label)),o.some(r=>r.spanningReads!==0)?(0,C.jsxs)("div",{style:L,children:[(0,C.jsx)(Un,{color:ur}),(0,C.jsx)("span",{children:"allele length called for this walk"})]}):null,o.some(r=>r.spanningReads===0)?(0,C.jsxs)("div",{style:L,children:[(0,C.jsx)(Un,{color:fr}),(0,C.jsx)("span",{children:"called with no read spanning it"})]}):null,o.some(r=>r.agrees===!1)?(0,C.jsxs)("div",{style:L,children:[(0,C.jsx)("div",{style:me}),(0,C.jsxs)("span",{style:{color:pt},children:["walk and call over ",Math.round(.1*100),"% apart"]})]}):null]})}),gr=(0,Ke.observer)(function({model:e}){let n=(0,qn.useId)().replace(/[^\w-]/g,""),o=e.walkRowBars;if(!o)return null;let{paneWidth:a,canvasHeight:r}=e;return(0,C.jsx)("svg",{style:pr,width:a,height:r,"data-testid":"graph-walk-rows",children:(0,C.jsx)(Fe,{el:ut(o,{scaleX:e.scaleX,scaleY:e.scaleY,translateX:e.translateX,translateY:e.translateY,width:a,height:r},{ramp:e.referenceRampDomain,rowGenes:e.walkRowGenes,idPrefix:n})})})}),Qn=gr;function eo(t){return Promise.resolve(new ve(t))}var l=i(v(),1),to={position:"absolute",bottom:8,right:8,background:"rgba(0,0,0,0.75)",color:"white",padding:"4px 8px",borderRadius:4,fontSize:12,pointerEvents:"none",zIndex:6},br={position:"relative"},yr={position:"relative",lineHeight:0,isolation:"isolate"},vr={position:"absolute",left:0,right:0,bottom:0,zIndex:0},wr={position:"absolute",inset:0,zIndex:10,lineHeight:"normal",pointerEvents:"none"},Sr={position:"absolute",left:6,transform:"translateY(-50%)",background:"rgba(255,255,255,0.82)",padding:"0 4px",borderRadius:3,fontSize:11,lineHeight:"16px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:4},xr=(0,_.observer)(function({model:e}){let n=e.drawnRowLabels;return(0,l.jsx)(l.Fragment,{children:n.map(({label:o,y:a})=>{let r=a*e.scaleY+e.translateY;return r>=0&&r<=e.canvasHeight?(0,l.jsx)("div",{"data-testid":"graph-row-label",style:{...Sr,top:r},children:o},a):null})})}),kr={position:"absolute",top:be,right:be,display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4,pointerEvents:"none",zIndex:4},Mr={width:18,height:3,borderRadius:2},Cr=(0,_.observer)(function({model:e}){let{pathLegend:n}=e;return n.length>0?(0,l.jsx)("div",{style:N,"data-testid":"graph-path-legend",children:n.map(({name:o,label:a,color:r})=>(0,l.jsxs)("div",{style:L,children:[(0,l.jsx)("div",{style:{...Mr,backgroundColor:r}}),(0,l.jsx)("span",{children:a})]},o))}):null}),Lr=(0,_.observer)(function({model:e}){let n=e.walkLift;return n?(0,l.jsxs)("div",{style:N,"data-testid":"graph-walk-readout",children:[n.walks.map(o=>(0,l.jsx)(pe,{walk:o,label:e.walkLabel(o.name),reference:e.walkReference,at:e.hoveredOn(o)},o.name)),e.liftPaintsOffReference?(0,l.jsx)(oo,{}):null,(0,l.jsxs)("div",{style:L,children:[(0,l.jsx)("div",{style:{...te,background:de}}),(0,l.jsxs)("span",{children:["not on ",e.liftedWalksLabel]})]})]}):null}),Rr={minWidth:90,height:8,borderRadius:2,background:ye},Pr={display:"flex",justifyContent:"space-between",gap:8},Er=(0,_.observer)(function({model:e}){let n=e.walkLift?void 0:e.referenceRampDomain,{offReference:o,unplaced:a}=e.referenceRampOffKeys,r=Math.round(n?.start??0),s=Math.round(n?.end??0);return n?(0,l.jsxs)("div",{style:N,"data-testid":"graph-ramp-legend",children:[(0,l.jsx)("div",{style:Rr}),(0,l.jsxs)("div",{style:Pr,children:[(0,l.jsx)("span",{children:r.toLocaleString()}),(0,l.jsxs)("span",{children:["(",ge(s-r),")"]}),(0,l.jsx)("span",{children:s.toLocaleString()})]}),o?(0,l.jsx)(oo,{}):null,a?(0,l.jsxs)("div",{style:L,children:[(0,l.jsx)("div",{style:{...te,background:Ir}}),(0,l.jsx)("span",{children:"no reference position"})]}):null]}):null}),Ir="rgb(160, 160, 160)";function oo(){return(0,l.jsxs)("div",{style:L,children:[(0,l.jsx)("div",{style:{...te,background:st}}),(0,l.jsx)("span",{children:"off the reference"})]})}var Gr={...te,border:`2px solid ${ue}`,borderRadius:5,boxSizing:"border-box"},Nr=(0,_.observer)(function({model:e}){return e.genePins.some(n=>n.exonsByNode.length>0)?(0,l.jsx)("div",{style:N,"data-testid":"graph-gene-legend",children:(0,l.jsxs)("div",{style:L,children:[(0,l.jsx)("div",{style:Gr}),(0,l.jsx)("span",{children:"exon"})]})}):null}),ro={position:"absolute",transform:"translate(-50%, -50%)",background:"rgba(255,255,255,0.78)",padding:"0 3px",borderRadius:3,fontSize:10,lineHeight:"13px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:3},Tr={...ro,color:"#18181c",fontWeight:600},Hr={position:"absolute",left:0,top:0,pointerEvents:"none",overflow:"visible",zIndex:2},_r=(0,_.observer)(function({model:e}){let n=(0,Ee.useRef)(null);return(0,Ee.useEffect)(()=>{let o=n.current;if(!o)return;let a=new ResizeObserver(()=>{(0,Ve.isAlive)(e)&&e.hoveredNode===null&&e.setLegendSize({width:o.offsetWidth,height:o.offsetHeight})});return a.observe(o),()=>{a.disconnect()}},[e]),(0,l.jsxs)("div",{ref:n,style:{...kr,top:be+e.referenceStripZonePx},children:[(0,l.jsx)(Er,{model:e}),(0,l.jsx)(zn,{model:e}),(0,l.jsx)(Nt,{model:e}),(0,l.jsx)(Nr,{model:e}),(0,l.jsx)(Cr,{model:e}),(0,l.jsx)(Yn,{model:e}),(0,l.jsx)(Jn,{model:e}),(0,l.jsx)(Lr,{model:e})]})}),Br=(0,_.observer)(function({model:e}){let n=e.overlayLabels.sizes,o=n.flatMap(({key:a,leader:r})=>r?[{key:a,...r}]:[]);return(0,l.jsxs)(l.Fragment,{children:[o.length>0?(0,l.jsx)("svg",{style:Hr,width:e.paneWidth,height:e.canvasHeight,children:o.map(({key:a,arcX:r,arcY:s,labelX:c,labelY:u})=>(0,l.jsx)("line",{"data-testid":"graph-label-leader",x1:r,y1:s,x2:c,y2:u,stroke:"#18181c",strokeWidth:1},a))}):null,n.map(({key:a,text:r,x:s,y:c,kind:u})=>(0,l.jsx)("div",{"data-testid":"graph-size-label",style:{...u==="deletion"?Tr:ro,left:s,top:c},children:r},a))]})}),zr=(0,_.observer)(function({model:e}){let n=e.hoveredNode?e.nodeById?.get(e.hoveredNode):null,o=e.hoveredEdge!==null&&e.graph?e.graph.edges[e.hoveredEdge]:null,a=n?kt(n):void 0,r=e.hoveredEdge===null?void 0:e.deletions.find(s=>s.edgeIndex===e.hoveredEdge);return(0,l.jsxs)(l.Fragment,{children:[n?(0,l.jsxs)("div",{style:to,children:[(0,l.jsx)("strong",{children:n.name})," \u2014"," ",n.length.toLocaleString()," bp, depth"," ",n.depth.toFixed(1),a?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("br",{}),a.sample," ",Te(a)," (rank"," ",n.stable?.rank,")"]}):null]}):null,o?(0,l.jsx)("div",{style:to,children:r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("strong",{children:"Deletion"})," ",r.bp.toLocaleString()," bp",(0,l.jsx)("br",{}),r.refName,":",r.start.toLocaleString(),"-",r.end.toLocaleString()]}):(0,l.jsxs)(l.Fragment,{children:["Edge: ",o.from," \u2192 ",o.to]})}):null]})}),Wr=(0,_.observer)(function({model:e,nodeId:n,top:o,left:a,onClose:r}){let{own:s,reference:c,highlight:u}=e.nodeLaunchTargets(n);return(0,l.jsx)(Q.Menu,{open:!0,anchorReference:"anchorPosition",anchorPosition:{top:o,left:a},onClose:()=>{r()},onMenuItemClick:p=>{p()},menuItems:[{label:"Node details",icon:It,onClick:()=>{e.showNodeDetails(n)}},...Mt({own:s,reference:c,highlight:u,onShowLinear:p=>{e.showInLinearView(p)},onHighlight:e.canHighlightInLinearView?p=>{e.highlightInLinearView(p)}:void 0})]})}),Or=(0,_.observer)(function({model:e,row:n,top:o,left:a,onClose:r}){let s=e.walkRowLaunchTarget(n),c=s?.assembly;return(0,l.jsx)(Q.Menu,{open:!0,anchorReference:"anchorPosition",anchorPosition:{top:o,left:a},onClose:()=>{r()},onMenuItemClick:u=>{u()},menuItems:[s&&c?{label:`Linear genome view \u2014 ${c} ${Te(s.location)}`,icon:He,onClick:()=>{e.showInLinearView({location:s.location,assembly:c})}}:{label:"Linear genome view",icon:He,disabled:!0,disabledHelpText:s?`No assembly in this session is ${s.location.haplotype??s.label}`:"This walk states no contig coordinates",onClick:()=>{}}]})}),Ar=(0,_.observer)(function({model:e,ownChrome:n=!0}){let{canvasRef:o,canvas:a,error:r,retry:s}=(0,no.useRenderingBackend)(eo,e),{handlers:c,contextNode:u,contextRow:p,closeContextMenu:h}=Ft(e);ke(a,e);let d=e.facetPanels!==void 0;return(0,l.jsxs)("div",{style:br,children:[n?(0,l.jsx)(Ln,{model:e}):null,(0,l.jsxs)("div",{style:yr,onMouseEnter:()=>{e.setPointerInPane(!0)},onMouseLeave:()=>{(0,Ve.isAlive)(e)&&e.setPointerInPane(!1)},children:[e.referenceStripShown?(0,l.jsx)("div",{style:{...vr,top:e.referenceStripZonePx,background:e.paperCss}}):null,(0,l.jsx)("canvas",{ref:o,"data-testid":"graph-genome-canvas",style:{width:e.paneWidth,height:e.canvasHeight,cursor:e.isPanning||e.draggingNode?"grabbing":"grab",display:"block",position:"relative",zIndex:1},...c}),d?(0,l.jsx)(Kt,{model:e,handlers:c}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Dn,{model:e}),(0,l.jsx)(_n,{model:e}),(0,l.jsx)(xr,{model:e}),(0,l.jsx)(Br,{model:e}),(0,l.jsx)(Gt,{model:e}),(0,l.jsx)(jt,{model:e}),(0,l.jsx)(Gn,{model:e}),(0,l.jsx)(Qn,{model:e}),(0,l.jsx)(_r,{model:e})]}),(0,l.jsx)(Kn,{model:e}),n?(0,l.jsx)("div",{style:wr,children:(0,l.jsx)(Q.LoadingOverlay,{isVisible:e.isLoading,immediate:!e.layoutResult,statusMessage:e.statusMessage,onCancel:e.canCancelLoad?()=>{e.cancelLoad()}:void 0})}):null]}),(0,l.jsx)(zr,{model:e}),u?(0,l.jsx)(Wr,{model:e,nodeId:u.nodeId,top:u.top,left:u.left,onClose:h}):null,p?(0,l.jsx)(Or,{model:e,row:p.row,top:p.top,left:p.left,onClose:h}):null,r?(0,l.jsx)(Q.ErrorBanner,{error:r,onReset:s}):null,n&&e.error?(0,l.jsx)(Q.ErrorBanner,{error:e.error,onReset:e.canRetryLoad?()=>{e.retryLoad()}:void 0}):null]})}),Vs=Ar;export{Vs as a};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-HW55QCJG.js.map
|