jbrowse-plugin-graphgenomeviewer 7.4.1 → 7.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/chunks/{GbzBaseSyntenyAdapter-FZWSXPAE.js → GbzBaseSyntenyAdapter-BVLBK4OO.js} +2 -2
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-FZWSXPAE.js.map → GbzBaseSyntenyAdapter-BVLBK4OO.js.map} +1 -1
  3. package/dist/chunks/{GraphGenomeView-52OPGZER.js → GraphGenomeView-UCOAMRF7.js} +2 -2
  4. package/dist/chunks/{GraphTrackSettingsDialog-JHIP2F5N.js → GraphTrackSettingsDialog-MR7X75EY.js} +2 -2
  5. package/dist/chunks/{HighlightColorDialog-S2WPOSDF.js → HighlightColorDialog-ZBAZDYIR.js} +2 -2
  6. package/dist/chunks/{LinearGraphDisplay-EF2GE7X7.js → LinearGraphDisplay-AJ5OZN27.js} +2 -2
  7. package/dist/chunks/{MinigraphBubbleAdapter-XC75BCG3.js → MinigraphBubbleAdapter-PEQK5NII.js} +2 -2
  8. package/dist/chunks/{RgfaTabixAdapter-56X2U424.js → RgfaTabixAdapter-Q63YLPK4.js} +2 -2
  9. package/dist/chunks/{WalkTabixSyntenyAdapter-ECW557IS.js → WalkTabixSyntenyAdapter-N5PFI4LS.js} +2 -2
  10. package/dist/chunks/{chunk-UW7INEQF.js → chunk-2XZYJLCE.js} +1 -1
  11. package/dist/chunks/{chunk-UW7INEQF.js.map → chunk-2XZYJLCE.js.map} +1 -1
  12. package/dist/chunks/{chunk-ADZBAET3.js → chunk-55DIX25J.js} +3 -3
  13. package/dist/chunks/{chunk-ADZBAET3.js.map → chunk-55DIX25J.js.map} +3 -3
  14. package/dist/chunks/{chunk-2BTNRN57.js → chunk-62AHPP6H.js} +2 -2
  15. package/dist/chunks/{chunk-2BTNRN57.js.map → chunk-62AHPP6H.js.map} +1 -1
  16. package/dist/chunks/{chunk-OUHKJSKZ.js → chunk-AWGMTI73.js} +2 -2
  17. package/dist/chunks/{chunk-2Q4D5RHL.js → chunk-DXNE2CFX.js} +2 -2
  18. package/dist/chunks/{chunk-2Q4D5RHL.js.map → chunk-DXNE2CFX.js.map} +1 -1
  19. package/dist/chunks/{chunk-XT4U7I3D.js → chunk-FWVXBJ64.js} +3 -3
  20. package/dist/chunks/{chunk-XT4U7I3D.js.map → chunk-FWVXBJ64.js.map} +2 -2
  21. package/dist/chunks/{chunk-Z4YNEFPC.js → chunk-HI3YK2SO.js} +2 -2
  22. package/dist/chunks/chunk-J3AXN7JQ.js +2 -0
  23. package/dist/chunks/{chunk-LTN6XZR5.js → chunk-JSRGX4TC.js} +1 -1
  24. package/dist/chunks/{chunk-LTN6XZR5.js.map → chunk-JSRGX4TC.js.map} +1 -1
  25. package/dist/chunks/{chunk-SI64QXFH.js → chunk-LFTZNUXB.js} +2 -2
  26. package/dist/chunks/{chunk-SI64QXFH.js.map → chunk-LFTZNUXB.js.map} +1 -1
  27. package/dist/chunks/{chunk-YBZA7LPQ.js → chunk-MEMUEG5Z.js} +2 -2
  28. package/dist/chunks/{chunk-YBZA7LPQ.js.map → chunk-MEMUEG5Z.js.map} +1 -1
  29. package/dist/chunks/{chunk-PLTIGGGS.js → chunk-PUREF4BM.js} +2 -2
  30. package/dist/chunks/{chunk-PLTIGGGS.js.map → chunk-PUREF4BM.js.map} +1 -1
  31. package/dist/chunks/chunk-Q3BXNKEL.js +2 -0
  32. package/dist/chunks/chunk-Q3BXNKEL.js.map +7 -0
  33. package/dist/chunks/{chunk-VIVPTP5Z.js → chunk-RCXOOBLX.js} +1 -1
  34. package/dist/chunks/{chunk-VIVPTP5Z.js.map → chunk-RCXOOBLX.js.map} +1 -1
  35. package/dist/chunks/{chunk-MLVBPMBU.js → chunk-S75MFZDE.js} +2 -2
  36. package/dist/chunks/{chunk-MLVBPMBU.js.map → chunk-S75MFZDE.js.map} +2 -2
  37. package/dist/chunks/{chunk-KPP5H27W.js → chunk-SFYSQ52W.js} +2 -2
  38. package/dist/chunks/{chunk-4AAW5P6N.js → chunk-U5PIXAF2.js} +2 -2
  39. package/dist/chunks/{chunk-4AAW5P6N.js.map → chunk-U5PIXAF2.js.map} +1 -1
  40. package/dist/chunks/{chunk-XLSVRKFJ.js → chunk-WJGCVNGH.js} +2 -2
  41. package/dist/chunks/{chunk-JXOLZ5IZ.js → chunk-WY5W5X62.js} +2 -2
  42. package/dist/chunks/{chunk-JXOLZ5IZ.js.map → chunk-WY5W5X62.js.map} +1 -1
  43. package/dist/chunks/{chunk-4XM5OBD5.js → chunk-ZG2CQXOW.js} +2 -2
  44. package/dist/chunks/{chunk-4XM5OBD5.js.map → chunk-ZG2CQXOW.js.map} +1 -1
  45. package/dist/chunks/{renderSvg-IXWB7R54.js → renderSvg-Z7YIXVQ5.js} +2 -2
  46. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +4 -4
  47. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  48. package/package.json +2 -2
  49. package/src/version.ts +1 -1
  50. package/dist/chunks/chunk-D5PRXUSS.js +0 -2
  51. package/dist/chunks/chunk-D5PRXUSS.js.map +0 -7
  52. package/dist/chunks/chunk-QASFRHPG.js +0 -2
  53. /package/dist/chunks/{GraphGenomeView-52OPGZER.js.map → GraphGenomeView-UCOAMRF7.js.map} +0 -0
  54. /package/dist/chunks/{GraphTrackSettingsDialog-JHIP2F5N.js.map → GraphTrackSettingsDialog-MR7X75EY.js.map} +0 -0
  55. /package/dist/chunks/{HighlightColorDialog-S2WPOSDF.js.map → HighlightColorDialog-ZBAZDYIR.js.map} +0 -0
  56. /package/dist/chunks/{LinearGraphDisplay-EF2GE7X7.js.map → LinearGraphDisplay-AJ5OZN27.js.map} +0 -0
  57. /package/dist/chunks/{MinigraphBubbleAdapter-XC75BCG3.js.map → MinigraphBubbleAdapter-PEQK5NII.js.map} +0 -0
  58. /package/dist/chunks/{RgfaTabixAdapter-56X2U424.js.map → RgfaTabixAdapter-Q63YLPK4.js.map} +0 -0
  59. /package/dist/chunks/{WalkTabixSyntenyAdapter-ECW557IS.js.map → WalkTabixSyntenyAdapter-N5PFI4LS.js.map} +0 -0
  60. /package/dist/chunks/{chunk-OUHKJSKZ.js.map → chunk-AWGMTI73.js.map} +0 -0
  61. /package/dist/chunks/{chunk-Z4YNEFPC.js.map → chunk-HI3YK2SO.js.map} +0 -0
  62. /package/dist/chunks/{chunk-QASFRHPG.js.map → chunk-J3AXN7JQ.js.map} +0 -0
  63. /package/dist/chunks/{chunk-KPP5H27W.js.map → chunk-SFYSQ52W.js.map} +0 -0
  64. /package/dist/chunks/{chunk-XLSVRKFJ.js.map → chunk-WJGCVNGH.js.map} +0 -0
  65. /package/dist/chunks/{renderSvg-IXWB7R54.js.map → renderSvg-Z7YIXVQ5.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{a as ne,b as ae,c as ue,d as re,e as oe,f as O,g as ie,h as se}from"./chunk-Z4YNEFPC.js";import{a as te}from"./chunk-QASFRHPG.js";import{a as ee}from"./chunk-KOB7YIMR.js";import{a as Q,b as D,c as Z,d as u,e as k,f as M,g as j,h as $,i as W,k as U}from"./chunk-PLTIGGGS.js";import"./chunk-2Q4D5RHL.js";import{b as z,c as E}from"./chunk-SI64QXFH.js";import"./chunk-M2D7NUOY.js";import"./chunk-YBLNN5FU.js";import"./chunk-YBZA7LPQ.js";import"./chunk-4AAW5P6N.js";import{a as K,c as L,p as V}from"./chunk-OUHKJSKZ.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{g as F,h as N,i as C}from"./chunk-VIVPTP5Z.js";import"./chunk-T4R3ZVEM.js";import{d as G,g as X,h as Y,i as J}from"./chunk-IKJZPPOA.js";import"./chunk-7WIBGKBU.js";import{a as P}from"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{e as _,o as B}from"./chunk-TENPGIPX.js";function A(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function ge(n){return Y(n)&&A(X(n))?J(n,i=>A(i)):void 0}function ye(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function ce(n,i){let e=ge(n);if(!e)return{};try{return await P(e,i).stat(),{location:e}}catch(t){return ye(t)?{}:{unreadable:String(t)}}}var be=5e3,we=50*2**20,H=class extends Error{constructor(e){super(`this GAF is ${(e/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function xe(n,i){if(n.length<=i)return n;let e=n.length/i;return Array.from({length:i},(t,a)=>n[Math.floor(a*e)])}var pe=(n,i)=>n.path.some(e=>i.has(e.name)),v=class{constructor(i,e){this.file=i;this.tabix=e;this.whole=L({setup:async({signal:i})=>{let{size:e}=await this.file.stat();if(e>we)throw new H(e);let t=await this.file.readFile({signal:i}),a=new TextDecoder().decode(t[0]===31&&t[1]===139?await K(t):t);return E(a)}})}async readIndexed(i,e,t){let a=1/0,r=-1/0;for(let s of e){let c=Number(s);Number.isInteger(c)&&(a=Math.min(a,c),r=Math.max(r,c))}let o=[];return a<=r&&await i.getLines("{node}",a,r+1,{signal:t,lineCallback:s=>{let c=z(s);c&&pe(c,e)&&o.push(c)}}),o}async readsOver(i,{signal:e}={}){let t=this.tabix?await this.readIndexed(this.tabix,i,e):(await this.whole({signal:e})).filter(a=>pe(a,i));return{records:xe(t,be),total:t.length}}};var I=class extends Error{constructor(e){super(e===void 0?"no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation":`the haplotype index beside the graph database could not be checked (${e}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},q=class extends Error{constructor(e,t){super(`the graph is cut on its reference, ${t}; a window on ${e} has no reference coordinates to cut at. Open the graph from a ${t} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function Se(n,i){return`${u(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function Ne({alignment:n,assemblyName:i,refName:e,lane:t}){let{refStart:a,refEnd:r,strand:o,cigar:s}=n;if(!(r<=a)){let{name:c,hapStart:p,hapEnd:l}=n,f=Se(c,n),g={uniqueId:f,assemblyName:i,refName:e,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:s,syntenyId:f,mate:{refName:c.contig,start:p,end:l,assemblyName:t}};return new ne(g)}}function Pe({pair:n,lane:i,mateLane:e}){return se({target:{name:`${u(n.target)}#${n.target.contig}`,assemblyName:i,refName:n.target.contig,start:n.targetStart,end:n.targetEnd},query:{name:`${u(n.query)}#${n.query.contig}`,assemblyName:e,refName:n.query.contig,start:n.queryStart,end:n.queryEnd},strand:n.strand,cigar:n.cigar,matches:n.matches,columns:n.columns})}var Le=12e4;function Re(n,i){let e=new Map;for(let a of n)for(let{name:r,start:o,end:s}of a.walkSpans()){let c=u(r);if(i.has(c)){let p=`${c}#${r.contig}`,l=e.get(p);l?l.push([o,s]):e.set(p,[[o,s]])}}let t=0;for(let a of e.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Le&&(t=Math.max(t,o))}}return t}function fe(n,i){return n instanceof Z&&(n.message=`Zoom in to about ${_(n.fitsBp)} to see ${i}`),n}var le=(n,i,e)=>ie(fe(W(n,i,e)??n,"lanes"),e),me=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),T=class extends ae{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let e=this.getConf("gbzDbLocation"),t=this.getConf("haplotypeIndexLocation"),a=G(t)?{location:t}:await ce(e,this.pluginManager),r=a.location,o=await D.open({source:P(e,this.pluginManager),haplotypeIndex:r?P(r,this.pluginManager):void 0}),s=this.getConf("assemblyNames")[0];if(s===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let c=await M(o),p=j({configured:this.getConf("referenceSample"),anchorPrefix:N(this,s),referenceSamples:c});return{db:o,anchor:s,referenceSample:p,referenceSamples:c,unreadableIndex:a.unreadable}}});this.gaf=L({label:"Opening reads",setup:async()=>{let e=this.getConf("readsLocation"),t=this.getConf(["readsIndex","location"]);return G(e)?new v(P(e,this.pluginManager),G(t)?V(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(e,t){let{db:a,referenceSample:r}=await this.graph(t);return $(a,r,e)}async getHaplotypes(e={}){let{db:t,referenceSamples:a}=await this.graph(e),r=new Map;for(let o of await t.paths()){let s=u(o.name),c=r.get(s);c?c.contigs.includes(o.name.contig)||c.contigs.push(o.name.contig):r.set(s,{prefix:s,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(e={}){let{anchor:t,referenceSample:a}=await this.graph(e),r=C(this),o=[];for(let s of await this.getHaplotypes(e))s.sample!==a&&o.push({name:O(r,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:t,lanes:o}}async getRefNames(e={}){let{db:t,anchor:a,referenceSample:r}=await this.graph(e),{assemblyName:o}=e,s=o===a?void 0:N(this,o),c=(await t.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:F(u(p.name),s)).map(p=>p.name.contig);return[...new Set(c)]}keepPredicate(e,t){let a=e===void 0||e.length===0?void 0:e.map(r=>N(this,r));return a===void 0&&t===void 0?void 0:r=>k(r,a)&&(t===void 0||F(u(r),t))}async getSubgraph(e,t={}){let{signal:a}=t,{db:r,anchor:o,referenceSample:s,unreadableIndex:c}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:f,end:g}=me(e);if(p!==o)throw new q(p,o);let y=await this.referenceQuery(l,{signal:a});if(!y)throw new Error(`${s} has no indexed path ${l} in this graph`);let b=this.keepPredicate(t.haplotypes);if(b!==void 0&&!r.hasHaplotypeIndex)throw new I(c);let d=await U(r,y,f,g,{context:this.getConf("context"),snarls:t.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:t.signal,keep:b}).catch(w=>{throw fe(w,"the graph")});return typeof d=="string"?d:te(d,{start:f,end:g},t.walkRows)}async getReads(e,t={}){let a=await this.gaf(t);return a?a.readsOver(new Set(e),t):{records:[],total:0}}async laneHaplotypes(e,t){let a=N(this,e);return(await this.getHaplotypes(t)).filter(r=>F(r.prefix,a))}async anchorFeatures(e,t){let{db:a}=await this.graph(t),{assemblyName:r,refName:o,start:s,end:c}=e,p=N(this,t.targetAssemblyName),l=C(this),f=this.keepPredicate(t.haplotypes,p),g=await this.referenceQuery(o,t),y=this.getConf("nodeLimit");return(g?await B(`Reading graph ${o}:${s.toLocaleString()}-${c.toLocaleString()}`,t.statusCallback,()=>a.getAlignments({path:g,start:s,end:c,context:this.getConf("context"),haplotypes:"all",limit:y,signal:t.signal,keep:f}).catch(d=>{throw le(d,y,c-s)})):[]).flatMap(d=>{let w=d.resolved?Ne({alignment:d,assemblyName:r,refName:o,lane:O(l,u(d.name))}):void 0;return w===void 0?[]:[w]})}async pairFeatures(e,t,a){let{db:r}=await this.graph(a),{refName:o,start:s,end:c}=e,l=(await Promise.all(t.map(async m=>({pair:m,featureSide:await this.laneHaplotypes(m.queryAssemblyName,a),mateSide:await this.laneHaplotypes(m.targetAssemblyName,a)})))).filter(({featureSide:m,mateSide:h})=>m.length>0&&h.length>0),f=new Set(l.flatMap(({featureSide:m,mateSide:h})=>[...m,...h].map(u))),g=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),b=this.getConf("context"),d=(m,h)=>r.getSubgraphs({path:m,start:s,end:c,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:x=>f.has(u(x))}),w=async m=>{let h=await d(m,b).catch(S=>{throw le(S,y,c-s)}),x=Re(h,f),R=Math.ceil(x/2)+2e3;return x>0&&R>b?d(m,R).catch(S=>{if(S instanceof Q)return h;throw S}):h};return(g&&l.length>0?await B(oe(t),a.statusCallback,()=>w(g)):[]).flatMap(m=>l.flatMap(({pair:h,featureSide:x,mateSide:R})=>x.flatMap(S=>R.flatMap(de=>m.pairAlignments({target:S,query:de,bases:!1}).map(he=>Pe({pair:he,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(e,t={}){let a=me(e);return ee(async r=>{let{db:o,anchor:s,unreadableIndex:c}=await this.graph(t);if(!o.hasHaplotypeIndex)throw new I(c);if(a.assemblyName===s){let p=re(t),l=p.length>0?await this.pairFeatures(a,p,t):await this.anchorFeatures(a,t);for(let f of l)r.next(f)}r.complete()},t.signal)}};export{I as NoHaplotypeIndexError,ue as PairTargetError,T as default,Re as widestWalkGap};
2
- //# sourceMappingURL=GbzBaseSyntenyAdapter-FZWSXPAE.js.map
1
+ import{a as ne,b as ae,c as ue,d as re,e as oe,f as O,g as ie,h as se}from"./chunk-HI3YK2SO.js";import{a as te}from"./chunk-J3AXN7JQ.js";import{a as ee}from"./chunk-KOB7YIMR.js";import{a as Q,b as D,c as Z,d as u,e as k,f as M,g as j,h as $,i as W,k as U}from"./chunk-PUREF4BM.js";import"./chunk-DXNE2CFX.js";import{b as z,c as E}from"./chunk-LFTZNUXB.js";import"./chunk-M2D7NUOY.js";import"./chunk-YBLNN5FU.js";import"./chunk-MEMUEG5Z.js";import"./chunk-U5PIXAF2.js";import{a as K,c as L,p as V}from"./chunk-AWGMTI73.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{g as F,h as N,i as C}from"./chunk-RCXOOBLX.js";import"./chunk-T4R3ZVEM.js";import{d as G,g as X,h as Y,i as J}from"./chunk-IKJZPPOA.js";import"./chunk-7WIBGKBU.js";import{a as P}from"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{e as _,o as B}from"./chunk-TENPGIPX.js";function A(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function ge(n){return Y(n)&&A(X(n))?J(n,i=>A(i)):void 0}function ye(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function ce(n,i){let e=ge(n);if(!e)return{};try{return await P(e,i).stat(),{location:e}}catch(t){return ye(t)?{}:{unreadable:String(t)}}}var be=5e3,we=50*2**20,H=class extends Error{constructor(e){super(`this GAF is ${(e/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function xe(n,i){if(n.length<=i)return n;let e=n.length/i;return Array.from({length:i},(t,a)=>n[Math.floor(a*e)])}var pe=(n,i)=>n.path.some(e=>i.has(e.name)),v=class{constructor(i,e){this.file=i;this.tabix=e;this.whole=L({setup:async({signal:i})=>{let{size:e}=await this.file.stat();if(e>we)throw new H(e);let t=await this.file.readFile({signal:i}),a=new TextDecoder().decode(t[0]===31&&t[1]===139?await K(t):t);return E(a)}})}async readIndexed(i,e,t){let a=1/0,r=-1/0;for(let s of e){let c=Number(s);Number.isInteger(c)&&(a=Math.min(a,c),r=Math.max(r,c))}let o=[];return a<=r&&await i.getLines("{node}",a,r+1,{signal:t,lineCallback:s=>{let c=z(s);c&&pe(c,e)&&o.push(c)}}),o}async readsOver(i,{signal:e}={}){let t=this.tabix?await this.readIndexed(this.tabix,i,e):(await this.whole({signal:e})).filter(a=>pe(a,i));return{records:xe(t,be),total:t.length}}};var I=class extends Error{constructor(e){super(e===void 0?"no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation":`the haplotype index beside the graph database could not be checked (${e}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},q=class extends Error{constructor(e,t){super(`the graph is cut on its reference, ${t}; a window on ${e} has no reference coordinates to cut at. Open the graph from a ${t} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function Se(n,i){return`${u(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function Ne({alignment:n,assemblyName:i,refName:e,lane:t}){let{refStart:a,refEnd:r,strand:o,cigar:s}=n;if(!(r<=a)){let{name:c,hapStart:p,hapEnd:l}=n,f=Se(c,n),g={uniqueId:f,assemblyName:i,refName:e,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:s,syntenyId:f,mate:{refName:c.contig,start:p,end:l,assemblyName:t}};return new ne(g)}}function Pe({pair:n,lane:i,mateLane:e}){return se({target:{name:`${u(n.target)}#${n.target.contig}`,assemblyName:i,refName:n.target.contig,start:n.targetStart,end:n.targetEnd},query:{name:`${u(n.query)}#${n.query.contig}`,assemblyName:e,refName:n.query.contig,start:n.queryStart,end:n.queryEnd},strand:n.strand,cigar:n.cigar,matches:n.matches,columns:n.columns})}var Le=12e4;function Re(n,i){let e=new Map;for(let a of n)for(let{name:r,start:o,end:s}of a.walkSpans()){let c=u(r);if(i.has(c)){let p=`${c}#${r.contig}`,l=e.get(p);l?l.push([o,s]):e.set(p,[[o,s]])}}let t=0;for(let a of e.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Le&&(t=Math.max(t,o))}}return t}function fe(n,i){return n instanceof Z&&(n.message=`Zoom in to about ${_(n.fitsBp)} to see ${i}`),n}var le=(n,i,e)=>ie(fe(W(n,i,e)??n,"lanes"),e),me=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),T=class extends ae{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let e=this.getConf("gbzDbLocation"),t=this.getConf("haplotypeIndexLocation"),a=G(t)?{location:t}:await ce(e,this.pluginManager),r=a.location,o=await D.open({source:P(e,this.pluginManager),haplotypeIndex:r?P(r,this.pluginManager):void 0}),s=this.getConf("assemblyNames")[0];if(s===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let c=await M(o),p=j({configured:this.getConf("referenceSample"),anchorPrefix:N(this,s),referenceSamples:c});return{db:o,anchor:s,referenceSample:p,referenceSamples:c,unreadableIndex:a.unreadable}}});this.gaf=L({label:"Opening reads",setup:async()=>{let e=this.getConf("readsLocation"),t=this.getConf(["readsIndex","location"]);return G(e)?new v(P(e,this.pluginManager),G(t)?V(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(e,t){let{db:a,referenceSample:r}=await this.graph(t);return $(a,r,e)}async getHaplotypes(e={}){let{db:t,referenceSamples:a}=await this.graph(e),r=new Map;for(let o of await t.paths()){let s=u(o.name),c=r.get(s);c?c.contigs.includes(o.name.contig)||c.contigs.push(o.name.contig):r.set(s,{prefix:s,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(e={}){let{anchor:t,referenceSample:a}=await this.graph(e),r=C(this),o=[];for(let s of await this.getHaplotypes(e))s.sample!==a&&o.push({name:O(r,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:t,lanes:o}}async getRefNames(e={}){let{db:t,anchor:a,referenceSample:r}=await this.graph(e),{assemblyName:o}=e,s=o===a?void 0:N(this,o),c=(await t.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:F(u(p.name),s)).map(p=>p.name.contig);return[...new Set(c)]}keepPredicate(e,t){let a=e===void 0||e.length===0?void 0:e.map(r=>N(this,r));return a===void 0&&t===void 0?void 0:r=>k(r,a)&&(t===void 0||F(u(r),t))}async getSubgraph(e,t={}){let{signal:a}=t,{db:r,anchor:o,referenceSample:s,unreadableIndex:c}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:f,end:g}=me(e);if(p!==o)throw new q(p,o);let y=await this.referenceQuery(l,{signal:a});if(!y)throw new Error(`${s} has no indexed path ${l} in this graph`);let b=this.keepPredicate(t.haplotypes);if(b!==void 0&&!r.hasHaplotypeIndex)throw new I(c);let d=await U(r,y,f,g,{context:this.getConf("context"),snarls:t.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:t.signal,keep:b}).catch(w=>{throw fe(w,"the graph")});return typeof d=="string"?d:te(d,{start:f,end:g},t.walkRows)}async getReads(e,t={}){let a=await this.gaf(t);return a?a.readsOver(new Set(e),t):{records:[],total:0}}async laneHaplotypes(e,t){let a=N(this,e);return(await this.getHaplotypes(t)).filter(r=>F(r.prefix,a))}async anchorFeatures(e,t){let{db:a}=await this.graph(t),{assemblyName:r,refName:o,start:s,end:c}=e,p=N(this,t.targetAssemblyName),l=C(this),f=this.keepPredicate(t.haplotypes,p),g=await this.referenceQuery(o,t),y=this.getConf("nodeLimit");return(g?await B(`Reading graph ${o}:${s.toLocaleString()}-${c.toLocaleString()}`,t.statusCallback,()=>a.getAlignments({path:g,start:s,end:c,context:this.getConf("context"),haplotypes:"all",limit:y,signal:t.signal,keep:f}).catch(d=>{throw le(d,y,c-s)})):[]).flatMap(d=>{let w=d.resolved?Ne({alignment:d,assemblyName:r,refName:o,lane:O(l,u(d.name))}):void 0;return w===void 0?[]:[w]})}async pairFeatures(e,t,a){let{db:r}=await this.graph(a),{refName:o,start:s,end:c}=e,l=(await Promise.all(t.map(async m=>({pair:m,featureSide:await this.laneHaplotypes(m.queryAssemblyName,a),mateSide:await this.laneHaplotypes(m.targetAssemblyName,a)})))).filter(({featureSide:m,mateSide:h})=>m.length>0&&h.length>0),f=new Set(l.flatMap(({featureSide:m,mateSide:h})=>[...m,...h].map(u))),g=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),b=this.getConf("context"),d=(m,h)=>r.getSubgraphs({path:m,start:s,end:c,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:x=>f.has(u(x))}),w=async m=>{let h=await d(m,b).catch(S=>{throw le(S,y,c-s)}),x=Re(h,f),R=Math.ceil(x/2)+2e3;return x>0&&R>b?d(m,R).catch(S=>{if(S instanceof Q)return h;throw S}):h};return(g&&l.length>0?await B(oe(t),a.statusCallback,()=>w(g)):[]).flatMap(m=>l.flatMap(({pair:h,featureSide:x,mateSide:R})=>x.flatMap(S=>R.flatMap(de=>m.pairAlignments({target:S,query:de,bases:!1}).map(he=>Pe({pair:he,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(e,t={}){let a=me(e);return ee(async r=>{let{db:o,anchor:s,unreadableIndex:c}=await this.graph(t);if(!o.hasHaplotypeIndex)throw new I(c);if(a.assemblyName===s){let p=re(t),l=p.length>0?await this.pairFeatures(a,p,t):await this.anchorFeatures(a,t);for(let f of l)r.next(f)}r.complete()},t.signal)}};export{I as NoHaplotypeIndexError,ue as PairTargetError,T as default,Re as widestWalkGap};
2
+ //# sourceMappingURL=GbzBaseSyntenyAdapter-BVLBK4OO.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@11.7.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-FNDNSDKW.js", "../../src/GbzBaseSyntenyAdapter/companion.ts", "../../src/gaf/gafFile.ts", "../../src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts"],
3
+ "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@11.7.1/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-FNDNSDKW.js", "../../src/GbzBaseSyntenyAdapter/companion.ts", "../../src/gaf/gafFile.ts", "../../src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts"],
4
4
  "sourcesContent": ["import {\n GBZ_CUT_DEFAULTS,\n NoReferenceSampleError,\n aliasedSample,\n cutWindowGFA,\n haplotypeWanted,\n referencePathQuery,\n referenceSamplesOf\n} from \"./chunk-ZKSC7QVE.js\";\nimport {\n panSNSample\n} from \"./chunk-2JL2JVZ2.js\";\n\n// src/gbzCut.ts\nimport { GBZBase } from \"@gmod/gbz-base\";\nvar HPRC_GBZ = {\n db: \"https://s3-us-west-2.amazonaws.com/human-pangenomics/pangenomes/freeze/release2/minigraph-cactus/v2.1/hprc-v2.1-mc-grch38/hprc-v2.1-mc-grch38.gbz.db\",\n index: \"https://jbrowse.org/demos/hprc/hprc-v2.1-mc-grch38.haplotype-index.f3.db\"\n};\nfunction gbzLocations({ db, index }) {\n return db === \"hprc\" ? { db: HPRC_GBZ.db, index: index ?? HPRC_GBZ.index } : { db, index };\n}\nfunction haplotypeIndexBeside(db) {\n const GBZ_DB = /\\.gbz\\.db$/i;\n return GBZ_DB.test(db) ? db.replace(GBZ_DB, \".haplotype-index.db\") : void 0;\n}\nfunction parseRegion(text) {\n const m = /^\\s*(\\S+?):([\\d,]+)-([\\d,]+)\\s*$/.exec(text);\n if (!m) {\n throw new Error(\n `\"${text}\" is not a 0-based region like chr6:160,614,797-160,647,758`\n );\n }\n const n = (s) => Number(s.replaceAll(\",\", \"\"));\n const region = { refName: m[1], start: n(m[2]), end: n(m[3]) };\n if (region.end <= region.start) {\n throw new Error(`\"${text}\" ends at or before it starts`);\n }\n return region;\n}\nasync function openGbz(db, index) {\n const base = await GBZBase.open({ source: db, haplotypeIndex: index });\n return { base, referenceSamples: await referenceSamplesOf(base) };\n}\nfunction referenceSample(ref, samples) {\n if (ref) {\n return aliasedSample(panSNSample(ref), samples) ?? ref;\n }\n const first = samples[0];\n if (first === void 0) {\n throw new NoReferenceSampleError(\"\", samples);\n }\n return first;\n}\nasync function cutGbzRegion({ base, referenceSamples }, src, signal) {\n const region = parseRegion(src.region);\n const sample = referenceSample(src.referenceSample, referenceSamples);\n const query = await referencePathQuery(base, sample, region.refName);\n if (!query) {\n throw new Error(`${sample} has no indexed path named ${region.refName}`);\n }\n signal?.throwIfAborted();\n const wanted = src.haplotypes?.length ? src.haplotypes : void 0;\n const text = await cutWindowGFA(base, query, region.start, region.end, {\n context: src.context ?? GBZ_CUT_DEFAULTS.context,\n snarls: src.snarls ?? GBZ_CUT_DEFAULTS.snarls,\n limit: GBZ_CUT_DEFAULTS.limit,\n signal,\n keep: wanted ? (name) => haplotypeWanted(name, wanted) : void 0\n });\n return { text, region, sample };\n}\n\nexport {\n HPRC_GBZ,\n gbzLocations,\n haplotypeIndexBeside,\n parseRegion,\n openGbz,\n cutGbzRegion\n};\n", "import { haplotypeIndexBeside } from '@jbrowse/bandage-core/gbzCut'\nimport { openLocation } from '@jbrowse/core/util/io'\n\nimport { locationName, readsSiblings, renamed } from '../locationName'\n\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { FileLocation } from '@jbrowse/core/util/types'\n\nexport function siblingCompanion(gbzDb: FileLocation) {\n return readsSiblings(gbzDb) && haplotypeIndexBeside(locationName(gbzDb))\n ? renamed(gbzDb, name => haplotypeIndexBeside(name)!)\n : undefined\n}\n\n// 404 is a missing file, and so is 403 from a bucket that does not let a\n// reader list it; anything else leaves the file's presence unknown\nfunction isMissing(error: unknown) {\n return (\n error instanceof Error &&\n (/\\bHTTP 40[34]\\b/.test(error.message) ||\n (error as { code?: unknown }).code === 'ENOENT')\n )\n}\n\n// `unreadable` is why a companion that may be there could not be checked, such\n// as a network error, or a server that answers a missing file without CORS\nexport async function findCompanion(\n gbzDb: FileLocation,\n pluginManager?: PluginManager,\n): Promise<{ location?: FileLocation; unreadable?: string }> {\n const candidate = siblingCompanion(gbzDb)\n if (!candidate) {\n return {}\n }\n try {\n await openLocation(candidate, pluginManager).stat()\n return { location: candidate }\n } catch (error) {\n return isMissing(error) ? {} : { unreadable: String(error) }\n }\n}\n", "import { unzip } from '@gmod/bgzf-filehandle'\nimport { parseGaf, parseGafLine } from '@jbrowse/bandage-core/gaf/parseGaf'\nimport { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'\n\nimport type { TabixIndexedFile } from '@gmod/tabix'\nimport type { GafRecord } from '@jbrowse/bandage-core/gaf/parseGaf'\n\ninterface WholeFile {\n stat(): Promise<{ size: number }>\n readFile(opts?: { signal?: AbortSignal }): Promise<Uint8Array>\n}\n\nexport interface GafReads {\n records: GafRecord[]\n // reads over the nodes before sampling\n total: number\n}\n\n// The tube map lays reads out on the main thread at about 40 ms per thousand\nexport const MAX_READS = 5000\n\n// An unindexed GAF is read whole, once, into the worker\nconst MAX_UNINDEXED_BYTES = 50 * 2 ** 20\n\nexport class UnindexedGafTooLargeError extends Error {\n override name = 'UnindexedGafTooLargeError'\n\n constructor(size: number) {\n super(\n `this GAF is ${(size / 2 ** 20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`,\n )\n }\n}\n\n// Evenly spaced, so a pileup thins out rather than losing its right half\nfunction sample(records: GafRecord[], max: number) {\n if (records.length <= max) {\n return records\n }\n const stride = records.length / max\n return Array.from({ length: max }, (_, k) => records[Math.floor(k * stride)]!)\n}\n\nconst touches = (record: GafRecord, names: ReadonlySet<string>) =>\n record.path.some(step => names.has(step.name))\n\n// A GAF over a graph's segments: bgzipped and indexed with `tabix -p gaf`,\n// which keys each line by its lowest and highest node id and so needs numeric\n// segment names, or plain or gzipped and read whole.\nexport class GafFile {\n // Shared by every window, so the signal is cachedSetup's own, which aborts\n // once no caller is left waiting\n private whole = cachedSetup({\n setup: async ({ signal }) => {\n const { size } = await this.file.stat()\n if (size > MAX_UNINDEXED_BYTES) {\n throw new UnindexedGafTooLargeError(size)\n }\n const bytes = await this.file.readFile({ signal })\n const text = new TextDecoder().decode(\n bytes[0] === 0x1f && bytes[1] === 0x8b ? await unzip(bytes) : bytes,\n )\n return parseGaf(text)\n },\n })\n\n constructor(\n private file: WholeFile,\n private tabix?: TabixIndexedFile,\n ) {}\n\n private async readIndexed(\n tabix: TabixIndexedFile,\n names: ReadonlySet<string>,\n signal?: AbortSignal,\n ) {\n let lo = Infinity\n let hi = -Infinity\n for (const name of names) {\n const id = Number(name)\n if (Number.isInteger(id)) {\n lo = Math.min(lo, id)\n hi = Math.max(hi, id)\n }\n }\n const records: GafRecord[] = []\n if (lo <= hi) {\n // a GAF index ignores the refName, and getLines keeps a read whose node\n // ids span min..max when min < end && max >= start, hence hi + 1\n await tabix.getLines('{node}', lo, hi + 1, {\n signal,\n lineCallback: line => {\n const record = parseGafLine(line)\n if (record && touches(record, names)) {\n records.push(record)\n }\n },\n })\n }\n return records\n }\n\n async readsOver(\n names: ReadonlySet<string>,\n { signal }: { signal?: AbortSignal } = {},\n ): Promise<GafReads> {\n const records = this.tabix\n ? await this.readIndexed(this.tabix, names, signal)\n : (await this.whole({ signal })).filter(r => touches(r, names))\n return { records: sample(records, MAX_READS), total: records.length }\n }\n}\n", "import { GBZBase, SubgraphLimitError } from '@gmod/gbz-base'\nimport {\n NodeLimitError,\n cutWindowTables,\n haplotypePrefix,\n haplotypeWanted,\n nodeLimitError,\n referencePathQuery,\n referenceSamplesOf,\n resolveReferenceSample,\n} from '@jbrowse/bandage-core/gbzWindow'\nimport {\n assemblyByPanSNPrefix,\n panSNMatchesPrefix,\n resolvePanSNPrefix,\n} from '@jbrowse/bandage-core/pansn'\nimport { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { getBpDisplayStr, updateStatus } from '@jbrowse/core/util'\nimport { openLocation } from '@jbrowse/core/util/io'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\n\nimport { findCompanion } from './companion.ts'\nimport { walkCutFor } from '../RgfaTabixAdapter/walkCut.ts'\nimport { GafFile } from '../gaf/gafFile.ts'\nimport { locationIsSet } from '../locationName.ts'\nimport { openTabixSlot } from '../panSNTabix.ts'\nimport { ComparativeAdapterBase } from '../synteny/ComparativeAdapterBase.ts'\nimport SyntenyFeature from '../synteny/SyntenyFeature.ts'\nimport {\n laneAssemblyName,\n lanePairsStatus,\n requestedPairs,\n} from '../synteny/lanePairs.ts'\nimport { laneZoomNotice } from '../synteny/laneZoomNotice.ts'\nimport { matchFeature } from '../synteny/matchFeature.ts'\n\nimport type { GbzBaseSyntenyAdapterConfig } from './configSchema.ts'\nimport type { SubgraphAdapterOptions } from '../GetSubgraph.ts'\nimport type { GafReads } from '../gaf/gafFile.ts'\nimport type { LaneFeatureOptions, LanePair } from '../synteny/lanePairs.ts'\nimport type {\n HaplotypeAlignment,\n HaplotypeRef,\n PairAlignment,\n PathName,\n PathQuery,\n Subgraph,\n} from '@gmod/gbz-base'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { Feature, SimpleFeatureSerialized } from '@jbrowse/core/util'\nimport type { FileLocation, Region } from '@jbrowse/core/util/types'\n\nexport class NoHaplotypeIndexError extends Error {\n override name = 'NoHaplotypeIndexError'\n\n constructor(unreadable?: string) {\n super(\n unreadable === undefined\n ? 'no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation'\n : `the haplotype index beside the graph database could not be checked (${unreadable}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`,\n )\n }\n}\n\ninterface GbzHaplotype {\n prefix: string\n sample: string\n haplotype: number\n contigs: string[]\n isReference: boolean\n}\n\n/**\n * One lane the header declares, in the shape MultiWaySyntenyDisplay's lane\n * picker reads: `name` is the lane's assembly name, the same string the\n * fetched features' mates carry, `label` its PanSN prefix and `group` its\n * sample, so a diploid sample's two lanes sit together\n */\ninterface GbzHeaderLane {\n name: string\n label: string\n group: string\n}\n\nexport { PairTargetError } from '../synteny/lanePairs.ts'\n\nclass HaplotypeWindowError extends Error {\n override name = 'HaplotypeWindowError'\n\n constructor(assemblyName: string, anchor: string) {\n super(\n `the graph is cut on its reference, ${anchor}; a window on ${assemblyName} has no reference coordinates to cut at. Open the graph from a ${anchor} view, and find this haplotype's lane there`,\n )\n }\n}\n\ntype ResolvedAlignment = Extract<HaplotypeAlignment, { resolved: true }>\n\n/**\n * The id of one haplotype fragment: the walk's GBWT position at its first node\n * in the window, which is a property of the graph, so the same fragment gets\n * the same id on a refetch of the same window and the display's hover and\n * selection survive it. `clipToRegion` suffixes the window.\n */\nfunction fragmentId(name: PathName, alignment: ResolvedAlignment) {\n return `${haplotypePrefix(name)}#${name.contig}@${alignment.start.node}.${alignment.start.offset}`\n}\n\nfunction fragmentFeature({\n alignment,\n assemblyName,\n refName,\n lane,\n}: {\n alignment: ResolvedAlignment\n assemblyName: string\n refName: string\n lane: string\n}) {\n const { refStart, refEnd, strand, cigar } = alignment\n if (refEnd <= refStart) {\n return undefined\n } else {\n const { name, hapStart, hapEnd } = alignment\n const id = fragmentId(name, alignment)\n const data: SimpleFeatureSerialized = {\n uniqueId: id,\n assemblyName,\n refName,\n start: refStart,\n end: refEnd,\n type: 'match',\n strand: strand === '-' ? -1 : 1,\n CIGAR: cigar,\n syntenyId: id,\n mate: {\n refName: name.contig,\n start: hapStart,\n end: hapEnd,\n assemblyName: lane,\n },\n }\n return new SyntenyFeature(data)\n }\n}\n\n// gbz-base writes the CIGAR along the target, which is the side a JBrowse\n// feature is, so it passes through unchanged\nfunction pairFeature({\n pair,\n lane,\n mateLane,\n}: {\n pair: PairAlignment\n lane: string\n mateLane: string\n}) {\n return matchFeature({\n target: {\n name: `${haplotypePrefix(pair.target)}#${pair.target.contig}`,\n assemblyName: lane,\n refName: pair.target.contig,\n start: pair.targetStart,\n end: pair.targetEnd,\n },\n query: {\n name: `${haplotypePrefix(pair.query)}#${pair.query.contig}`,\n assemblyName: mateLane,\n refName: pair.query.contig,\n start: pair.queryStart,\n end: pair.queryEnd,\n },\n strand: pair.strand,\n cigar: pair.cigar,\n matches: pair.matches,\n columns: pair.columns,\n })\n}\n\n// The longest detour a pair cut widens its context to take in\nconst BRIDGE_MAX_BP = 120_000\n\n/**\n * The widest gap, up to `BRIDGE_MAX_BP`, between two pieces of one kept walk:\n * a haplotype that left the cut's nodes for sequence the reference lacks and\n * came back. Two kept haplotypes that share that sequence only align across it\n * once its nodes are in the cut.\n */\nexport function widestWalkGap(subgraphs: Subgraph[], kept: Set<string>) {\n const byPath = new Map<string, [number, number][]>()\n for (const subgraph of subgraphs) {\n for (const { name, start, end } of subgraph.walkSpans()) {\n const prefix = haplotypePrefix(name)\n if (kept.has(prefix)) {\n const key = `${prefix}#${name.contig}`\n const spans = byPath.get(key)\n if (spans) {\n spans.push([start, end])\n } else {\n byPath.set(key, [[start, end]])\n }\n }\n }\n }\n let widest = 0\n for (const spans of byPath.values()) {\n spans.sort((a, b) => a[0] - b[0])\n for (let i = 1; i < spans.length; i++) {\n const gap = spans[i]![0] - spans[i - 1]![1]\n if (gap > 0 && gap <= BRIDGE_MAX_BP) {\n widest = Math.max(widest, gap)\n }\n }\n }\n return widest\n}\n\n// A window past the node limit fails as a zoom-in notice naming a span that\n// fits\nfunction zoomInNotice(error: unknown, what: string) {\n if (error instanceof NodeLimitError) {\n error.message = `Zoom in to about ${getBpDisplayStr(error.fitsBp)} to see ${what}`\n }\n return error\n}\n\nconst laneLimitNotice = (error: unknown, nodeLimit: number, windowBp: number) =>\n laneZoomNotice(\n zoomInNotice(nodeLimitError(error, nodeLimit, windowBp) ?? error, 'lanes'),\n windowBp,\n )\n\n// gbz-base reads whole bp; a view asks at fractional ones\nconst wholeBp = (region: Region) => ({\n ...region,\n start: Math.floor(region.start),\n end: Math.ceil(region.end),\n})\n\nexport default class GbzBaseSyntenyAdapter extends ComparativeAdapterBase<GbzBaseSyntenyAdapterConfig> {\n private graph = cachedSetup({\n label: 'Opening pangenome database',\n setup: async () => {\n const gbzDb: FileLocation = this.getConf('gbzDbLocation')\n const configured: FileLocation = this.getConf('haplotypeIndexLocation')\n const companion = locationIsSet(configured)\n ? { location: configured }\n : await findCompanion(gbzDb, this.pluginManager)\n const indexLocation = companion.location\n const db = await GBZBase.open({\n source: openLocation(gbzDb, this.pluginManager),\n haplotypeIndex: indexLocation\n ? openLocation(indexLocation, this.pluginManager)\n : undefined,\n })\n const anchor = this.getConf('assemblyNames')[0]\n if (anchor === undefined) {\n throw new Error(\n 'GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as',\n )\n }\n const referenceSamples = await referenceSamplesOf(db)\n const referenceSample = resolveReferenceSample({\n configured: this.getConf('referenceSample'),\n anchorPrefix: resolvePanSNPrefix(this, anchor),\n referenceSamples,\n })\n return {\n db,\n anchor,\n referenceSample,\n referenceSamples,\n unreadableIndex: companion.unreadable,\n }\n },\n })\n\n /**\n * The indexed reference path a window on `refName` resolves against, or\n * undefined when the reference sample has no indexed path by that contig.\n */\n private async referenceQuery(\n refName: string,\n opts: BaseOptions,\n ): Promise<PathQuery | undefined> {\n const { db, referenceSample } = await this.graph(opts)\n return referencePathQuery(db, referenceSample, refName)\n }\n\n /**\n * Every haplotype the graph carries a walk for, `sample#haplotype` with its\n * contigs, from the Paths scan the adapter already makes; the lane picker's\n * source list. Reference samples are included and flagged.\n */\n async getHaplotypes(opts: BaseOptions = {}): Promise<GbzHaplotype[]> {\n const { db, referenceSamples } = await this.graph(opts)\n const byPrefix = new Map<string, GbzHaplotype>()\n for (const path of await db.paths()) {\n const prefix = haplotypePrefix(path.name)\n const entry = byPrefix.get(prefix)\n if (entry) {\n if (!entry.contigs.includes(path.name.contig)) {\n entry.contigs.push(path.name.contig)\n }\n } else {\n byPrefix.set(prefix, {\n prefix,\n sample: path.name.sample,\n haplotype: path.name.haplotype,\n contigs: [path.name.contig],\n isReference: referenceSamples.includes(path.name.sample),\n })\n }\n }\n return [...byPrefix.values()]\n }\n\n /**\n * `lanes` is every haplotype but the reference sample's own, which is the\n * anchor rather than a lane, declared up front so the display can offer the\n * whole graph's haplotypes before a fetch has placed any of them.\n */\n async getHeader(opts: BaseOptions = {}) {\n const { anchor, referenceSample } = await this.graph(opts)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const lanes: GbzHeaderLane[] = []\n for (const haplotype of await this.getHaplotypes(opts)) {\n if (haplotype.sample !== referenceSample) {\n lanes.push({\n name: laneAssemblyName(asmByPrefix, haplotype.prefix),\n label: haplotype.prefix,\n group: haplotype.sample,\n })\n }\n }\n return {\n hasCoarseTier: false,\n anchorAssemblyName: anchor,\n lanes,\n }\n }\n\n async getRefNames(opts: BaseOptions = {}) {\n const { db, anchor, referenceSample } = await this.graph(opts)\n const { assemblyName } = opts\n const prefix =\n assemblyName === anchor\n ? undefined\n : resolvePanSNPrefix(this, assemblyName)\n const contigs = (await db.paths())\n .filter(path =>\n assemblyName === anchor\n ? path.isIndexed && path.name.sample === referenceSample\n : panSNMatchesPrefix(haplotypePrefix(path.name), prefix),\n )\n .map(path => path.name.contig)\n return [...new Set(contigs)]\n }\n\n /**\n * The predicate gbz-base builds a window for, from the lanes a fetch asks\n * for. With a companion whose stray rows cover the window gbz-base walks\n * only the wanted haplotypes; otherwise it names every walk and keeps the\n * ones the predicate accepts, and throws rather than guess when a walk has\n * no name. Either way a cut holds those walks, the reference, and the nodes\n * they visit. Undefined when every haplotype is wanted.\n */\n //\n // `targetPrefix` is a pairwise view's one lane, and it belongs in here: left\n // to filter what came back, it handed gbz-base no predicate, and every\n // haplotype in the graph was walked for one to be kept.\n private keepPredicate(\n haplotypes: string[] | undefined,\n targetPrefix?: string,\n ) {\n const wantedPrefixes =\n haplotypes === undefined || haplotypes.length === 0\n ? undefined\n : haplotypes.map(lane => resolvePanSNPrefix(this, lane))\n return wantedPrefixes === undefined && targetPrefix === undefined\n ? undefined\n : (name: PathName) =>\n haplotypeWanted(name, wantedPrefixes) &&\n (targetPrefix === undefined ||\n panSNMatchesPrefix(haplotypePrefix(name), targetPrefix))\n }\n\n /**\n * The graph view's cut of the window, as tables: the reference walk, every\n * top-level snarl contained in it, and one walk per haplotype, PanSN-named\n * when the database (or its companion) carries the haplotype index and\n * `unknown#N` otherwise. The reference walk is the first, which is the one\n * the view anchors on by default. With `haplotypes` the walks are that\n * set's and the nodes those walks visit, the reference walk kept. With\n * `walkRows` the rows' runs come along, as on a walk-file cut.\n *\n * Only a window on the anchor can be cut: a haplotype lane's coordinates\n * are its own contig's, and the graph is indexed for random access on the\n * reference sample's paths alone.\n */\n async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {\n const { signal } = opts\n const { db, anchor, referenceSample, unreadableIndex } = await this.graph({\n signal,\n })\n const { assemblyName, refName, start, end } = wholeBp(region)\n if (assemblyName !== anchor) {\n throw new HaplotypeWindowError(assemblyName, anchor)\n }\n const query = await this.referenceQuery(refName, { signal })\n if (!query) {\n throw new Error(\n `${referenceSample} has no indexed path ${refName} in this graph`,\n )\n }\n const keep = this.keepPredicate(opts.haplotypes)\n if (keep !== undefined && !db.hasHaplotypeIndex) {\n throw new NoHaplotypeIndexError(unreadableIndex)\n }\n const cut = await cutWindowTables(db, query, start, end, {\n context: this.getConf('context'),\n snarls: opts.snarls ?? this.getConf('subgraphSnarls'),\n limit: this.getConf('nodeLimit'),\n signal: opts.signal,\n keep,\n }).catch((error: unknown) => {\n throw zoomInNotice(error, 'the graph')\n })\n return typeof cut === 'string'\n ? cut\n : walkCutFor(cut, { start, end }, opts.walkRows)\n }\n\n private gaf = cachedSetup({\n label: 'Opening reads',\n setup: async () => {\n const location: FileLocation = this.getConf('readsLocation')\n const index: FileLocation = this.getConf(['readsIndex', 'location'])\n return locationIsSet(location)\n ? new GafFile(\n openLocation(location, this.pluginManager),\n locationIsSet(index)\n ? openTabixSlot(this, ['readsLocation'], ['readsIndex'])\n : undefined,\n )\n : undefined\n },\n })\n\n /**\n * The reads over a cut's segments, from `readsLocation`, sampled down to\n * what the tube map lays out at interactive speed\n */\n async getReads(\n nodeNames: string[],\n opts: BaseOptions = {},\n ): Promise<GafReads> {\n const gaf = await this.gaf(opts)\n return gaf\n ? gaf.readsOver(new Set(nodeNames), opts)\n : { records: [], total: 0 }\n }\n\n private async laneHaplotypes(\n assemblyName: string,\n opts: BaseOptions,\n ): Promise<HaplotypeRef[]> {\n const prefix = resolvePanSNPrefix(this, assemblyName)\n return (await this.getHaplotypes(opts)).filter(haplotype =>\n panSNMatchesPrefix(haplotype.prefix, prefix),\n )\n }\n\n private async anchorFeatures(region: Region, opts: LaneFeatureOptions) {\n const { db } = await this.graph(opts)\n const { assemblyName, refName, start, end } = region\n const targetPrefix = resolvePanSNPrefix(this, opts.targetAssemblyName)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const keep = this.keepPredicate(opts.haplotypes, targetPrefix)\n const query = await this.referenceQuery(refName, opts)\n const nodeLimit: number = this.getConf('nodeLimit')\n const alignments = query\n ? await updateStatus(\n `Reading graph ${refName}:${start.toLocaleString()}-${end.toLocaleString()}`,\n opts.statusCallback,\n () =>\n db\n .getAlignments({\n path: query,\n start,\n end,\n context: this.getConf('context'),\n haplotypes: 'all',\n limit: nodeLimit,\n signal: opts.signal,\n keep,\n })\n .catch((error: unknown) => {\n throw laneLimitNotice(error, nodeLimit, end - start)\n }),\n )\n : []\n return alignments.flatMap(alignment => {\n const feature = alignment.resolved\n ? fragmentFeature({\n alignment,\n assemblyName,\n refName,\n lane: laneAssemblyName(\n asmByPrefix,\n haplotypePrefix(alignment.name),\n ),\n })\n : undefined\n return feature === undefined ? [] : [feature]\n })\n }\n\n /**\n * Each pair's two lanes cut out of the anchor window alone, all pairs in one\n * cut, and each walk of a pair's query lane aligned to each walk of its\n * target lane on the nodes both visit, with no base compared. A pair's\n * records sit on its query lane's contigs, the lane the display draws on top.\n *\n * Whether the index has anchor rows changes only how fast gbz-base finds\n * the walks: both routes cut the same pieces.\n */\n private async pairFeatures(\n region: Region,\n pairs: LanePair[],\n opts: LaneFeatureOptions,\n ) {\n const { db } = await this.graph(opts)\n const { refName, start, end } = region\n const sides = await Promise.all(\n pairs.map(async pair => ({\n pair,\n featureSide: await this.laneHaplotypes(pair.queryAssemblyName, opts),\n mateSide: await this.laneHaplotypes(pair.targetAssemblyName, opts),\n })),\n )\n const answerable = sides.filter(\n ({ featureSide, mateSide }) =>\n featureSide.length > 0 && mateSide.length > 0,\n )\n const kept = new Set(\n answerable.flatMap(({ featureSide, mateSide }) =>\n [...featureSide, ...mateSide].map(haplotypePrefix),\n ),\n )\n const query = await this.referenceQuery(refName, opts)\n const nodeLimit: number = this.getConf('nodeLimit')\n const baseContext: number = this.getConf('context')\n const cut = (path: PathQuery, context: number) =>\n db.getSubgraphs({\n path,\n start,\n end,\n context,\n snarls: this.getConf('subgraphSnarls'),\n haplotypes: 'all',\n limit: nodeLimit,\n signal: opts.signal,\n keep: name => kept.has(haplotypePrefix(name)),\n })\n // a cut past the node limit for the wider context keeps the first one\n const bridged = async (path: PathQuery) => {\n const subgraphs = await cut(path, baseContext).catch((error: unknown) => {\n throw laneLimitNotice(error, nodeLimit, end - start)\n })\n const gap = widestWalkGap(subgraphs, kept)\n const context = Math.ceil(gap / 2) + 2000\n return gap > 0 && context > baseContext\n ? cut(path, context).catch((error: unknown) => {\n if (error instanceof SubgraphLimitError) {\n return subgraphs\n }\n throw error\n })\n : subgraphs\n }\n const subgraphs =\n query && answerable.length > 0\n ? await updateStatus(lanePairsStatus(pairs), opts.statusCallback, () =>\n bridged(query),\n )\n : []\n return subgraphs.flatMap(subgraph =>\n answerable.flatMap(({ pair, featureSide, mateSide }) =>\n featureSide.flatMap(target =>\n mateSide.flatMap(mate =>\n subgraph\n .pairAlignments({ target, query: mate, bases: false })\n .map(alignment =>\n pairFeature({\n pair: alignment,\n lane: pair.queryAssemblyName,\n mateLane: pair.targetAssemblyName,\n }),\n ),\n ),\n ),\n ),\n )\n }\n\n getFeatures(asked: Region, opts: LaneFeatureOptions = {}) {\n const region = wholeBp(asked)\n return ObservableCreate<Feature>(async observer => {\n const { db, anchor, unreadableIndex } = await this.graph(opts)\n if (!db.hasHaplotypeIndex) {\n throw new NoHaplotypeIndexError(unreadableIndex)\n }\n // the graph is indexed on its reference alone, so a window on a\n // haplotype lane has no answer: a lane pair is read inside the anchor's\n if (region.assemblyName === anchor) {\n const pairs = requestedPairs(opts)\n const features =\n pairs.length > 0\n ? await this.pairFeatures(region, pairs, opts)\n : await this.anchorFeatures(region, opts)\n for (const feature of features) {\n observer.next(feature)\n }\n }\n observer.complete()\n }, opts.signal)\n }\n}\n"],
5
5
  "mappings": "g2BAsBA,SAASA,EAAqBC,EAAI,CAChC,IAAMC,EAAS,cACf,OAAOA,EAAO,KAAKD,CAAE,EAAIA,EAAG,QAAQC,EAAQ,qBAAqB,EAAI,MACvE,CCjBO,SAASC,GAAiBC,EAAqB,CACpD,OAAOC,E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ACHc,GAAY,CACV,KAAMd,GACN,KAAMe,EAAK,kBACX,SAAUA,EAAK,kBACjB,CAAC,CACH,CACJ,CACF,CACF,CACF,CACF,CAEA,YAAY0F,EAAetC,EAA2B,CAAC,EAAG,CACxD,IAAMtB,EAASD,GAAQ6D,CAAK,EAC5B,OAAOC,GAA0B,MAAMC,GAAY,CACjD,GAAM,CAAE,GAAApD,EAAI,OAAA1D,EAAQ,gBAAAuF,CAAgB,EAAI,MAAM,KAAK,MAAMjB,CAAI,EAC7D,GAAI,CAACZ,EAAG,kBACN,MAAM,IAAI9D,EAAsB2F,CAAe,EAIjD,GAAIvC,EAAO,eAAiBhD,EAAQ,CAClC,IAAMiG,EAAQc,GAAezC,CAAI,EAC3B0C,EACJf,EAAM,OAAS,EACX,MAAM,KAAK,aAAajD,EAAQiD,EAAO3B,CAAI,EAC3C,MAAM,KAAK,eAAetB,EAAQsB,CAAI,EAC5C,QAAW0B,KAAWgB,EACpBF,EAAS,KAAKd,CAAO,CAEzB,CACAc,EAAS,SAAS,CACpB,EAAGxC,EAAK,MAAM,CAChB,CACF",
6
6
  "names": ["haplotypeIndexBeside", "db", "GBZ_DB", "siblingCompanion", "gbzDb", "readsSiblings", "haplotypeIndexBeside", "locationName", "renamed", "name", "isMissing", "error", "findCompanion", "pluginManager", "candidate", "openLocation", "MAX_READS", "MAX_UNINDEXED_BYTES", "UnindexedGafTooLargeError", "size", "sample", "records", "max", "stride", "_", "k", "touches", "record", "names", "step", "GafFile", "file", "tabix", "cachedSetup", "signal", "bytes", "text", "unzip", "parseGaf", "lo", "hi", "name", "id", "line", "parseGafLine", "r", "NoHaplotypeIndexError", "unreadable", "HaplotypeWindowError", "assemblyName", "anchor", "fragmentId", "name", "alignment", "haplotypePrefix", "fragmentFeature", "refName", "lane", "refStart", "refEnd", "strand", "cigar", "hapStart", "hapEnd", "id", "data", "SyntenyFeature", "pairFeature", "pair", "mateLane", "matchFeature", "BRIDGE_MAX_BP", "widestWalkGap", "subgraphs", "kept", "byPath", "subgraph", "start", "end", "prefix", "key", "spans", "widest", "a", "b", "i", "gap", "zoomInNotice", "error", "what", "NodeLimitError", "getBpDisplayStr", "laneLimitNotice", "nodeLimit", "windowBp", "laneZoomNotice", "nodeLimitError", "wholeBp", "region", "GbzBaseSyntenyAdapter", "ComparativeAdapterBase", "cachedSetup", "gbzDb", "configured", "companion", "locationIsSet", "findCompanion", "indexLocation", "db", "GBZBase", "openLocation", "referenceSamples", "referenceSamplesOf", "referenceSample", "resolveReferenceSample", "resolvePanSNPrefix", "location", "index", "GafFile", "openTabixSlot", "opts", "referencePathQuery", "byPrefix", "path", "entry", "asmByPrefix", "assemblyByPanSNPrefix", "lanes", "haplotype", "laneAssemblyName", "contigs", "panSNMatchesPrefix", "haplotypes", "targetPrefix", "wantedPrefixes", "haplotypeWanted", "signal", "unreadableIndex", "query", "keep", "cut", "cutWindowTables", "walkCutFor", "nodeNames", "gaf", "updateStatus", "feature", "pairs", "answerable", "featureSide", "mateSide", "baseContext", "context", "bridged", "SubgraphLimitError", "lanePairsStatus", "target", "mate", "asked", "ObservableCreate", "observer", "requestedPairs", "features"]
@@ -1,4 +1,4 @@
1
- import{a as C}from"./chunk-2BTNRN57.js";import"./chunk-JXOLZ5IZ.js";import"./chunk-XLSVRKFJ.js";import"./chunk-XT4U7I3D.js";import{n as d}from"./chunk-4XM5OBD5.js";import"./chunk-ADZBAET3.js";import"./chunk-MLVBPMBU.js";import"./chunk-UW7INEQF.js";import"./chunk-D5PRXUSS.js";import"./chunk-LTN6XZR5.js";import"./chunk-2Q4D5RHL.js";import"./chunk-SI64QXFH.js";import"./chunk-YBLNN5FU.js";import"./chunk-YBZA7LPQ.js";import"./chunk-4AAW5P6N.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-VIVPTP5Z.js";import"./chunk-IKJZPPOA.js";import"./chunk-NDRLCGPC.js";import"./chunk-TENPGIPX.js";import{h as L}from"./chunk-YU7T5WOQ.js";import{A as l,F as G,H as p,e as s,j as v,o as n,x as y}from"./chunk-UGCNPRKC.js";import{a as h,b as e,c as r,d as i}from"./chunk-JMBDTNUR.js";var N=d()({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}}),S=i(function({model:a}){let{classes:t}=N();return!a.error&&!a.loadCanceled?r(l,{className:t.paper,"data-testid":"graph-genome-loading",children:[r("div",{className:t.row,children:[e(v,{variant:"h6",message:a.statusMessage||void 0}),a.canCancelLoad?e(n,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{a.cancelLoad()},children:"Cancel"}):null]}),e(y,{variant:"indeterminate"})]}):a.error?e(l,{className:t.paper,children:e(s,{error:a.error,onReset:()=>{a.retryLoad()}})}):e(l,{className:t.paper,"data-testid":"graph-genome-load-canceled",children:r("div",{className:t.row,children:[e(p,{variant:"h6",children:"Loading canceled"}),e(n,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{a.retryLoad()},children:"Retry"})]})})}),f=S;var T=`H VN:Z:1.0
1
+ import{a as C}from"./chunk-62AHPP6H.js";import"./chunk-WY5W5X62.js";import"./chunk-WJGCVNGH.js";import"./chunk-FWVXBJ64.js";import{n as d}from"./chunk-ZG2CQXOW.js";import"./chunk-55DIX25J.js";import"./chunk-S75MFZDE.js";import"./chunk-2XZYJLCE.js";import"./chunk-Q3BXNKEL.js";import"./chunk-JSRGX4TC.js";import"./chunk-DXNE2CFX.js";import"./chunk-LFTZNUXB.js";import"./chunk-YBLNN5FU.js";import"./chunk-MEMUEG5Z.js";import"./chunk-U5PIXAF2.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-RCXOOBLX.js";import"./chunk-IKJZPPOA.js";import"./chunk-NDRLCGPC.js";import"./chunk-TENPGIPX.js";import{h as L}from"./chunk-YU7T5WOQ.js";import{A as l,F as G,H as p,e as s,j as v,o as n,x as y}from"./chunk-UGCNPRKC.js";import{a as h,b as e,c as r,d as i}from"./chunk-JMBDTNUR.js";var N=d()({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}}),S=i(function({model:a}){let{classes:t}=N();return!a.error&&!a.loadCanceled?r(l,{className:t.paper,"data-testid":"graph-genome-loading",children:[r("div",{className:t.row,children:[e(v,{variant:"h6",message:a.statusMessage||void 0}),a.canCancelLoad?e(n,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{a.cancelLoad()},children:"Cancel"}):null]}),e(y,{variant:"indeterminate"})]}):a.error?e(l,{className:t.paper,children:e(s,{error:a.error,onReset:()=>{a.retryLoad()}})}):e(l,{className:t.paper,"data-testid":"graph-genome-load-canceled",children:r("div",{className:t.row,children:[e(p,{variant:"h6",children:"Loading canceled"}),e(n,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{a.retryLoad()},children:"Retry"})]})})}),f=S;var T=`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`,E=d()({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"}}),F=i(function({model:a}){let{classes:t}=E(),[m,w]=L("");function u(){let o=m.trim();o&&a.openGfaLocation({uri:o,locationType:"UriLocation"})}function M(o){let c=o.target.files?.[0];o.target.value="",c&&a.loadGFAFile(c,c.name)}return r(l,{className:t.paper,children:[e("div",{className:t.header,children:e(p,{variant:"h6",children:"Load a GFA graph"})}),r("div",{className:t.column,children:[r("div",{className:t.rowCenter,children:[r(n,{variant:"outlined",component:"label",size:"small",children:["Choose file",e("input",{type:"file",accept:".gfa,.gfa1,.gfa2,.gz",hidden:!0,onChange:o=>{M(o)}})]}),e(p,{variant:"caption",color:"text.secondary",children:"Whole-file GFA; best for small/medium graphs."})]}),r("div",{className:t.rowEnd,children:[e(G,{size:"small",label:"URL",placeholder:"https://example.com/graph.gfa",value:m,onChange:o=>{w(o.target.value)},onKeyDown:o=>{o.key==="Enter"&&u()},className:t.flex1}),e(n,{variant:"contained",onClick:()=>{u()},disabled:!m.trim(),children:"Open"})]})]}),e("div",{className:t.footer,children:e(n,{size:"small",onClick:()=>{a.loadGFA(T,"Example graph")},children:"Load 4-node example"})}),a.error?e(s,{error:a.error}):null]})}),x=F;var B=i(function({model:a}){return a.hasGraph?e(C,{model:a}):a.canRetryLoad?e(f,{model:a}):r(h,{children:[a.isLoading?e(f,{model:a}):null,e("div",{hidden:a.isLoading,children:e(x,{model:a})})]})}),q=B;export{q as default};
10
- //# sourceMappingURL=GraphGenomeView-52OPGZER.js.map
10
+ //# sourceMappingURL=GraphGenomeView-UCOAMRF7.js.map
@@ -1,6 +1,6 @@
1
- import{a as G,b as L}from"./chunk-JXOLZ5IZ.js";import{b as v,c as x,n as d}from"./chunk-4XM5OBD5.js";import"./chunk-UW7INEQF.js";import"./chunk-D5PRXUSS.js";import"./chunk-4AAW5P6N.js";import"./chunk-MVVXRZXV.js";import"./chunk-VIVPTP5Z.js";import"./chunk-IKJZPPOA.js";import{g,h}from"./chunk-YU7T5WOQ.js";import{F as m,H as u,n as C}from"./chunk-UGCNPRKC.js";import{b as r,c as i,d as c}from"./chunk-JMBDTNUR.js";var P=d()({section:{marginBottom:24}}),T=[{value:"0",label:"None"},{value:"1",label:"1 hop"},{value:"2",label:"2 hops"}],w=c(function({model:t}){let{classes:l}=P(),o=t.sourceAdapter;return o?.type==="RgfaTabixAdapter"&&!v(o)?i("div",{className:l.section,children:[r(G,{label:"Graph context",sx:{minWidth:200},value:String(t.subgraphContext),options:T,testId:"graph-context-select",onChange:a=>{t.setSubgraphContext(Number(a)),t.recut()}}),r(u,{variant:"caption",component:"div",color:"text.secondary",children:"How far the cut follows links out of the region. At none, a detour that leaves the window draws as two stubs. No effect on gfa-to-tabix's default anchored index."})]}):null}),k=w;var F=d()({section:{marginBottom:24}});function M(n){return n.split(/[\s,]+/).filter(t=>t!=="")}var I=c(function({model:t}){let[l,o]=h(t.cutHaplotypes?.join(", ")??""),a=()=>{let e=M(l);e.join(`
1
+ import{a as G,b as L}from"./chunk-WY5W5X62.js";import{b as v,c as x,n as d}from"./chunk-ZG2CQXOW.js";import"./chunk-2XZYJLCE.js";import"./chunk-Q3BXNKEL.js";import"./chunk-U5PIXAF2.js";import"./chunk-MVVXRZXV.js";import"./chunk-RCXOOBLX.js";import"./chunk-IKJZPPOA.js";import{g,h}from"./chunk-YU7T5WOQ.js";import{F as m,H as u,n as C}from"./chunk-UGCNPRKC.js";import{b as r,c as i,d as c}from"./chunk-JMBDTNUR.js";var P=d()({section:{marginBottom:24}}),T=[{value:"0",label:"None"},{value:"1",label:"1 hop"},{value:"2",label:"2 hops"}],w=c(function({model:t}){let{classes:l}=P(),o=t.sourceAdapter;return o?.type==="RgfaTabixAdapter"&&!v(o)?i("div",{className:l.section,children:[r(G,{label:"Graph context",sx:{minWidth:200},value:String(t.subgraphContext),options:T,testId:"graph-context-select",onChange:a=>{t.setSubgraphContext(Number(a)),t.recut()}}),r(u,{variant:"caption",component:"div",color:"text.secondary",children:"How far the cut follows links out of the region. At none, a detour that leaves the window draws as two stubs. No effect on gfa-to-tabix's default anchored index."})]}):null}),k=w;var F=d()({section:{marginBottom:24}});function M(n){return n.split(/[\s,]+/).filter(t=>t!=="")}var I=c(function({model:t}){let[l,o]=h(t.cutHaplotypes?.join(", ")??""),a=()=>{let e=M(l);e.join(`
2
2
  `)===(t.cutHaplotypes??[]).join(`
3
3
  `)||(t.setSubgraphHaplotypes(e),t.recut())};return r(m,{fullWidth:!0,label:"Haplotypes",placeholder:"every haplotype",value:l,slotProps:{htmlInput:{"data-testid":"graph-haplotypes-field"}},onChange:e=>{o(e.target.value)},onBlur:()=>{a()},onKeyDown:e=>{e.key==="Enter"&&a()}})}),A=c(function({model:t,names:l}){let[o,a]=h(t.cutHaplotypes??[]),e=g(o),f=g(""),[b,S]=h(!1),H=p=>{p.join(`
4
4
  `)!==(t.cutHaplotypes??[]).join(`
5
5
  `)&&(t.setSubgraphHaplotypes(p),t.recut())};return r(C,{multiple:!0,freeSolo:!0,disableCloseOnSelect:!0,options:l,value:o,open:b,onOpen:()=>{S(!0)},onInputChange:(p,s)=>{f.current=s},onClose:(p,s)=>{S(!1);let y=f.current.trim();s==="blur"&&y&&!e.current.includes(y)&&(e.current=[...e.current,y],a(e.current)),H(e.current)},onChange:(p,s)=>{e.current=s,a(s),b||H(s)},renderInput:p=>r(m,{...p,label:"Haplotypes",placeholder:o.length===0?"every haplotype":void 0,slotProps:{...p.slotProps,htmlInput:{...p.slotProps.htmlInput,"data-testid":"graph-haplotypes-field"}}})})}),D=c(function({model:t}){let{classes:l}=F(),o=t.haplotypeNames,a=t.cutHaplotypes?.join(",")??"",e=t.sourceAdapter;return e&&x(e)?i("div",{className:l.section,children:[o?r(A,{model:t,names:o},a):r(I,{model:t},a),i(u,{variant:"caption",component:"div",color:"text.secondary",children:[o?`Which of the graph's ${o.length.toLocaleString()} haplotypes to cut, or a PanSN prefix (HG002 for both).`:"Which haplotypes to cut, as lane assembly names or PanSN prefixes (HG002#1, or HG002 for both) separated by commas."," ","Empty is every haplotype."]})]}):null}),N=D;function B({model:n,onClose:t}){return i(L,{model:n,onClose:t,children:[r(k,{model:n}),r(N,{model:n})]})}export{B as default};
6
- //# sourceMappingURL=GraphTrackSettingsDialog-JHIP2F5N.js.map
6
+ //# sourceMappingURL=GraphTrackSettingsDialog-MR7X75EY.js.map
@@ -1,2 +1,2 @@
1
- import{u as v,v as C}from"./chunk-MLVBPMBU.js";import"./chunk-D5PRXUSS.js";import"./chunk-4AAW5P6N.js";import"./chunk-VIVPTP5Z.js";import{F as g,H as t,d as u,o as y,q as c,r as d,z as s}from"./chunk-UGCNPRKC.js";import{a as h,b as l,c as p,d as m}from"./chunk-JMBDTNUR.js";var b=m(function({model:o,onClose:r}){return p(u,{open:!0,onClose:r,title:"Color highlighted haplotypes",children:[p(d,{sx:{display:"grid",gridTemplateColumns:"auto 1fr 1fr",alignItems:"center",gap:1.5},children:[l(t,{variant:"subtitle2",children:"Haplotype"}),l(t,{variant:"subtitle2",children:"Color by"}),l(t,{variant:"subtitle2",children:"Palette"}),o.drawnWalks.map(({name:a,encoding:n})=>l(f,{label:o.walkLabel(a),field:n.field,scheme:n.scheme,onField:e=>{o.setWalkColor(a,{field:e})},onScheme:e=>{o.setWalkColor(a,{scheme:e})}},a))]}),l(c,{children:l(y,{variant:"contained",onClick:r,children:"Done"})})]})});function f({label:i,field:o,scheme:r,onField:a,onScheme:n}){return p(h,{children:[l(t,{variant:"body2",children:i}),l(g,{select:!0,size:"small",value:o,slotProps:{select:{SelectDisplayProps:{"aria-label":`Color ${i} by`}}},onChange:e=>{a(e.target.value)},children:v.map(e=>l(s,{value:e.value,children:e.label},e.value))}),l(g,{select:!0,size:"small",value:r,slotProps:{select:{SelectDisplayProps:{"aria-label":`Palette for ${i}`}}},onChange:e=>{n(e.target.value)},children:C.filter(e=>e.value!=="rainbow"||o==="reference").map(e=>l(s,{value:e.value,children:e.label},e.value))})]})}var P=b;export{P as default};
2
- //# sourceMappingURL=HighlightColorDialog-S2WPOSDF.js.map
1
+ import{u as v,v as C}from"./chunk-S75MFZDE.js";import"./chunk-Q3BXNKEL.js";import"./chunk-U5PIXAF2.js";import"./chunk-RCXOOBLX.js";import{F as g,H as t,d as u,o as y,q as c,r as d,z as s}from"./chunk-UGCNPRKC.js";import{a as h,b as l,c as p,d as m}from"./chunk-JMBDTNUR.js";var b=m(function({model:o,onClose:r}){return p(u,{open:!0,onClose:r,title:"Color highlighted haplotypes",children:[p(d,{sx:{display:"grid",gridTemplateColumns:"auto 1fr 1fr",alignItems:"center",gap:1.5},children:[l(t,{variant:"subtitle2",children:"Haplotype"}),l(t,{variant:"subtitle2",children:"Color by"}),l(t,{variant:"subtitle2",children:"Palette"}),o.drawnWalks.map(({name:a,encoding:n})=>l(f,{label:o.walkLabel(a),field:n.field,scheme:n.scheme,onField:e=>{o.setWalkColor(a,{field:e})},onScheme:e=>{o.setWalkColor(a,{scheme:e})}},a))]}),l(c,{children:l(y,{variant:"contained",onClick:r,children:"Done"})})]})});function f({label:i,field:o,scheme:r,onField:a,onScheme:n}){return p(h,{children:[l(t,{variant:"body2",children:i}),l(g,{select:!0,size:"small",value:o,slotProps:{select:{SelectDisplayProps:{"aria-label":`Color ${i} by`}}},onChange:e=>{a(e.target.value)},children:v.map(e=>l(s,{value:e.value,children:e.label},e.value))}),l(g,{select:!0,size:"small",value:r,slotProps:{select:{SelectDisplayProps:{"aria-label":`Palette for ${i}`}}},onChange:e=>{n(e.target.value)},children:C.filter(e=>e.value!=="rainbow"||o==="reference").map(e=>l(s,{value:e.value,children:e.label},e.value))})]})}var P=b;export{P as default};
2
+ //# sourceMappingURL=HighlightColorDialog-ZBAZDYIR.js.map
@@ -1,2 +1,2 @@
1
- import{a as h}from"./chunk-2BTNRN57.js";import"./chunk-JXOLZ5IZ.js";import"./chunk-XLSVRKFJ.js";import"./chunk-XT4U7I3D.js";import"./chunk-4XM5OBD5.js";import"./chunk-ADZBAET3.js";import"./chunk-MLVBPMBU.js";import"./chunk-UW7INEQF.js";import"./chunk-D5PRXUSS.js";import"./chunk-LTN6XZR5.js";import"./chunk-2Q4D5RHL.js";import"./chunk-SI64QXFH.js";import"./chunk-YBLNN5FU.js";import"./chunk-YBZA7LPQ.js";import"./chunk-4AAW5P6N.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-VIVPTP5Z.js";import"./chunk-IKJZPPOA.js";import"./chunk-NDRLCGPC.js";import"./chunk-TENPGIPX.js";import{h as T}from"./chunk-YU7T5WOQ.js";import"./chunk-UGCNPRKC.js";import{b as e,c as d,d as i}from"./chunk-JMBDTNUR.js";var n=JBrowseExports["@jbrowse/display-kit/DisplayBackgroundProgress"];var f=n&&n.__esModule?n.default:n;var l=JBrowseExports["@jbrowse/display-kit/DisplayErrorBar"];var v=l&&l.__esModule?l.default:l;var p=JBrowseExports["@jbrowse/display-kit/DisplayLoadingOverlay"];var O=p&&p.__esModule?p.default:p;var c=JBrowseExports["@jbrowse/display-kit/TooLargeMessage"];var L=c&&c.__esModule?c.default:c;var s=JBrowseExports["@jbrowse/display-ui"],u=r=>s!=null&&r in Object(s)?s[r]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+r+"' from '@jbrowse/display-ui' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:r});var w=u("BottomRightCornerContext");var g=u("TrackOverlayPortal");var C=u("useChromeOverlayOverride");var U=s&&s.__esModule?s.default:s;var k={TooLarge:L,ErrorBar:v,Loading:O,BackgroundProgress:f},m="Zoom in to see features, or force load this track for the rest of the session (may be slow)",M="Force load this track for the rest of the session (may be slow)";function H(r){let o=r.error??r.renderError,t=o instanceof Error&&o.regionTooLarge===!0;return{error:{error:o,onRetry:t?void 0:()=>{r.reload()}},tooLarge:{message:[r.regionTooLargeReason,r.zoomCanReleaseGate?m:M].filter(Boolean).join(". "),onForceLoad:()=>{r.forceLoad()}},loading:{message:r.statusMessage,progress:r.statusProgress,canceled:r.fetchCanceled,onCancel:()=>{r.cancelFetchByUser()},onRetry:()=>{r.reload()}},background:{message:r.statusMessage,progress:r.statusProgress}}}var _=i(function({model:o,phase:t,drawn:x,testid:E,style:B,children:G,...S}){let{TooLarge:b,ErrorBar:P,Loading:A,BackgroundProgress:D}=C()??k,[R,I]=T(null),a=H(o),y={...S,"data-testid":E,"data-display-id":o.configuration.displayId,"data-display-drawn":x,"data-display-phase":t};return t==="tooLarge"?e("div",{style:{display:"contents"},...y,children:e(g,{children:e("div",{style:{pointerEvents:"auto"},children:e(b,{model:o,...a.tooLarge})})})}):d("div",{style:{position:"relative",height:o.height,...B},...y,children:[e(w,{value:R,children:G}),d(g,{children:[t==="error"?e(P,{model:o,visible:!0,...a.error}):null,e(A,{model:o,...a.loading,visible:t==="loading"||t==="canceled",immediate:!x}),e("div",{ref:I,style:{position:"absolute",bottom:2,right:2,display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4,pointerEvents:"none"},children:t==="ready"&&o.statusMessage?e(D,{model:o,visible:!0,...a.background}):null})]})]})});var j=i(function({model:o}){return e(_,{model:o,phase:o.displayPhase,drawn:o.painted&&o.geometryPainted,testid:"linear-graph-display","data-layout":o.chosenLayoutMode,"data-cut-tier":o.cutTier,"data-recuts":o.recuts,"data-node-count":o.hasGraph?o.nodeCount:void 0,"data-loading":o.isLoading?"":void 0,style:{width:o.paneWidth,height:o.height,overflow:"hidden"},children:e(h,{model:o,ownChrome:!1})})}),so=j;export{so as default};
2
- //# sourceMappingURL=LinearGraphDisplay-EF2GE7X7.js.map
1
+ import{a as h}from"./chunk-62AHPP6H.js";import"./chunk-WY5W5X62.js";import"./chunk-WJGCVNGH.js";import"./chunk-FWVXBJ64.js";import"./chunk-ZG2CQXOW.js";import"./chunk-55DIX25J.js";import"./chunk-S75MFZDE.js";import"./chunk-2XZYJLCE.js";import"./chunk-Q3BXNKEL.js";import"./chunk-JSRGX4TC.js";import"./chunk-DXNE2CFX.js";import"./chunk-LFTZNUXB.js";import"./chunk-YBLNN5FU.js";import"./chunk-MEMUEG5Z.js";import"./chunk-U5PIXAF2.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-RCXOOBLX.js";import"./chunk-IKJZPPOA.js";import"./chunk-NDRLCGPC.js";import"./chunk-TENPGIPX.js";import{h as T}from"./chunk-YU7T5WOQ.js";import"./chunk-UGCNPRKC.js";import{b as e,c as d,d as i}from"./chunk-JMBDTNUR.js";var n=JBrowseExports["@jbrowse/display-kit/DisplayBackgroundProgress"];var f=n&&n.__esModule?n.default:n;var l=JBrowseExports["@jbrowse/display-kit/DisplayErrorBar"];var v=l&&l.__esModule?l.default:l;var p=JBrowseExports["@jbrowse/display-kit/DisplayLoadingOverlay"];var O=p&&p.__esModule?p.default:p;var c=JBrowseExports["@jbrowse/display-kit/TooLargeMessage"];var L=c&&c.__esModule?c.default:c;var s=JBrowseExports["@jbrowse/display-ui"],u=r=>s!=null&&r in Object(s)?s[r]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+r+"' from '@jbrowse/display-ui' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:r});var w=u("BottomRightCornerContext");var g=u("TrackOverlayPortal");var C=u("useChromeOverlayOverride");var U=s&&s.__esModule?s.default:s;var k={TooLarge:L,ErrorBar:v,Loading:O,BackgroundProgress:f},m="Zoom in to see features, or force load this track for the rest of the session (may be slow)",M="Force load this track for the rest of the session (may be slow)";function H(r){let o=r.error??r.renderError,t=o instanceof Error&&o.regionTooLarge===!0;return{error:{error:o,onRetry:t?void 0:()=>{r.reload()}},tooLarge:{message:[r.regionTooLargeReason,r.zoomCanReleaseGate?m:M].filter(Boolean).join(". "),onForceLoad:()=>{r.forceLoad()}},loading:{message:r.statusMessage,progress:r.statusProgress,canceled:r.fetchCanceled,onCancel:()=>{r.cancelFetchByUser()},onRetry:()=>{r.reload()}},background:{message:r.statusMessage,progress:r.statusProgress}}}var _=i(function({model:o,phase:t,drawn:x,testid:E,style:B,children:G,...S}){let{TooLarge:b,ErrorBar:P,Loading:A,BackgroundProgress:D}=C()??k,[R,I]=T(null),a=H(o),y={...S,"data-testid":E,"data-display-id":o.configuration.displayId,"data-display-drawn":x,"data-display-phase":t};return t==="tooLarge"?e("div",{style:{display:"contents"},...y,children:e(g,{children:e("div",{style:{pointerEvents:"auto"},children:e(b,{model:o,...a.tooLarge})})})}):d("div",{style:{position:"relative",height:o.height,...B},...y,children:[e(w,{value:R,children:G}),d(g,{children:[t==="error"?e(P,{model:o,visible:!0,...a.error}):null,e(A,{model:o,...a.loading,visible:t==="loading"||t==="canceled",immediate:!x}),e("div",{ref:I,style:{position:"absolute",bottom:2,right:2,display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4,pointerEvents:"none"},children:t==="ready"&&o.statusMessage?e(D,{model:o,visible:!0,...a.background}):null})]})]})});var j=i(function({model:o}){return e(_,{model:o,phase:o.displayPhase,drawn:o.painted&&o.geometryPainted,testid:"linear-graph-display","data-layout":o.chosenLayoutMode,"data-cut-tier":o.cutTier,"data-recuts":o.recuts,"data-node-count":o.hasGraph?o.nodeCount:void 0,"data-loading":o.isLoading?"":void 0,style:{width:o.paneWidth,height:o.height,overflow:"hidden"},children:e(h,{model:o,ownChrome:!1})})}),so=j;export{so as default};
2
+ //# sourceMappingURL=LinearGraphDisplay-AJ5OZN27.js.map
@@ -1,2 +1,2 @@
1
- import{a as f,d as c,f as d}from"./chunk-LTN6XZR5.js";import{a as g}from"./chunk-KOB7YIMR.js";import{b,k as m,p,r as u}from"./chunk-OUHKJSKZ.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-VIVPTP5Z.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as i,o as l}from"./chunk-TENPGIPX.js";var a=class extends b{constructor(){super(...arguments);this.bubbles=p(this,["bubblesLocation"],["index"]);this.refNames=new u(this.bubbles,this)}static{this.capabilities=["getFeatures","getRefNames"]}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async getRegionByteSize(t,s={}){return this.refNames.regionBytes(t,s)}async hasDataForRefName(){return!0}getFeatures(t,s={}){let{signal:n,statusCallback:h}=s;return g(async r=>{let o=await this.refNames.resolveMapped(t,s);o!==void 0&&await l("Downloading bubbles",h,()=>m(this.bubbles,o,t.start,t.end,{signal:n,lineCallback:(N,y)=>{let e=f(N);r.next(new i({uniqueId:`bubble-${y}`,refName:t.refName,start:e.start,end:e.end,name:c(e),description:d(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),r.complete()},n)}};export{a as default};
2
- //# sourceMappingURL=MinigraphBubbleAdapter-XC75BCG3.js.map
1
+ import{a as f,d as c,f as d}from"./chunk-JSRGX4TC.js";import{a as g}from"./chunk-KOB7YIMR.js";import{b,k as m,p,r as u}from"./chunk-AWGMTI73.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-RCXOOBLX.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as i,o as l}from"./chunk-TENPGIPX.js";var a=class extends b{constructor(){super(...arguments);this.bubbles=p(this,["bubblesLocation"],["index"]);this.refNames=new u(this.bubbles,this)}static{this.capabilities=["getFeatures","getRefNames"]}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async getRegionByteSize(t,s={}){return this.refNames.regionBytes(t,s)}async hasDataForRefName(){return!0}getFeatures(t,s={}){let{signal:n,statusCallback:h}=s;return g(async r=>{let o=await this.refNames.resolveMapped(t,s);o!==void 0&&await l("Downloading bubbles",h,()=>m(this.bubbles,o,t.start,t.end,{signal:n,lineCallback:(N,y)=>{let e=f(N);r.next(new i({uniqueId:`bubble-${y}`,refName:t.refName,start:e.start,end:e.end,name:c(e),description:d(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),r.complete()},n)}};export{a as default};
2
+ //# sourceMappingURL=MinigraphBubbleAdapter-PEQK5NII.js.map
@@ -1,2 +1,2 @@
1
- import{a as b}from"./chunk-KPP5H27W.js";import"./chunk-QASFRHPG.js";import{a as N}from"./chunk-KOB7YIMR.js";import"./chunk-YBLNN5FU.js";import"./chunk-YBZA7LPQ.js";import"./chunk-4AAW5P6N.js";import{b as g,h as c,i as u,j as h,k as w,p as m,q as k,r as x}from"./chunk-OUHKJSKZ.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-VIVPTP5Z.js";import{d}from"./chunk-IKJZPPOA.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as p,o as f}from"./chunk-TENPGIPX.js";var l=class extends g{constructor(){super(...arguments);this.fine=this.openIndex([])}static{this.capabilities=["getFeatures","getRefNames"]}openIndex(e){let a=m(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),s=m(this,[...e,"linksLocation"],[...e,"linksIndex"]),n=this.getConf("walksLocation"),r=e.length===0&&d(n)?new b(m(this,["walksLocation"],["walksIndex"]),this):void 0;return{segments:a,links:s,walks:r,refNames:new x(r?.file??a,this)}}async getHaplotypeNames(e={}){return this.fine.walks?.haplotypeNames(e)}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 getRegionByteSize(e,a={}){let{walks:s,refNames:n}=this.fine;return n.regionBytes(e,a,s&&((r,{start:t,end:i})=>s.reader.queryStart(t,{...a,refName:r,end:i})))}async hasDataForRefName(){return!0}getFeatures(e,a={}){return N(async s=>{let n=await this.fine.refNames.resolveMapped(e,a);if(n!==void 0){let{walks:r}=this.fine,t=i=>{s.next(i)};await(r?this.walkFeatures(r,n,e,a,t):this.segmentFeatures(n,e,a,t))}s.complete()},a.signal)}async walkFeatures(e,a,s,n,r){let t=await f("Downloading walks",n.statusCallback,()=>e.referenceNodes(a,s,n));for(let i of t){let o=String(i.id);r(new p({uniqueId:o,refName:s.refName,start:i.start,end:i.end,name:o,type:"segment",rank:0,stableName:i.refName}))}}async segmentFeatures(e,a,s,n){await f("Downloading segments",s.statusCallback,()=>w(this.fine.segments,e,a.start,a.end,{signal:s.signal,lineCallback:r=>{let{segment:t,anchored:i}=c(r);if(i&&t.refName!==e)return;let o=u(t);n(new p({uniqueId:t.id,refName:a.refName,start:t.start,end:t.end,name:t.id,type:"segment",rank:t.rank,stableName:t.refName,...o&&{samples:o,sampleCount:o.length}}))}}))}async getSubgraph(e,a={}){let{hops:s,signal:n,tier:r}=a,t=this.index(r),i=await t.refNames.resolve(e,{signal:n});if(i===void 0)throw new Error(k(e));return t.walks?t.walks.subgraph(i,e,a):h(t,{refName:i,start:e.start,end:e.end},{hops:s,signal:n})}};export{l as default};
2
- //# sourceMappingURL=RgfaTabixAdapter-56X2U424.js.map
1
+ import{a as b}from"./chunk-SFYSQ52W.js";import"./chunk-J3AXN7JQ.js";import{a as N}from"./chunk-KOB7YIMR.js";import"./chunk-YBLNN5FU.js";import"./chunk-MEMUEG5Z.js";import"./chunk-U5PIXAF2.js";import{b as g,h as c,i as u,j as h,k as w,p as m,q as k,r as x}from"./chunk-AWGMTI73.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-RCXOOBLX.js";import{d}from"./chunk-IKJZPPOA.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as p,o as f}from"./chunk-TENPGIPX.js";var l=class extends g{constructor(){super(...arguments);this.fine=this.openIndex([])}static{this.capabilities=["getFeatures","getRefNames"]}openIndex(e){let a=m(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),s=m(this,[...e,"linksLocation"],[...e,"linksIndex"]),n=this.getConf("walksLocation"),r=e.length===0&&d(n)?new b(m(this,["walksLocation"],["walksIndex"]),this):void 0;return{segments:a,links:s,walks:r,refNames:new x(r?.file??a,this)}}async getHaplotypeNames(e={}){return this.fine.walks?.haplotypeNames(e)}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 getRegionByteSize(e,a={}){let{walks:s,refNames:n}=this.fine;return n.regionBytes(e,a,s&&((r,{start:t,end:i})=>s.reader.queryStart(t,{...a,refName:r,end:i})))}async hasDataForRefName(){return!0}getFeatures(e,a={}){return N(async s=>{let n=await this.fine.refNames.resolveMapped(e,a);if(n!==void 0){let{walks:r}=this.fine,t=i=>{s.next(i)};await(r?this.walkFeatures(r,n,e,a,t):this.segmentFeatures(n,e,a,t))}s.complete()},a.signal)}async walkFeatures(e,a,s,n,r){let t=await f("Downloading walks",n.statusCallback,()=>e.referenceNodes(a,s,n));for(let i of t){let o=String(i.id);r(new p({uniqueId:o,refName:s.refName,start:i.start,end:i.end,name:o,type:"segment",rank:0,stableName:i.refName}))}}async segmentFeatures(e,a,s,n){await f("Downloading segments",s.statusCallback,()=>w(this.fine.segments,e,a.start,a.end,{signal:s.signal,lineCallback:r=>{let{segment:t,anchored:i}=c(r);if(i&&t.refName!==e)return;let o=u(t);n(new p({uniqueId:t.id,refName:a.refName,start:t.start,end:t.end,name:t.id,type:"segment",rank:t.rank,stableName:t.refName,...o&&{samples:o,sampleCount:o.length}}))}}))}async getSubgraph(e,a={}){let{hops:s,signal:n,tier:r}=a,t=this.index(r),i=await t.refNames.resolve(e,{signal:n});if(i===void 0)throw new Error(k(e));return t.walks?t.walks.subgraph(i,e,a):h(t,{refName:i,start:e.start,end:e.end},{hops:s,signal:n})}};export{l as default};
2
+ //# sourceMappingURL=RgfaTabixAdapter-Q63YLPK4.js.map
@@ -1,2 +1,2 @@
1
- import{a as K}from"./chunk-KPP5H27W.js";import{b as q,d as U,e as X,f as O,g as z,h as G}from"./chunk-Z4YNEFPC.js";import"./chunk-QASFRHPG.js";import{a as H}from"./chunk-KOB7YIMR.js";import{p as M,q as _,r as T}from"./chunk-M2D7NUOY.js";import"./chunk-YBLNN5FU.js";import"./chunk-YBZA7LPQ.js";import"./chunk-4AAW5P6N.js";import{e as $,p as j,r as D}from"./chunk-OUHKJSKZ.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{a as A,c as I,d as W,g as F,h as w,i as x}from"./chunk-VIVPTP5Z.js";import"./chunk-T4R3ZVEM.js";import"./chunk-7WIBGKBU.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{o as R}from"./chunk-TENPGIPX.js";var se=50;function re(r){let i=[];for(let e=0;e<r.length;e++){let[t,a]=r[e],[s,n]=r[e+1]??[];a===n&&a<=se&&(t==="I"&&s==="D"||t==="D"&&s==="I")?(i.push(["X",a]),e++):i.push([t,a])}return i}function v(r){return Array.from(r.ids,(i,e)=>2*i+r.rev[e])}function P(r,i){let e=r.get(i);return e===void 0?0:e.end-e.start}function V(r){let i=new Map,e=s=>{let n=P(r,s),o=i.get(n);return o===void 0&&(o="N".repeat(n),i.set(n,o)),o},t=new Map,a=s=>{let n=t.get(s);return n===void 0&&(n=v(s),t.set(s,n)),n};return(s,n)=>_({query:a(s),target:a(n),sequenceOf:e,bases:!1})}var B=100;function E(r,i,e){let t=r.at(-1);e>0&&(t?.[0]===i?t[1]+=e:r.push([i,e]))}function Z(r){let i=t=>P(r,t>>1),e=t=>{let a=new Float64Array(t.length+1);return t.forEach((s,n)=>{a[n+1]=a[n]+i(s)}),a};return(t,a)=>{let s=v(a),n=v(t),[o,l]=M(n,s,i),[u,f]=M(n.map(g=>g^1).reverse(),s,i),c=f>l,p=c?u:o,N=Math.max(l,f);if(N<B)return[];let d=e(s),h=e(n),y=g=>c?n.length-1-p[g][0]:p[g][0],m=[];p.forEach(([,g],k)=>{if(k>0){let[ee,te]=[y(k-1),y(k)].sort((ae,ne)=>ae-ne);E(m,"I",h[te]-h[ee+1]),E(m,"D",d[g]-d[p[k-1][1]+1])}E(m,"=",i(s[g]))});let[b,S]=[y(0),y(p.length-1)].sort((g,k)=>g-k);return[{queryStart:h[b],queryEnd:h[S+1],targetStart:d[p[0][1]],targetEnd:d[p.at(-1)[1]+1],strand:c?"-":"+",edits:m,sharedBases:N}]}}function oe(r){let i=new Map,e=new Set;r.ids.forEach((t,a)=>{i.has(t)?e.add(t):i.set(t,r.rev[a])});for(let t of e)i.delete(t);return i}function J(r){let i=new Map,e=t=>{let a=i.get(t);return a===void 0&&(a=oe(t),i.set(t,a)),a};return(t,a)=>{let s=e(a),n=0,o=0;for(let[l,u]of e(t)){let f=s.get(l);f===u?n+=P(r,l):f!==void 0&&(o+=P(r,l))}return{same:n,opposite:o}}}function Q(r){let i=Z(r),e=V(r),t=J(r);return(a,s)=>{let{same:n,opposite:o}=t(a,s);return n>=B&&o>=B?e(a,s):i(a,s)}}var ie=1e4;function Y(r){let i=Z(r),e=V(r),t=J(r);return(a,s)=>{let n=i(a,s),o=n[0]?.strand,{same:l,opposite:u}=t(a,s);return o===void 0||Math.min(l,u)<ie?n:[...n,...e(a,s).filter(f=>f.strand!==o)]}}function C({chain:r,target:i,query:e,assemblyName:t,refName:a,mateAssemblyName:s}){let n=re(r.edits);return G({target:{name:i.name,assemblyName:t,refName:a,start:i.hapStart+r.targetStart,end:i.hapStart+r.targetEnd},query:{name:e.name,assemblyName:s,refName:W(e.name),start:e.hapStart+r.queryStart,end:e.hapStart+r.queryEnd},strand:r.strand,cigar:T(n),matches:n.reduce((o,[l,u])=>o+(l==="="?u:0),0),columns:n.reduce((o,[,l])=>o+l,0)})}var me=r=>I(r.name)??r.name,L=class extends q{constructor(){super(...arguments);this.walks=new K(j(this,["walksLocation"],["walksIndex"]),this);this.refNames=new D(this.walks.file,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){return this.walks.haplotypeNames(e)}async getHeader(e={}){let{haplotypes:t}=await this.walks.reader.header(e),{anchor:a}=this,s=w(this,a),n=x(this);return{hasCoarseTier:!1,anchorAssemblyName:a,lanes:t.filter(o=>o!==s&&A(o)!==s).map(o=>({name:O(n,o),label:o,group:A(o)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}async getSubgraph(e,t={}){let a=await this.refNames.resolve(e,{signal:t.signal});if(a===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; the graph is cut on ${this.anchor}, mapped to its PanSN prefix in assemblyNameToPanSN`);return this.walks.subgraph(a,e,t)}async laneWalks(e,t,a,s,n){let o=$(a,e);return R(n,s.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.budgets(),signal:s.signal,keep:o,expand:o,links:!1}).catch(l=>{throw z(l,t.end-t.start)}))}async anchorFeatures(e,t,a){let s=a.haplotypes?.length?a.haplotypes.map(m=>w(this,m)):void 0,n=w(this,a.targetAssemblyName),o=n===void 0?s:s===void 0||s.some(m=>F(n,m)||F(m,n))?[n]:[];if(o?.length===0)return[];let{start:l,end:u}=t,{graph:f,fragments:c}=await this.laneWalks(e,t,o,a,`Reading walks ${t.refName}:${l.toLocaleString()}-${u.toLocaleString()}`),p=Y(f.nodes),N=x(this),d=c.filter(m=>m.name===e),h=m=>o===void 0?0:o.findIndex(b=>F(m.name,b));return c.filter(m=>m.name!==e&&h(m)>=0).sort((m,b)=>h(m)-h(b)).flatMap(m=>d.flatMap(b=>p(m,b).map(S=>C({chain:S,target:b,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:O(N,me(m))}))))}async pairFeatures(e,t,a,s){let n=a.map(c=>({pair:c,featurePrefix:w(this,c.queryAssemblyName),matePrefix:w(this,c.targetAssemblyName)})),{graph:o,fragments:l}=await this.laneWalks(e,t,n.flatMap(c=>[c.featurePrefix,c.matePrefix]),s,X(a)),u=Q(o.nodes),f=c=>l.filter(p=>F(p.name,c));return n.flatMap(({pair:c,featurePrefix:p,matePrefix:N})=>f(p).flatMap(d=>f(N).flatMap(h=>u(h,d).map(y=>C({chain:y,target:d,query:h,assemblyName:c.queryAssemblyName,refName:W(d.name),mateAssemblyName:c.targetAssemblyName})))))}getFeatures(e,t={}){return H(async a=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let n=U(t),o=n.length>0?await this.pairFeatures(s,e,n,t):await this.anchorFeatures(s,e,t);for(let l of o)a.next(l)}a.complete()},t.signal)}};export{L as default};
2
- //# sourceMappingURL=WalkTabixSyntenyAdapter-ECW557IS.js.map
1
+ import{a as K}from"./chunk-SFYSQ52W.js";import{b as q,d as U,e as X,f as O,g as z,h as G}from"./chunk-HI3YK2SO.js";import"./chunk-J3AXN7JQ.js";import{a as H}from"./chunk-KOB7YIMR.js";import{p as M,q as _,r as T}from"./chunk-M2D7NUOY.js";import"./chunk-YBLNN5FU.js";import"./chunk-MEMUEG5Z.js";import"./chunk-U5PIXAF2.js";import{e as $,p as j,r as D}from"./chunk-AWGMTI73.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{a as A,c as I,d as W,g as F,h as w,i as x}from"./chunk-RCXOOBLX.js";import"./chunk-T4R3ZVEM.js";import"./chunk-7WIBGKBU.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{o as R}from"./chunk-TENPGIPX.js";var se=50;function re(r){let i=[];for(let e=0;e<r.length;e++){let[t,a]=r[e],[s,n]=r[e+1]??[];a===n&&a<=se&&(t==="I"&&s==="D"||t==="D"&&s==="I")?(i.push(["X",a]),e++):i.push([t,a])}return i}function v(r){return Array.from(r.ids,(i,e)=>2*i+r.rev[e])}function P(r,i){let e=r.get(i);return e===void 0?0:e.end-e.start}function V(r){let i=new Map,e=s=>{let n=P(r,s),o=i.get(n);return o===void 0&&(o="N".repeat(n),i.set(n,o)),o},t=new Map,a=s=>{let n=t.get(s);return n===void 0&&(n=v(s),t.set(s,n)),n};return(s,n)=>_({query:a(s),target:a(n),sequenceOf:e,bases:!1})}var B=100;function E(r,i,e){let t=r.at(-1);e>0&&(t?.[0]===i?t[1]+=e:r.push([i,e]))}function Z(r){let i=t=>P(r,t>>1),e=t=>{let a=new Float64Array(t.length+1);return t.forEach((s,n)=>{a[n+1]=a[n]+i(s)}),a};return(t,a)=>{let s=v(a),n=v(t),[o,l]=M(n,s,i),[u,f]=M(n.map(g=>g^1).reverse(),s,i),c=f>l,p=c?u:o,N=Math.max(l,f);if(N<B)return[];let d=e(s),h=e(n),y=g=>c?n.length-1-p[g][0]:p[g][0],m=[];p.forEach(([,g],k)=>{if(k>0){let[ee,te]=[y(k-1),y(k)].sort((ae,ne)=>ae-ne);E(m,"I",h[te]-h[ee+1]),E(m,"D",d[g]-d[p[k-1][1]+1])}E(m,"=",i(s[g]))});let[b,S]=[y(0),y(p.length-1)].sort((g,k)=>g-k);return[{queryStart:h[b],queryEnd:h[S+1],targetStart:d[p[0][1]],targetEnd:d[p.at(-1)[1]+1],strand:c?"-":"+",edits:m,sharedBases:N}]}}function oe(r){let i=new Map,e=new Set;r.ids.forEach((t,a)=>{i.has(t)?e.add(t):i.set(t,r.rev[a])});for(let t of e)i.delete(t);return i}function J(r){let i=new Map,e=t=>{let a=i.get(t);return a===void 0&&(a=oe(t),i.set(t,a)),a};return(t,a)=>{let s=e(a),n=0,o=0;for(let[l,u]of e(t)){let f=s.get(l);f===u?n+=P(r,l):f!==void 0&&(o+=P(r,l))}return{same:n,opposite:o}}}function Q(r){let i=Z(r),e=V(r),t=J(r);return(a,s)=>{let{same:n,opposite:o}=t(a,s);return n>=B&&o>=B?e(a,s):i(a,s)}}var ie=1e4;function Y(r){let i=Z(r),e=V(r),t=J(r);return(a,s)=>{let n=i(a,s),o=n[0]?.strand,{same:l,opposite:u}=t(a,s);return o===void 0||Math.min(l,u)<ie?n:[...n,...e(a,s).filter(f=>f.strand!==o)]}}function C({chain:r,target:i,query:e,assemblyName:t,refName:a,mateAssemblyName:s}){let n=re(r.edits);return G({target:{name:i.name,assemblyName:t,refName:a,start:i.hapStart+r.targetStart,end:i.hapStart+r.targetEnd},query:{name:e.name,assemblyName:s,refName:W(e.name),start:e.hapStart+r.queryStart,end:e.hapStart+r.queryEnd},strand:r.strand,cigar:T(n),matches:n.reduce((o,[l,u])=>o+(l==="="?u:0),0),columns:n.reduce((o,[,l])=>o+l,0)})}var me=r=>I(r.name)??r.name,L=class extends q{constructor(){super(...arguments);this.walks=new K(j(this,["walksLocation"],["walksIndex"]),this);this.refNames=new D(this.walks.file,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){return this.walks.haplotypeNames(e)}async getHeader(e={}){let{haplotypes:t}=await this.walks.reader.header(e),{anchor:a}=this,s=w(this,a),n=x(this);return{hasCoarseTier:!1,anchorAssemblyName:a,lanes:t.filter(o=>o!==s&&A(o)!==s).map(o=>({name:O(n,o),label:o,group:A(o)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}async getSubgraph(e,t={}){let a=await this.refNames.resolve(e,{signal:t.signal});if(a===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; the graph is cut on ${this.anchor}, mapped to its PanSN prefix in assemblyNameToPanSN`);return this.walks.subgraph(a,e,t)}async laneWalks(e,t,a,s,n){let o=$(a,e);return R(n,s.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.budgets(),signal:s.signal,keep:o,expand:o,links:!1}).catch(l=>{throw z(l,t.end-t.start)}))}async anchorFeatures(e,t,a){let s=a.haplotypes?.length?a.haplotypes.map(m=>w(this,m)):void 0,n=w(this,a.targetAssemblyName),o=n===void 0?s:s===void 0||s.some(m=>F(n,m)||F(m,n))?[n]:[];if(o?.length===0)return[];let{start:l,end:u}=t,{graph:f,fragments:c}=await this.laneWalks(e,t,o,a,`Reading walks ${t.refName}:${l.toLocaleString()}-${u.toLocaleString()}`),p=Y(f.nodes),N=x(this),d=c.filter(m=>m.name===e),h=m=>o===void 0?0:o.findIndex(b=>F(m.name,b));return c.filter(m=>m.name!==e&&h(m)>=0).sort((m,b)=>h(m)-h(b)).flatMap(m=>d.flatMap(b=>p(m,b).map(S=>C({chain:S,target:b,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:O(N,me(m))}))))}async pairFeatures(e,t,a,s){let n=a.map(c=>({pair:c,featurePrefix:w(this,c.queryAssemblyName),matePrefix:w(this,c.targetAssemblyName)})),{graph:o,fragments:l}=await this.laneWalks(e,t,n.flatMap(c=>[c.featurePrefix,c.matePrefix]),s,X(a)),u=Q(o.nodes),f=c=>l.filter(p=>F(p.name,c));return n.flatMap(({pair:c,featurePrefix:p,matePrefix:N})=>f(p).flatMap(d=>f(N).flatMap(h=>u(h,d).map(y=>C({chain:y,target:d,query:h,assemblyName:c.queryAssemblyName,refName:W(d.name),mateAssemblyName:c.targetAssemblyName})))))}getFeatures(e,t={}){return H(async a=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let n=U(t),o=n.length>0?await this.pairFeatures(s,e,n,t):await this.anchorFeatures(s,e,t);for(let l of o)a.next(l)}a.complete()},t.signal)}};export{L as default};
2
+ //# sourceMappingURL=WalkTabixSyntenyAdapter-N5PFI4LS.js.map
@@ -1,2 +1,2 @@
1
1
  var tt;function ut(){return tt??(tt=import("./bandage-layout-UZEOCKMS.js").then(o=>o.default()).catch(o=>{throw tt=void 0,o})),tt}async function dt(o){return(await ut()).computeLayout(o.graph,o.options)}var Bt="\0deletion:";var kt=25*Math.PI/180,Pt=.25,St=150,nn=[0,-.35,.35,-.7,.7,-1.05,1.05,-1.4,1.4],pt=[0,1];function _t(o){return o?0:1}function lt(o,t){let n=t.x-o.x,e=t.y-o.y,s=Math.hypot(n,e)||1;return{x:n/s,y:e/s}}function gt(o,t,n){return{x:o.x+(t.x-o.x)*n,y:o.y+(t.y-o.y)*n}}function Ut(o){let t=0,n=0;for(let e of o)t+=e.x,n+=e.y;return{x:t/o.length,y:n/o.length}}function Gt(o){let t=new Float64Array(o.length);for(let n=1;n<o.length;n++)t[n]=t[n-1]+Math.hypot(o[n].x-o[n-1].x,o[n].y-o[n-1].y);return t}function Dt(o){var t;return(t=Gt(o)[o.length-1])!==null&&t!==void 0?t:0}var ct=new Map;function en(o){let t=ct.get(o);if(t!==void 0)return t;let n=on(o);return ct.size>1e4&&ct.clear(),ct.set(o,n),n}function on(o){let t=1e-6,n=2*Math.PI-1e-6;for(let e=0;e<60;e++){let s=(t+n)/2;s/(2*Math.sin(s/2))<o?t=s:n=s}return(t+n)/2}function sn(o,t){if(o<1e-9)return Math.PI*t;let n=(o*o/4+t*t)/(2*t),e=2*Math.asin(Math.min(1,o/(2*n)));return n*(t>n?2*Math.PI-e:e)}function mt(o,t,n,e){let s=t-2*n,i=o<1e-9?2*Math.PI:en(s/o),r=s/i,l=Math.cos(i/2),d=o/2,a=e+n-r*l;return{at:c=>{if(c<=n)return{u:0,v:e+c};if(c>=t-n)return{u:o,v:e+t-c};let h=(c-n)/r-i/2;return{u:d+r*Math.sin(h),v:a+r*Math.cos(h)}},apex:e+n+r*(1-l),length:t}}function It(o,t,n){if(!n)return o;let e=Math.cos(n),s=Math.sin(n);return{...o,at:i=>{let{u:r,v:l}=o.at(i),d=r-t/2;return{u:t/2+d*e-l*s,v:d*s+l*e}}}}function rn(o){for(let t=0;t<=32;t++)if(o.at(o.length*t/32).v<-1e-6)return!0;return!1}function Ot(o,t,n,e,s){return{at:i=>({u:o+n*i,v:t+e*i}),apex:t+Math.max(0,e)*s,length:s}}var ot=class{constructor(t,n,e=!1){var s;this.pts=t,this.normals=n,this.straight=e,this.arc=Gt(t),this.total=(s=this.arc[t.length-1])!==null&&s!==void 0?s:0}segment(t){let{arc:n}=this,e=1,s=n.length-1;for(;e<s;){let i=e+s>>1;n[i]<t?e=i+1:s=i}return e}fraction(t,n){let e=this.arc[t]-this.arc[t-1];return e>0?(n-this.arc[t-1])/e:0}pointAt(t){let{pts:n}=this,e=n.length-1;if(e===0)return{...n[0]};if(t<=0){let i=lt(n[0],n[1]);return{x:n[0].x+i.x*t,y:n[0].y+i.y*t}}if(t>=this.total){let i=lt(n[e-1],n[e]),r=t-this.total;return{x:n[e].x+i.x*r,y:n[e].y+i.y*r}}let s=this.segment(t);return gt(n[s-1],n[s],this.fraction(s,t))}normalAt(t){let{normals:n}=this;if(n.length===1||t<=0)return n[0];if(t>=this.total)return n[n.length-1];let e=this.segment(t),{x:s,y:i}=gt(n[e-1],n[e],this.fraction(e,t)),r=Math.hypot(s,i)||1;return{x:s/r,y:i/r}}};function cn(o,t){let n=Ut(o);return o.map((e,s)=>{let i=lt(o[Math.max(0,s-1)],o[Math.min(o.length-1,s+1)]),r={x:-i.y,y:i.x},l=e.x-n.x,d=e.y-n.y,a=Math.hypot(l,d),c=r.x*l+r.y*d,h=t[s],f=a>1e-9&&Math.abs(c)>.3*a?Math.sign(c):Math.sign(r.x*h.x+r.y*h.y)||1;return{x:r.x*f,y:r.y*f}})}function xt(o,t,n,e,s){let i=Math.min(s,Math.max(e.length/24,.5)),r=[],l=[];for(let d=0;d<=e.length+1e-9;d+=i){let{u:a,v:c}=e.at(Math.min(d,e.length)),h=o.pointAt(t+a),f=o.normalAt(t+a),u=f.x*n,g=f.y*n;r.push({x:h.x+u*c,y:h.y+g*c}),l.push({x:u,y:g})}return{pts:r,refs:l}}var Tt=5,an=10.5/2;function yt(o,t,n,e,s,i){let r=s,l=xt(o,t,n,e(r),i);if(o.straight)return l;for(let d=0;d<6;d++){let a=Dt(l.pts);if(!(a>0)||Math.abs(a/s-1)<.001)break;r*=s/a,l=xt(o,t,n,e(r),i)}return l}function at(o,t){return Array.from({length:t},(n,e)=>o+e*15/2)}function Ft(o){if(o.length===0)return 1/0;let t=1/0,n=-1/0;for(let e of o)t=Math.min(t,e.point.x),n=Math.max(n,e.point.x);return n-t}function Rt(o,t){return o*73856093^t*19349663}var ht=class{constructor(t){this.c=t,this.grid=new Map;let{ids:n,first:e,count:s,per:i,seedX:r,seedY:l,backbone:d}=t,a=n.length;this.points=Array.from({length:a},()=>{}),this.params=Array.from({length:a},()=>{}),this.curves=Array.from({length:a},()=>{}),this.links=t.links.map((f,u)=>f.map(g=>g.filter(([M])=>M!==u))),this.route=n.map(f=>f.startsWith(Bt));let c=1/0,h=-1/0;for(let f=0;f<a;f++){let u=e[f];!d[u]||Number.isNaN(r[u])||(c=Math.min(c,r[u]),h=Math.max(h,r[u]+i[f]*(s[f]-1)))}this.backbone=new ot([{x:c,y:0},{x:h,y:0}],[{x:0,y:1},{x:0,y:1}],!0),this.backboneCentroid={x:(c+h)/2,y:0};for(let f=0;f<a;f++){let u=e[f];if(!d[u]||Number.isNaN(r[u]))continue;let g=[],M=[];for(let b=0;b<s[f];b++){let D=r[u]+b*i[f];g.push({x:D,y:l[u]}),M.push(D-c)}this.points[f]=g,this.params[f]=M,this.curves[f]=this.backbone,this.occupy(g,this.backbone)}}static hasBackbone(t){for(let n=0;n<t.ids.length;n++){let e=t.first[n];if(t.backbone[e]&&!Number.isNaN(t.seedX[e]))return!0}return!1}run(){let t=[];for(let e=0;e<this.points.length;e++)this.points[e]||t.push(e);let n=this.componentsOf(t).map(e=>({members:e,anchors:this.anchorsOf(e)})).filter(e=>e.anchors.length).map(e=>({members:e.members,span:Ft(e.anchors),drawn:e.members.reduce((s,i)=>s+this.drawn(i),0),feet:e.anchors.map(s=>`${s.point.x},${s.point.y}`).sort().join(" ")})).sort((e,s)=>e.span-s.span||(e.feet===s.feet?s.drawn-e.drawn:e.drawn-s.drawn));for(let e of n)this.placePiece(e.members,this.backboneCentroid)}write(t,n){let{first:e}=this.c;this.points.forEach((s,i)=>{s?.forEach((r,l)=>{t[e[i]+l]=r.x,n[e[i]+l]=r.y})})}drawn(t){return this.c.per[t]*(this.c.count[t]-1)}endIndex(t,n){return n?this.c.count[t]-1:0}occupy(t,n){for(let e of t){let s=Rt(Math.floor(e.x/10.5),Math.floor(e.y/10.5)),i=this.grid.get(s),r={x:e.x,y:e.y,curve:n};i?i.push(r):this.grid.set(s,[r])}}violations(t,n,e,s){var i;let r=0;for(let l of t){if(e.some(c=>Math.hypot(l.x-c.x,l.y-c.y)<15))continue;let d=Math.floor(l.x/10.5),a=Math.floor(l.y/10.5);for(let c=d-1;c<=d+1;c++)for(let h=a-1;h<=a+1;h++)for(let f of(i=this.grid.get(Rt(c,h)))!==null&&i!==void 0?i:[])if(f.curve!==n&&Math.hypot(l.x-f.x,l.y-f.y)<10.5&&(r++,r>=s))return r}return r}choose(t,n,e){let s,i=1/0;for(let r of t){let l=this.violations(r(an).pts,n,e,i);if(l===0)return r(Tt);l<i&&(i=l,s=r)}return s(Tt)}anchorsOf(t){let n=new Set(t),e=[];for(let s of t)for(let i of pt)for(let[r,l]of this.links[s][i]){let d=this.points[r];if(n.has(r)||!d)continue;let a=this.endIndex(r,l);e.push({u:s,uSide:i,v:r,vSide:l,point:d[a],curve:this.curves[r],t:this.params[r][a]})}return e}componentsOf(t){let n=new Set(t),e=new Set,s=[];for(let i of t){if(e.has(i))continue;let r=[i];e.add(i);for(let l of r)for(let d of pt)for(let[a]of this.links[l][d])n.has(a)&&!e.has(a)&&(e.add(a),r.push(a));s.push(r)}return s}spinePath(t,n,e,s,i){let r=new Set(t),l=(u,g)=>u*2+g,d=(u,g)=>u===s&&_t(g)===i,a=new Map([[l(n,e),-1]]),c=[[n,e]],h=[n,e];for(let[u,g]of c){if(h=[u,g],s!==void 0&&d(u,g))break;for(let[M,b]of this.links[u][_t(g)])!r.has(M)||a.has(l(M,b))||(a.set(l(M,b),l(u,g)),c.push([M,b]))}if(s!==void 0&&!d(h[0],h[1]))return;let f=[];for(let u=l(h[0],h[1]);u!==-1;u=a.get(u))f.push({k:u>>1,enter:u&1});return f.reverse()}loosePath(t,n,e){let s=new Set(t),i=new Map([[n,-1]]),r=new Map([[n,0]]),l=[n];for(let a of l){if(a===e)break;for(let c of pt)for(let[h,f]of this.links[a][c])!s.has(h)||i.has(h)||(i.set(h,a),r.set(h,f),l.push(h))}let d=[];for(let a=e;a!==-1;a=i.get(a))d.push({k:a,enter:r.get(a)});return d.reverse()}spineLength(t){let{link:n}=this.c;return t.reduce((e,{k:s})=>e+this.drawn(s)+n,n)}layAlong(t,n,e,s){let{count:i,per:r,link:l}=this.c,d=e,a=[];for(let{k:c,enter:h}of t){let f=s??r[c],u=[],g=[];for(let M=0;M<i[c];M++)u.push(n.pointAt(d+M*f)),g.push(d+M*f);h===1&&(u.reverse(),g.reverse()),this.points[c]=u,this.params[c]=g,this.curves[c]=n,a.push(...u),d+=f*(i[c]-1)+l}return a}arcCandidates(t,n,e,s,i){let r=(i-s)/2-1e-6,l=i>2*s?nn:[0],d=[];for(let a of at(0,8))for(let c of l)for(let h=0;h<=16;h++){let f=r*h/16,u=It(mt(s,i,f,a),s,c);h<16&&u.apex<12||rn(u)||d.push(g=>yt(t,n,e,M=>It(mt(s,M,Math.min(f,(M-s)/2-1e-6),a),s,c),i,g))}return d}placePiece(t,n){var e;let{count:s,link:i}=this.c,r=this.anchorsOf(t);if(r.length===0)return;let l=t.every(x=>this.route[x]),d=r.every(x=>x.curve===r[0].curve)?r[0].curve:void 0,a,c,h,f;if(d)r.sort((x,F)=>x.t-F.t),a=d,c=r[0].t,h=r[r.length-1].t,f=a===this.backbone&&l?-1:1;else{r.sort((W,Q)=>W.point.x-Q.point.x||W.point.y-Q.point.y);let x=r[0].point,F=r[r.length-1].point,V=Math.hypot(F.x-x.x,F.y-x.y),B=V>1e-9?lt(x,F):{x:1,y:0},U={x:-B.y,y:B.x},C=gt(x,F,.5);f=r.some(W=>W.curve===this.backbone)?(l?-1:1)*(Math.sign(U.y)||1):(C.x-n.x)*U.x+(C.y-n.y)*U.y>=0?1:-1,a=new ot([x,F],[U,U],!0),c=0,h=V}let u=r[0],g=r[r.length-1],M=h-c,b=r.length===1||u.u===g.u&&u.uSide===g.uSide&&M<1e-9,D=[u.point,g.point],v=x=>this.choose(x,d,D),A,y,L=i,w;if(b){A=this.spinePath(t,u.u,u.uSide);let x=this.spineLength(A),F=u.vSide?Math.max(0,s[u.v]-2):Math.min(1,s[u.v]-1),B=(u.t>=this.params[u.v][F]?1:-1)*Math.cos(kt),U=Math.sin(kt);y=v(at(0,12).map(C=>W=>yt(a,c,f,Q=>Ot(0,C,B,U,Q),x,W)))}else{A=(e=this.spinePath(t,u.u,u.uSide,g.u,g.uSide))!==null&&e!==void 0?e:this.loosePath(t,u.u,g.u);let x=this.spineLength(A);if(l){let F=Math.max(12,Math.min(Pt*M,St));y=v(at(F,12).map(B=>U=>xt(a,c,f,mt(M,sn(M,B),0,0),U)));let V=Dt(y.pts);w=Math.max(.001,(V-2*i)/(s[A[0].k]-1))}else if(x>M+1e-6)y=v(this.arcCandidates(a,c,f,M,x));else{let F=x-2*i,V=Math.max(12,Math.min(Pt*(M-F),St));y=v(at(V,12).map(B=>U=>yt(a,c,f,C=>Ot(M/2-C/2,B,1,0,C),F,U))),L=0}}let E=new ot(y.pts,cn(y.pts,y.refs)),O=this.layAlong(A,E,L,w);this.occupy(O,E);let _=Ut(O),R=t.filter(x=>!this.points[x]),T=this.componentsOf(R).map(x=>({members:x,span:Ft(this.anchorsOf(x))})).sort((x,F)=>x.span-F.span);for(let x of T)this.placePiece(x.members,_)}};function Mt(o){let t=new Float64Array(o.n).fill(NaN),n=new Float64Array(o.n).fill(NaN);if(ht.hasBackbone(o)){let e=new ht(o);e.run(),e.write(t,n)}return{X:t,Y:n}}var ln=[{walks:2,iterations:15},{walks:4,iterations:30},{walks:8,iterations:60},{walks:12,iterations:90},{walks:16,iterations:120}],hn=20,fn=3,wt=.3,un=2,dn=200,pn=.1,mn=.5,yn=o=>{var t;return((t=o.stable)===null||t===void 0?void 0:t.rank)===0};function Ct(o,t){let n=t.at(-1);return(o==="+"||o==="-")&&(n==="+"||n==="-")&&o!==n}function gn(o){let t=Math.imul(o,2654435761)>>>0||1;return()=>(t^=t<<13,t>>>=0,t^=t>>>17,t^=t<<5,t>>>=0,t/4294967296)}function z(o,t){return typeof o=="number"&&Number.isFinite(o)?o:t}function At(o,t){return Math.max(z(o.nodeLengthPerMegabase,1e3)*t/1e6,z(o.minimumNodeLength,1))}function Ht(o){let{nodes:t,edges:n}=o.graph,e=o.options,s=z(e.nodeSegmentLength,1),i=z(e.edgeLength,1),r=t.map(w=>w.id),l=new Int32Array(t.length),d=new Int32Array(t.length),a=new Float64Array(t.length),c=0;t.forEach((w,E)=>{let O=At(e,w.length),_=Math.max(1,Math.ceil(O/s));l[E]=c,d[E]=_+1,a[E]=O/_,c+=_+1});let h=new Int32Array(c),f=new Int32Array(c),u=new Float64Array(c).fill(NaN),g=new Float64Array(c).fill(NaN),M=new Uint8Array(c),b=Array.from({length:c},()=>[]);t.forEach((w,E)=>{let O=typeof w.x=="number"&&typeof w.y=="number",_=yn(w)?1:0;for(let R=0;R<d[E];R++){let T=l[E]+R;h[T]=E,f[T]=R,M[T]=_,O&&(u[T]=w.x+R*a[E],g[T]=w.y),R>0&&(b[T-1].push([T,a[E]]),b[T].push([T-1,a[E]]))}});let D=new Map(r.map((w,E)=>[w,E])),v=t.map(()=>[[],[]]);for(let w of n){let E=D.get(w.from),O=D.get(w.to);if(E===void 0||O===void 0||E===O&&d[E]<=2)continue;let _=Ct(w.fromStrand,w.from)?0:1,R=Ct(w.toStrand,w.to)?1:0,T=l[E]+(_?d[E]-1:0),x=l[O]+(R?d[O]-1:0);b[T].push([x,i]),b[x].push([T,i]),v[E][_].push([O,R]),v[O][R].push([E,_])}let A=new Int32Array(c+1);for(let w=0;w<c;w++)A[w+1]=A[w]+b[w].length;let y=new Int32Array(A[c]),L=new Float64Array(A[c]);for(let w=0;w<c;w++)b[w].forEach(([E,O],_)=>{y[A[w]+_]=E,L[A[w]+_]=O});return{ids:r,first:l,count:d,per:a,links:v,chainOf:h,indexOf:f,seedX:u,seedY:g,backbone:M,off:A,nb:y,wt:L,n:c,link:i}}function xn(o){let{n:t,off:n,nb:e}=o,s=new Int32Array(t).fill(-1),i=[];for(let r=0;r<t;r++){if(s[r]>=0)continue;let l=[r];s[r]=i.length;for(let d of l)for(let a=n[d];a<n[d+1];a++){let c=e[a];s[c]<0&&(s[c]=i.length,l.push(c))}i.push(l)}return{comp:s,members:i}}function Nt(o,t={}){var n,e,s;let i=Ht(o),{n:r,off:l,nb:d,wt:a,seedX:c,seedY:h,first:f,count:u,per:g,link:M}=i,b=o.options,D=ln[Math.max(0,Math.min(4,z((n=t.quality)!==null&&n!==void 0?n:b.quality,2)))],v=z((e=t.componentSeparation)!==null&&e!==void 0?e:b.componentSeparation,15),A=gn(z((s=t.seed)!==null&&s!==void 0?s:b.seed,1)),y=new Float64Array(r),L=new Float64Array(r),w={};if(r===0)return{nodePositions:w};let{comp:E,members:O}=xn(i),_=1/0,R=0;for(let p=0;p<d.length;p++)_=Math.min(_,a[p]),R+=a[p];R/=2;let T=!1;for(let p=0;p<r;p++)if(!Number.isNaN(c[p])){T=!0;break}let x=T?Mt(i):void 0,F=Math.sqrt(r)*20;for(let p=0;p<r;p++)x&&!Number.isNaN(x.X[p])?(y[p]=x.X[p],L[p]=x.Y[p]):T&&!Number.isNaN(c[p])?(y[p]=c[p]+A()-.5,L[p]=h[p]+A()-.5):(y[p]=A()*F,L[p]=A()*F);let V=O.map(p=>x!==void 0&&p.every(N=>!Number.isNaN(x.X[N]))),B=[],U=!0;for(let p=0;p<r;p++)V[E[p]]||(B.push(p),U&&(U=!Number.isNaN(c[p])));let C=Math.max(R/4,_*10),W=C*C,Q=pn*_*_,{walks:Jt,iterations:rt}=D,Qt=Math.log(W/Q)/Math.max(1,rt-1),bt=Math.log(_),Zt=Math.log(C),Lt=(p,N,m,k)=>{let S=k/(m*m);S>1&&(S=1);let P=y[p]-y[N],I=L[p]-L[N],q=Math.sqrt(P*P+I*I)||1e-9,G=S*(q-m)/(2*q),j=G*P,H=G*I;y[p]=y[p]-j,L[p]=L[p]-H,y[N]=y[N]+j,L[N]=L[N]+H},et=0,Yt=(p,N)=>{let m=i.chainOf[p],k=i.indexOf[p],S=A()<.5?-1:1,P=N;for(let I=0;I<dn;I++){let q=u[m],G=g[m],j=(S>0?q-1-k:k)*G;if(P<=j){let J=Math.round(P/G);return et=N-P+J*G,f[m]+k+S*J}P-=j;let H=i.links[m][S>0?1:0];if(H.length===0)return et=N-P,f[m]+(S>0?q-1:0);let[Y,$]=H[Math.floor(A()*H.length)];if(P-=M,m=Y,S=$===0?1:-1,k=$===0?0:u[Y]-1,P<=0)return et=N-P,f[m]+k}return-1},Et=(p,N)=>{for(let m=l[p];m<l[p+1];m++){let k=d[m];k>p&&Lt(p,k,a[m],N)}},Z=Int32Array.from(B),Xt=U?Math.floor(mn*rt):0;for(let p=B.length?Xt:rt;p<rt;p++){let N=W*Math.exp(-Qt*p);for(let m=Z.length-1;m>0;m--){let k=Math.floor(A()*(m+1)),S=Z[m];Z[m]=Z[k],Z[k]=S}for(let m of Z){Et(m,N);for(let k=0;k<Jt;k++){let S=Math.exp(bt+A()*(Zt-bt)),P=Yt(m,S);P>=0&&P!==m&&et>0&&Lt(m,P,et,N)}}}let K=fn*M,tn=(p,N)=>Math.floor(p/K)*73856093^Math.floor(N/K)*19349663;for(let p=0;p<(B.length?hn:0);p++){let N=new Map;for(let m of B){let k=tn(y[m],L[m]),S=N.get(k);S?S.push(m):N.set(k,[m])}for(let m of B){let k=Math.floor(y[m]/K),S=Math.floor(L[m]/K);for(let P=k-1;P<=k+1;P++)for(let I=S-1;I<=S+1;I++){let q=N.get(P*73856093^I*19349663);if(q)for(let G of q){if(G<=m)continue;let j=!1;for(let X=l[m];X<l[m+1];X++)if(d[X]===G){j=!0;break}if(j)continue;let H=y[m]-y[G],Y=L[m]-L[G],$=Math.sqrt(H*H+Y*Y);if($>=K)continue;let J,it;if($>1e-6){let X=wt*(K-$)/(2*$);J=X*H,it=X*Y}else J=wt*K*(A()-.5),it=wt*K*(A()-.5);y[m]=y[m]+J,L[m]=L[m]+it,y[G]=y[G]-J,L[G]=L[G]-it}}}for(let m of B)Et(m,1/0)}for(let p=0;p<u.length;p++){let N=f[p],m=u[p];if(!(m<3)){for(let k=0;k<un;k++){let S=y.slice(N,N+m),P=L.slice(N,N+m);for(let I=1;I+1<m;I++)y[N+I]=.5*S[I]+.25*(S[I-1]+S[I+1]),L[N+I]=.5*P[I]+.25*(P[I-1]+P[I+1])}Mn(y,L,N,m,g[p])}}An(E,O,y,L,T,v);for(let p=0;p<i.ids.length;p++){let N=[];for(let m=0;m<u[p];m++)N.push({x:y[f[p]+m],y:L[f[p]+m]});w[i.ids[p]]=N}return{nodePositions:w}}function Mn(o,t,n,e,s){wn(o,t,n,e,s*(e-1));let i=new Float64Array(e);for(let c=1;c<e;c++)i[c]=i[c-1]+Math.hypot(o[n+c]-o[n+c-1],t[n+c]-t[n+c-1]);if(!i[e-1])return;let r=i[e-1],l=o.slice(n,n+e),d=t.slice(n,n+e),a=1;for(let c=1;c+1<e;c++){let h=r*c/(e-1);for(;a<e-1&&i[a]<h;)a++;let f=i[a]-i[a-1],u=f>0?(h-i[a-1])/f:0;o[n+c]=l[a-1]+(l[a]-l[a-1])*u,t[n+c]=d[a-1]+(d[a]-d[a-1])*u}}function wn(o,t,n,e,s){let i=n+e-1,r=o[n],l=t[n],d=Math.hypot(o[i]-r,t[i]-l),a=d>1e-9?(o[i]-r)/d:1,c=d>1e-9?(t[i]-l)/d:0,h=new Float64Array(e),f=new Float64Array(e),u=!0;for(let v=0;v<e;v++){let A=o[n+v]-r,y=t[n+v]-l;h[v]=A*a+y*c,f[v]=y*a-A*c,u&&(u=Math.abs(f[v])<1e-6)}let g=v=>{let A=0;for(let y=1;y<e;y++)A+=Math.hypot(h[y]-h[y-1],v*(f[y]-f[y-1]));return A};if(u||g(1)>=s)return;let M=1,b=2;for(;g(b)<s&&b<1e6;)M=b,b*=2;for(let v=0;v<40;v++){let A=(M+b)/2;g(A)<s?M=A:b=A}let D=(M+b)/2;for(let v=1;v+1<e;v++)o[n+v]=r+h[v]*a-D*f[v]*c,t[n+v]=l+h[v]*c+D*f[v]*a}function An(o,t,n,e,s,i){if(!s)for(let h of t)Nn(n,e,h);if(t.length<2)return;let r=new Float64Array(t.length).fill(1/0),l=new Float64Array(t.length).fill(1/0),d=new Float64Array(t.length).fill(-1/0);for(let h=0;h<n.length;h++){let f=o[h];r[f]=Math.min(r[f],n[h]),l[f]=Math.min(l[f],e[h]),d[f]=Math.max(d[f],e[h])}let a=new Float64Array(t.length),c=0;for(let h=0;h<t.length;h++)a[h]=c-l[h],c+=d[h]-l[h]+i;for(let h=0;h<n.length;h++){let f=o[h];n[h]=n[h]-r[f],e[h]=e[h]+a[f]}}function Nn(o,t,n){if(n.length<3)return;let e=0,s=0;for(let h of n)e+=o[h],s+=t[h];e/=n.length,s/=n.length;let i=0,r=0,l=0;for(let h of n){let f=o[h]-e,u=t[h]-s;i+=f*f,r+=u*u,l+=f*u}let d=-.5*Math.atan2(2*l,i-r),a=Math.cos(d),c=Math.sin(d);for(let h of n){let f=o[h]-e,u=t[h]-s;o[h]=e+a*f-c*u,t[h]=s+c*f+a*u}}var Vt=[{value:"fmmm",label:"Bandage (FMMM)",description:"Bandage's force-directed layout: OGDF's fast multipole multilevel method, compiled to wasm."},{value:"stress",label:"Stress",description:"Plain JS: the reference drawn straight and each variant placed against it, an allele as a lens, a repeat loop as a ring, a deletion as an arch; stress by stochastic gradient descent for components with no reference."}],vn=Vt.map(o=>o.value);var bn=async o=>{let t=performance.now();return{result:o.options.engine==="stress"?Nt(o):await dt(o),duration:performance.now()-t}};var st=40,Kt=500,ft=5;function Ln(o,t){return Math.max(o.nodeLengthPerMegabase*t/1e6,o.minimumNodeLength)}function qt(o,t=ft){let e=o.nodes.reduce((i,r)=>i+r.length,0)/1e6,s=Math.max(o.nodes.length*st,Kt);return{nodeLengthPerMegabase:e>0?s/e:1e4,minimumNodeLength:Math.max(ft,t),edgeLength:5,nodeSegmentLength:20}}var nt={power:1,effect:1};function jt(o){return o.power===1&&o.effect===1}function zt(o,t){let n=o.nodes.length,e=o.nodes.reduce((r,l)=>r+l.length,0),s=n>0?e/n:0,i=n>0?Math.max(n*st,Kt)/n:st;return r=>{if(s<=0)return i;let l=(r/s)**t.power;return Math.max(i*((l-1)*t.effect+1),ft)}}var Wt=1e3,$t={law:nt,minNodeLength:0};function Qn(o,t=$t){let{law:n,minNodeLength:e}=t,s=qt(o,e);if(jt(n))return{nodes:o.nodes,opts:s};let i=zt(o,n);return{nodes:o.nodes.map(r=>({...r,length:Math.round(i(r.length)*Wt)})),opts:{...s,nodeLengthPerMegabase:1e6/Wt,minimumNodeLength:ft}}}function Zn(o,t=$t){if(jt(t.law)){let n=qt(o,t.minNodeLength);return e=>Ln(n,e)}return zt(o,t.law)}var vt=[{value:"auto",label:"Proportional",description:"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.",law:nt,minNodeFactor:0},{value:"open",label:"Open bubbles",description:"Give every allele a drawn length, so a bubble reads as two arms rather than a knot.",law:nt,minNodeFactor:2.5},{value:"wide",label:"Wide bubbles",description:"As open, spread further. Best on a window of a dozen bubbles.",law:nt,minNodeFactor:10},{value:"compress",label:"Compress lengths",description:"Pull the longest and shortest nodes towards the graph\u2019s mean, so a cut spanning kb and bp fits one pane.",law:{power:.5,effect:.5},minNodeFactor:0}],En=vt.map(o=>o.value);function kn(o){let t=vt.find(n=>n.value===o);return{law:t?.law??nt,minNodeLength:(t?.minNodeFactor??0)*st}}export{Bt as a,Vt as b,vn as c,bn as d,Ln as e,Qn as f,Zn as g,vt as h,En as i,kn as j};
2
- //# sourceMappingURL=chunk-UW7INEQF.js.map
2
+ //# sourceMappingURL=chunk-2XZYJLCE.js.map