jbrowse-plugin-graphgenomeviewer 7.1.0 → 7.1.1

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 (60) hide show
  1. package/README.md +17 -8
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-TIXR4Y3J.js → GbzBaseSyntenyAdapter-A56NDFW7.js} +2 -2
  3. package/dist/chunks/{GbzBaseSyntenyAdapter-TIXR4Y3J.js.map → GbzBaseSyntenyAdapter-A56NDFW7.js.map} +1 -1
  4. package/dist/chunks/{GraphGenomeView-Z2WZKEEO.js → GraphGenomeView-BG7UHKCT.js} +2 -2
  5. package/dist/chunks/{GraphTrackSettingsDialog-TAM6PMXD.js → GraphTrackSettingsDialog-YOJF7KCT.js} +2 -2
  6. package/dist/chunks/{HighlightColorDialog-EYBKFSJU.js → HighlightColorDialog-YT55H62Y.js} +2 -2
  7. package/dist/chunks/{LinearGraphDisplay-WIBVWRQE.js → LinearGraphDisplay-SPILNH4J.js} +2 -2
  8. package/dist/chunks/{MinigraphBubbleAdapter-AGI2UYQR.js → MinigraphBubbleAdapter-2XGZPDI4.js} +2 -2
  9. package/dist/chunks/{RgfaTabixAdapter-2OL5X3HF.js → RgfaTabixAdapter-ZTFVNM4G.js} +2 -2
  10. package/dist/chunks/{WalkTabixSyntenyAdapter-UKFHCFOF.js → WalkTabixSyntenyAdapter-I6E6HAN4.js} +2 -2
  11. package/dist/chunks/{chunk-WX26KTZM.js → chunk-2QQDYK5V.js} +2 -2
  12. package/dist/chunks/{chunk-AMFIBQVR.js → chunk-4IJKHORO.js} +2 -2
  13. package/dist/chunks/{chunk-AMFIBQVR.js.map → chunk-4IJKHORO.js.map} +3 -3
  14. package/dist/chunks/chunk-6CAAGNOP.js +4 -0
  15. package/dist/chunks/{chunk-IJQTSJGT.js.map → chunk-6CAAGNOP.js.map} +3 -3
  16. package/dist/chunks/{chunk-AU73K7LX.js → chunk-77GS3NVS.js} +1 -1
  17. package/dist/chunks/{chunk-AU73K7LX.js.map → chunk-77GS3NVS.js.map} +1 -1
  18. package/dist/chunks/{chunk-XT766CZ5.js → chunk-ABNOMXT3.js} +1 -1
  19. package/dist/chunks/{chunk-XT766CZ5.js.map → chunk-ABNOMXT3.js.map} +1 -1
  20. package/dist/chunks/{chunk-MHPJB22Z.js → chunk-CPCTMFXV.js} +2 -2
  21. package/dist/chunks/{chunk-MHPJB22Z.js.map → chunk-CPCTMFXV.js.map} +1 -1
  22. package/dist/chunks/{chunk-YJHYBDYF.js → chunk-FAVU7473.js} +2 -2
  23. package/dist/chunks/{chunk-YJHYBDYF.js.map → chunk-FAVU7473.js.map} +1 -1
  24. package/dist/chunks/{chunk-BJMRBVG3.js → chunk-FBGWMI6M.js} +2 -2
  25. package/dist/chunks/{chunk-BJMRBVG3.js.map → chunk-FBGWMI6M.js.map} +1 -1
  26. package/dist/chunks/{chunk-GOFS7BXK.js → chunk-G63ZHV6F.js} +2 -2
  27. package/dist/chunks/{chunk-YSTMDXXX.js → chunk-GUNY323E.js} +1 -1
  28. package/dist/chunks/{chunk-YSTMDXXX.js.map → chunk-GUNY323E.js.map} +1 -1
  29. package/dist/chunks/{chunk-446RWIA3.js → chunk-IIGYYZI5.js} +1 -1
  30. package/dist/chunks/{chunk-446RWIA3.js.map → chunk-IIGYYZI5.js.map} +1 -1
  31. package/dist/chunks/{chunk-3Q4RBDCL.js → chunk-JT3RXYIL.js} +1 -1
  32. package/dist/chunks/{chunk-3Q4RBDCL.js.map → chunk-JT3RXYIL.js.map} +1 -1
  33. package/dist/chunks/{chunk-5SFGHDQA.js → chunk-NKBE5KYL.js} +2 -2
  34. package/dist/chunks/{chunk-5SFGHDQA.js.map → chunk-NKBE5KYL.js.map} +1 -1
  35. package/dist/chunks/{chunk-EWFJBQDV.js → chunk-S3QFRJR3.js} +2 -2
  36. package/dist/chunks/{chunk-EWFJBQDV.js.map → chunk-S3QFRJR3.js.map} +1 -1
  37. package/dist/chunks/{chunk-DZ4OUKQV.js → chunk-SIGBYUXP.js} +2 -2
  38. package/dist/chunks/{chunk-DZ4OUKQV.js.map → chunk-SIGBYUXP.js.map} +1 -1
  39. package/dist/chunks/{chunk-IXQK7JAW.js → chunk-T4HOC6O3.js} +1 -1
  40. package/dist/chunks/{chunk-IXQK7JAW.js.map → chunk-T4HOC6O3.js.map} +1 -1
  41. package/dist/chunks/{chunk-SAMJE6GH.js → chunk-WI7LRX6I.js} +2 -2
  42. package/dist/chunks/{chunk-J6NZIAZF.js → chunk-YAADZ2AI.js} +2 -2
  43. package/dist/chunks/{chunk-J6NZIAZF.js.map → chunk-YAADZ2AI.js.map} +1 -1
  44. package/dist/chunks/{renderSvg-ST2GBBOC.js → renderSvg-B3WCFN65.js} +2 -2
  45. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +2 -2
  46. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +2 -2
  47. package/package.json +6 -6
  48. package/src/version.ts +1 -1
  49. package/dist/chunks/chunk-IJQTSJGT.js +0 -4
  50. /package/dist/chunks/{GraphGenomeView-Z2WZKEEO.js.map → GraphGenomeView-BG7UHKCT.js.map} +0 -0
  51. /package/dist/chunks/{GraphTrackSettingsDialog-TAM6PMXD.js.map → GraphTrackSettingsDialog-YOJF7KCT.js.map} +0 -0
  52. /package/dist/chunks/{HighlightColorDialog-EYBKFSJU.js.map → HighlightColorDialog-YT55H62Y.js.map} +0 -0
  53. /package/dist/chunks/{LinearGraphDisplay-WIBVWRQE.js.map → LinearGraphDisplay-SPILNH4J.js.map} +0 -0
  54. /package/dist/chunks/{MinigraphBubbleAdapter-AGI2UYQR.js.map → MinigraphBubbleAdapter-2XGZPDI4.js.map} +0 -0
  55. /package/dist/chunks/{RgfaTabixAdapter-2OL5X3HF.js.map → RgfaTabixAdapter-ZTFVNM4G.js.map} +0 -0
  56. /package/dist/chunks/{WalkTabixSyntenyAdapter-UKFHCFOF.js.map → WalkTabixSyntenyAdapter-I6E6HAN4.js.map} +0 -0
  57. /package/dist/chunks/{chunk-WX26KTZM.js.map → chunk-2QQDYK5V.js.map} +0 -0
  58. /package/dist/chunks/{chunk-GOFS7BXK.js.map → chunk-G63ZHV6F.js.map} +0 -0
  59. /package/dist/chunks/{chunk-SAMJE6GH.js.map → chunk-WI7LRX6I.js.map} +0 -0
  60. /package/dist/chunks/{renderSvg-ST2GBBOC.js.map → renderSvg-B3WCFN65.js.map} +0 -0
package/README.md CHANGED
@@ -84,24 +84,33 @@ In reading order:
84
84
  - [sequenceTubeMap, MemPanG26 edition](https://github.com/cmdcolin/sequenceTubeMap):
85
85
  our fork of the tube map app
86
86
 
87
- ### Programmatic usage
87
+ Supporting utility libraries
88
88
 
89
- - [@jbrowse/bandage-core](https://github.com/GMOD/bandage-core) (npm): layout
90
- and drawing engine, plus `bandage-figure` for SVGs with no browser
91
- - [@jbrowse/graph-stress-layout](https://github.com/GMOD/graph-stress-layout)
92
- (npm): stress layout
89
+ - [@jbrowse/bandage-core](https://github.com/GMOD/bandage-core) (npm): bandage
90
+ layout and drawing engine
93
91
  - [@jbrowse/tubemap-core](https://github.com/GMOD/tubemap-core) (npm): tube map
94
92
  layout
95
93
  - [@gmod/gbz-base](https://github.com/GMOD/gbz-base-js) (npm): `.gbz.db` reader
96
- - [ggbandage](https://github.com/GMOD/ggbandage) (R): Bandage layout as ggplot2
97
- layers
98
- - [ggtubemap](https://github.com/GMOD/ggtubemap) (R): tube map as ggplot2 layers
94
+
95
+ Supporting graph layout libraries
96
+
97
+ - [@jbrowse/graph-stress-layout](https://github.com/GMOD/graph-stress-layout)
98
+ - [@jbrowse/graph-fmmm-layout](https://github.com/GMOD/graph-fmmm-layout)
99
+
100
+ Supporting data preparation toolkits
101
+
99
102
  - [gfa-to-tabix](https://github.com/GMOD/gfa-to-tabix): indexes a GFA
100
103
  - [gbz-haplotype-index](https://github.com/GMOD/gbz-haplotype-index): names
101
104
  every walk in a gbz-base cut
102
105
  - [gfa-to-pairwise-paf](https://github.com/cmdcolin/gfa-to-pairwise-paf-rs):
103
106
  graph to PAF, for synteny views
104
107
 
108
+ Standalone R packages
109
+
110
+ - [ggbandage](https://github.com/GMOD/ggbandage) (R): Bandage layout as ggplot2
111
+ layers
112
+ - [ggtubemap](https://github.com/GMOD/ggtubemap) (R): tube map as ggplot2 layers
113
+
105
114
  ## License
106
115
 
107
116
  GPL-3.0-or-later, based on work from Bandage and OGDF, both GPL.
@@ -1,2 +1,2 @@
1
- import{a as q,b as re,c as de,d as oe,e as T}from"./chunk-SAMJE6GH.js";import{a as ne}from"./chunk-KOB7YIMR.js";import{a as Z,b as U,c as X,d as g,e as C,f as M,g as k,h as E,i as z,k as Y}from"./chunk-YJHYBDYF.js";import"./chunk-EWFJBQDV.js";import{a as O,b as H}from"./chunk-3Q4RBDCL.js";import"./chunk-AU73K7LX.js";import"./chunk-IXQK7JAW.js";import{a as ae}from"./chunk-TXI43PEN.js";import{a as ee,c as L,f as te}from"./chunk-AMFIBQVR.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{e as A,f as P,g as B}from"./chunk-446RWIA3.js";import"./chunk-E7J6SB5P.js";import{b as G,e as J,f as K,g as V}from"./chunk-5OI6LO4I.js";import"./chunk-7WIBGKBU.js";import{a as N}from"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{e as W,o as $}from"./chunk-TENPGIPX.js";function F(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function fe(n){return K(n)&&F(J(n))?V(n,i=>F(i)):void 0}function he(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function se(n,i){let t=fe(n);if(!t)return{};try{return await N(t,i).stat(),{location:t}}catch(e){return he(e)?{}:{unreadable:String(e)}}}var ge=5e3,ue=50*2**20,_=class extends Error{constructor(t){super(`this GAF is ${(t/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function ye(n,i){if(n.length<=i)return n;let t=n.length/i;return Array.from({length:i},(e,a)=>n[Math.floor(a*t)])}var ie=(n,i)=>n.path.some(t=>i.has(t.name)),v=class{constructor(i,t){this.file=i;this.tabix=t;this.whole=L({setup:async({signal:i})=>{let{size:t}=await this.file.stat();if(t>ue)throw new _(t);let e=await this.file.readFile({signal:i}),a=new TextDecoder().decode(e[0]===31&&e[1]===139?await ee(e):e);return H(a)}})}async readIndexed(i,t,e){let a=1/0,r=-1/0;for(let c of t){let s=Number(c);Number.isInteger(s)&&(a=Math.min(a,s),r=Math.max(r,s))}let o=[];return a<=r&&await i.getLines("{node}",a,r+1,{signal:e,lineCallback:c=>{let s=O(c);s&&ie(s,t)&&o.push(s)}}),o}async readsOver(i,{signal:t}={}){let e=this.tabix?await this.readIndexed(this.tabix,i,t):(await this.whole({signal:t})).filter(a=>ie(a,i));return{records:ye(e,ge),total:e.length}}};var I=class extends Error{constructor(t){super(t===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 (${t}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},D=class extends Error{constructor(t,e){super(`the graph is cut on its reference, ${e}; a window on ${t} has no reference coordinates to cut at. Open the graph from a ${e} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function be(n,i){return`${g(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function we({alignment:n,assemblyName:i,refName:t,lane:e}){let{refStart:a,refEnd:r,strand:o,cigar:c}=n;if(!(r<=a)){let{name:s,hapStart:p,hapEnd:l}=n,f=be(s,n),u={uniqueId:f,assemblyName:i,refName:t,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:c,syntenyId:f,mate:{refName:s.contig,start:p,end:l,assemblyName:e}};return new q(u)}}function xe({pair:n,lane:i,mateLane:t}){let e=`${g(n.target)}#${n.target.contig}:${n.targetStart}-${n.targetEnd}|${g(n.query)}#${n.query.contig}:${n.queryStart}-${n.queryEnd}`;return new q({uniqueId:e,assemblyName:i,refName:n.target.contig,start:n.targetStart,end:n.targetEnd,type:"match",strand:n.strand==="-"?-1:1,CIGAR:n.cigar,syntenyId:e,identity:n.matches/Math.max(n.columns,1),numMatches:n.matches,blockLen:n.columns,mate:{refName:n.query.contig,start:n.queryStart,end:n.queryEnd,assemblyName:t}})}var Se=12e4;function Pe(n,i){let t=new Map;for(let a of n)for(let{name:r,start:o,end:c}of a.walkSpans()){let s=g(r);if(i.has(s)){let p=`${s}#${r.contig}`,l=t.get(p);l?l.push([o,c]):t.set(p,[[o,c]])}}let e=0;for(let a of t.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<=Se&&(e=Math.max(e,o))}}return e}function Q(n,i){return n instanceof X&&(n.message=`Zoom in to about ${W(n.fitsBp)} to see ${i}`),n}var ce=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),j=class extends re{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let t=this.getConf("gbzDbLocation"),e=this.getConf("haplotypeIndexLocation"),a=G(e)?{location:e}:await se(t,this.pluginManager),r=a.location,o=await U.open({source:N(t,this.pluginManager),haplotypeIndex:r?N(r,this.pluginManager):void 0}),c=this.getConf("assemblyNames")[0];if(c===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let s=await M(o),p=k({configured:this.getConf("referenceSample"),anchorPrefix:P(this,c),referenceSamples:s});return{db:o,anchor:c,referenceSample:p,referenceSamples:s,unreadableIndex:a.unreadable}}});this.gaf=L({label:"Opening reads",setup:async()=>{let t=this.getConf("readsLocation"),e=this.getConf(["readsIndex","location"]);return G(t)?new v(N(t,this.pluginManager),G(e)?te(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(t,e){let{db:a,referenceSample:r}=await this.graph(e);return E(a,r,t)}async getHaplotypes(t={}){let{db:e,referenceSamples:a}=await this.graph(t),r=new Map;for(let o of await e.paths()){let c=g(o.name),s=r.get(c);s?s.contigs.includes(o.name.contig)||s.contigs.push(o.name.contig):r.set(c,{prefix:c,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(t={}){let{anchor:e,referenceSample:a,referenceSamples:r}=await this.graph(t),o=B(this),c=[];for(let s of await this.getHaplotypes(t))s.sample!==a&&c.push({name:T(o,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:e,referenceSample:a,referenceSamples:r,lanes:c}}async getRefNames(t={}){let{db:e,anchor:a,referenceSample:r}=await this.graph(t),{assemblyName:o}=t,c=o===a?void 0:P(this,o),s=(await e.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:A(g(p.name),c)).map(p=>p.name.contig);return[...new Set(s)]}keepPredicate(t,e){let a=t===void 0||t.length===0?void 0:t.map(r=>P(this,r));return a===void 0&&e===void 0?void 0:r=>C(r,a)&&(e===void 0||A(g(r),e))}async getSubgraph(t,e={}){let{signal:a}=e,{db:r,anchor:o,referenceSample:c,unreadableIndex:s}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:f,end:u}=ce(t);if(p!==o)throw new D(p,o);let y=await this.referenceQuery(l,{signal:a});if(!y)throw new Error(`${c} has no indexed path ${l} in this graph`);let x=this.keepPredicate(e.haplotypes);if(x!==void 0&&!r.hasHaplotypeIndex)throw new I(s);let m=await Y(r,y,f,u,{context:this.getConf("context"),snarls:e.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:e.signal,keep:x}).catch(b=>{throw Q(b,"the graph")});return typeof m=="string"?m:ae(m,{start:f,end:u},e.walkRows)}async getReads(t,e={}){let a=await this.gaf(e);return a?a.readsOver(new Set(t),e):{records:[],total:0}}async laneHaplotypes(t,e){let a=P(this,t);return(await this.getHaplotypes(e)).filter(r=>A(r.prefix,a))}async anchorFeatures(t,e){let{db:a}=await this.graph(e),{assemblyName:r,refName:o,start:c,end:s}=t,p=P(this,e.targetAssemblyName),l=B(this),f=this.keepPredicate(e.haplotypes,p),u=await this.referenceQuery(o,e),y=this.getConf("nodeLimit");return(u?await $(`Reading graph ${o}:${c.toLocaleString()}-${s.toLocaleString()}`,e.statusCallback,()=>a.getAlignments({path:u,start:c,end:s,context:this.getConf("context"),haplotypes:"all",limit:y,signal:e.signal,keep:f}).catch(m=>{throw Q(z(m,y,s-c)??m,"lanes")})):[]).flatMap(m=>{let b=m.resolved?we({alignment:m,assemblyName:r,refName:o,lane:T(l,g(m.name))}):void 0;return b===void 0?[]:[b]})}async pairFeatures(t,e,a){let{db:r}=await this.graph(a),{refName:o,start:c,end:s}=t,l=(await Promise.all(e.map(async d=>({pair:d,featureSide:await this.laneHaplotypes(d.queryAssemblyName,a),mateSide:await this.laneHaplotypes(d.targetAssemblyName,a)})))).filter(({featureSide:d,mateSide:h})=>d.length>0&&h.length>0),f=new Set(l.flatMap(({featureSide:d,mateSide:h})=>[...d,...h].map(g))),u=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),x=this.getConf("context"),[m]=e,b=(d,h)=>r.getSubgraphs({path:d,start:c,end:s,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:S=>f.has(g(S))}),pe=async d=>{let h=await b(d,x).catch(w=>{throw Q(z(w,y,s-c)??w,"lanes")}),S=Pe(h,f),R=Math.ceil(S/2)+2e3;return S>0&&R>x?b(d,R).catch(w=>{if(w instanceof Z)return h;throw w}):h};return(u&&m&&l.length>0?await $(e.length===1?`Reading ${m.queryAssemblyName} against ${m.targetAssemblyName}`:`Reading ${e.length} lane pairs`,a.statusCallback,()=>pe(u)):[]).flatMap(d=>l.flatMap(({pair:h,featureSide:S,mateSide:R})=>S.flatMap(w=>R.flatMap(le=>d.pairAlignments({target:w,query:le,bases:!1}).map(me=>xe({pair:me,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(t,e={}){let a=ce(t);return ne(async r=>{let{db:o,anchor:c,unreadableIndex:s}=await this.graph(e);if(!o.hasHaplotypeIndex)throw new I(s);if(a.assemblyName===c){let p=oe(e),l=p.length>0?await this.pairFeatures(a,p,e):await this.anchorFeatures(a,e);for(let f of l)r.next(f)}r.complete()},e.signal)}};export{D as HaplotypeWindowError,I as NoHaplotypeIndexError,de as PairTargetError,j as default,we as fragmentFeature,xe as pairFeature,Pe as widestWalkGap};
2
- //# sourceMappingURL=GbzBaseSyntenyAdapter-TIXR4Y3J.js.map
1
+ import{a as q,b as re,c as de,d as oe,e as T}from"./chunk-WI7LRX6I.js";import{a as ne}from"./chunk-KOB7YIMR.js";import{a as Z,b as U,c as X,d as g,e as C,f as M,g as k,h as E,i as z,k as Y}from"./chunk-FAVU7473.js";import"./chunk-S3QFRJR3.js";import{a as O,b as H}from"./chunk-JT3RXYIL.js";import"./chunk-77GS3NVS.js";import"./chunk-T4HOC6O3.js";import{a as ae}from"./chunk-TXI43PEN.js";import{a as ee,c as L,f as te}from"./chunk-4IJKHORO.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{e as A,f as P,g as B}from"./chunk-IIGYYZI5.js";import"./chunk-E7J6SB5P.js";import{b as G,e as J,f as K,g as V}from"./chunk-5OI6LO4I.js";import"./chunk-7WIBGKBU.js";import{a as N}from"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{e as W,o as $}from"./chunk-TENPGIPX.js";function F(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function fe(n){return K(n)&&F(J(n))?V(n,i=>F(i)):void 0}function he(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function se(n,i){let t=fe(n);if(!t)return{};try{return await N(t,i).stat(),{location:t}}catch(e){return he(e)?{}:{unreadable:String(e)}}}var ge=5e3,ue=50*2**20,_=class extends Error{constructor(t){super(`this GAF is ${(t/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function ye(n,i){if(n.length<=i)return n;let t=n.length/i;return Array.from({length:i},(e,a)=>n[Math.floor(a*t)])}var ie=(n,i)=>n.path.some(t=>i.has(t.name)),v=class{constructor(i,t){this.file=i;this.tabix=t;this.whole=L({setup:async({signal:i})=>{let{size:t}=await this.file.stat();if(t>ue)throw new _(t);let e=await this.file.readFile({signal:i}),a=new TextDecoder().decode(e[0]===31&&e[1]===139?await ee(e):e);return H(a)}})}async readIndexed(i,t,e){let a=1/0,r=-1/0;for(let c of t){let s=Number(c);Number.isInteger(s)&&(a=Math.min(a,s),r=Math.max(r,s))}let o=[];return a<=r&&await i.getLines("{node}",a,r+1,{signal:e,lineCallback:c=>{let s=O(c);s&&ie(s,t)&&o.push(s)}}),o}async readsOver(i,{signal:t}={}){let e=this.tabix?await this.readIndexed(this.tabix,i,t):(await this.whole({signal:t})).filter(a=>ie(a,i));return{records:ye(e,ge),total:e.length}}};var I=class extends Error{constructor(t){super(t===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 (${t}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},D=class extends Error{constructor(t,e){super(`the graph is cut on its reference, ${e}; a window on ${t} has no reference coordinates to cut at. Open the graph from a ${e} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function be(n,i){return`${g(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function we({alignment:n,assemblyName:i,refName:t,lane:e}){let{refStart:a,refEnd:r,strand:o,cigar:c}=n;if(!(r<=a)){let{name:s,hapStart:p,hapEnd:l}=n,f=be(s,n),u={uniqueId:f,assemblyName:i,refName:t,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:c,syntenyId:f,mate:{refName:s.contig,start:p,end:l,assemblyName:e}};return new q(u)}}function xe({pair:n,lane:i,mateLane:t}){let e=`${g(n.target)}#${n.target.contig}:${n.targetStart}-${n.targetEnd}|${g(n.query)}#${n.query.contig}:${n.queryStart}-${n.queryEnd}`;return new q({uniqueId:e,assemblyName:i,refName:n.target.contig,start:n.targetStart,end:n.targetEnd,type:"match",strand:n.strand==="-"?-1:1,CIGAR:n.cigar,syntenyId:e,identity:n.matches/Math.max(n.columns,1),numMatches:n.matches,blockLen:n.columns,mate:{refName:n.query.contig,start:n.queryStart,end:n.queryEnd,assemblyName:t}})}var Se=12e4;function Pe(n,i){let t=new Map;for(let a of n)for(let{name:r,start:o,end:c}of a.walkSpans()){let s=g(r);if(i.has(s)){let p=`${s}#${r.contig}`,l=t.get(p);l?l.push([o,c]):t.set(p,[[o,c]])}}let e=0;for(let a of t.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<=Se&&(e=Math.max(e,o))}}return e}function Q(n,i){return n instanceof X&&(n.message=`Zoom in to about ${W(n.fitsBp)} to see ${i}`),n}var ce=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),j=class extends re{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let t=this.getConf("gbzDbLocation"),e=this.getConf("haplotypeIndexLocation"),a=G(e)?{location:e}:await se(t,this.pluginManager),r=a.location,o=await U.open({source:N(t,this.pluginManager),haplotypeIndex:r?N(r,this.pluginManager):void 0}),c=this.getConf("assemblyNames")[0];if(c===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let s=await M(o),p=k({configured:this.getConf("referenceSample"),anchorPrefix:P(this,c),referenceSamples:s});return{db:o,anchor:c,referenceSample:p,referenceSamples:s,unreadableIndex:a.unreadable}}});this.gaf=L({label:"Opening reads",setup:async()=>{let t=this.getConf("readsLocation"),e=this.getConf(["readsIndex","location"]);return G(t)?new v(N(t,this.pluginManager),G(e)?te(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(t,e){let{db:a,referenceSample:r}=await this.graph(e);return E(a,r,t)}async getHaplotypes(t={}){let{db:e,referenceSamples:a}=await this.graph(t),r=new Map;for(let o of await e.paths()){let c=g(o.name),s=r.get(c);s?s.contigs.includes(o.name.contig)||s.contigs.push(o.name.contig):r.set(c,{prefix:c,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(t={}){let{anchor:e,referenceSample:a,referenceSamples:r}=await this.graph(t),o=B(this),c=[];for(let s of await this.getHaplotypes(t))s.sample!==a&&c.push({name:T(o,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:e,referenceSample:a,referenceSamples:r,lanes:c}}async getRefNames(t={}){let{db:e,anchor:a,referenceSample:r}=await this.graph(t),{assemblyName:o}=t,c=o===a?void 0:P(this,o),s=(await e.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:A(g(p.name),c)).map(p=>p.name.contig);return[...new Set(s)]}keepPredicate(t,e){let a=t===void 0||t.length===0?void 0:t.map(r=>P(this,r));return a===void 0&&e===void 0?void 0:r=>C(r,a)&&(e===void 0||A(g(r),e))}async getSubgraph(t,e={}){let{signal:a}=e,{db:r,anchor:o,referenceSample:c,unreadableIndex:s}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:f,end:u}=ce(t);if(p!==o)throw new D(p,o);let y=await this.referenceQuery(l,{signal:a});if(!y)throw new Error(`${c} has no indexed path ${l} in this graph`);let x=this.keepPredicate(e.haplotypes);if(x!==void 0&&!r.hasHaplotypeIndex)throw new I(s);let m=await Y(r,y,f,u,{context:this.getConf("context"),snarls:e.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:e.signal,keep:x}).catch(b=>{throw Q(b,"the graph")});return typeof m=="string"?m:ae(m,{start:f,end:u},e.walkRows)}async getReads(t,e={}){let a=await this.gaf(e);return a?a.readsOver(new Set(t),e):{records:[],total:0}}async laneHaplotypes(t,e){let a=P(this,t);return(await this.getHaplotypes(e)).filter(r=>A(r.prefix,a))}async anchorFeatures(t,e){let{db:a}=await this.graph(e),{assemblyName:r,refName:o,start:c,end:s}=t,p=P(this,e.targetAssemblyName),l=B(this),f=this.keepPredicate(e.haplotypes,p),u=await this.referenceQuery(o,e),y=this.getConf("nodeLimit");return(u?await $(`Reading graph ${o}:${c.toLocaleString()}-${s.toLocaleString()}`,e.statusCallback,()=>a.getAlignments({path:u,start:c,end:s,context:this.getConf("context"),haplotypes:"all",limit:y,signal:e.signal,keep:f}).catch(m=>{throw Q(z(m,y,s-c)??m,"lanes")})):[]).flatMap(m=>{let b=m.resolved?we({alignment:m,assemblyName:r,refName:o,lane:T(l,g(m.name))}):void 0;return b===void 0?[]:[b]})}async pairFeatures(t,e,a){let{db:r}=await this.graph(a),{refName:o,start:c,end:s}=t,l=(await Promise.all(e.map(async d=>({pair:d,featureSide:await this.laneHaplotypes(d.queryAssemblyName,a),mateSide:await this.laneHaplotypes(d.targetAssemblyName,a)})))).filter(({featureSide:d,mateSide:h})=>d.length>0&&h.length>0),f=new Set(l.flatMap(({featureSide:d,mateSide:h})=>[...d,...h].map(g))),u=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),x=this.getConf("context"),[m]=e,b=(d,h)=>r.getSubgraphs({path:d,start:c,end:s,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:S=>f.has(g(S))}),pe=async d=>{let h=await b(d,x).catch(w=>{throw Q(z(w,y,s-c)??w,"lanes")}),S=Pe(h,f),R=Math.ceil(S/2)+2e3;return S>0&&R>x?b(d,R).catch(w=>{if(w instanceof Z)return h;throw w}):h};return(u&&m&&l.length>0?await $(e.length===1?`Reading ${m.queryAssemblyName} against ${m.targetAssemblyName}`:`Reading ${e.length} lane pairs`,a.statusCallback,()=>pe(u)):[]).flatMap(d=>l.flatMap(({pair:h,featureSide:S,mateSide:R})=>S.flatMap(w=>R.flatMap(le=>d.pairAlignments({target:w,query:le,bases:!1}).map(me=>xe({pair:me,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(t,e={}){let a=ce(t);return ne(async r=>{let{db:o,anchor:c,unreadableIndex:s}=await this.graph(e);if(!o.hasHaplotypeIndex)throw new I(s);if(a.assemblyName===c){let p=oe(e),l=p.length>0?await this.pairFeatures(a,p,e):await this.anchorFeatures(a,e);for(let f of l)r.next(f)}r.complete()},e.signal)}};export{D as HaplotypeWindowError,I as NoHaplotypeIndexError,de as PairTargetError,j as default,we as fragmentFeature,xe as pairFeature,Pe as widestWalkGap};
2
+ //# sourceMappingURL=GbzBaseSyntenyAdapter-A56NDFW7.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@10.2.4/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-VQWHMWLF.js", "../../src/GbzBaseSyntenyAdapter/companion.ts", "../../src/gaf/gafFile.ts", "../../src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts"],
3
+ "sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@10.2.5/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-VQWHMWLF.js", "../../src/GbzBaseSyntenyAdapter/companion.ts", "../../src/gaf/gafFile.ts", "../../src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts"],
4
4
  "sourcesContent": ["import {\n GBZ_CUT_DEFAULTS,\n cutWindowGFA,\n haplotypeWanted,\n referencePathQuery,\n referenceSamplesOf,\n resolveReferenceSample\n} from \"./chunk-Q7LYHGGQ.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 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 region like chr6:160,614,798-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 try {\n return resolveReferenceSample({\n configured: \"\",\n anchorPrefix: ref ?? samples[0] ?? \"\",\n referenceSamples: samples\n });\n } catch (e) {\n if (ref) {\n return ref;\n }\n throw e;\n }\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 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/walkRowRuns.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 { laneAssemblyName, requestedPairs } from '../synteny/lanePairs.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\nexport interface 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'\nexport type { LanePair } from '../synteny/lanePairs.ts'\n\nexport class 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\nexport function 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/**\n * One record of a lane pair, on the target walk's own contig with the query\n * walk as its mate. gbz-base writes the CIGAR along the target, a `D` being\n * target bases the query lacks, which is the side a JBrowse feature is, so it\n * passes through unchanged.\n */\nexport function pairFeature({\n pair,\n lane,\n mateLane,\n}: {\n pair: PairAlignment\n lane: string\n mateLane: string\n}) {\n const id = `${haplotypePrefix(pair.target)}#${pair.target.contig}:${pair.targetStart}-${pair.targetEnd}|${haplotypePrefix(pair.query)}#${pair.query.contig}:${pair.queryStart}-${pair.queryEnd}`\n return new SyntenyFeature({\n uniqueId: id,\n assemblyName: lane,\n refName: pair.target.contig,\n start: pair.targetStart,\n end: pair.targetEnd,\n type: 'match',\n strand: pair.strand === '-' ? -1 : 1,\n CIGAR: pair.cigar,\n syntenyId: id,\n identity: pair.matches / Math.max(pair.columns, 1),\n numMatches: pair.matches,\n blockLen: pair.columns,\n mate: {\n refName: pair.query.contig,\n start: pair.queryStart,\n end: pair.queryEnd,\n assemblyName: mateLane,\n },\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\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, referenceSamples } = 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 referenceSample,\n referenceSamples,\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 zoomInNotice(\n nodeLimitError(error, nodeLimit, end - start) ?? error,\n 'lanes',\n )\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 [first] = pairs\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 zoomInNotice(\n nodeLimitError(error, nodeLimit, end - start) ?? error,\n 'lanes',\n )\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 && first && answerable.length > 0\n ? await updateStatus(\n pairs.length === 1\n ? `Reading ${first.queryAssemblyName} against ${first.targetAssemblyName}`\n : `Reading ${pairs.length} lane pairs`,\n 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": "ixBAeA,SAASA,EAAqBC,EAAI,CAChC,IAAMC,EAAS,cACf,OAAOA,EAAO,KAAKD,CAAE,EAAIA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B,YAAYA,EAAM,kBAAkB,GACtE,WAAWL,EAAM,MAAM,cAC3B7B,EAAK,eACL,IAAMoC,GAAQlB,CAAK,CACrB,EACA,CAAC,GACU,QAAQzD,GACvBqE,EAAW,QAAQ,CAAC,CAAE,KAAA5E,EAAM,YAAA6E,EAAa,SAAAC,CAAS,IAChDD,EAAY,QAAQO,GAClBN,EAAS,QAAQO,IACf9E,EACG,eAAe,CAAE,OAAA6E,EAAQ,MAAOC,GAAM,MAAO,EAAM,CAAC,EACpD,IAAIpG,IACHc,GAAY,CACV,KAAMd,GACN,KAAMe,EAAK,kBACX,SAAUA,EAAK,kBACjB,CAAC,CACH,CACJ,CACF,CACF,CACF,CACF,CAEA,YAAYsF,EAAexC,EAA2B,CAAC,EAAG,CACxD,IAAMtB,EAASD,GAAQ+D,CAAK,EAC5B,OAAOC,GAA0B,MAAMC,GAAY,CACjD,GAAM,CAAE,GAAAtD,EAAI,OAAApD,EAAQ,gBAAAiF,CAAgB,EAAI,MAAM,KAAK,MAAMjB,CAAI,EAC7D,GAAI,CAACZ,EAAG,kBACN,MAAM,IAAIxD,EAAsBqF,CAAe,EAIjD,GAAIvC,EAAO,eAAiB1C,EAAQ,CAClC,IAAM6F,EAAQc,GAAe3C,CAAI,EAC3B4C,EACJf,EAAM,OAAS,EACX,MAAM,KAAK,aAAanD,EAAQmD,EAAO7B,CAAI,EAC3C,MAAM,KAAK,eAAetB,EAAQsB,CAAI,EAC5C,QAAW4B,KAAWgB,EACpBF,EAAS,KAAKd,CAAO,CAEzB,CACAc,EAAS,SAAS,CACpB,EAAG1C,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", "BRIDGE_MAX_BP", "widestWalkGap", "subgraphs", "kept", "byPath", "subgraph", "start", "end", "prefix", "key", "spans", "widest", "a", "b", "i", "gap", "zoomInNotice", "error", "what", "NodeLimitError", "getBpDisplayStr", "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", "nodeLimit", "updateStatus", "nodeLimitError", "feature", "pairs", "answerable", "featureSide", "mateSide", "baseContext", "first", "context", "bridged", "SubgraphLimitError", "target", "mate", "asked", "ObservableCreate", "observer", "requestedPairs", "features"]
@@ -1,4 +1,4 @@
1
- import{a as C}from"./chunk-BJMRBVG3.js";import"./chunk-J6NZIAZF.js";import"./chunk-GOFS7BXK.js";import"./chunk-IJQTSJGT.js";import{k as d}from"./chunk-YSTMDXXX.js";import"./chunk-5SFGHDQA.js";import"./chunk-DZ4OUKQV.js";import"./chunk-MHPJB22Z.js";import"./chunk-XT766CZ5.js";import"./chunk-EWFJBQDV.js";import"./chunk-3Q4RBDCL.js";import"./chunk-AU73K7LX.js";import"./chunk-TXI43PEN.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-446RWIA3.js";import"./chunk-5OI6LO4I.js";import"./chunk-NDRLCGPC.js";import"./chunk-TENPGIPX.js";import{g as x}from"./chunk-6OPB7FOJ.js";import{A as l,F as L,H as p,d as s,i as v,o as n,x as G}from"./chunk-E3WYW7Z6.js";import{a as y,b as a,c as r,d as i}from"./chunk-JMBDTNUR.js";var w=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}}),E=i(function({model:e}){let{classes:t}=w();return e.isLoading?r(l,{className:t.paper,"data-testid":"graph-genome-loading",children:[r("div",{className:t.row,children:[a(v,{variant:"h6",message:e.statusMessage}),a(n,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{e.cancelLoad()},children:"Cancel"})]}),a(G,{variant:"indeterminate"})]}):e.error?a(l,{className:t.paper,children:a(s,{error:e.error,onReset:()=>{e.retryLoad()}})}):a(l,{className:t.paper,"data-testid":"graph-genome-load-canceled",children:r("div",{className:t.row,children:[a(p,{variant:"h6",children:"Loading canceled"}),a(n,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{e.retryLoad()},children:"Retry"})]})})}),g=E;var F=`H VN:Z:1.0
1
+ import{a as C}from"./chunk-FBGWMI6M.js";import"./chunk-YAADZ2AI.js";import"./chunk-G63ZHV6F.js";import"./chunk-6CAAGNOP.js";import{k as d}from"./chunk-GUNY323E.js";import"./chunk-NKBE5KYL.js";import"./chunk-SIGBYUXP.js";import"./chunk-CPCTMFXV.js";import"./chunk-ABNOMXT3.js";import"./chunk-S3QFRJR3.js";import"./chunk-JT3RXYIL.js";import"./chunk-77GS3NVS.js";import"./chunk-TXI43PEN.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-IIGYYZI5.js";import"./chunk-5OI6LO4I.js";import"./chunk-NDRLCGPC.js";import"./chunk-TENPGIPX.js";import{g as x}from"./chunk-6OPB7FOJ.js";import{A as l,F as L,H as p,d as s,i as v,o as n,x as G}from"./chunk-E3WYW7Z6.js";import{a as y,b as a,c as r,d as i}from"./chunk-JMBDTNUR.js";var w=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}}),E=i(function({model:e}){let{classes:t}=w();return e.isLoading?r(l,{className:t.paper,"data-testid":"graph-genome-loading",children:[r("div",{className:t.row,children:[a(v,{variant:"h6",message:e.statusMessage}),a(n,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{e.cancelLoad()},children:"Cancel"})]}),a(G,{variant:"indeterminate"})]}):e.error?a(l,{className:t.paper,children:a(s,{error:e.error,onReset:()=>{e.retryLoad()}})}):a(l,{className:t.paper,"data-testid":"graph-genome-load-canceled",children:r("div",{className:t.row,children:[a(p,{variant:"h6",children:"Loading canceled"}),a(n,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{e.retryLoad()},children:"Retry"})]})})}),g=E;var F=`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`,S=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"}}),T=i(function({model:e}){let{classes:t}=S(),[m,M]=x("");function u(){let o=m.trim();o&&e.loadGFAFromLocation({uri:o,locationType:"UriLocation"})}function N(o){let c=o.target.files?.[0];o.target.value="",c&&c.text().then(f=>e.loadGFA(f,c.name)).catch(f=>{e.setError(f)})}return r(l,{className:t.paper,children:[a("div",{className:t.header,children:a(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",a("input",{type:"file",accept:".gfa,.gfa1,.gfa2",hidden:!0,onChange:o=>{N(o)}})]}),a(p,{variant:"caption",color:"text.secondary",children:"Whole-file GFA; best for small/medium graphs."})]}),r("div",{className:t.rowEnd,children:[a(L,{size:"small",label:"URL",placeholder:"https://example.com/graph.gfa",value:m,onChange:o=>{M(o.target.value)},onKeyDown:o=>{o.key==="Enter"&&u()},className:t.flex1}),a(n,{variant:"contained",onClick:()=>{u()},disabled:!m.trim(),children:"Open"})]})]}),a("div",{className:t.footer,children:a(n,{size:"small",onClick:()=>{e.loadGFA(F,"Example graph")},children:"Load 4-node example"})}),e.error?a(s,{error:e.error}):null]})}),P=T;var A=i(function({model:e}){return e.hasGraph?a(C,{model:e}):e.canRetryLoad&&(e.error||e.loadCanceled)?a(g,{model:e}):r(y,{children:[e.isLoading?a(g,{model:e}):null,a("div",{hidden:e.isLoading,children:a(P,{model:e})})]})}),J=A;export{J as default};
10
- //# sourceMappingURL=GraphGenomeView-Z2WZKEEO.js.map
10
+ //# sourceMappingURL=GraphGenomeView-BG7UHKCT.js.map
@@ -1,6 +1,6 @@
1
- import{b as G}from"./chunk-J6NZIAZF.js";import{b as H,c as x}from"./chunk-E2QPSDQL.js";import{k as h}from"./chunk-YSTMDXXX.js";import"./chunk-MHPJB22Z.js";import"./chunk-AU73K7LX.js";import"./chunk-MVVXRZXV.js";import"./chunk-446RWIA3.js";import"./chunk-5OI6LO4I.js";import{g as u}from"./chunk-6OPB7FOJ.js";import{D as v,F as f,H as c,n as g,s as b,w as S,z as C}from"./chunk-E3WYW7Z6.js";import{b as a,c as l,d as i}from"./chunk-JMBDTNUR.js";var F=h()({section:{marginBottom:24},formControl:{minWidth:200}}),M=[{value:0,label:"None"},{value:1,label:"1 hop"},{value:2,label:"2 hops"}],I=i(function({model:t}){let{classes:e}=F();return t.adapterConfig.type==="RgfaTabixAdapter"&&!H(t.adapterConfig)?l("div",{className:e.section,children:[l(b,{className:e.formControl,children:[a(S,{children:"Graph context"}),a(v,{value:t.subgraphContext,label:"Graph context","data-testid":"graph-context-select",onChange:o=>{t.setSubgraphContext(o.target.value),t.cut()},children:M.map(({value:o,label:p})=>a(C,{value:o,children:p},o))})]}),a(c,{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}),L=I;var N=h()({section:{marginBottom:24}});function P(n){let t=n.split(/[\s,]+/).map(e=>e.trim()).filter(e=>e!=="");return t.length===0?void 0:t}var T=i(function({model:t}){let[e,o]=u(t.cutHaplotypes?.join(", ")??""),p=()=>{let r=P(e)??[];r.join(`
1
+ import{b as G}from"./chunk-YAADZ2AI.js";import{b as H,c as x}from"./chunk-E2QPSDQL.js";import{k as h}from"./chunk-GUNY323E.js";import"./chunk-CPCTMFXV.js";import"./chunk-77GS3NVS.js";import"./chunk-MVVXRZXV.js";import"./chunk-IIGYYZI5.js";import"./chunk-5OI6LO4I.js";import{g as u}from"./chunk-6OPB7FOJ.js";import{D as v,F as f,H as c,n as g,s as b,w as S,z as C}from"./chunk-E3WYW7Z6.js";import{b as a,c as l,d as i}from"./chunk-JMBDTNUR.js";var F=h()({section:{marginBottom:24},formControl:{minWidth:200}}),M=[{value:0,label:"None"},{value:1,label:"1 hop"},{value:2,label:"2 hops"}],I=i(function({model:t}){let{classes:e}=F();return t.adapterConfig.type==="RgfaTabixAdapter"&&!H(t.adapterConfig)?l("div",{className:e.section,children:[l(b,{className:e.formControl,children:[a(S,{children:"Graph context"}),a(v,{value:t.subgraphContext,label:"Graph context","data-testid":"graph-context-select",onChange:o=>{t.setSubgraphContext(o.target.value),t.cut()},children:M.map(({value:o,label:p})=>a(C,{value:o,children:p},o))})]}),a(c,{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}),L=I;var N=h()({section:{marginBottom:24}});function P(n){let t=n.split(/[\s,]+/).map(e=>e.trim()).filter(e=>e!=="");return t.length===0?void 0:t}var T=i(function({model:t}){let[e,o]=u(t.cutHaplotypes?.join(", ")??""),p=()=>{let r=P(e)??[];r.join(`
2
2
  `)===(t.cutHaplotypes??[]).join(`
3
3
  `)||(t.setSubgraphHaplotypes(r),t.cut())};return a(f,{fullWidth:!0,label:"Haplotypes",placeholder:"every haplotype",value:e,slotProps:{htmlInput:{"data-testid":"graph-haplotypes-field"}},onChange:r=>{o(r.target.value)},onBlur:()=>{p()},onKeyDown:r=>{r.key==="Enter"&&p()}})}),w=i(function({model:t,names:e}){let[o,p]=u(t.cutHaplotypes??[]),[r,d]=u(!1),m=s=>{s.join(`
4
4
  `)!==(t.cutHaplotypes??[]).join(`
5
5
  `)&&(t.setSubgraphHaplotypes(s),t.cut())};return a(g,{multiple:!0,freeSolo:!0,disableCloseOnSelect:!0,options:e,value:o,open:r,onOpen:()=>{d(!0)},onClose:()=>{d(!1),m(o)},onChange:(s,y)=>{p(y),r||m(y)},renderInput:s=>a(f,{...s,label:"Haplotypes",placeholder:o.length===0?"every haplotype":void 0,slotProps:{...s.slotProps,htmlInput:{...s.slotProps.htmlInput,"data-testid":"graph-haplotypes-field"}}})})}),D=i(function({model:t}){let{classes:e}=N(),o=t.haplotypeNames,p=t.cutHaplotypes?.join(",")??"";return x(t.adapterConfig)?l("div",{className:e.section,children:[o?a(w,{model:t,names:o},p):a(T,{model:t},p),l(c,{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}),k=D;function B({model:n,open:t,onClose:e}){return l(G,{model:n,open:t,onClose:e,children:[a(L,{model:n}),a(k,{model:n})]})}export{B as default};
6
- //# sourceMappingURL=GraphTrackSettingsDialog-TAM6PMXD.js.map
6
+ //# sourceMappingURL=GraphTrackSettingsDialog-YOJF7KCT.js.map
@@ -1,2 +1,2 @@
1
- import{o as v,p as C}from"./chunk-DZ4OUKQV.js";import"./chunk-MHPJB22Z.js";import"./chunk-AU73K7LX.js";import"./chunk-446RWIA3.js";import{F as g,H as t,c as u,o as y,q as c,r as d,z as s}from"./chunk-E3WYW7Z6.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-EYBKFSJU.js.map
1
+ import{o as v,p as C}from"./chunk-SIGBYUXP.js";import"./chunk-CPCTMFXV.js";import"./chunk-77GS3NVS.js";import"./chunk-IIGYYZI5.js";import{F as g,H as t,c as u,o as y,q as c,r as d,z as s}from"./chunk-E3WYW7Z6.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-YT55H62Y.js.map
@@ -1,2 +1,2 @@
1
- import{a as g}from"./chunk-BJMRBVG3.js";import"./chunk-J6NZIAZF.js";import"./chunk-GOFS7BXK.js";import"./chunk-IJQTSJGT.js";import"./chunk-YSTMDXXX.js";import"./chunk-5SFGHDQA.js";import"./chunk-DZ4OUKQV.js";import"./chunk-MHPJB22Z.js";import"./chunk-XT766CZ5.js";import"./chunk-EWFJBQDV.js";import"./chunk-3Q4RBDCL.js";import"./chunk-AU73K7LX.js";import"./chunk-TXI43PEN.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-446RWIA3.js";import"./chunk-5OI6LO4I.js";import"./chunk-NDRLCGPC.js";import"./chunk-TENPGIPX.js";import{g as y}from"./chunk-6OPB7FOJ.js";import"./chunk-E3WYW7Z6.js";import{b as e,c as l,d as T}from"./chunk-JMBDTNUR.js";var s=JBrowseExports["@jbrowse/display-kit/DisplayBackgroundProgress"];var v=s&&s.__esModule?s.default:s;var i=JBrowseExports["@jbrowse/display-kit/DisplayErrorBar"];var h=i&&i.__esModule?i.default:i;var a=JBrowseExports["@jbrowse/display-kit/DisplayLoadingOverlay"];var O=a&&a.__esModule?a.default:a;var n=JBrowseExports["@jbrowse/display-kit/TooLargeMessage"];var f=n&&n.__esModule?n.default:n;var t=JBrowseExports["@jbrowse/display-ui"],p=r=>t!=null&&r in Object(t)?t[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=p("BottomRightCornerContext");var c=p("TrackOverlayPortal");var L=p("useChromeOverlayOverride");var j=t&&t.__esModule?t.default:t;var D={TooLarge:f,ErrorBar:h,Loading:O,BackgroundProgress:v};function d({model:r,phase:o,drawn:u,testid:_,style:C,children:E,...B}){let{TooLarge:G,ErrorBar:S,Loading:b,BackgroundProgress:m}=L()??D,[P,A]=y(null),x={...B,"data-testid":_,"data-display-id":r.configuration.displayId,"data-display-drawn":u,"data-display-phase":o};return o==="tooLarge"?e("div",{style:{display:"contents"},...x,children:e(c,{children:e("div",{style:{pointerEvents:"auto"},children:e(G,{model:r})})})}):l("div",{style:{position:"relative",height:r.height,...C},...x,children:[e(w,{value:P,children:E}),l(c,{children:[e(S,{model:r,visible:o==="error"}),e(b,{model:r,visible:o==="loading"||o==="canceled",immediate:!u}),e("div",{ref:A,style:{position:"absolute",bottom:2,right:2,display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4,pointerEvents:"none"},children:e(m,{model:r,visible:o==="ready"})})]})]})}var I=T(function({model:o}){return e(d,{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(g,{model:o,ownChrome:!1})})}),Q=I;export{Q as default};
2
- //# sourceMappingURL=LinearGraphDisplay-WIBVWRQE.js.map
1
+ import{a as g}from"./chunk-FBGWMI6M.js";import"./chunk-YAADZ2AI.js";import"./chunk-G63ZHV6F.js";import"./chunk-6CAAGNOP.js";import"./chunk-GUNY323E.js";import"./chunk-NKBE5KYL.js";import"./chunk-SIGBYUXP.js";import"./chunk-CPCTMFXV.js";import"./chunk-ABNOMXT3.js";import"./chunk-S3QFRJR3.js";import"./chunk-JT3RXYIL.js";import"./chunk-77GS3NVS.js";import"./chunk-TXI43PEN.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-IIGYYZI5.js";import"./chunk-5OI6LO4I.js";import"./chunk-NDRLCGPC.js";import"./chunk-TENPGIPX.js";import{g as y}from"./chunk-6OPB7FOJ.js";import"./chunk-E3WYW7Z6.js";import{b as e,c as l,d as T}from"./chunk-JMBDTNUR.js";var s=JBrowseExports["@jbrowse/display-kit/DisplayBackgroundProgress"];var v=s&&s.__esModule?s.default:s;var i=JBrowseExports["@jbrowse/display-kit/DisplayErrorBar"];var h=i&&i.__esModule?i.default:i;var a=JBrowseExports["@jbrowse/display-kit/DisplayLoadingOverlay"];var O=a&&a.__esModule?a.default:a;var n=JBrowseExports["@jbrowse/display-kit/TooLargeMessage"];var f=n&&n.__esModule?n.default:n;var t=JBrowseExports["@jbrowse/display-ui"],p=r=>t!=null&&r in Object(t)?t[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=p("BottomRightCornerContext");var c=p("TrackOverlayPortal");var L=p("useChromeOverlayOverride");var j=t&&t.__esModule?t.default:t;var D={TooLarge:f,ErrorBar:h,Loading:O,BackgroundProgress:v};function d({model:r,phase:o,drawn:u,testid:_,style:C,children:E,...B}){let{TooLarge:G,ErrorBar:S,Loading:b,BackgroundProgress:m}=L()??D,[P,A]=y(null),x={...B,"data-testid":_,"data-display-id":r.configuration.displayId,"data-display-drawn":u,"data-display-phase":o};return o==="tooLarge"?e("div",{style:{display:"contents"},...x,children:e(c,{children:e("div",{style:{pointerEvents:"auto"},children:e(G,{model:r})})})}):l("div",{style:{position:"relative",height:r.height,...C},...x,children:[e(w,{value:P,children:E}),l(c,{children:[e(S,{model:r,visible:o==="error"}),e(b,{model:r,visible:o==="loading"||o==="canceled",immediate:!u}),e("div",{ref:A,style:{position:"absolute",bottom:2,right:2,display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4,pointerEvents:"none"},children:e(m,{model:r,visible:o==="ready"})})]})]})}var I=T(function({model:o}){return e(d,{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(g,{model:o,ownChrome:!1})})}),Q=I;export{Q as default};
2
+ //# sourceMappingURL=LinearGraphDisplay-SPILNH4J.js.map
@@ -1,2 +1,2 @@
1
- import{a as d}from"./chunk-WRH2EJKX.js";import{a as g,d as f,f as c}from"./chunk-XT766CZ5.js";import{a as u}from"./chunk-KOB7YIMR.js";import{b,f as p,g as m}from"./chunk-AMFIBQVR.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-446RWIA3.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as i,o as l}from"./chunk-TENPGIPX.js";var r=class extends b{static{this.capabilities=["getFeatures","getRefNames"]}constructor(t,a,s){super(t,a,s),this.bubbles=p(this,["bubblesLocation"],["index"]),this.refNames=new m(this.bubbles,this)}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async hasDataForRefName(){return!0}getFeatures(t,a={}){let{signal:s,statusCallback:h}=a;return u(async o=>{let n=await this.refNames.resolve(t,a);n!==void 0&&await l("Downloading bubbles",h,()=>d(this.bubbles,n,t.start,t.end,{signal:s,lineCallback:(A,y)=>{let e=g(A);o.next(new i({uniqueId:`bubble-${y}`,refName:t.refName,start:e.start,end:e.end,name:f(e),description:c(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}))}})),o.complete()},s)}};export{r as default};
2
- //# sourceMappingURL=MinigraphBubbleAdapter-AGI2UYQR.js.map
1
+ import{a as d}from"./chunk-WRH2EJKX.js";import{a as g,d as f,f as c}from"./chunk-ABNOMXT3.js";import{a as u}from"./chunk-KOB7YIMR.js";import{b,f as p,g as m}from"./chunk-4IJKHORO.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import"./chunk-IIGYYZI5.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as i,o as l}from"./chunk-TENPGIPX.js";var r=class extends b{static{this.capabilities=["getFeatures","getRefNames"]}constructor(t,a,s){super(t,a,s),this.bubbles=p(this,["bubblesLocation"],["index"]),this.refNames=new m(this.bubbles,this)}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async hasDataForRefName(){return!0}getFeatures(t,a={}){let{signal:s,statusCallback:h}=a;return u(async o=>{let n=await this.refNames.resolve(t,a);n!==void 0&&await l("Downloading bubbles",h,()=>d(this.bubbles,n,t.start,t.end,{signal:s,lineCallback:(A,y)=>{let e=g(A);o.next(new i({uniqueId:`bubble-${y}`,refName:t.refName,start:e.start,end:e.end,name:f(e),description:c(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}))}})),o.complete()},s)}};export{r as default};
2
+ //# sourceMappingURL=MinigraphBubbleAdapter-2XGZPDI4.js.map
@@ -1,3 +1,3 @@
1
- import{a as h}from"./chunk-WRH2EJKX.js";import{a as P,c as v,e as O}from"./chunk-WX26KTZM.js";import{a as T}from"./chunk-KOB7YIMR.js";import"./chunk-TXI43PEN.js";import{b as A,f as b,g as B}from"./chunk-AMFIBQVR.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{f as I}from"./chunk-446RWIA3.js";import{b as M}from"./chunk-5OI6LO4I.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as L,o as y}from"./chunk-TENPGIPX.js";function C(i){let e=i.split(" "),n=e.length>=8,s=n?5:0;return{anchored:n,segment:{refName:e[s],start:+e[s+1],end:+e[s+2],id:e[3],rank:+e[4],tags:e[n?8:5]??""}}}function Z(i){let e=i.tags.split(" ").find(s=>s.startsWith("SM:Z:"));if(e===void 0)return;let n=e.slice(5).split(",").map(s=>s.trim()).filter(Boolean);return n.length>0?n:void 0}function j(i){return{id:i.slice(0,-1),strand:i.slice(-1)}}function x(i){let e=i.split(" "),n=j(e[3]),s=j(e[4]);return{source:n.id,sourceStrand:n.strand,target:s.id,targetStrand:s.strand,sourceSegment:{id:n.id,refName:e[5],start:+e[6],end:+e[7],rank:+e[8],tags:e[13]??""},targetSegment:{id:s.id,refName:e[9],start:+e[10],end:+e[11],rank:+e[12],tags:e[14]??""}}}function k(i){return`${i.source}${i.sourceStrand}${i.target}${i.targetStrand}`}function W(i,e,n){let s=a=>a.rank!==0||a.refName!==n.refName?0:a.end<=n.start?-1:a.start>=n.end?1:0,t=new Map(i),r=new Map;for(let a of e)if(i.has(a.source)||i.has(a.target)||s(a.sourceSegment)*s(a.targetSegment)===-1){r.set(k(a),a);for(let f of[a.sourceSegment,a.targetSegment])t.has(f.id)||t.set(f.id,f)}for(let a of e)t.has(a.source)&&t.has(a.target)&&r.set(k(a),a);return{segments:t,links:r}}function D(i,e,n){let s=t=>t.refName!==n.refName||t.end<=n.start||t.start>=n.end;return[...G(i.filter(t=>t.rank>0),e,n.end-n.start),...G(i.filter(t=>t.rank===0&&s(t)),new Set(i.map(t=>t.id)),0)]}function G(i,e,n){let s=[...i].sort((r,a)=>w(r.refName,a.refName)||r.start-a.start),t=[];for(let r of s){let a=t.at(-1);a?.refName===r.refName&&r.start-a.end<=n?(a.needed||=r.start>a.end||e.has(r.id),a.end=Math.max(a.end,r.end)):t.push({refName:r.refName,start:r.start,end:r.end,needed:e.has(r.id)})}return t.filter(r=>r.needed).map(({refName:r,start:a,end:f})=>({refName:r,start:a,end:f}))}function H(i,e,n){let s=t=>e.has(t.id)||n.some(r=>r.refName===t.refName&&t.start>=r.start&&t.end<=r.end);return i.filter(t=>s(t.sourceSegment)&&s(t.targetSegment))}var E=/^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/;function K(i){let{id:e,refName:n,start:s,end:t,rank:r,tags:a}=i,f=a.split(" ").filter(p=>E.test(p)),l=f.length===0?"":` ${f.join(" ")}`;return`S ${e} * LN:i:${t-s} SN:Z:${n} SO:i:${s} SR:i:${r}${l}`}function J(i){let{source:e,sourceStrand:n,target:s,targetStrand:t}=i;return`L ${e} ${n} ${s} ${t} 0M`}function w(i,e){return i<e?-1:i>e?1:0}function $(i,e){let n=[...i.values()].sort((t,r)=>w(t.refName,r.refName)||t.start-r.start||w(t.id,r.id)),s=[...e.keys()].sort((t,r)=>w(t,r));return["H VN:Z:1.0",...n.map(t=>K(t)),...s.map(t=>J(e.get(t)))].join(`
1
+ import{a as h}from"./chunk-WRH2EJKX.js";import{a as P,c as v,e as O}from"./chunk-2QQDYK5V.js";import{a as T}from"./chunk-KOB7YIMR.js";import"./chunk-TXI43PEN.js";import{b as A,f as b,g as B}from"./chunk-4IJKHORO.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{f as I}from"./chunk-IIGYYZI5.js";import{b as M}from"./chunk-5OI6LO4I.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{a as L,o as y}from"./chunk-TENPGIPX.js";function C(i){let e=i.split(" "),n=e.length>=8,s=n?5:0;return{anchored:n,segment:{refName:e[s],start:+e[s+1],end:+e[s+2],id:e[3],rank:+e[4],tags:e[n?8:5]??""}}}function Z(i){let e=i.tags.split(" ").find(s=>s.startsWith("SM:Z:"));if(e===void 0)return;let n=e.slice(5).split(",").map(s=>s.trim()).filter(Boolean);return n.length>0?n:void 0}function j(i){return{id:i.slice(0,-1),strand:i.slice(-1)}}function x(i){let e=i.split(" "),n=j(e[3]),s=j(e[4]);return{source:n.id,sourceStrand:n.strand,target:s.id,targetStrand:s.strand,sourceSegment:{id:n.id,refName:e[5],start:+e[6],end:+e[7],rank:+e[8],tags:e[13]??""},targetSegment:{id:s.id,refName:e[9],start:+e[10],end:+e[11],rank:+e[12],tags:e[14]??""}}}function k(i){return`${i.source}${i.sourceStrand}${i.target}${i.targetStrand}`}function W(i,e,n){let s=a=>a.rank!==0||a.refName!==n.refName?0:a.end<=n.start?-1:a.start>=n.end?1:0,t=new Map(i),r=new Map;for(let a of e)if(i.has(a.source)||i.has(a.target)||s(a.sourceSegment)*s(a.targetSegment)===-1){r.set(k(a),a);for(let f of[a.sourceSegment,a.targetSegment])t.has(f.id)||t.set(f.id,f)}for(let a of e)t.has(a.source)&&t.has(a.target)&&r.set(k(a),a);return{segments:t,links:r}}function D(i,e,n){let s=t=>t.refName!==n.refName||t.end<=n.start||t.start>=n.end;return[...G(i.filter(t=>t.rank>0),e,n.end-n.start),...G(i.filter(t=>t.rank===0&&s(t)),new Set(i.map(t=>t.id)),0)]}function G(i,e,n){let s=[...i].sort((r,a)=>w(r.refName,a.refName)||r.start-a.start),t=[];for(let r of s){let a=t.at(-1);a?.refName===r.refName&&r.start-a.end<=n?(a.needed||=r.start>a.end||e.has(r.id),a.end=Math.max(a.end,r.end)):t.push({refName:r.refName,start:r.start,end:r.end,needed:e.has(r.id)})}return t.filter(r=>r.needed).map(({refName:r,start:a,end:f})=>({refName:r,start:a,end:f}))}function H(i,e,n){let s=t=>e.has(t.id)||n.some(r=>r.refName===t.refName&&t.start>=r.start&&t.end<=r.end);return i.filter(t=>s(t.sourceSegment)&&s(t.targetSegment))}var E=/^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/;function K(i){let{id:e,refName:n,start:s,end:t,rank:r,tags:a}=i,f=a.split(" ").filter(p=>E.test(p)),l=f.length===0?"":` ${f.join(" ")}`;return`S ${e} * LN:i:${t-s} SN:Z:${n} SO:i:${s} SR:i:${r}${l}`}function J(i){let{source:e,sourceStrand:n,target:s,targetStrand:t}=i;return`L ${e} ${n} ${s} ${t} 0M`}function w(i,e){return i<e?-1:i>e?1:0}function $(i,e){let n=[...i.values()].sort((t,r)=>w(t.refName,r.refName)||t.start-r.start||w(t.id,r.id)),s=[...e.keys()].sort((t,r)=>w(t,r));return["H VN:Z:1.0",...n.map(t=>K(t)),...s.map(t=>J(e.get(t)))].join(`
2
2
  `)}function _(i){return i.filter(e=>e.rank>0)}var F=class extends A{static{this.capabilities=["getFeatures","getRefNames"]}constructor(e,n,s){super(e,n,s),this.fine=this.openIndex([])}openIndex(e){let n=b(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),s=this.getConf("walksLocation"),t=e.length===0&&M(s),r=b(this,[...e,"linksLocation"],[...e,"linksIndex"]),a=t?b(this,["walksLocation"],["walksIndex"]):void 0;return{segments:n,links:r,walkFile:a,walks:a?new v(a):void 0,refNames:new B(a??n,this)}}async getHaplotypeNames(e={}){let n=await this.fine.walks?.header(e);return n?.haplotypes.length?n.haplotypes:void 0}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async hasDataForRefName(){return!0}getFeatures(e,n={}){let{signal:s,statusCallback:t}=n;return T(async r=>{let a=await this.fine.refNames.resolve(e,n);if(a!==void 0){let{walks:f,walkFile:l}=this.fine,p=f?await f.queryStart(e.start,n):e.start;if(l&&f){await f.header(n);let S=[];await y("Downloading walks",t,()=>h(l,a,p,e.end,{signal:s,lineCallback:g=>{let o=g.split(" ");o[3]==="ref"&&S.push(o)}}));let d=new Set;for(let g of P(S))if(g.refName===a&&g.end>e.start&&!d.has(g.id)){d.add(g.id);let o=String(g.id);r.next(new L({uniqueId:o,refName:e.refName,start:g.start,end:g.end,name:o,type:"segment",rank:0,stableName:g.refName}))}r.complete();return}await y("Downloading segments",t,()=>h(this.fine.segments,a,p,e.end,{signal:s,lineCallback:S=>{let{segment:d,anchored:g}=C(S);if(g&&d.refName!==a||d.end<=e.start)return;let o=Z(d);r.next(new L({uniqueId:d.id,refName:e.refName,start:d.start,end:d.end,name:d.id,type:"segment",rank:d.rank,stableName:d.refName,...o&&{samples:o,sampleCount:o.length}}))}}))}r.complete()},s)}async getSubgraph(e,n={}){let{hops:s=0,signal:t,tier:r}=n,a=this.index(r),f=new Map,l=new Map,p=await a.refNames.resolve(e,{signal:t}),S=async(o,c,m)=>{let u=[];return await h(a.links,o,c,m,{signal:t,lineCallback:z=>{let N=x(z);l.set(k(N),N);for(let R of[N.sourceSegment,N.targetSegment])f.has(R.id)||(f.set(R.id,R),u.push(R))}}),u};if(p===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${e.assemblyName} mapped to its prefix in assemblyNameToPanSN`);if(a.walks)return O(a.walks,p,e,{signal:t,prefixes:n.haplotypes?.map(o=>I(this,o)),walkRows:n.walkRows,stepBudget:this.getConf("walkStepBudget"),byteBudget:this.getConf("walkByteBudget")});let d={anchored:!1};if(await h(a.segments,p,e.start,e.end,{signal:t,lineCallback:o=>{let c=C(o);d.anchored||=c.anchored,f.set(c.segment.id,c.segment)}}),d.anchored){let o=[];await h(a.links,p,e.start,e.end,{signal:t,lineCallback:m=>{o.push(x(m))}});let c=W(f,o,{refName:p,start:e.start,end:e.end});return $(c.segments,c.links)}let g=_(await S(p,e.start,e.end));for(let o=0;o<s;o++){let c=await Promise.all(g.map(m=>S(m.refName,m.start,m.end)));g=_(c.flat())}if(s>0){let o=D([...f.values()],new Set(g.map(m=>m.id)),{refName:p,start:e.start,end:e.end}),c=[];await Promise.all(o.map(m=>h(a.links,m.refName,m.start,m.end,{signal:t,lineCallback:u=>{c.push(x(u))}})));for(let m of H(c,f,o)){l.set(k(m),m);for(let u of[m.sourceSegment,m.targetSegment])f.has(u.id)||f.set(u.id,u)}}return $(f,l)}};export{F as default};
3
- //# sourceMappingURL=RgfaTabixAdapter-2OL5X3HF.js.map
3
+ //# sourceMappingURL=RgfaTabixAdapter-ZTFVNM4G.js.map
@@ -1,2 +1,2 @@
1
- import{b as q,c as D,d as H,e as G}from"./chunk-WX26KTZM.js";import{a as _}from"./chunk-LUTMKRXY.js";import{a as T,b as I,d as j,e as B}from"./chunk-SAMJE6GH.js";import{a as R}from"./chunk-KOB7YIMR.js";import{p as W,q as L}from"./chunk-IXQK7JAW.js";import"./chunk-TXI43PEN.js";import{f as $,g as v}from"./chunk-AMFIBQVR.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{a as P,c as F,d as A,e as k,f as N,g as x}from"./chunk-446RWIA3.js";import"./chunk-E7J6SB5P.js";import"./chunk-7WIBGKBU.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{o as C}from"./chunk-TENPGIPX.js";var Z=50;function ee(m){let e=[];for(let t=0;t<m.length;t++){let[r,s]=m[t],[n,a]=m[t+1]??[];s===a&&s<=Z&&(r==="I"&&n==="D"||r==="D"&&n==="I")?(e.push(["X",s]),t++):e.push([r,s])}return e}function te(m){return m.map(([e,t])=>`${t}${e}`).join("")}function U(m){let e=new Map,t=n=>{let a=m.get(n),i=a===void 0?0:a.end-a.start,p=e.get(i);return p===void 0&&(p="N".repeat(i),e.set(i,p)),p},r=new Map,s=n=>{let a=r.get(n);return a===void 0&&(a=Array.from(n.ids,(i,p)=>2*i+n.rev[p]),r.set(n,a)),a};return(n,a)=>L({query:s(n),target:s(a),sequenceOf:t,bases:!1})}var ae=100;function E(m,e,t){let r=m.at(-1);t>0&&(r?.[0]===e?r[1]+=t:m.push([e,t]))}function X(m){let e=s=>{let n=m.get(s>>1);return n===void 0?0:n.end-n.start},t=s=>{let n=new Float64Array(s.length+1);return s.forEach((a,i)=>{n[i+1]=n[i]+e(a)}),n},r=s=>Array.from(s.ids,(n,a)=>2*n+s.rev[a]);return(s,n)=>{let a=r(n),i=r(s),[p,y]=W(i,a,e),[h,l]=W(i.map(b=>b^1).reverse(),a,e),d=l>y,c=d?h:p,f=Math.max(y,l);if(f<ae)return[];let u=t(a),o=t(i),g=b=>d?i.length-1-c[b][0]:c[b][0],w=[];c.forEach(([,b],S)=>{if(S>0){let[K,Q]=[g(S-1),g(S)].sort((V,Y)=>V-Y);E(w,"I",o[Q]-o[K+1]),E(w,"D",u[b]-u[c[S-1][1]+1])}E(w,"=",e(a[b]))});let[z,J]=[g(0),g(c.length-1)].sort((b,S)=>b-S);return[{queryStart:o[z],queryEnd:o[J+1],targetStart:u[c[0][1]],targetEnd:u[c.at(-1)[1]+1],strand:d?"-":"+",edits:w,sharedBases:f}]}}function O({chain:m,target:e,query:t,assemblyName:r,refName:s,mateAssemblyName:n}){let a=e.hapStart+m.targetStart,i=e.hapStart+m.targetEnd,p=t.hapStart+m.queryStart,y=t.hapStart+m.queryEnd,h=ee(m.edits),l=h.reduce((f,[u,o])=>f+(u==="="?o:0),0),d=h.reduce((f,[,u])=>f+u,0),c=`${e.name}:${a}-${i}|${t.name}:${p}-${y}`;return new T({uniqueId:c,assemblyName:r,refName:s,start:a,end:i,type:"match",strand:m.strand==="-"?-1:1,CIGAR:te(h),syntenyId:c,identity:l/Math.max(d,1),numMatches:l,blockLen:d,mate:{refName:A(t.name),start:p,end:y,assemblyName:n}})}var ne=m=>F(m.name)??m.name,M=class extends I{constructor(e,t,r){super(e,t,r);let s=$(this,["walksLocation"],["walksIndex"]);this.reader=new D(s),this.refNames=new v(s,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={}){let{haplotypes:t}=await this.reader.header(e);return t.length>0?t:void 0}async getHeader(e={}){let{haplotypes:t,references:r}=await this.reader.header(e),{anchor:s}=this,n=N(this,s),a=x(this);return{hasCoarseTier:!1,anchorAssemblyName:s,referenceSamples:r,lanes:t.filter(i=>i!==n&&P(i)!==n).map(i=>({name:B(a,i),label:i,group:P(i)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}budgets(){return{stepBudget:this.getConf("walkStepBudget"),byteBudget:this.getConf("walkByteBudget"),budgetNames:H}}async getSubgraph(e,t={}){let{signal:r,haplotypes:s,walkRows:n}=t,a=await this.refNames.resolve(e,{signal:r});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 G(this.reader,a,e,{...this.budgets(),signal:r,prefixes:s?.map(i=>N(this,i)),walkRows:n})}async laneWalks(e,t,r,s,n){return C(n,s.statusCallback,()=>this.reader.cut(e,t,{...this.budgets(),signal:s.signal,keep:q(r,F(e)),links:!1}).catch(a=>{throw _(a)&&a instanceof Error&&(a.message=a.message.replace("to see the graph","to see lanes")),a}))}async anchorFeatures(e,t,r){let s=r.haplotypes?.length?r.haplotypes.map(o=>N(this,o)):void 0,n=N(this,r.targetAssemblyName),a=n===void 0?s:s===void 0||s.some(o=>k(n,o)||k(o,n))?[n]:[];if(a?.length===0)return[];let{start:i,end:p}=t,{graph:y,fragments:h}=await this.laneWalks(e,t,a,r,`Reading walks ${t.refName}:${i.toLocaleString()}-${p.toLocaleString()}`),l=X(y.nodes),d=x(this),c=h.filter(o=>o.name===e),f=o=>a===void 0?0:a.findIndex(g=>k(o.name,g));return h.filter(o=>o.name!==e&&f(o)>=0).sort((o,g)=>f(o)-f(g)).flatMap(o=>c.flatMap(g=>l(o,g).map(w=>O({chain:w,target:g,query:o,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:B(d,ne(o))}))))}async pairFeatures(e,t,r,s){let[n]=r,a=r.map(l=>({pair:l,featurePrefix:N(this,l.queryAssemblyName),matePrefix:N(this,l.targetAssemblyName)})),{graph:i,fragments:p}=await this.laneWalks(e,t,a.flatMap(l=>[l.featurePrefix,l.matePrefix]),s,r.length===1&&n?`Reading ${n.queryAssemblyName} against ${n.targetAssemblyName}`:`Reading ${r.length} lane pairs`),y=U(i.nodes),h=l=>p.filter(d=>k(d.name,l));return a.flatMap(({pair:l,featurePrefix:d,matePrefix:c})=>h(d).flatMap(f=>h(c).flatMap(u=>y(u,f).map(o=>O({chain:o,target:f,query:u,assemblyName:l.queryAssemblyName,refName:A(f.name),mateAssemblyName:l.targetAssemblyName})))))}getFeatures(e,t={}){return R(async r=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let n=j(t),a=n.length>0?await this.pairFeatures(s,e,n,t):await this.anchorFeatures(s,e,t);for(let i of a)r.next(i)}r.complete()},t.signal)}};export{M as default};
2
- //# sourceMappingURL=WalkTabixSyntenyAdapter-UKFHCFOF.js.map
1
+ import{b as q,c as D,d as H,e as G}from"./chunk-2QQDYK5V.js";import{a as _}from"./chunk-LUTMKRXY.js";import{a as T,b as I,d as j,e as B}from"./chunk-WI7LRX6I.js";import{a as R}from"./chunk-KOB7YIMR.js";import{p as W,q as L}from"./chunk-T4HOC6O3.js";import"./chunk-TXI43PEN.js";import{f as $,g as v}from"./chunk-4IJKHORO.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{a as P,c as F,d as A,e as k,f as N,g as x}from"./chunk-IIGYYZI5.js";import"./chunk-E7J6SB5P.js";import"./chunk-7WIBGKBU.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{o as C}from"./chunk-TENPGIPX.js";var Z=50;function ee(m){let e=[];for(let t=0;t<m.length;t++){let[r,s]=m[t],[n,a]=m[t+1]??[];s===a&&s<=Z&&(r==="I"&&n==="D"||r==="D"&&n==="I")?(e.push(["X",s]),t++):e.push([r,s])}return e}function te(m){return m.map(([e,t])=>`${t}${e}`).join("")}function U(m){let e=new Map,t=n=>{let a=m.get(n),i=a===void 0?0:a.end-a.start,p=e.get(i);return p===void 0&&(p="N".repeat(i),e.set(i,p)),p},r=new Map,s=n=>{let a=r.get(n);return a===void 0&&(a=Array.from(n.ids,(i,p)=>2*i+n.rev[p]),r.set(n,a)),a};return(n,a)=>L({query:s(n),target:s(a),sequenceOf:t,bases:!1})}var ae=100;function E(m,e,t){let r=m.at(-1);t>0&&(r?.[0]===e?r[1]+=t:m.push([e,t]))}function X(m){let e=s=>{let n=m.get(s>>1);return n===void 0?0:n.end-n.start},t=s=>{let n=new Float64Array(s.length+1);return s.forEach((a,i)=>{n[i+1]=n[i]+e(a)}),n},r=s=>Array.from(s.ids,(n,a)=>2*n+s.rev[a]);return(s,n)=>{let a=r(n),i=r(s),[p,y]=W(i,a,e),[h,l]=W(i.map(b=>b^1).reverse(),a,e),d=l>y,c=d?h:p,f=Math.max(y,l);if(f<ae)return[];let u=t(a),o=t(i),g=b=>d?i.length-1-c[b][0]:c[b][0],w=[];c.forEach(([,b],S)=>{if(S>0){let[K,Q]=[g(S-1),g(S)].sort((V,Y)=>V-Y);E(w,"I",o[Q]-o[K+1]),E(w,"D",u[b]-u[c[S-1][1]+1])}E(w,"=",e(a[b]))});let[z,J]=[g(0),g(c.length-1)].sort((b,S)=>b-S);return[{queryStart:o[z],queryEnd:o[J+1],targetStart:u[c[0][1]],targetEnd:u[c.at(-1)[1]+1],strand:d?"-":"+",edits:w,sharedBases:f}]}}function O({chain:m,target:e,query:t,assemblyName:r,refName:s,mateAssemblyName:n}){let a=e.hapStart+m.targetStart,i=e.hapStart+m.targetEnd,p=t.hapStart+m.queryStart,y=t.hapStart+m.queryEnd,h=ee(m.edits),l=h.reduce((f,[u,o])=>f+(u==="="?o:0),0),d=h.reduce((f,[,u])=>f+u,0),c=`${e.name}:${a}-${i}|${t.name}:${p}-${y}`;return new T({uniqueId:c,assemblyName:r,refName:s,start:a,end:i,type:"match",strand:m.strand==="-"?-1:1,CIGAR:te(h),syntenyId:c,identity:l/Math.max(d,1),numMatches:l,blockLen:d,mate:{refName:A(t.name),start:p,end:y,assemblyName:n}})}var ne=m=>F(m.name)??m.name,M=class extends I{constructor(e,t,r){super(e,t,r);let s=$(this,["walksLocation"],["walksIndex"]);this.reader=new D(s),this.refNames=new v(s,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={}){let{haplotypes:t}=await this.reader.header(e);return t.length>0?t:void 0}async getHeader(e={}){let{haplotypes:t,references:r}=await this.reader.header(e),{anchor:s}=this,n=N(this,s),a=x(this);return{hasCoarseTier:!1,anchorAssemblyName:s,referenceSamples:r,lanes:t.filter(i=>i!==n&&P(i)!==n).map(i=>({name:B(a,i),label:i,group:P(i)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}budgets(){return{stepBudget:this.getConf("walkStepBudget"),byteBudget:this.getConf("walkByteBudget"),budgetNames:H}}async getSubgraph(e,t={}){let{signal:r,haplotypes:s,walkRows:n}=t,a=await this.refNames.resolve(e,{signal:r});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 G(this.reader,a,e,{...this.budgets(),signal:r,prefixes:s?.map(i=>N(this,i)),walkRows:n})}async laneWalks(e,t,r,s,n){return C(n,s.statusCallback,()=>this.reader.cut(e,t,{...this.budgets(),signal:s.signal,keep:q(r,F(e)),links:!1}).catch(a=>{throw _(a)&&a instanceof Error&&(a.message=a.message.replace("to see the graph","to see lanes")),a}))}async anchorFeatures(e,t,r){let s=r.haplotypes?.length?r.haplotypes.map(o=>N(this,o)):void 0,n=N(this,r.targetAssemblyName),a=n===void 0?s:s===void 0||s.some(o=>k(n,o)||k(o,n))?[n]:[];if(a?.length===0)return[];let{start:i,end:p}=t,{graph:y,fragments:h}=await this.laneWalks(e,t,a,r,`Reading walks ${t.refName}:${i.toLocaleString()}-${p.toLocaleString()}`),l=X(y.nodes),d=x(this),c=h.filter(o=>o.name===e),f=o=>a===void 0?0:a.findIndex(g=>k(o.name,g));return h.filter(o=>o.name!==e&&f(o)>=0).sort((o,g)=>f(o)-f(g)).flatMap(o=>c.flatMap(g=>l(o,g).map(w=>O({chain:w,target:g,query:o,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:B(d,ne(o))}))))}async pairFeatures(e,t,r,s){let[n]=r,a=r.map(l=>({pair:l,featurePrefix:N(this,l.queryAssemblyName),matePrefix:N(this,l.targetAssemblyName)})),{graph:i,fragments:p}=await this.laneWalks(e,t,a.flatMap(l=>[l.featurePrefix,l.matePrefix]),s,r.length===1&&n?`Reading ${n.queryAssemblyName} against ${n.targetAssemblyName}`:`Reading ${r.length} lane pairs`),y=U(i.nodes),h=l=>p.filter(d=>k(d.name,l));return a.flatMap(({pair:l,featurePrefix:d,matePrefix:c})=>h(d).flatMap(f=>h(c).flatMap(u=>y(u,f).map(o=>O({chain:o,target:f,query:u,assemblyName:l.queryAssemblyName,refName:A(f.name),mateAssemblyName:l.targetAssemblyName})))))}getFeatures(e,t={}){return R(async r=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let n=j(t),a=n.length>0?await this.pairFeatures(s,e,n,t):await this.anchorFeatures(s,e,t);for(let i of a)r.next(i)}r.complete()},t.signal)}};export{M as default};
2
+ //# sourceMappingURL=WalkTabixSyntenyAdapter-I6E6HAN4.js.map
@@ -1,2 +1,2 @@
1
- import{a as ht}from"./chunk-TXI43PEN.js";import{c as ft}from"./chunk-446RWIA3.js";var $=r=>(r-(r&1))/2,I=r=>r&1?r-1:r+1;function U(r,t,n){if(r===".")return n;let e=0,o=!1;for(let s=0;s<=r.length;s++){let i=s<r.length?r.charCodeAt(s):44;if(i===44){let f=o?-e:e,y=f&1;t.id+=(f-y)/2,n.push(t.id*2+y),e=0,o=!1}else i===45?o=!0:e=e*10+(i-48)}return n}function D(r){return r==="."?[]:r.split(",").map(Number)}function Z(r,t){return r>I(t)?[I(t),I(r)]:[r,t]}function ut(r,t,n){let e,o;for(let s=t;s<r.length;s++){let i=r[s];if(i.startsWith("pv:")||i.startsWith("nx:")){let f=i.lastIndexOf(":"),y={refName:i[3]==="Z"?i.slice(5,f):n,start:+i.slice(f+1)};i.startsWith("pv:")?e=y:o=y}}return{prev:e,next:o}}var Y=class{constructor(){this.handles=[],this.before=[0],this.occurrences=new Map}add(t,n){for(let e=0;e<t.length;e++){let o=t[e],s=this.handles.length;this.handles.push(o),this.before.push(this.before[s]+n[e]);let i=$(o),f=this.occurrences.get(i);f?f.push(s):this.occurrences.set(i,[s])}}bp(t){return this.before[t]}first(t){var n;return(n=this.occurrences.get($(t)))===null||n===void 0?void 0:n[0]}nearest(t,n){var e;let o;for(let s of(e=this.occurrences.get($(t)))!==null&&e!==void 0?e:[])(o===void 0||Math.abs(s-n)<=Math.abs(o-n))&&(o=s);return o}reach(t,n,e){var o;let s=this.handles[t]===n,i;for(let f of(o=this.occurrences.get($(e)))!==null&&o!==void 0?o:[])s&&f>=t&&this.handles[f]===e?(i===void 0||f<i)&&(i=f):!s&&f<=t&&I(this.handles[f])===e&&(i===void 0||f>i)&&(i=f);return i}handleAt(t,n){return n?this.handles[t]:I(this.handles[t])}},L=class extends Error{},tt=(r,t)=>t?r.exit===-1?-1:I(r.exit):r.entry,pt=(r,t)=>t?r.entry===-1?-1:I(r.entry):r.exit,G=(r,t,n)=>t?I(r.interior[r.interior.length-1-n]):r.interior[n];function Nt(r){let t=[];if(r!=="."){let n=0,e=0,o=!1,s=0,i=!1;for(let f=0;f<=r.length;f++){let y=f<r.length?r.charCodeAt(f):44;if(y===44){let w=o?-e:e,S=i?s:w,v=S&1;n+=(S-v)/2,t.push(n,v,i?w:0),e=0,o=!1,i=!1}else y===58?(s=o?-e:e,e=0,o=!1,i=!0):y===45?o=!0:e=e*10+(y-48)}}return t}function gt(r,t,n,e,o,s){let i=e.indexOf(":"),f=n+ +(i<0?e:e.slice(0,i)),y=i>=0,w=y?+e.slice(i+1):0,S=a=>{let c=t[a];if(!c)throw new L(`route ${a} is not in the chunk`);return c},v=0;if(o.length>0&&tt(S(o[0]),o[1]===1)===-1){if(!s.route(o[0],o[1]===1))return;v=3}let b=n,l=r.first(b);if(l===void 0)throw new L("a walk row starts off its chunk");s.step(b);let k=(a,c)=>{let d=r.handles[l]===b,u=y?l+(d?c:-c):r.reach(l,b,a);if(u===void 0||u<0||u>=r.handles.length)throw new L("a walk row runs off its chunk");u!==l&&s.stretch(l,u,d),l=u,b=r.handleAt(u,d)};for(;v<o.length;v+=3){let a=o[v],c=o[v+1]===1,d=S(a),u=tt(d,c);if(u===-1)throw new L("an open route after the first choice");if(k(u,o[v+2]),!s.route(a,c))return;let p=pt(d,c);if(p===-1)return;if(b=p,l=r.nearest(b,l),l===void 0)throw new L("a route lands off its chunk");s.step(b)}if(k(f,w),b!==f)throw new L("a walk row misses its last handle")}function St(r,t,n,e,o){let s=new Int32Array(o),i=new Uint8Array(o),f=0,y=w=>{if(f>=o)throw new L("a walk row decodes to more steps than it states");s[f]=$(w),i[f++]=w&1};if(gt(r,t,+n[9],n[10],e,{step:y,stretch(w,S,v){if(v)for(let b=w+1;b<=S;b++)y(r.handles[b]);else for(let b=w-1;b>=S;b--)y(I(r.handles[b]))},route(w,S){let v=t[w];for(let b=0;b<v.interior.length;b++)y(G(v,S,b));return!0}}),f!==o)throw new L(`a walk row decodes to ${f} steps, not ${o}`);return{ids:s,rev:i}}function dt(r,t,n,e,o){let s=r.slice(t).find(f=>f.startsWith("SQ:Z:"));if(s===void 0)return;let i=5;for(let f=0;f<n.length;f++){let y=e[f];o.set(n[f],s.slice(i,i+y)),i+=y}}function wt(r,t,n=!1){var e,o,s;let i=new Y,f=new Map,y=[],w={sequences:new Map,rows:[],nodes:new Map,ends:[],chunk:{path:i,routes:y,walks:[],lengths:f}},S={id:0},v=r.filter(l=>l[3]==="ref").sort((l,k)=>+l[6]-+k[6]);for(let l of v){let k=l[0],a=U(l[9],{id:0},[]),c=D(l[10]),d=+l[6];i.add(a,c),n&&dt(l,11,a.map($),c,w.sequences);let u=d;for(let p=0;p<a.length;p++){let g=$(a[p]),x=c[p];f.set(g,x),w.nodes.has(g)||w.nodes.set(g,{refName:l[4],start:u,end:u+x,rank:0}),u+=x}w.ends.push({name:l[4],fragStart:+l[5],piece:+l[7],first:a[0],last:a.at(-1)}),(t===void 0||t(l[4]))&&w.rows.push({chunkStart:+l[1],name:l[4],fragStart:+l[5],hapOffset:d,piece:+l[7],n:a.length,steps:{ids:Int32Array.from(a,$),rev:Uint8Array.from(a,p=>p&1)},...ut(l,11,k)})}for(let l of r)if(l[3]==="nodes"){let k=D(l[4]),a=D(l[5]),c=0;for(let d=0;d<k.length;d++)c+=k[d],k[d]=c,f.set(c,a[d]);n&&dt(l,6,k,a,w.sequences)}else if(l[3]==="route"){let k=U(l[4],S,[]),a=U(l[5],S,[]),c=U(l[6],S,[]);y.push({entry:(e=k[0])!==null&&e!==void 0?e:-1,interior:a,exit:(o=c[0])!==null&&o!==void 0?o:-1})}let b=l=>{let k=y[l];if(!k)throw new L(`route ${l} is not in the chunk`);return k};for(let l of r){if(l[3]!=="walk")continue;let k=Nt(l[11]);w.chunk.walks.push({cols:l,choices:k});let a=l[4],c=+l[9],d=l[10],u=d.indexOf(":"),p=c,g=c+ +(u<0?d:d.slice(0,u));if(k.length>0){let x=b(k[0]),h=k[1]===1;tt(x,h)===-1&&(p=G(x,h,0));let m=k.length-3,N=b(k[m]),M=k[m+1]===1;pt(N,M)===-1&&(g=G(N,M,N.interior.length-1))}if(w.ends.push({name:a,fragStart:+l[5],piece:+l[7],first:p,last:g}),t===void 0||t(a)){let x=+l[8];for(let h=0;h<k.length;h+=3)for(let m of b(k[h]).interior){let N=$(m);if(!w.nodes.has(N)){let M=(s=f.get(N))!==null&&s!==void 0?s:0;w.nodes.set(N,{refName:a,start:0,end:M,rank:1})}}w.rows.push({chunkStart:+l[1],name:a,fragStart:+l[5],hapOffset:+l[6],piece:+l[7],n:x,steps:St(i,y,l,k,x),...ut(l,12,l[0])})}}return w}function kt(r,t,n,e){let o=new Map;for(let{path:s,routes:i,walks:f,lengths:y}of r){let w=s.handles;for(let a=1;a<w.length;a++)t.has($(w[a-1]))&&t.has($(w[a]))&&e(...Z(w[a-1],w[a]));let S=new Uint8Array(i.length);for(let a=0;a<i.length;a++){let{entry:c,interior:d,exit:u}=i[a],p=!1,g=c;for(let x of d){let h=t.has($(x));p||(p=h),h&&g!==-1&&t.has($(g))&&e(...Z(g,x)),g=x}g!==-1&&u!==-1&&t.has($(g))&&t.has($(u))&&e(...Z(g,u)),S[a]=p?1:0}let v=a=>{var c;return(c=y.get($(a)))!==null&&c!==void 0?c:0},b=new Float64Array(i.length).fill(-1),l=a=>(b[a]<0&&(b[a]=i[a].interior.reduce((c,d)=>c+v(d),0)),b[a]),k=new Uint8Array(i.length);for(let{cols:a,choices:c}of f){let d=0;for(let g=0;g<c.length;g+=3){let x=c[g];S[x]&&!k[x]&&d++}if(d===0)continue;let u=a[4],p=+a[6];gt(s,i,+a[9],a[10],c,{step(g){p+=v(g)},stretch(g,x,h){p+=h?s.bp(x+1)-s.bp(g+1):s.bp(g)-s.bp(x)},route(g,x){if(!S[g]||k[g])return p+=l(g),!0;k[g]=1;let h=i[g];for(let m=0;m<h.interior.length;m++){let N=G(h,x,m),M=$(N),A=v(N);if(t.has(M)){let E=o.get(M);(!E||u<E.refName||u===E.refName&&p<E.start)&&o.set(M,{refName:u,start:p,end:p+A,rank:1})}p+=A}return d--,d>0}})}}for(let[s,i]of o)n(s,i)}function Et(r){let t=[];for(let n of r){if(n[3]!=="ref")continue;let e=U(n[9],{id:0},[]),o=D(n[10]),s=+n[6];for(let i=0;i<e.length;i++){let f=o[i];t.push({id:$(e[i]),refName:n[4],start:s,end:s+f,rank:0}),s+=f}}return t}function mt(r){let t=new Map;for(let e of r){let o=`${e.name} ${e.fragStart}`,s=t.get(o);s||(s=new Map,t.set(o,s)),s.set(e.piece,e)}let n=[];for(let e of t.values())for(let[o,s]of e){let i=e.get(o+1);i&&n.push(Z(s.last,i.first))}return n}var q=class extends Error{constructor(t,n,e,o){super(t),this.regionTooLarge=!0,this.name="NodeLimitError",this.limit=n,this.windowBp=e,this.fitsBp=o}},Mt="#";function Q(r,t){return t!==void 0&&(r===t||r.startsWith(t+Mt))}var yt=r=>Number.parseFloat(r.toPrecision(3));function P(r){let t=yt(r/1e6);return t>=1?`${t.toLocaleString("en-US")}Mbp`:r>=1e3?`${yt(r/1e3).toLocaleString("en-US")}Kbp`:`${Math.floor(r)}bp`}function et(r,t){let n=new RegExp(`(?:^|\\t)${t}:i:(\\d+)`).exec(r);return n?+n[1]:void 0}function nt(r){var t,n,e;let o={references:[],haplotypes:[]};for(let s of r){let[i,f=""]=s.split(" ");i==="#reference"?o.references.push(f):i==="#haplotype"?o.haplotypes.push(f):((t=o.format)!==null&&t!==void 0||(o.format=et(s,"format")),(n=o.chunk)!==null&&n!==void 0||(o.chunk=et(s,"chunk")),(e=o.maxNode)!==null&&e!==void 0||(o.maxNode=et(s,"maxnode")))}return o}function st(r,t){return r===void 0?1:Math.max(1,Math.ceil(r/t))}function K(r,t,n=1){return Math.max(0,(Math.floor(r/t)-n)*t)}function ot(r,t){return r===void 0||r.length===0?void 0:n=>Q(n,t)||r.some(e=>Q(n,e))}function z(r){let t=new Map;for(let e of r){let o=`${e.name} ${e.fragStart}`,s=t.get(o);s?s.push(e):t.set(o,[e])}let n=[];for(let e of t.values()){e.sort((s,i)=>s.piece-i.piece);let o=0;for(let s=1;s<=e.length;s++)(s===e.length||e[s].piece!==e[s-1].piece+1)&&(n.push(At(e.slice(o,s))),o=s)}return n}function At(r){let t=r.reduce((i,f)=>i+f.n,0),n=new Int32Array(t),e=new Uint8Array(t),o=0;for(let i of r)n.set(i.steps.ids,o),e.set(i.steps.rev,o),o+=i.n;let s=r[0];return{name:s.name,hapOffset:s.hapOffset,ids:n,rev:e,prev:s.prev,next:r.at(-1).next}}function X(r,t,n){let e=a=>{var c;return((c=t.get(a))===null||c===void 0?void 0:c.onWindow)===!0},o=a=>{let c=t.get(a);return c?.rank===0?c:void 0},s=new Map,i=a=>{a&&s.set(`${a.refName}:${a.start}`,a)},f=(a,c,d)=>{let{ids:u}=a,p=c+d;for(;p>=0&&p<u.length&&o(u[p])===void 0;)p+=d;if(p<0||p>=u.length)return i(d<0?a.prev:a.next),p-d;let g=o(u[c]),x=o(u[p]);return x.refName!==n?p-d:p===c+d&&(x.start===g.end||x.end===g.start)?c:p},y=1/0,w=-1/0,S=[];for(let a of r){let{ids:c}=a,d=-1,u=-1;for(let p=0;p<c.length;p++)e(c[p])&&(d<0&&(d=p),u=p);if(d>=0){if(a.name!==n){d=f(a,d,-1),u=f(a,u,1);for(let p of[d,u]){let g=o(c[p]);g&&(y=Math.min(y,g.start),w=Math.max(w,g.end))}}S.push({run:a,first:d,last:u})}}let v=a=>{let c=o(a);return e(a)||c?.refName===n&&c.end>y&&c.start<w},b=new Set;for(let[a,c]of t)c.onWindow&&b.add(a);for(let a of S){let{ids:c}=a.run;if(a.run.name===n){for(;a.first>0&&v(c[a.first-1]);)a.first--;for(;a.last<c.length-1&&v(c[a.last+1]);)a.last++}for(let d=a.first;d<=a.last;d++)b.add(c[d])}let l=a=>{let c=t.get(a);return c===void 0?0:c.end-c.start},k=[];for(let{run:a,first:c,last:d}of S){let{ids:u,rev:p}=a,g=c,x=d;for(;g>0&&b.has(u[g-1]);)g--;for(;x<u.length-1&&b.has(u[x+1]);)x++;let h=a.hapOffset;for(let N=0;N<g;N++)h+=l(u[N]);let m=h;for(let N=g;N<=x;N++)m+=l(u[N]);k.push({name:a.name,hapStart:h,hapEnd:m,ids:u.subarray(g,x+1),rev:p.subarray(g,x+1)})}return{kept:b,fragments:k,open:[...s.values()]}}var T=class{constructor(t){this.nodes=new Map,this.sequences=new Map,this.links=[],this.chunks=[],this.window=t}placeNode(t,n){if(this.nodes.has(t))return;let{window:e}=this;this.nodes.set(t,{...n,onWindow:n.rank===0&&n.refName===e.refName&&n.end>e.start-e.context&&n.start<e.end+e.context})}addLinkEnds(t,n){this.links.push(t,n)}addChunk(t){this.chunks.push(t)}addSequences(t){if(this.window.sequences)for(let[n,e]of t)this.sequences.set(n,e)}tables(t,n){this.chunks.length>0&&kt(this.chunks,t,(h,m)=>{let N=this.nodes.get(h);N&&this.nodes.set(h,{...N,...m})},(h,m)=>{this.links.push(h,m)});let e=[];for(let h of t){let m=this.nodes.get(h);m&&e.push({...m,id:h})}e.sort((h,m)=>h.refName<m.refName?-1:h.refName>m.refName?1:h.start-m.start||h.id-m.id);let o=new Map,s=[],i=[],f=new Map,y=new Int32Array(e.length),w=new Int32Array(e.length),S=new Float64Array(e.length),v=new Int32Array(e.length);e.forEach(({id:h,refName:m,start:N,end:M,rank:A},E)=>{o.set(h,E),s.push(String(h));let O=f.get(m);O===void 0&&(O=i.length,f.set(m,O),i.push(m)),y[E]=M-N,w[E]=O,S[E]=N,v[E]=A});let b=h=>{let m=o.get(h);return m===void 0&&(m=s.length,o.set(h,m),s.push(String(h))),m},l=new Map;for(let h=0;h<this.links.length;h+=2){let m=this.links[h],N=this.links[h+1],M=Math.floor(m/2),A=Math.floor(N/2);t.has(M)&&t.has(A)&&l.set(`${M} ${m%2?"-":"+"} ${A} ${N%2?"-":"+"}`,h)}let k=[...l.keys()].sort(),a=new Int32Array(k.length),c=new Int32Array(k.length),d=new Uint8Array(k.length);k.forEach((h,m)=>{let N=l.get(h),M=this.links[N],A=this.links[N+1];a[m]=b(Math.floor(M/2)),c[m]=b(Math.floor(A/2)),d[m]=M%2|A%2<<1});let u=this.referenceFirst(n),p=new Int32Array(u.length+1);u.forEach(({ids:h},m)=>{p[m+1]=p[m]+h.length});let g=new Int32Array(p[u.length]),x=new Uint8Array(g.length);return u.forEach(({ids:h,rev:m},N)=>{let M=p[N];for(let A=0;A<h.length;A++)g[M+A]=b(h[A]);x.set(m,M)}),{nodes:{names:s,lengths:y,refs:w,starts:S,ranks:v,refNames:i},links:{from:a,to:c,strands:d},walks:{names:u.map(h=>h.name),starts:Float64Array.from(u,h=>h.hapStart),ends:Float64Array.from(u,h=>h.hapEnd),offsets:p,steps:g,reversed:x}}}referenceFirst(t){let{refName:n}=this.window;return[...t].sort((e,o)=>+(o.name===n)-+(e.name===n)||(e.name<o.name?-1:e.name>o.name?1:e.hapStart-o.hapStart))}},rt={steps:"the step budget",bytes:"a byte budget of"};function at(r,t,n,e,o,s,i=rt){var f;let y=0,w=new Map,S=new Set;for(let c of r)y+=c.n,w.set(c.chunkStart,((f=w.get(c.chunkStart))!==null&&f!==void 0?f:0)+c.n),S.add(c.name);let v=t*n;if(y<=v)return;let b=e.end-e.start,l=0,k=0;for(let c of[...w.keys()].sort((d,u)=>d-u)){if(l+=w.get(c),l>v)break;k=Math.max(k,c+o-e.start)}let a=!s&&S.size>2&&2*y/S.size<=v;return new q(k>0?`Zoom in to about ${P(k)}${a?", or choose fewer haplotypes,":""} to see the graph`:`Too many haplotype steps here to draw ${s?"these haplotypes":"every haplotype"} (${l.toLocaleString()} steps read, over ${n} \xD7 ${i.steps} of ${t.toLocaleString()}); choose fewer haplotypes`,v,b,Math.max(k,1))}function it(r,t,n,e){let o=r.reduce((f,y)=>f+y.ids.length,0);if(o<=t)return;let s=n.end-n.start,i=Math.max(1,Math.floor(s*t/o));return new q(`Zoom in to about ${P(i)}${e?"":", or choose fewer haplotypes,"} to see the graph`,t,s,i)}async function ct(r,t,n,e,o=rt){let s=await r(n.end);if(s<=t)return;let i=0,f;for(let w=Math.floor(n.start/e)*e;w<n.end;w+=e){let S=await r(w+1);if(f??(f=S),S>t)break;i=w+e-n.start}let y=n.end-n.start;return new q(i>0?`Zoom in to about ${P(i)} to see the graph`:`Too much graph here to fetch (${bt(f??s)} against ${o.bytes} ${bt(t)})`,t,y,Math.max(i,1))}var bt=r=>`${(r/1e6).toFixed(1)} MB`;var $t=8,Ot=3,Lt=4,Bt=1e3,J=class extends Error{constructor(){super(...arguments),this.name="WalkFormatError"}};function xt(r,t,n){if(!Number.isFinite(t)||!Number.isFinite(n))throw new Error(`${r}:${t}-${n} is not a finite range to query the graph's index for`)}function Ct(r,t){return t?(t.throwIfAborted(),new Promise((n,e)=>{let o=()=>{e(t.reason instanceof Error?t.reason:new Error(String(t.reason)))};t.addEventListener("abort",o,{once:!0}),r.then(n,e).finally(()=>{t.removeEventListener("abort",o)})})):r}var lt=class{constructor(t){this.walks=t}header(t={}){if(!this.headerRead){let n=this.walks.getHeaderLines().then(e=>{var o;let s=nt(e);if(s.format!==2)throw new J("This walk file is format 1, from gfa-to-tabix 0.12 or earlier; rebuild it with gfa-to-tabix 1.0 or later");let i=(o=s.chunk)!==null&&o!==void 0?o:65536;return{...s,chunk:i,lookback:st(s.maxNode,i)}});n.catch(()=>{this.headerRead===n&&(this.headerRead=void 0)}),this.headerRead=n}return Ct(this.headerRead,t.signal)}referenceSequences(t={}){return this.walks.getReferenceSequenceNames(t)}async queryStart(t,n={}){let{chunk:e,lookback:o}=await this.header(n);return K(t,e,o)}async cut(t,n,e={}){var o;let{signal:s,keep:i,context:f=Bt,stepBudget:y=1/0,byteBudget:w=1/0,links:S=!0}=e,{chunk:v,lookback:b}=await this.header({signal:s}),l=K(n.start,v,b),k=(o=this.walks.bytesForRegions)===null||o===void 0?void 0:o.bind(this.walks),a=Number.isFinite(w)&&k!==void 0,c=async E=>a?k(E.map(O=>({refName:t,...O})),{signal:s}):0,d=a?await ct(async E=>(xt(t,l,E),c([{start:l,end:E}])),w,n,v,e.budgetNames):void 0;if(d)throw d;let u=new AbortController,p=()=>{u.abort(s?.reason)};s?.throwIfAborted(),s?.addEventListener("abort",p,{once:!0});let g=[],x,h=new T({refName:t,start:n.start,end:n.end,context:f,sequences:e.sequences}),m=new Set,N=[],M=async(E,O)=>{xt(t,E,O);let _=new Map;await this.walks.getLines(t,E,O,{signal:u.signal,lineCallback:F=>{let R=F.split(" "),B=+R[1],W=_.get(B);W?W.push(R):_.set(B,[R])}});for(let[F,R]of _){if(m.has(F))continue;m.add(F);let B=wt(R,i,e.sequences);g.push(...B.rows);for(let[W,j]of B.nodes)h.placeNode(W,j);h.addSequences(B.sequences),h.addChunk(B.chunk),N.push(...B.ends)}if(S)for(let[F,R]of mt(N))h.addLinkEnds(F,R)};try{await M(l,n.end);let E=at(g,y,$t,n,v,i!==void 0,e.budgetNames);if(E)throw E;let O=l,_=Math.floor((n.end-1)/v)*v,F=Lt*v,[R,B]=[O-F,_+F];x=X(z(g),h.nodes,t);let W=await c([{start:l,end:n.end}]);for(let j=0;j<Ot;j++){let H=x.open.filter(C=>C.refName===t&&C.start>=R&&C.start<=B).map(C=>C.start),V=[{start:Math.min(O,...H),end:O},{start:_+v,end:Math.max(_,...H)+1}].filter(C=>C.end>C.start);if(V.length===0||(W+=await c(V),W>w))break;O=Math.min(O,...H),_=Math.max(_,...H),await Promise.all(V.map(({start:C,end:vt})=>M(C,vt))),x=X(z(g),h.nodes,t)}}catch(E){throw u.abort(),E}finally{s?.removeEventListener("abort",p)}let A=it(x.fragments,y,n,i!==void 0);if(A)throw A;return{graph:h,...x}}};var _t={steps:"walkStepBudget",bytes:"walkByteBudget"};async function Jt(r,t,n,e){let{graph:o,kept:s,fragments:i}=await r.cut(t,n,{signal:e.signal,keep:ot(e.prefixes,ft(t)),stepBudget:e.walkRows?1/0:e.stepBudget,byteBudget:e.byteBudget,budgetNames:_t});return ht(o.tables(s,i),n,e.walkRows)}export{Et as a,ot as b,lt as c,_t as d,Jt as e};
2
- //# sourceMappingURL=chunk-WX26KTZM.js.map
1
+ import{a as ht}from"./chunk-TXI43PEN.js";import{c as ft}from"./chunk-IIGYYZI5.js";var $=r=>(r-(r&1))/2,I=r=>r&1?r-1:r+1;function U(r,t,n){if(r===".")return n;let e=0,o=!1;for(let s=0;s<=r.length;s++){let i=s<r.length?r.charCodeAt(s):44;if(i===44){let f=o?-e:e,y=f&1;t.id+=(f-y)/2,n.push(t.id*2+y),e=0,o=!1}else i===45?o=!0:e=e*10+(i-48)}return n}function D(r){return r==="."?[]:r.split(",").map(Number)}function Z(r,t){return r>I(t)?[I(t),I(r)]:[r,t]}function ut(r,t,n){let e,o;for(let s=t;s<r.length;s++){let i=r[s];if(i.startsWith("pv:")||i.startsWith("nx:")){let f=i.lastIndexOf(":"),y={refName:i[3]==="Z"?i.slice(5,f):n,start:+i.slice(f+1)};i.startsWith("pv:")?e=y:o=y}}return{prev:e,next:o}}var Y=class{constructor(){this.handles=[],this.before=[0],this.occurrences=new Map}add(t,n){for(let e=0;e<t.length;e++){let o=t[e],s=this.handles.length;this.handles.push(o),this.before.push(this.before[s]+n[e]);let i=$(o),f=this.occurrences.get(i);f?f.push(s):this.occurrences.set(i,[s])}}bp(t){return this.before[t]}first(t){var n;return(n=this.occurrences.get($(t)))===null||n===void 0?void 0:n[0]}nearest(t,n){var e;let o;for(let s of(e=this.occurrences.get($(t)))!==null&&e!==void 0?e:[])(o===void 0||Math.abs(s-n)<=Math.abs(o-n))&&(o=s);return o}reach(t,n,e){var o;let s=this.handles[t]===n,i;for(let f of(o=this.occurrences.get($(e)))!==null&&o!==void 0?o:[])s&&f>=t&&this.handles[f]===e?(i===void 0||f<i)&&(i=f):!s&&f<=t&&I(this.handles[f])===e&&(i===void 0||f>i)&&(i=f);return i}handleAt(t,n){return n?this.handles[t]:I(this.handles[t])}},L=class extends Error{},tt=(r,t)=>t?r.exit===-1?-1:I(r.exit):r.entry,pt=(r,t)=>t?r.entry===-1?-1:I(r.entry):r.exit,G=(r,t,n)=>t?I(r.interior[r.interior.length-1-n]):r.interior[n];function Nt(r){let t=[];if(r!=="."){let n=0,e=0,o=!1,s=0,i=!1;for(let f=0;f<=r.length;f++){let y=f<r.length?r.charCodeAt(f):44;if(y===44){let w=o?-e:e,S=i?s:w,v=S&1;n+=(S-v)/2,t.push(n,v,i?w:0),e=0,o=!1,i=!1}else y===58?(s=o?-e:e,e=0,o=!1,i=!0):y===45?o=!0:e=e*10+(y-48)}}return t}function gt(r,t,n,e,o,s){let i=e.indexOf(":"),f=n+ +(i<0?e:e.slice(0,i)),y=i>=0,w=y?+e.slice(i+1):0,S=a=>{let c=t[a];if(!c)throw new L(`route ${a} is not in the chunk`);return c},v=0;if(o.length>0&&tt(S(o[0]),o[1]===1)===-1){if(!s.route(o[0],o[1]===1))return;v=3}let b=n,l=r.first(b);if(l===void 0)throw new L("a walk row starts off its chunk");s.step(b);let k=(a,c)=>{let d=r.handles[l]===b,u=y?l+(d?c:-c):r.reach(l,b,a);if(u===void 0||u<0||u>=r.handles.length)throw new L("a walk row runs off its chunk");u!==l&&s.stretch(l,u,d),l=u,b=r.handleAt(u,d)};for(;v<o.length;v+=3){let a=o[v],c=o[v+1]===1,d=S(a),u=tt(d,c);if(u===-1)throw new L("an open route after the first choice");if(k(u,o[v+2]),!s.route(a,c))return;let p=pt(d,c);if(p===-1)return;if(b=p,l=r.nearest(b,l),l===void 0)throw new L("a route lands off its chunk");s.step(b)}if(k(f,w),b!==f)throw new L("a walk row misses its last handle")}function St(r,t,n,e,o){let s=new Int32Array(o),i=new Uint8Array(o),f=0,y=w=>{if(f>=o)throw new L("a walk row decodes to more steps than it states");s[f]=$(w),i[f++]=w&1};if(gt(r,t,+n[9],n[10],e,{step:y,stretch(w,S,v){if(v)for(let b=w+1;b<=S;b++)y(r.handles[b]);else for(let b=w-1;b>=S;b--)y(I(r.handles[b]))},route(w,S){let v=t[w];for(let b=0;b<v.interior.length;b++)y(G(v,S,b));return!0}}),f!==o)throw new L(`a walk row decodes to ${f} steps, not ${o}`);return{ids:s,rev:i}}function dt(r,t,n,e,o){let s=r.slice(t).find(f=>f.startsWith("SQ:Z:"));if(s===void 0)return;let i=5;for(let f=0;f<n.length;f++){let y=e[f];o.set(n[f],s.slice(i,i+y)),i+=y}}function wt(r,t,n=!1){var e,o,s;let i=new Y,f=new Map,y=[],w={sequences:new Map,rows:[],nodes:new Map,ends:[],chunk:{path:i,routes:y,walks:[],lengths:f}},S={id:0},v=r.filter(l=>l[3]==="ref").sort((l,k)=>+l[6]-+k[6]);for(let l of v){let k=l[0],a=U(l[9],{id:0},[]),c=D(l[10]),d=+l[6];i.add(a,c),n&&dt(l,11,a.map($),c,w.sequences);let u=d;for(let p=0;p<a.length;p++){let g=$(a[p]),x=c[p];f.set(g,x),w.nodes.has(g)||w.nodes.set(g,{refName:l[4],start:u,end:u+x,rank:0}),u+=x}w.ends.push({name:l[4],fragStart:+l[5],piece:+l[7],first:a[0],last:a.at(-1)}),(t===void 0||t(l[4]))&&w.rows.push({chunkStart:+l[1],name:l[4],fragStart:+l[5],hapOffset:d,piece:+l[7],n:a.length,steps:{ids:Int32Array.from(a,$),rev:Uint8Array.from(a,p=>p&1)},...ut(l,11,k)})}for(let l of r)if(l[3]==="nodes"){let k=D(l[4]),a=D(l[5]),c=0;for(let d=0;d<k.length;d++)c+=k[d],k[d]=c,f.set(c,a[d]);n&&dt(l,6,k,a,w.sequences)}else if(l[3]==="route"){let k=U(l[4],S,[]),a=U(l[5],S,[]),c=U(l[6],S,[]);y.push({entry:(e=k[0])!==null&&e!==void 0?e:-1,interior:a,exit:(o=c[0])!==null&&o!==void 0?o:-1})}let b=l=>{let k=y[l];if(!k)throw new L(`route ${l} is not in the chunk`);return k};for(let l of r){if(l[3]!=="walk")continue;let k=Nt(l[11]);w.chunk.walks.push({cols:l,choices:k});let a=l[4],c=+l[9],d=l[10],u=d.indexOf(":"),p=c,g=c+ +(u<0?d:d.slice(0,u));if(k.length>0){let x=b(k[0]),h=k[1]===1;tt(x,h)===-1&&(p=G(x,h,0));let m=k.length-3,N=b(k[m]),M=k[m+1]===1;pt(N,M)===-1&&(g=G(N,M,N.interior.length-1))}if(w.ends.push({name:a,fragStart:+l[5],piece:+l[7],first:p,last:g}),t===void 0||t(a)){let x=+l[8];for(let h=0;h<k.length;h+=3)for(let m of b(k[h]).interior){let N=$(m);if(!w.nodes.has(N)){let M=(s=f.get(N))!==null&&s!==void 0?s:0;w.nodes.set(N,{refName:a,start:0,end:M,rank:1})}}w.rows.push({chunkStart:+l[1],name:a,fragStart:+l[5],hapOffset:+l[6],piece:+l[7],n:x,steps:St(i,y,l,k,x),...ut(l,12,l[0])})}}return w}function kt(r,t,n,e){let o=new Map;for(let{path:s,routes:i,walks:f,lengths:y}of r){let w=s.handles;for(let a=1;a<w.length;a++)t.has($(w[a-1]))&&t.has($(w[a]))&&e(...Z(w[a-1],w[a]));let S=new Uint8Array(i.length);for(let a=0;a<i.length;a++){let{entry:c,interior:d,exit:u}=i[a],p=!1,g=c;for(let x of d){let h=t.has($(x));p||(p=h),h&&g!==-1&&t.has($(g))&&e(...Z(g,x)),g=x}g!==-1&&u!==-1&&t.has($(g))&&t.has($(u))&&e(...Z(g,u)),S[a]=p?1:0}let v=a=>{var c;return(c=y.get($(a)))!==null&&c!==void 0?c:0},b=new Float64Array(i.length).fill(-1),l=a=>(b[a]<0&&(b[a]=i[a].interior.reduce((c,d)=>c+v(d),0)),b[a]),k=new Uint8Array(i.length);for(let{cols:a,choices:c}of f){let d=0;for(let g=0;g<c.length;g+=3){let x=c[g];S[x]&&!k[x]&&d++}if(d===0)continue;let u=a[4],p=+a[6];gt(s,i,+a[9],a[10],c,{step(g){p+=v(g)},stretch(g,x,h){p+=h?s.bp(x+1)-s.bp(g+1):s.bp(g)-s.bp(x)},route(g,x){if(!S[g]||k[g])return p+=l(g),!0;k[g]=1;let h=i[g];for(let m=0;m<h.interior.length;m++){let N=G(h,x,m),M=$(N),A=v(N);if(t.has(M)){let E=o.get(M);(!E||u<E.refName||u===E.refName&&p<E.start)&&o.set(M,{refName:u,start:p,end:p+A,rank:1})}p+=A}return d--,d>0}})}}for(let[s,i]of o)n(s,i)}function Et(r){let t=[];for(let n of r){if(n[3]!=="ref")continue;let e=U(n[9],{id:0},[]),o=D(n[10]),s=+n[6];for(let i=0;i<e.length;i++){let f=o[i];t.push({id:$(e[i]),refName:n[4],start:s,end:s+f,rank:0}),s+=f}}return t}function mt(r){let t=new Map;for(let e of r){let o=`${e.name} ${e.fragStart}`,s=t.get(o);s||(s=new Map,t.set(o,s)),s.set(e.piece,e)}let n=[];for(let e of t.values())for(let[o,s]of e){let i=e.get(o+1);i&&n.push(Z(s.last,i.first))}return n}var q=class extends Error{constructor(t,n,e,o){super(t),this.regionTooLarge=!0,this.name="NodeLimitError",this.limit=n,this.windowBp=e,this.fitsBp=o}},Mt="#";function Q(r,t){return t!==void 0&&(r===t||r.startsWith(t+Mt))}var yt=r=>Number.parseFloat(r.toPrecision(3));function P(r){let t=yt(r/1e6);return t>=1?`${t.toLocaleString("en-US")}Mbp`:r>=1e3?`${yt(r/1e3).toLocaleString("en-US")}Kbp`:`${Math.floor(r)}bp`}function et(r,t){let n=new RegExp(`(?:^|\\t)${t}:i:(\\d+)`).exec(r);return n?+n[1]:void 0}function nt(r){var t,n,e;let o={references:[],haplotypes:[]};for(let s of r){let[i,f=""]=s.split(" ");i==="#reference"?o.references.push(f):i==="#haplotype"?o.haplotypes.push(f):((t=o.format)!==null&&t!==void 0||(o.format=et(s,"format")),(n=o.chunk)!==null&&n!==void 0||(o.chunk=et(s,"chunk")),(e=o.maxNode)!==null&&e!==void 0||(o.maxNode=et(s,"maxnode")))}return o}function st(r,t){return r===void 0?1:Math.max(1,Math.ceil(r/t))}function K(r,t,n=1){return Math.max(0,(Math.floor(r/t)-n)*t)}function ot(r,t){return r===void 0||r.length===0?void 0:n=>Q(n,t)||r.some(e=>Q(n,e))}function z(r){let t=new Map;for(let e of r){let o=`${e.name} ${e.fragStart}`,s=t.get(o);s?s.push(e):t.set(o,[e])}let n=[];for(let e of t.values()){e.sort((s,i)=>s.piece-i.piece);let o=0;for(let s=1;s<=e.length;s++)(s===e.length||e[s].piece!==e[s-1].piece+1)&&(n.push(At(e.slice(o,s))),o=s)}return n}function At(r){let t=r.reduce((i,f)=>i+f.n,0),n=new Int32Array(t),e=new Uint8Array(t),o=0;for(let i of r)n.set(i.steps.ids,o),e.set(i.steps.rev,o),o+=i.n;let s=r[0];return{name:s.name,hapOffset:s.hapOffset,ids:n,rev:e,prev:s.prev,next:r.at(-1).next}}function X(r,t,n){let e=a=>{var c;return((c=t.get(a))===null||c===void 0?void 0:c.onWindow)===!0},o=a=>{let c=t.get(a);return c?.rank===0?c:void 0},s=new Map,i=a=>{a&&s.set(`${a.refName}:${a.start}`,a)},f=(a,c,d)=>{let{ids:u}=a,p=c+d;for(;p>=0&&p<u.length&&o(u[p])===void 0;)p+=d;if(p<0||p>=u.length)return i(d<0?a.prev:a.next),p-d;let g=o(u[c]),x=o(u[p]);return x.refName!==n?p-d:p===c+d&&(x.start===g.end||x.end===g.start)?c:p},y=1/0,w=-1/0,S=[];for(let a of r){let{ids:c}=a,d=-1,u=-1;for(let p=0;p<c.length;p++)e(c[p])&&(d<0&&(d=p),u=p);if(d>=0){if(a.name!==n){d=f(a,d,-1),u=f(a,u,1);for(let p of[d,u]){let g=o(c[p]);g&&(y=Math.min(y,g.start),w=Math.max(w,g.end))}}S.push({run:a,first:d,last:u})}}let v=a=>{let c=o(a);return e(a)||c?.refName===n&&c.end>y&&c.start<w},b=new Set;for(let[a,c]of t)c.onWindow&&b.add(a);for(let a of S){let{ids:c}=a.run;if(a.run.name===n){for(;a.first>0&&v(c[a.first-1]);)a.first--;for(;a.last<c.length-1&&v(c[a.last+1]);)a.last++}for(let d=a.first;d<=a.last;d++)b.add(c[d])}let l=a=>{let c=t.get(a);return c===void 0?0:c.end-c.start},k=[];for(let{run:a,first:c,last:d}of S){let{ids:u,rev:p}=a,g=c,x=d;for(;g>0&&b.has(u[g-1]);)g--;for(;x<u.length-1&&b.has(u[x+1]);)x++;let h=a.hapOffset;for(let N=0;N<g;N++)h+=l(u[N]);let m=h;for(let N=g;N<=x;N++)m+=l(u[N]);k.push({name:a.name,hapStart:h,hapEnd:m,ids:u.subarray(g,x+1),rev:p.subarray(g,x+1)})}return{kept:b,fragments:k,open:[...s.values()]}}var T=class{constructor(t){this.nodes=new Map,this.sequences=new Map,this.links=[],this.chunks=[],this.window=t}placeNode(t,n){if(this.nodes.has(t))return;let{window:e}=this;this.nodes.set(t,{...n,onWindow:n.rank===0&&n.refName===e.refName&&n.end>e.start-e.context&&n.start<e.end+e.context})}addLinkEnds(t,n){this.links.push(t,n)}addChunk(t){this.chunks.push(t)}addSequences(t){if(this.window.sequences)for(let[n,e]of t)this.sequences.set(n,e)}tables(t,n){this.chunks.length>0&&kt(this.chunks,t,(h,m)=>{let N=this.nodes.get(h);N&&this.nodes.set(h,{...N,...m})},(h,m)=>{this.links.push(h,m)});let e=[];for(let h of t){let m=this.nodes.get(h);m&&e.push({...m,id:h})}e.sort((h,m)=>h.refName<m.refName?-1:h.refName>m.refName?1:h.start-m.start||h.id-m.id);let o=new Map,s=[],i=[],f=new Map,y=new Int32Array(e.length),w=new Int32Array(e.length),S=new Float64Array(e.length),v=new Int32Array(e.length);e.forEach(({id:h,refName:m,start:N,end:M,rank:A},E)=>{o.set(h,E),s.push(String(h));let O=f.get(m);O===void 0&&(O=i.length,f.set(m,O),i.push(m)),y[E]=M-N,w[E]=O,S[E]=N,v[E]=A});let b=h=>{let m=o.get(h);return m===void 0&&(m=s.length,o.set(h,m),s.push(String(h))),m},l=new Map;for(let h=0;h<this.links.length;h+=2){let m=this.links[h],N=this.links[h+1],M=Math.floor(m/2),A=Math.floor(N/2);t.has(M)&&t.has(A)&&l.set(`${M} ${m%2?"-":"+"} ${A} ${N%2?"-":"+"}`,h)}let k=[...l.keys()].sort(),a=new Int32Array(k.length),c=new Int32Array(k.length),d=new Uint8Array(k.length);k.forEach((h,m)=>{let N=l.get(h),M=this.links[N],A=this.links[N+1];a[m]=b(Math.floor(M/2)),c[m]=b(Math.floor(A/2)),d[m]=M%2|A%2<<1});let u=this.referenceFirst(n),p=new Int32Array(u.length+1);u.forEach(({ids:h},m)=>{p[m+1]=p[m]+h.length});let g=new Int32Array(p[u.length]),x=new Uint8Array(g.length);return u.forEach(({ids:h,rev:m},N)=>{let M=p[N];for(let A=0;A<h.length;A++)g[M+A]=b(h[A]);x.set(m,M)}),{nodes:{names:s,lengths:y,refs:w,starts:S,ranks:v,refNames:i},links:{from:a,to:c,strands:d},walks:{names:u.map(h=>h.name),starts:Float64Array.from(u,h=>h.hapStart),ends:Float64Array.from(u,h=>h.hapEnd),offsets:p,steps:g,reversed:x}}}referenceFirst(t){let{refName:n}=this.window;return[...t].sort((e,o)=>+(o.name===n)-+(e.name===n)||(e.name<o.name?-1:e.name>o.name?1:e.hapStart-o.hapStart))}},rt={steps:"the step budget",bytes:"a byte budget of"};function at(r,t,n,e,o,s,i=rt){var f;let y=0,w=new Map,S=new Set;for(let c of r)y+=c.n,w.set(c.chunkStart,((f=w.get(c.chunkStart))!==null&&f!==void 0?f:0)+c.n),S.add(c.name);let v=t*n;if(y<=v)return;let b=e.end-e.start,l=0,k=0;for(let c of[...w.keys()].sort((d,u)=>d-u)){if(l+=w.get(c),l>v)break;k=Math.max(k,c+o-e.start)}let a=!s&&S.size>2&&2*y/S.size<=v;return new q(k>0?`Zoom in to about ${P(k)}${a?", or choose fewer haplotypes,":""} to see the graph`:`Too many haplotype steps here to draw ${s?"these haplotypes":"every haplotype"} (${l.toLocaleString()} steps read, over ${n} \xD7 ${i.steps} of ${t.toLocaleString()}); choose fewer haplotypes`,v,b,Math.max(k,1))}function it(r,t,n,e){let o=r.reduce((f,y)=>f+y.ids.length,0);if(o<=t)return;let s=n.end-n.start,i=Math.max(1,Math.floor(s*t/o));return new q(`Zoom in to about ${P(i)}${e?"":", or choose fewer haplotypes,"} to see the graph`,t,s,i)}async function ct(r,t,n,e,o=rt){let s=await r(n.end);if(s<=t)return;let i=0,f;for(let w=Math.floor(n.start/e)*e;w<n.end;w+=e){let S=await r(w+1);if(f??(f=S),S>t)break;i=w+e-n.start}let y=n.end-n.start;return new q(i>0?`Zoom in to about ${P(i)} to see the graph`:`Too much graph here to fetch (${bt(f??s)} against ${o.bytes} ${bt(t)})`,t,y,Math.max(i,1))}var bt=r=>`${(r/1e6).toFixed(1)} MB`;var $t=8,Ot=3,Lt=4,Bt=1e3,J=class extends Error{constructor(){super(...arguments),this.name="WalkFormatError"}};function xt(r,t,n){if(!Number.isFinite(t)||!Number.isFinite(n))throw new Error(`${r}:${t}-${n} is not a finite range to query the graph's index for`)}function Ct(r,t){return t?(t.throwIfAborted(),new Promise((n,e)=>{let o=()=>{e(t.reason instanceof Error?t.reason:new Error(String(t.reason)))};t.addEventListener("abort",o,{once:!0}),r.then(n,e).finally(()=>{t.removeEventListener("abort",o)})})):r}var lt=class{constructor(t){this.walks=t}header(t={}){if(!this.headerRead){let n=this.walks.getHeaderLines().then(e=>{var o;let s=nt(e);if(s.format!==2)throw new J("This walk file is format 1, from gfa-to-tabix 0.12 or earlier; rebuild it with gfa-to-tabix 1.0 or later");let i=(o=s.chunk)!==null&&o!==void 0?o:65536;return{...s,chunk:i,lookback:st(s.maxNode,i)}});n.catch(()=>{this.headerRead===n&&(this.headerRead=void 0)}),this.headerRead=n}return Ct(this.headerRead,t.signal)}referenceSequences(t={}){return this.walks.getReferenceSequenceNames(t)}async queryStart(t,n={}){let{chunk:e,lookback:o}=await this.header(n);return K(t,e,o)}async cut(t,n,e={}){var o;let{signal:s,keep:i,context:f=Bt,stepBudget:y=1/0,byteBudget:w=1/0,links:S=!0}=e,{chunk:v,lookback:b}=await this.header({signal:s}),l=K(n.start,v,b),k=(o=this.walks.bytesForRegions)===null||o===void 0?void 0:o.bind(this.walks),a=Number.isFinite(w)&&k!==void 0,c=async E=>a?k(E.map(O=>({refName:t,...O})),{signal:s}):0,d=a?await ct(async E=>(xt(t,l,E),c([{start:l,end:E}])),w,n,v,e.budgetNames):void 0;if(d)throw d;let u=new AbortController,p=()=>{u.abort(s?.reason)};s?.throwIfAborted(),s?.addEventListener("abort",p,{once:!0});let g=[],x,h=new T({refName:t,start:n.start,end:n.end,context:f,sequences:e.sequences}),m=new Set,N=[],M=async(E,O)=>{xt(t,E,O);let _=new Map;await this.walks.getLines(t,E,O,{signal:u.signal,lineCallback:F=>{let R=F.split(" "),B=+R[1],W=_.get(B);W?W.push(R):_.set(B,[R])}});for(let[F,R]of _){if(m.has(F))continue;m.add(F);let B=wt(R,i,e.sequences);g.push(...B.rows);for(let[W,j]of B.nodes)h.placeNode(W,j);h.addSequences(B.sequences),h.addChunk(B.chunk),N.push(...B.ends)}if(S)for(let[F,R]of mt(N))h.addLinkEnds(F,R)};try{await M(l,n.end);let E=at(g,y,$t,n,v,i!==void 0,e.budgetNames);if(E)throw E;let O=l,_=Math.floor((n.end-1)/v)*v,F=Lt*v,[R,B]=[O-F,_+F];x=X(z(g),h.nodes,t);let W=await c([{start:l,end:n.end}]);for(let j=0;j<Ot;j++){let H=x.open.filter(C=>C.refName===t&&C.start>=R&&C.start<=B).map(C=>C.start),V=[{start:Math.min(O,...H),end:O},{start:_+v,end:Math.max(_,...H)+1}].filter(C=>C.end>C.start);if(V.length===0||(W+=await c(V),W>w))break;O=Math.min(O,...H),_=Math.max(_,...H),await Promise.all(V.map(({start:C,end:vt})=>M(C,vt))),x=X(z(g),h.nodes,t)}}catch(E){throw u.abort(),E}finally{s?.removeEventListener("abort",p)}let A=it(x.fragments,y,n,i!==void 0);if(A)throw A;return{graph:h,...x}}};var _t={steps:"walkStepBudget",bytes:"walkByteBudget"};async function Jt(r,t,n,e){let{graph:o,kept:s,fragments:i}=await r.cut(t,n,{signal:e.signal,keep:ot(e.prefixes,ft(t)),stepBudget:e.walkRows?1/0:e.stepBudget,byteBudget:e.byteBudget,budgetNames:_t});return ht(o.tables(s,i),n,e.walkRows)}export{Et as a,ot as b,lt as c,_t as d,Jt as e};
2
+ //# sourceMappingURL=chunk-2QQDYK5V.js.map