jbrowse-plugin-graphgenomeviewer 8.8.2 → 8.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/{GbzBaseSyntenyAdapter-NAXISJUH.js → GbzBaseSyntenyAdapter-7SUMECKQ.js} +2 -2
  3. package/dist/chunks/{GraphGenomeView-PPOVN5LA.js → GraphGenomeView-XIZVEDCF.js} +2 -2
  4. package/dist/chunks/{GraphTrackSettingsDialog-BRTDTVOJ.js → GraphTrackSettingsDialog-GHTWJVWE.js} +2 -2
  5. package/dist/chunks/{LinearGraphDisplay-2AZ7X7TK.js → LinearGraphDisplay-CA2GSNK3.js} +2 -2
  6. package/dist/chunks/{MinigraphBubbleAdapter-NR3MMUUG.js → MinigraphBubbleAdapter-YOIBRCD3.js} +2 -2
  7. package/dist/chunks/{RgfaTabixAdapter-JDQLVQVP.js → RgfaTabixAdapter-AOOEVRF6.js} +2 -2
  8. package/dist/chunks/{TrackWarningsDialog-23WL6FPV.js → TrackWarningsDialog-V5YSUFRO.js} +1 -1
  9. package/dist/chunks/{TrackWarningsDialog-23WL6FPV.js.map → TrackWarningsDialog-V5YSUFRO.js.map} +1 -1
  10. package/dist/chunks/WalkFormsAdapter-5ALR4RU4.js +2 -0
  11. package/dist/chunks/WalkFormsAdapter-5ALR4RU4.js.map +7 -0
  12. package/dist/chunks/{WalkTabixSyntenyAdapter-PBWN53PE.js → WalkTabixSyntenyAdapter-2SGCZXRI.js} +2 -2
  13. package/dist/chunks/{chunk-GLSUAMGV.js → chunk-3WUOWIYO.js} +2 -2
  14. package/dist/chunks/{chunk-LFQFVYNY.js → chunk-BHRMUIK6.js} +3 -3
  15. package/dist/chunks/chunk-BHRMUIK6.js.map +7 -0
  16. package/dist/chunks/{chunk-AGUEPVOR.js → chunk-FQI75MV6.js} +1 -1
  17. package/dist/chunks/{chunk-AGUEPVOR.js.map → chunk-FQI75MV6.js.map} +1 -1
  18. package/dist/chunks/chunk-LZUH4IUR.js +2 -0
  19. package/dist/chunks/{chunk-EEWEXRY6.js.map → chunk-LZUH4IUR.js.map} +3 -3
  20. package/dist/chunks/{chunk-NSQ4VXKR.js → chunk-MTMW4HY6.js} +2 -2
  21. package/dist/chunks/{chunk-RS274NAD.js → chunk-MURQDZ33.js} +2 -2
  22. package/dist/chunks/{chunk-5HDIVUAZ.js → chunk-RJZG46KB.js} +2 -2
  23. package/dist/chunks/{chunk-MWQGJP3J.js → chunk-RU3HHR5K.js} +2 -2
  24. package/dist/chunks/chunk-T7NMFIRW.js +2 -0
  25. package/dist/chunks/chunk-T7NMFIRW.js.map +7 -0
  26. package/dist/chunks/{chunk-HKGTCZOL.js → chunk-TFJLUI7X.js} +4 -4
  27. package/dist/chunks/{chunk-HKGTCZOL.js.map → chunk-TFJLUI7X.js.map} +2 -2
  28. package/dist/chunks/{chunk-ZBFIEBO6.js → chunk-VQVV42DS.js} +2 -2
  29. package/dist/chunks/{chunk-EH5OCKSE.js → chunk-ZNDMFZLV.js} +2 -2
  30. package/dist/chunks/{chunk-EH5OCKSE.js.map → chunk-ZNDMFZLV.js.map} +3 -3
  31. package/dist/chunks/{executeDiagonalize-HZFFXMG4.js → executeDiagonalize-ZMW5BLEJ.js} +2 -2
  32. package/dist/chunks/{executeDiagonalize-HZFFXMG4.js.map → executeDiagonalize-ZMW5BLEJ.js.map} +1 -1
  33. package/dist/chunks/{renderSvg-UKXPWKKV.js → renderSvg-DKGTDQU4.js} +2 -2
  34. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +5 -5
  35. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  36. package/package.json +10 -10
  37. package/src/GraphGenomeView/pane/loadActions.ts +7 -2
  38. package/src/GraphGenomeView/walkRowGroups.test.ts +14 -3
  39. package/src/GraphGenomeView/walkRowGroups.ts +0 -22
  40. package/src/WalkFormsAdapter/WalkFormsAdapter.test.ts +4 -25
  41. package/src/WalkFormsAdapter/WalkFormsAdapter.ts +1 -23
  42. package/src/WalkFormsAdapter/configSchema.ts +1 -1
  43. package/src/WalkFormsAdapter/formRows.test.ts +0 -6
  44. package/src/WalkFormsAdapter/formRows.ts +0 -12
  45. package/src/launchFromGraph/syntenyTracks.test.ts +1 -1
  46. package/src/version.ts +1 -1
  47. package/dist/chunks/WalkFormsAdapter-YMQC3NLG.js +0 -2
  48. package/dist/chunks/WalkFormsAdapter-YMQC3NLG.js.map +0 -7
  49. package/dist/chunks/chunk-EEWEXRY6.js +0 -2
  50. package/dist/chunks/chunk-LFQFVYNY.js.map +0 -7
  51. package/dist/chunks/chunk-QUDJ7AM3.js +0 -2
  52. package/dist/chunks/chunk-QUDJ7AM3.js.map +0 -7
  53. /package/dist/chunks/{GbzBaseSyntenyAdapter-NAXISJUH.js.map → GbzBaseSyntenyAdapter-7SUMECKQ.js.map} +0 -0
  54. /package/dist/chunks/{GraphGenomeView-PPOVN5LA.js.map → GraphGenomeView-XIZVEDCF.js.map} +0 -0
  55. /package/dist/chunks/{GraphTrackSettingsDialog-BRTDTVOJ.js.map → GraphTrackSettingsDialog-GHTWJVWE.js.map} +0 -0
  56. /package/dist/chunks/{LinearGraphDisplay-2AZ7X7TK.js.map → LinearGraphDisplay-CA2GSNK3.js.map} +0 -0
  57. /package/dist/chunks/{MinigraphBubbleAdapter-NR3MMUUG.js.map → MinigraphBubbleAdapter-YOIBRCD3.js.map} +0 -0
  58. /package/dist/chunks/{RgfaTabixAdapter-JDQLVQVP.js.map → RgfaTabixAdapter-AOOEVRF6.js.map} +0 -0
  59. /package/dist/chunks/{WalkTabixSyntenyAdapter-PBWN53PE.js.map → WalkTabixSyntenyAdapter-2SGCZXRI.js.map} +0 -0
  60. /package/dist/chunks/{chunk-GLSUAMGV.js.map → chunk-3WUOWIYO.js.map} +0 -0
  61. /package/dist/chunks/{chunk-NSQ4VXKR.js.map → chunk-MTMW4HY6.js.map} +0 -0
  62. /package/dist/chunks/{chunk-RS274NAD.js.map → chunk-MURQDZ33.js.map} +0 -0
  63. /package/dist/chunks/{chunk-5HDIVUAZ.js.map → chunk-RJZG46KB.js.map} +0 -0
  64. /package/dist/chunks/{chunk-MWQGJP3J.js.map → chunk-RU3HHR5K.js.map} +0 -0
  65. /package/dist/chunks/{chunk-ZBFIEBO6.js.map → chunk-VQVV42DS.js.map} +0 -0
  66. /package/dist/chunks/{renderSvg-UKXPWKKV.js.map → renderSvg-DKGTDQU4.js.map} +0 -0
package/README.md CHANGED
@@ -23,7 +23,7 @@ short.
23
23
 
24
24
  ## Quick start
25
25
 
26
- 1. Add the plugin to your JBrowse 5.0.0-beta.18 or later config:
26
+ 1. Add the plugin to your JBrowse 5.0.0-beta.20 or later config:
27
27
 
28
28
  ```json
29
29
  {
@@ -1,2 +1,2 @@
1
- import{a as ne,b as ae,c as ue,d as re,e as oe,f as O,g as ie,h as se}from"./chunk-LFQFVYNY.js";import{a as te}from"./chunk-APSXG7SV.js";import{a as ee}from"./chunk-V55TK2NP.js";import{a as Q,b as D,c as Z,d as u,e as k,f as M,g as j,h as $,i as W,k as U}from"./chunk-EFXNCI7R.js";import"./chunk-M2D7NUOY.js";import{h as z,i as E}from"./chunk-DEWVJ57F.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import{E as V,a as K,c as L}from"./chunk-GLSUAMGV.js";import"./chunk-YBLNN5FU.js";import"./chunk-QUDJ7AM3.js";import{g as F,h as N,i as C}from"./chunk-KBOVZ3GI.js";import"./chunk-AGUEPVOR.js";import"./chunk-TMM73K4C.js";import{e as G,h as X,i as Y,j as J}from"./chunk-6VNDP3UB.js";import{a as P}from"./chunk-D6TY2QEG.js";import"./chunk-FLKXKTS2.js";import{e as _,o as B}from"./chunk-TC265JAP.js";function A(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function ge(n){return Y(n)&&A(X(n))?J(n,i=>A(i)):void 0}function ye(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function ce(n,i){let e=ge(n);if(!e)return{};try{return await P(e,i).stat(),{location:e}}catch(t){return ye(t)?{}:{unreadable:String(t)}}}var be=5e3,we=50*2**20,H=class extends Error{constructor(e){super(`this GAF is ${(e/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function xe(n,i){if(n.length<=i)return n;let e=n.length/i;return Array.from({length:i},(t,a)=>n[Math.floor(a*e)])}var pe=(n,i)=>n.path.some(e=>i.has(e.name)),v=class{constructor(i,e){this.file=i;this.tabix=e;this.whole=L({setup:async({signal:i})=>{let{size:e}=await this.file.stat();if(e>we)throw new H(e);let t=await this.file.readFile({signal:i}),a=new TextDecoder().decode(t[0]===31&&t[1]===139?await K(t):t);return E(a)}})}async readIndexed(i,e,t){let a=1/0,r=-1/0;for(let s of e){let c=Number(s);Number.isInteger(c)&&(a=Math.min(a,c),r=Math.max(r,c))}let o=[];return a<=r&&await i.getLines("{node}",a,r+1,{signal:t,lineCallback:s=>{let c=z(s);c&&pe(c,e)&&o.push(c)}}),o}async readsOver(i,{signal:e}={}){let t=this.tabix?await this.readIndexed(this.tabix,i,e):(await this.whole({signal:e})).filter(a=>pe(a,i));return{records:xe(t,be),total:t.length}}};var I=class extends Error{constructor(e){super(e===void 0?"no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation":`the haplotype index beside the graph database could not be checked (${e}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},q=class extends Error{constructor(e,t){super(`the graph is cut on its reference, ${t}; a window on ${e} has no reference coordinates to cut at. Open the graph from a ${t} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function Se(n,i){return`${u(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function Ne({alignment:n,assemblyName:i,refName:e,lane:t}){let{refStart:a,refEnd:r,strand:o,cigar:s}=n;if(!(r<=a)){let{name:c,hapStart:p,hapEnd:l}=n,f=Se(c,n),g={uniqueId:f,assemblyName:i,refName:e,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:s,syntenyId:f,mate:{refName:c.contig,start:p,end:l,assemblyName:t}};return new ne(g)}}function Pe({pair:n,lane:i,mateLane:e}){return se({target:{name:`${u(n.target)}#${n.target.contig}`,assemblyName:i,refName:n.target.contig,start:n.targetStart,end:n.targetEnd},query:{name:`${u(n.query)}#${n.query.contig}`,assemblyName:e,refName:n.query.contig,start:n.queryStart,end:n.queryEnd},strand:n.strand,cigar:n.cigar,matches:n.matches,columns:n.columns})}var Le=12e4;function Re(n,i){let e=new Map;for(let a of n)for(let{name:r,start:o,end:s}of a.walkSpans()){let c=u(r);if(i.has(c)){let p=`${c}#${r.contig}`,l=e.get(p);l?l.push([o,s]):e.set(p,[[o,s]])}}let t=0;for(let a of e.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Le&&(t=Math.max(t,o))}}return t}function fe(n,i){return n instanceof Z&&(n.message=`Zoom in to about ${_(n.fitsBp)} to see ${i}`),n}var le=(n,i,e)=>ie(fe(W(n,i,e)??n,"lanes"),e),me=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),T=class extends ae{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let e=this.getConf("gbzDbLocation"),t=this.getConf("haplotypeIndexLocation"),a=G(t)?{location:t}:await ce(e,this.pluginManager),r=a.location,o=await D.open({source:P(e,this.pluginManager),haplotypeIndex:r?P(r,this.pluginManager):void 0}),s=this.getConf("assemblyNames")[0];if(s===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let c=await M(o),p=j({configured:this.getConf("referenceSample"),anchorPrefix:N(this,s),referenceSamples:c});return{db:o,anchor:s,referenceSample:p,referenceSamples:c,unreadableIndex:a.unreadable}}});this.gaf=L({label:"Opening reads",setup:async()=>{let e=this.getConf("readsLocation"),t=this.getConf(["readsIndex","location"]);return G(e)?new v(P(e,this.pluginManager),G(t)?V(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(e,t){let{db:a,referenceSample:r}=await this.graph(t);return $(a,r,e)}async getHaplotypes(e={}){let{db:t,referenceSamples:a}=await this.graph(e),r=new Map;for(let o of await t.paths()){let s=u(o.name),c=r.get(s);c?c.contigs.includes(o.name.contig)||c.contigs.push(o.name.contig):r.set(s,{prefix:s,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(e={}){let{anchor:t,referenceSample:a}=await this.graph(e),r=C(this),o=[];for(let s of await this.getHaplotypes(e))s.sample!==a&&o.push({name:O(r,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:t,lanes:o}}async getRefNames(e={}){let{db:t,anchor:a,referenceSample:r}=await this.graph(e),{assemblyName:o}=e,s=o===a?void 0:N(this,o),c=(await t.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:F(u(p.name),s)).map(p=>p.name.contig);return[...new Set(c)]}keepPredicate(e,t){let a=e===void 0||e.length===0?void 0:e.map(r=>N(this,r));return a===void 0&&t===void 0?void 0:r=>k(r,a)&&(t===void 0||F(u(r),t))}async getSubgraph(e,t={}){let{signal:a}=t,{db:r,anchor:o,referenceSample:s,unreadableIndex:c}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:f,end:g}=me(e);if(p!==o)throw new q(p,o);let y=await this.referenceQuery(l,{signal:a});if(!y)throw new Error(`${s} has no indexed path ${l} in this graph`);let b=this.keepPredicate(t.haplotypes);if(b!==void 0&&!r.hasHaplotypeIndex)throw new I(c);let d=await U(r,y,f,g,{context:this.getConf("context"),snarls:t.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:t.signal,keep:b}).catch(w=>{throw fe(w,"the graph")});return typeof d=="string"?d:te(d,{start:f,end:g},t.walkRows)}async getReads(e,t={}){let a=await this.gaf(t);return a?a.readsOver(new Set(e),t):{records:[],total:0}}async laneHaplotypes(e,t){let a=N(this,e);return(await this.getHaplotypes(t)).filter(r=>F(r.prefix,a))}async anchorFeatures(e,t){let{db:a}=await this.graph(t),{assemblyName:r,refName:o,start:s,end:c}=e,p=N(this,t.targetAssemblyName),l=C(this),f=this.keepPredicate(t.haplotypes,p),g=await this.referenceQuery(o,t),y=this.getConf("nodeLimit");return(g?await B(`Reading graph ${o}:${s.toLocaleString()}-${c.toLocaleString()}`,t.statusCallback,()=>a.getAlignments({path:g,start:s,end:c,context:this.getConf("context"),haplotypes:"all",limit:y,signal:t.signal,keep:f}).catch(d=>{throw le(d,y,c-s)})):[]).flatMap(d=>{let w=d.resolved?Ne({alignment:d,assemblyName:r,refName:o,lane:O(l,u(d.name))}):void 0;return w===void 0?[]:[w]})}async pairFeatures(e,t,a){let{db:r}=await this.graph(a),{refName:o,start:s,end:c}=e,l=(await Promise.all(t.map(async m=>({pair:m,featureSide:await this.laneHaplotypes(m.queryAssemblyName,a),mateSide:await this.laneHaplotypes(m.targetAssemblyName,a)})))).filter(({featureSide:m,mateSide:h})=>m.length>0&&h.length>0),f=new Set(l.flatMap(({featureSide:m,mateSide:h})=>[...m,...h].map(u))),g=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),b=this.getConf("context"),d=(m,h)=>r.getSubgraphs({path:m,start:s,end:c,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:x=>f.has(u(x))}),w=async m=>{let h=await d(m,b).catch(S=>{throw le(S,y,c-s)}),x=Re(h,f),R=Math.ceil(x/2)+2e3;return x>0&&R>b?d(m,R).catch(S=>{if(S instanceof Q)return h;throw S}):h};return(g&&l.length>0?await B(oe(t),a.statusCallback,()=>w(g)):[]).flatMap(m=>l.flatMap(({pair:h,featureSide:x,mateSide:R})=>x.flatMap(S=>R.flatMap(de=>m.pairAlignments({target:S,query:de,bases:!1}).map(he=>Pe({pair:he,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(e,t={}){let a=me(e);return ee(async r=>{let{db:o,anchor:s,unreadableIndex:c}=await this.graph(t);if(!o.hasHaplotypeIndex)throw new I(c);if(a.assemblyName===s){let p=re(t),l=p.length>0?await this.pairFeatures(a,p,t):await this.anchorFeatures(a,t);for(let f of l)r.next(f)}r.complete()},t.signal)}};export{I as NoHaplotypeIndexError,ue as PairTargetError,T as default,Re as widestWalkGap};
2
- //# sourceMappingURL=GbzBaseSyntenyAdapter-NAXISJUH.js.map
1
+ import{a as ne,b as ae,c as ue,d as re,e as oe,f as O,g as ie,h as se}from"./chunk-BHRMUIK6.js";import{a as te}from"./chunk-APSXG7SV.js";import{a as ee}from"./chunk-V55TK2NP.js";import{a as Q,b as D,c as Z,d as u,e as k,f as M,g as j,h as $,i as W,k as U}from"./chunk-EFXNCI7R.js";import"./chunk-M2D7NUOY.js";import{h as z,i as E}from"./chunk-DEWVJ57F.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import{E as V,a as K,c as L}from"./chunk-3WUOWIYO.js";import"./chunk-YBLNN5FU.js";import"./chunk-T7NMFIRW.js";import{g as F,h as N,i as C}from"./chunk-KBOVZ3GI.js";import"./chunk-FQI75MV6.js";import"./chunk-TMM73K4C.js";import{e as G,h as X,i as Y,j as J}from"./chunk-6VNDP3UB.js";import{a as P}from"./chunk-D6TY2QEG.js";import"./chunk-FLKXKTS2.js";import{e as _,o as B}from"./chunk-TC265JAP.js";function A(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function ge(n){return Y(n)&&A(X(n))?J(n,i=>A(i)):void 0}function ye(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function ce(n,i){let e=ge(n);if(!e)return{};try{return await P(e,i).stat(),{location:e}}catch(t){return ye(t)?{}:{unreadable:String(t)}}}var be=5e3,we=50*2**20,H=class extends Error{constructor(e){super(`this GAF is ${(e/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function xe(n,i){if(n.length<=i)return n;let e=n.length/i;return Array.from({length:i},(t,a)=>n[Math.floor(a*e)])}var pe=(n,i)=>n.path.some(e=>i.has(e.name)),v=class{constructor(i,e){this.file=i;this.tabix=e;this.whole=L({setup:async({signal:i})=>{let{size:e}=await this.file.stat();if(e>we)throw new H(e);let t=await this.file.readFile({signal:i}),a=new TextDecoder().decode(t[0]===31&&t[1]===139?await K(t):t);return E(a)}})}async readIndexed(i,e,t){let a=1/0,r=-1/0;for(let s of e){let c=Number(s);Number.isInteger(c)&&(a=Math.min(a,c),r=Math.max(r,c))}let o=[];return a<=r&&await i.getLines("{node}",a,r+1,{signal:t,lineCallback:s=>{let c=z(s);c&&pe(c,e)&&o.push(c)}}),o}async readsOver(i,{signal:e}={}){let t=this.tabix?await this.readIndexed(this.tabix,i,e):(await this.whole({signal:e})).filter(a=>pe(a,i));return{records:xe(t,be),total:t.length}}};var I=class extends Error{constructor(e){super(e===void 0?"no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation":`the haplotype index beside the graph database could not be checked (${e}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},q=class extends Error{constructor(e,t){super(`the graph is cut on its reference, ${t}; a window on ${e} has no reference coordinates to cut at. Open the graph from a ${t} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function Se(n,i){return`${u(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function Ne({alignment:n,assemblyName:i,refName:e,lane:t}){let{refStart:a,refEnd:r,strand:o,cigar:s}=n;if(!(r<=a)){let{name:c,hapStart:p,hapEnd:l}=n,f=Se(c,n),g={uniqueId:f,assemblyName:i,refName:e,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:s,syntenyId:f,mate:{refName:c.contig,start:p,end:l,assemblyName:t}};return new ne(g)}}function Pe({pair:n,lane:i,mateLane:e}){return se({target:{name:`${u(n.target)}#${n.target.contig}`,assemblyName:i,refName:n.target.contig,start:n.targetStart,end:n.targetEnd},query:{name:`${u(n.query)}#${n.query.contig}`,assemblyName:e,refName:n.query.contig,start:n.queryStart,end:n.queryEnd},strand:n.strand,cigar:n.cigar,matches:n.matches,columns:n.columns})}var Le=12e4;function Re(n,i){let e=new Map;for(let a of n)for(let{name:r,start:o,end:s}of a.walkSpans()){let c=u(r);if(i.has(c)){let p=`${c}#${r.contig}`,l=e.get(p);l?l.push([o,s]):e.set(p,[[o,s]])}}let t=0;for(let a of e.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Le&&(t=Math.max(t,o))}}return t}function fe(n,i){return n instanceof Z&&(n.message=`Zoom in to about ${_(n.fitsBp)} to see ${i}`),n}var le=(n,i,e)=>ie(fe(W(n,i,e)??n,"lanes"),e),me=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),T=class extends ae{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let e=this.getConf("gbzDbLocation"),t=this.getConf("haplotypeIndexLocation"),a=G(t)?{location:t}:await ce(e,this.pluginManager),r=a.location,o=await D.open({source:P(e,this.pluginManager),haplotypeIndex:r?P(r,this.pluginManager):void 0}),s=this.getConf("assemblyNames")[0];if(s===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let c=await M(o),p=j({configured:this.getConf("referenceSample"),anchorPrefix:N(this,s),referenceSamples:c});return{db:o,anchor:s,referenceSample:p,referenceSamples:c,unreadableIndex:a.unreadable}}});this.gaf=L({label:"Opening reads",setup:async()=>{let e=this.getConf("readsLocation"),t=this.getConf(["readsIndex","location"]);return G(e)?new v(P(e,this.pluginManager),G(t)?V(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(e,t){let{db:a,referenceSample:r}=await this.graph(t);return $(a,r,e)}async getHaplotypes(e={}){let{db:t,referenceSamples:a}=await this.graph(e),r=new Map;for(let o of await t.paths()){let s=u(o.name),c=r.get(s);c?c.contigs.includes(o.name.contig)||c.contigs.push(o.name.contig):r.set(s,{prefix:s,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(e={}){let{anchor:t,referenceSample:a}=await this.graph(e),r=C(this),o=[];for(let s of await this.getHaplotypes(e))s.sample!==a&&o.push({name:O(r,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:t,lanes:o}}async getRefNames(e={}){let{db:t,anchor:a,referenceSample:r}=await this.graph(e),{assemblyName:o}=e,s=o===a?void 0:N(this,o),c=(await t.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:F(u(p.name),s)).map(p=>p.name.contig);return[...new Set(c)]}keepPredicate(e,t){let a=e===void 0||e.length===0?void 0:e.map(r=>N(this,r));return a===void 0&&t===void 0?void 0:r=>k(r,a)&&(t===void 0||F(u(r),t))}async getSubgraph(e,t={}){let{signal:a}=t,{db:r,anchor:o,referenceSample:s,unreadableIndex:c}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:f,end:g}=me(e);if(p!==o)throw new q(p,o);let y=await this.referenceQuery(l,{signal:a});if(!y)throw new Error(`${s} has no indexed path ${l} in this graph`);let b=this.keepPredicate(t.haplotypes);if(b!==void 0&&!r.hasHaplotypeIndex)throw new I(c);let d=await U(r,y,f,g,{context:this.getConf("context"),snarls:t.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:t.signal,keep:b}).catch(w=>{throw fe(w,"the graph")});return typeof d=="string"?d:te(d,{start:f,end:g},t.walkRows)}async getReads(e,t={}){let a=await this.gaf(t);return a?a.readsOver(new Set(e),t):{records:[],total:0}}async laneHaplotypes(e,t){let a=N(this,e);return(await this.getHaplotypes(t)).filter(r=>F(r.prefix,a))}async anchorFeatures(e,t){let{db:a}=await this.graph(t),{assemblyName:r,refName:o,start:s,end:c}=e,p=N(this,t.targetAssemblyName),l=C(this),f=this.keepPredicate(t.haplotypes,p),g=await this.referenceQuery(o,t),y=this.getConf("nodeLimit");return(g?await B(`Reading graph ${o}:${s.toLocaleString()}-${c.toLocaleString()}`,t.statusCallback,()=>a.getAlignments({path:g,start:s,end:c,context:this.getConf("context"),haplotypes:"all",limit:y,signal:t.signal,keep:f}).catch(d=>{throw le(d,y,c-s)})):[]).flatMap(d=>{let w=d.resolved?Ne({alignment:d,assemblyName:r,refName:o,lane:O(l,u(d.name))}):void 0;return w===void 0?[]:[w]})}async pairFeatures(e,t,a){let{db:r}=await this.graph(a),{refName:o,start:s,end:c}=e,l=(await Promise.all(t.map(async m=>({pair:m,featureSide:await this.laneHaplotypes(m.queryAssemblyName,a),mateSide:await this.laneHaplotypes(m.targetAssemblyName,a)})))).filter(({featureSide:m,mateSide:h})=>m.length>0&&h.length>0),f=new Set(l.flatMap(({featureSide:m,mateSide:h})=>[...m,...h].map(u))),g=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),b=this.getConf("context"),d=(m,h)=>r.getSubgraphs({path:m,start:s,end:c,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:x=>f.has(u(x))}),w=async m=>{let h=await d(m,b).catch(S=>{throw le(S,y,c-s)}),x=Re(h,f),R=Math.ceil(x/2)+2e3;return x>0&&R>b?d(m,R).catch(S=>{if(S instanceof Q)return h;throw S}):h};return(g&&l.length>0?await B(oe(t),a.statusCallback,()=>w(g)):[]).flatMap(m=>l.flatMap(({pair:h,featureSide:x,mateSide:R})=>x.flatMap(S=>R.flatMap(de=>m.pairAlignments({target:S,query:de,bases:!1}).map(he=>Pe({pair:he,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(e,t={}){let a=me(e);return ee(async r=>{let{db:o,anchor:s,unreadableIndex:c}=await this.graph(t);if(!o.hasHaplotypeIndex)throw new I(c);if(a.assemblyName===s){let p=re(t),l=p.length>0?await this.pairFeatures(a,p,t):await this.anchorFeatures(a,t);for(let f of l)r.next(f)}r.complete()},t.signal)}};export{I as NoHaplotypeIndexError,ue as PairTargetError,T as default,Re as widestWalkGap};
2
+ //# sourceMappingURL=GbzBaseSyntenyAdapter-7SUMECKQ.js.map
@@ -1,4 +1,4 @@
1
- import{b as C}from"./chunk-MWQGJP3J.js";import"./chunk-RS274NAD.js";import"./chunk-HKGTCZOL.js";import"./chunk-NSQ4VXKR.js";import{s as d}from"./chunk-5HDIVUAZ.js";import"./chunk-EH5OCKSE.js";import"./chunk-FM4T47WH.js";import"./chunk-ZWHXVFZF.js";import"./chunk-CHLLRNBQ.js";import"./chunk-LKD5NRWR.js";import"./chunk-DEWVJ57F.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import"./chunk-YBLNN5FU.js";import"./chunk-QUDJ7AM3.js";import"./chunk-KBOVZ3GI.js";import"./chunk-TMM73K4C.js";import"./chunk-6VNDP3UB.js";import"./chunk-FLKXKTS2.js";import"./chunk-TC265JAP.js";import{i as L}from"./chunk-J2PN6CG3.js";import{A as l,F as G,H as p,e as s,j as v,o as n,x as y}from"./chunk-WE7DQVXF.js";import{a as h,b as e,c as r,d as i}from"./chunk-DUU6T2I5.js";var N=d()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}}),S=i(function({model:a}){let{classes:t}=N();return!a.error&&!a.loadCanceled?r(l,{className:t.paper,"data-testid":"graph-genome-loading",children:[r("div",{className:t.row,children:[e(v,{variant:"h6",message:a.statusMessage||void 0}),a.canCancelLoad?e(n,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{a.cancelLoad()},children:"Cancel"}):null]}),e(y,{variant:"indeterminate"})]}):a.error?e(l,{className:t.paper,children:e(s,{error:a.error,onReset:()=>{a.retryLoad()}})}):e(l,{className:t.paper,"data-testid":"graph-genome-load-canceled",children:r("div",{className:t.row,children:[e(p,{variant:"h6",children:"Loading canceled"}),e(n,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{a.retryLoad()},children:"Retry"})]})})}),f=S;var T=`H VN:Z:1.0
1
+ import{b as C}from"./chunk-RU3HHR5K.js";import"./chunk-MURQDZ33.js";import"./chunk-TFJLUI7X.js";import"./chunk-MTMW4HY6.js";import{s as d}from"./chunk-RJZG46KB.js";import"./chunk-ZNDMFZLV.js";import"./chunk-FM4T47WH.js";import"./chunk-ZWHXVFZF.js";import"./chunk-CHLLRNBQ.js";import"./chunk-LKD5NRWR.js";import"./chunk-DEWVJ57F.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import"./chunk-YBLNN5FU.js";import"./chunk-T7NMFIRW.js";import"./chunk-KBOVZ3GI.js";import"./chunk-TMM73K4C.js";import"./chunk-6VNDP3UB.js";import"./chunk-FLKXKTS2.js";import"./chunk-TC265JAP.js";import{i as L}from"./chunk-J2PN6CG3.js";import{A as l,F as G,H as p,e as s,j as v,o as n,x as y}from"./chunk-WE7DQVXF.js";import{a as h,b as e,c as r,d as i}from"./chunk-DUU6T2I5.js";var N=d()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}}),S=i(function({model:a}){let{classes:t}=N();return!a.error&&!a.loadCanceled?r(l,{className:t.paper,"data-testid":"graph-genome-loading",children:[r("div",{className:t.row,children:[e(v,{variant:"h6",message:a.statusMessage||void 0}),a.canCancelLoad?e(n,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{a.cancelLoad()},children:"Cancel"}):null]}),e(y,{variant:"indeterminate"})]}):a.error?e(l,{className:t.paper,children:e(s,{error:a.error,onReset:()=>{a.retryLoad()}})}):e(l,{className:t.paper,"data-testid":"graph-genome-load-canceled",children:r("div",{className:t.row,children:[e(p,{variant:"h6",children:"Loading canceled"}),e(n,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{a.retryLoad()},children:"Retry"})]})})}),f=S;var T=`H VN:Z:1.0
2
2
  S 1 ACGT
3
3
  S 2 GGCC
4
4
  S 3 TTAA
@@ -7,4 +7,4 @@ L 1 + 2 + 0M
7
7
  L 1 + 3 + 0M
8
8
  L 2 + 4 + 0M
9
9
  L 3 + 4 + 0M`,E=d()({column:{display:"flex",flexDirection:"column",gap:8},rowEnd:{display:"flex",gap:8,alignItems:"flex-end"},rowCenter:{display:"flex",gap:8,alignItems:"center"},flex1:{flex:1},paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto"},header:{marginBottom:12},footer:{marginTop:12,display:"flex",justifyContent:"flex-end"}}),F=i(function({model:a}){let{classes:t}=E(),[m,w]=L("");function u(){let o=m.trim();o&&a.openGfaLocation({uri:o,locationType:"UriLocation"})}function M(o){let c=o.target.files?.[0];o.target.value="",c&&a.loadGFAFile(c,c.name)}return r(l,{className:t.paper,children:[e("div",{className:t.header,children:e(p,{variant:"h6",children:"Load a GFA graph"})}),r("div",{className:t.column,children:[r("div",{className:t.rowCenter,children:[r(n,{variant:"outlined",component:"label",size:"small",children:["Choose file",e("input",{type:"file",accept:".gfa,.gfa1,.gfa2,.gz",hidden:!0,onChange:o=>{M(o)}})]}),e(p,{variant:"caption",color:"text.secondary",children:"Whole-file GFA; best for small/medium graphs."})]}),r("div",{className:t.rowEnd,children:[e(G,{size:"small",label:"URL",placeholder:"https://example.com/graph.gfa",value:m,onChange:o=>{w(o.target.value)},onKeyDown:o=>{o.key==="Enter"&&u()},className:t.flex1}),e(n,{variant:"contained",onClick:()=>{u()},disabled:!m.trim(),children:"Open"})]})]}),e("div",{className:t.footer,children:e(n,{size:"small",onClick:()=>{a.loadGFA(T,"Example graph")},children:"Load 4-node example"})}),a.error?e(s,{error:a.error}):null]})}),x=F;var B=i(function({model:a}){return a.hasGraph?e(C,{model:a}):a.canRetryLoad?e(f,{model:a}):r(h,{children:[a.isLoading?e(f,{model:a}):null,e("div",{hidden:a.isLoading,children:e(x,{model:a})})]})}),q=B;export{q as default};
10
- //# sourceMappingURL=GraphGenomeView-PPOVN5LA.js.map
10
+ //# sourceMappingURL=GraphGenomeView-XIZVEDCF.js.map
@@ -1,4 +1,4 @@
1
- import{a as G,b as L}from"./chunk-RS274NAD.js";import{e as v,f as x,s as f}from"./chunk-5HDIVUAZ.js";import"./chunk-ZWHXVFZF.js";import"./chunk-CHLLRNBQ.js";import"./chunk-SKB4GSET.js";import"./chunk-QUDJ7AM3.js";import"./chunk-KBOVZ3GI.js";import"./chunk-TMM73K4C.js";import"./chunk-6VNDP3UB.js";import{h as g,i as d}from"./chunk-J2PN6CG3.js";import{F as y,H as h,n as H}from"./chunk-WE7DQVXF.js";import{b as p,c as i,d as s}from"./chunk-DUU6T2I5.js";var k=f()({section:{marginBottom:24}}),w=[{value:"0",label:"None"},{value:"1",label:"1 hop"},{value:"2",label:"2 hops"}],F=s(function({model:t}){let{classes:o}=k(),e=t.sourceAdapter;return e?.type==="RgfaTabixAdapter"&&!v(e)?i("div",{className:o.section,children:[p(G,{label:"Graph context",sx:{minWidth:200},value:String(t.subgraphContext),options:w,testId:"graph-context-select",onChange:n=>{t.setSubgraphContext(Number(n)),t.recut()}}),p(h,{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}),M=F;var I=f()({section:{marginBottom:24}});function A(a){return a.split(/[\s,]+/).filter(t=>t!=="")}var N=(a,t)=>a.join(`
1
+ import{a as G,b as L}from"./chunk-MURQDZ33.js";import{e as v,f as x,s as f}from"./chunk-RJZG46KB.js";import"./chunk-ZWHXVFZF.js";import"./chunk-CHLLRNBQ.js";import"./chunk-SKB4GSET.js";import"./chunk-T7NMFIRW.js";import"./chunk-KBOVZ3GI.js";import"./chunk-TMM73K4C.js";import"./chunk-6VNDP3UB.js";import{h as g,i as d}from"./chunk-J2PN6CG3.js";import{F as y,H as h,n as H}from"./chunk-WE7DQVXF.js";import{b as p,c as i,d as s}from"./chunk-DUU6T2I5.js";var k=f()({section:{marginBottom:24}}),w=[{value:"0",label:"None"},{value:"1",label:"1 hop"},{value:"2",label:"2 hops"}],F=s(function({model:t}){let{classes:o}=k(),e=t.sourceAdapter;return e?.type==="RgfaTabixAdapter"&&!v(e)?i("div",{className:o.section,children:[p(G,{label:"Graph context",sx:{minWidth:200},value:String(t.subgraphContext),options:w,testId:"graph-context-select",onChange:n=>{t.setSubgraphContext(Number(n)),t.recut()}}),p(h,{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}),M=F;var I=f()({section:{marginBottom:24}});function A(a){return a.split(/[\s,]+/).filter(t=>t!=="")}var N=(a,t)=>a.join(`
2
2
  `)===t.join(`
3
3
  `);function P(a,t){let o=a.cutHaplotypes??[],[e,n]=d(o);return N(o,e)||(n(o),t()),r=>{N(r,o)||(n(r),a.setSubgraphHaplotypes(r),a.recut())}}var D=s(function({model:t}){let[o,e]=d(t.cutHaplotypes?.join(", ")??""),n=P(t,()=>{e(t.cutHaplotypes?.join(", ")??"")}),r=()=>{n(A(o))};return p(y,{fullWidth:!0,label:"Haplotypes",placeholder:"every haplotype",value:o,slotProps:{htmlInput:{"data-testid":"graph-haplotypes-field"}},onChange:c=>{e(c.target.value)},onBlur:()=>{r()},onKeyDown:c=>{c.key==="Enter"&&r()}})}),B=s(function({model:t,names:o}){let[e,n]=d(t.cutHaplotypes??[]),r=g(e),c=g(""),[b,S]=d(!1),C=P(t,()=>{r.current=t.cutHaplotypes??[],n(r.current)});return p(H,{multiple:!0,freeSolo:!0,disableCloseOnSelect:!0,options:o,value:e,open:b,onOpen:()=>{S(!0)},onInputChange:(u,l)=>{c.current=l},onClose:(u,l)=>{S(!1);let m=c.current.trim();l==="blur"&&m&&!r.current.includes(m)&&(r.current=[...r.current,m],n(r.current)),C(r.current)},onChange:(u,l)=>{r.current=l,n(l),b||C(l)},renderInput:u=>p(y,{...u,label:"Haplotypes",placeholder:e.length===0?"every haplotype":void 0,slotProps:{...u.slotProps,htmlInput:{...u.slotProps.htmlInput,"data-testid":"graph-haplotypes-field"}}})})}),O=s(function({model:t}){let{classes:o}=I(),e=t.haplotypeNames,n=t.sourceAdapter;return n&&x(n)?i("div",{className:o.section,children:[e?p(B,{model:t,names:e}):p(D,{model:t}),i(h,{variant:"caption",component:"div",color:"text.secondary",children:[e?`Which of the graph's ${e.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}),T=O;var ot=s(function({model:t,onClose:o}){return i(L,{model:t,onClose:o,children:[p(M,{model:t}),p(T,{model:t})]})});export{ot as default};
4
- //# sourceMappingURL=GraphTrackSettingsDialog-BRTDTVOJ.js.map
4
+ //# sourceMappingURL=GraphTrackSettingsDialog-GHTWJVWE.js.map
@@ -1,2 +1,2 @@
1
- import{a,b as i}from"./chunk-MWQGJP3J.js";import"./chunk-RS274NAD.js";import"./chunk-HKGTCZOL.js";import"./chunk-NSQ4VXKR.js";import"./chunk-5HDIVUAZ.js";import"./chunk-EH5OCKSE.js";import"./chunk-FM4T47WH.js";import"./chunk-ZWHXVFZF.js";import"./chunk-CHLLRNBQ.js";import"./chunk-LKD5NRWR.js";import"./chunk-DEWVJ57F.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import"./chunk-YBLNN5FU.js";import"./chunk-QUDJ7AM3.js";import"./chunk-KBOVZ3GI.js";import"./chunk-TMM73K4C.js";import"./chunk-6VNDP3UB.js";import"./chunk-FLKXKTS2.js";import"./chunk-TC265JAP.js";import"./chunk-J2PN6CG3.js";import"./chunk-WE7DQVXF.js";import{b as o,d as t}from"./chunk-DUU6T2I5.js";var e=JBrowseExports["@jbrowse/display-kit/DisplayChrome"];var s=e&&e.__esModule?e.default:e;var p=t(function({model:r}){return o(s,{model:r,factory:a,testid:"linear-graph-display","data-layout":r.chosenLayoutMode,"data-cut-tier":r.cutTier,"data-recuts":r.recuts,"data-node-count":r.hasGraph?r.nodeCount:void 0,"data-loading":r.isLoading?"":void 0,style:{width:r.paneWidth,height:r.height,overflow:"hidden"},children:n=>o(i,{model:r,handle:n})})}),c=p;export{c as default};
2
- //# sourceMappingURL=LinearGraphDisplay-2AZ7X7TK.js.map
1
+ import{a,b as i}from"./chunk-RU3HHR5K.js";import"./chunk-MURQDZ33.js";import"./chunk-TFJLUI7X.js";import"./chunk-MTMW4HY6.js";import"./chunk-RJZG46KB.js";import"./chunk-ZNDMFZLV.js";import"./chunk-FM4T47WH.js";import"./chunk-ZWHXVFZF.js";import"./chunk-CHLLRNBQ.js";import"./chunk-LKD5NRWR.js";import"./chunk-DEWVJ57F.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import"./chunk-YBLNN5FU.js";import"./chunk-T7NMFIRW.js";import"./chunk-KBOVZ3GI.js";import"./chunk-TMM73K4C.js";import"./chunk-6VNDP3UB.js";import"./chunk-FLKXKTS2.js";import"./chunk-TC265JAP.js";import"./chunk-J2PN6CG3.js";import"./chunk-WE7DQVXF.js";import{b as o,d as t}from"./chunk-DUU6T2I5.js";var e=JBrowseExports["@jbrowse/display-kit/DisplayChrome"];var s=e&&e.__esModule?e.default:e;var p=t(function({model:r}){return o(s,{model:r,factory:a,testid:"linear-graph-display","data-layout":r.chosenLayoutMode,"data-cut-tier":r.cutTier,"data-recuts":r.recuts,"data-node-count":r.hasGraph?r.nodeCount:void 0,"data-loading":r.isLoading?"":void 0,style:{width:r.paneWidth,height:r.height,overflow:"hidden"},children:n=>o(i,{model:r,handle:n})})}),c=p;export{c as default};
2
+ //# sourceMappingURL=LinearGraphDisplay-CA2GSNK3.js.map
@@ -1,2 +1,2 @@
1
- import{a as f,d as c,f as d}from"./chunk-LKD5NRWR.js";import{a as g}from"./chunk-V55TK2NP.js";import{E as p,F as u,b,z as m}from"./chunk-GLSUAMGV.js";import"./chunk-YBLNN5FU.js";import"./chunk-QUDJ7AM3.js";import"./chunk-KBOVZ3GI.js";import"./chunk-D6TY2QEG.js";import"./chunk-FLKXKTS2.js";import{a as i,o as l}from"./chunk-TC265JAP.js";var a=class extends b{constructor(){super(...arguments);this.bubbles=p(this,["bubblesLocation"],["index"]);this.refNames=new u(this.bubbles,this)}static{this.capabilities=["getFeatures","getRefNames"]}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async getRegionByteSize(t,s={}){return this.refNames.regionBytes(t,s)}async hasDataForRefName(){return!0}getFeatures(t,s={}){let{signal:n,statusCallback:h}=s;return g(async r=>{let o=await this.refNames.resolveMapped(t,s);o!==void 0&&await l("Downloading bubbles",h,()=>m(this.bubbles,o,t.start,t.end,{signal:n,lineCallback:(N,y)=>{let e=f(N);r.next(new i({uniqueId:`bubble-${y}`,refName:t.refName,start:e.start,end:e.end,name:c(e),description:d(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),r.complete()},n)}};export{a as default};
2
- //# sourceMappingURL=MinigraphBubbleAdapter-NR3MMUUG.js.map
1
+ import{a as f,d as c,f as d}from"./chunk-LKD5NRWR.js";import{a as g}from"./chunk-V55TK2NP.js";import{E as p,F as u,b,z as m}from"./chunk-3WUOWIYO.js";import"./chunk-YBLNN5FU.js";import"./chunk-T7NMFIRW.js";import"./chunk-KBOVZ3GI.js";import"./chunk-D6TY2QEG.js";import"./chunk-FLKXKTS2.js";import{a as i,o as l}from"./chunk-TC265JAP.js";var a=class extends b{constructor(){super(...arguments);this.bubbles=p(this,["bubblesLocation"],["index"]);this.refNames=new u(this.bubbles,this)}static{this.capabilities=["getFeatures","getRefNames"]}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async getRegionByteSize(t,s={}){return this.refNames.regionBytes(t,s)}async hasDataForRefName(){return!0}getFeatures(t,s={}){let{signal:n,statusCallback:h}=s;return g(async r=>{let o=await this.refNames.resolveMapped(t,s);o!==void 0&&await l("Downloading bubbles",h,()=>m(this.bubbles,o,t.start,t.end,{signal:n,lineCallback:(N,y)=>{let e=f(N);r.next(new i({uniqueId:`bubble-${y}`,refName:t.refName,start:e.start,end:e.end,name:c(e),description:d(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),r.complete()},n)}};export{a as default};
2
+ //# sourceMappingURL=MinigraphBubbleAdapter-YOIBRCD3.js.map
@@ -1,2 +1,2 @@
1
- import{a as F}from"./chunk-ZBFIEBO6.js";import"./chunk-APSXG7SV.js";import{a as N}from"./chunk-V55TK2NP.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import{E as p,F as d,b as h,u,v as w,w as k,x,y as b,z as g}from"./chunk-GLSUAMGV.js";import"./chunk-YBLNN5FU.js";import"./chunk-QUDJ7AM3.js";import"./chunk-KBOVZ3GI.js";import{e as f}from"./chunk-6VNDP3UB.js";import"./chunk-D6TY2QEG.js";import"./chunk-FLKXKTS2.js";import{a as l,o as m}from"./chunk-TC265JAP.js";var c=class extends h{constructor(){super(...arguments);this.fine=this.openIndex([])}static{this.capabilities=["getFeatures","getRefNames"]}openIndex(e){let t=this.getConf("walksLocation"),n=e.length===0&&f(t)?new F(p(this,["walksLocation"],["walksIndex"]),this):void 0,r=e.length===0?this.getConf("graphLocation"):this.getConf(["coarse","graphLocation"]);if(f(r)){let s=p(this,[...e,"graphLocation"],[...e,"graphIndex"]);return{graph:s,walks:n,refNames:new d(n?.file??s,this)}}let a=p(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),i=p(this,[...e,"linksLocation"],[...e,"linksIndex"]);return{segments:a,links:i,walks:n,refNames:new d(n?.file??a,this)}}async getHaplotypeNames(e={}){return this.fine.walks?.haplotypeNames(e)}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async getRegionByteSize(e,t={}){let{walks:n,refNames:r}=this.fine;return r.regionBytes(e,t,n&&((a,{start:i,end:s})=>n.reader.queryStart(i,{...t,refName:a,end:s})))}async hasDataForRefName(){return!0}getFeatures(e,t={}){return N(async n=>{let r=await this.fine.refNames.resolveMapped(e,t);if(r!==void 0){let{walks:a}=this.fine,i=s=>{n.next(s)};await(a?this.walkFeatures(a,r,e,t,i):this.segmentFeatures(r,e,t,i))}n.complete()},t.signal)}async walkFeatures(e,t,n,r,a){let i=await m("Downloading walks",r.statusCallback,()=>e.referenceNodes(t,n,r));for(let s of i){let o=String(s.id);a(new l({uniqueId:o,refName:n.refName,start:s.start,end:s.end,name:o,type:"segment",rank:0,stableName:s.refName}))}}async segmentRows(e,t,n,r){let a=this.fine;if("graph"in a){let i=k(await a.graph.getHeaderLines({signal:n.signal}));return g(a.graph,e,t.start,t.end,{signal:n.signal,lineCallback:s=>{let o=x(s,i);o?.kind==="N"&&r(o.segment,i.anchored)}})}return g(a.segments,e,t.start,t.end,{signal:n.signal,lineCallback:i=>{let{segment:s,anchored:o}=u(i);r(s,o)}})}async segmentFeatures(e,t,n,r){await m("Downloading segments",n.statusCallback,()=>this.segmentRows(e,t,n,(a,i)=>{if(i&&a.refName!==e)return;let s=w(a);r(new l({uniqueId:a.id,refName:t.refName,start:a.start,end:a.end,name:a.id,type:"segment",rank:a.rank,stableName:a.refName,...s&&{samples:s,sampleCount:s.length}}))}))}async getSubgraph(e,t={}){let{hops:n,signal:r,tier:a}=t,i=this.index(a),s=await i.refNames.resolveForCut(e,{signal:r});return i.walks?i.walks.subgraph(s,e,t):b(i,{refName:s,start:e.start,end:e.end},{hops:n,signal:r})}};export{c as default};
2
- //# sourceMappingURL=RgfaTabixAdapter-JDQLVQVP.js.map
1
+ import{a as F}from"./chunk-VQVV42DS.js";import"./chunk-APSXG7SV.js";import{a as N}from"./chunk-V55TK2NP.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import{E as p,F as d,b as h,u,v as w,w as k,x,y as b,z as g}from"./chunk-3WUOWIYO.js";import"./chunk-YBLNN5FU.js";import"./chunk-T7NMFIRW.js";import"./chunk-KBOVZ3GI.js";import{e as f}from"./chunk-6VNDP3UB.js";import"./chunk-D6TY2QEG.js";import"./chunk-FLKXKTS2.js";import{a as l,o as m}from"./chunk-TC265JAP.js";var c=class extends h{constructor(){super(...arguments);this.fine=this.openIndex([])}static{this.capabilities=["getFeatures","getRefNames"]}openIndex(e){let t=this.getConf("walksLocation"),n=e.length===0&&f(t)?new F(p(this,["walksLocation"],["walksIndex"]),this):void 0,r=e.length===0?this.getConf("graphLocation"):this.getConf(["coarse","graphLocation"]);if(f(r)){let s=p(this,[...e,"graphLocation"],[...e,"graphIndex"]);return{graph:s,walks:n,refNames:new d(n?.file??s,this)}}let a=p(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),i=p(this,[...e,"linksLocation"],[...e,"linksIndex"]);return{segments:a,links:i,walks:n,refNames:new d(n?.file??a,this)}}async getHaplotypeNames(e={}){return this.fine.walks?.haplotypeNames(e)}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async getRegionByteSize(e,t={}){let{walks:n,refNames:r}=this.fine;return r.regionBytes(e,t,n&&((a,{start:i,end:s})=>n.reader.queryStart(i,{...t,refName:a,end:s})))}async hasDataForRefName(){return!0}getFeatures(e,t={}){return N(async n=>{let r=await this.fine.refNames.resolveMapped(e,t);if(r!==void 0){let{walks:a}=this.fine,i=s=>{n.next(s)};await(a?this.walkFeatures(a,r,e,t,i):this.segmentFeatures(r,e,t,i))}n.complete()},t.signal)}async walkFeatures(e,t,n,r,a){let i=await m("Downloading walks",r.statusCallback,()=>e.referenceNodes(t,n,r));for(let s of i){let o=String(s.id);a(new l({uniqueId:o,refName:n.refName,start:s.start,end:s.end,name:o,type:"segment",rank:0,stableName:s.refName}))}}async segmentRows(e,t,n,r){let a=this.fine;if("graph"in a){let i=k(await a.graph.getHeaderLines({signal:n.signal}));return g(a.graph,e,t.start,t.end,{signal:n.signal,lineCallback:s=>{let o=x(s,i);o?.kind==="N"&&r(o.segment,i.anchored)}})}return g(a.segments,e,t.start,t.end,{signal:n.signal,lineCallback:i=>{let{segment:s,anchored:o}=u(i);r(s,o)}})}async segmentFeatures(e,t,n,r){await m("Downloading segments",n.statusCallback,()=>this.segmentRows(e,t,n,(a,i)=>{if(i&&a.refName!==e)return;let s=w(a);r(new l({uniqueId:a.id,refName:t.refName,start:a.start,end:a.end,name:a.id,type:"segment",rank:a.rank,stableName:a.refName,...s&&{samples:s,sampleCount:s.length}}))}))}async getSubgraph(e,t={}){let{hops:n,signal:r,tier:a}=t,i=this.index(a),s=await i.refNames.resolveForCut(e,{signal:r});return i.walks?i.walks.subgraph(s,e,t):b(i,{refName:s,start:e.start,end:e.end},{hops:n,signal:r})}};export{c as default};
2
+ //# sourceMappingURL=RgfaTabixAdapter-AOOEVRF6.js.map
@@ -1,2 +1,2 @@
1
1
  import{H as i,h as o,m as a}from"./chunk-WE7DQVXF.js";import{c as r,d as e}from"./chunk-DUU6T2I5.js";var u=e(function({model:n,title:s,children:l,handleClose:m}){return r(o,{open:!0,title:s,onClose:()=>{m()},children:[l,n.trackWarnings.flatMap(({name:f,warnings:g},p)=>g.map((t,c)=>r(a,{severity:"warning",style:{marginBottom:8},children:[r(i,{variant:"subtitle2",children:[f,": ",t.message]}),t.effect]},`${p}_${c}`)))]})}),x=u;export{x as default};
2
- //# sourceMappingURL=TrackWarningsDialog-23WL6FPV.js.map
2
+ //# sourceMappingURL=TrackWarningsDialog-V5YSUFRO.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../node_modules/.pnpm/@jbrowse+synteny-core@5.0.0-beta.19_@emotion+react@11.14.0_@types+react@19.3.0_react@19_eb34fd01d29d05a1c3ac8167d41484d7/node_modules/@jbrowse/synteny-core/esm/TrackWarningsDialog.js"],
3
+ "sources": ["../../node_modules/.pnpm/@jbrowse+synteny-core@5.0.0-beta.20_@emotion+react@11.14.0_@types+react@19.3.0_react@19_56a3e322b5b3da42dc5bccc6b71729c9/node_modules/@jbrowse/synteny-core/esm/TrackWarningsDialog.js"],
4
4
  "sourcesContent": ["import { jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { InfoDialog } from '@jbrowse/core/ui';\nimport { Alert, Typography } from '@mui/material';\nimport { observer } from 'mobx-react';\n/**\n * The render-warnings report both comparative views open, over the rows\n * `collectTrackWarnings` builds for them. Reads them off the view rather than\n * taking a copy, so a refetch that raises or clears a warning while the dialog\n * is open shows in it.\n *\n * Grouped by track, with the track name leading each row: a stacked view's\n * levels raise the same swapped-assemblies warning verbatim, and so does every\n * overlaid track that hits it, so an ungrouped list repeated one sentence N\n * times without ever naming the file to go fix.\n *\n * Keyed by position \u2014 the message is not an identity, and neither is the track\n * name once one track raises two warnings.\n */\nconst TrackWarningsDialog = observer(function TrackWarningsDialog({ model, title, children, handleClose, }) {\n return (_jsxs(InfoDialog, { open: true, title: title, onClose: () => {\n handleClose();\n }, children: [children, model.trackWarnings.flatMap(({ name, warnings }, i) => warnings.map((w, j) => (_jsxs(Alert\n // eslint-disable-next-line @eslint-react/no-array-index-key -- see above\n , { severity: \"warning\", style: { marginBottom: 8 }, children: [_jsxs(Typography, { variant: \"subtitle2\", children: [name, \": \", w.message] }), w.effect] }, `${i}_${j}`))))] }));\n});\nexport default TrackWarningsDialog;\n"],
5
5
  "mappings": "qGAkBA,IAAMA,EAAsBC,EAAS,SAA6B,CAAE,MAAAC,EAAO,MAAAC,EAAO,SAAAC,EAAU,YAAAC,CAAa,EAAG,CACxG,OAAQC,EAAMC,EAAY,CAAE,KAAM,GAAM,MAAOJ,EAAO,QAAS,IAAM,CAC7DE,EAAY,CAChB,EAAG,SAAU,CAACD,EAAUF,EAAM,cAAc,QAAQ,CAAC,CAAE,KAAAM,EAAM,SAAAC,CAAS,EAAGC,IAAMD,EAAS,IAAI,CAACE,EAAGC,IAAON,EAAMO,EAEvG,CAAE,SAAU,UAAW,MAAO,CAAE,aAAc,CAAE,EAAG,SAAU,CAACP,EAAMQ,EAAY,CAAE,QAAS,YAAa,SAAU,CAACN,EAAM,KAAMG,EAAE,OAAO,CAAE,CAAC,EAAGA,EAAE,MAAM,CAAE,EAAG,GAAGD,CAAC,IAAIE,CAAC,EAAE,CAAE,CAAC,CAAC,CAAE,CAAC,CAC3L,CAAC,EACMG,EAAQf",
6
6
  "names": ["TrackWarningsDialog", "observer", "model", "title", "children", "handleClose", "jsxs", "InfoDialog", "name", "warnings", "i", "w", "j", "Alert", "Typography", "TrackWarningsDialog_default"]
@@ -0,0 +1,2 @@
1
+ import{a as b,b as x,c as C,d as R,f,g as v,h as N}from"./chunk-LZUH4IUR.js";import{a as $}from"./chunk-V55TK2NP.js";import{E as k,b as l,d as w,e as g,f as h,g as m,k as y,o as B,s as F,t as S}from"./chunk-3WUOWIYO.js";import"./chunk-YBLNN5FU.js";import"./chunk-T7NMFIRW.js";import"./chunk-KBOVZ3GI.js";import"./chunk-D6TY2QEG.js";import"./chunk-FLKXKTS2.js";import{a as d,o as u}from"./chunk-TC265JAP.js";var P=r=>`${(r/1e6).toFixed(1)} MB`,O=r=>`${(r/1e6).toFixed(1)} M`;function T(r,p){if(!(r instanceof w))return r;let t=C(p);if(r instanceof F)return new Error(`The pinned window ${t} is too large to read every walk in full for structural forms: its walks take ${O(r.steps)} steps, over the ${O(r.limit)} step budget, and about ${m(r.fitsBp)} of it fits. Pin a narrower window`);let e=`walkByteBudget, ${P(r.limit)}`;return new Error(`The pinned window ${t} is too large to cut for structural forms: ${r.zoomHelps?`about ${m(r.fitsBp)} of it fits in ${e}. Pin a narrower window or raise walkByteBudget`:`its cut fetches ${P(r.bytes??0)}, over ${e}. Raise walkByteBudget`}`)}var E=8,i=new Map;function L(r,p){let t=i.get(r),e=t??p();if(i.delete(r),i.set(r,e),!t){e.catch(()=>{i.get(r)===e&&i.delete(r)});for(let s of i.keys()){if(i.size<=E)break;i.delete(s)}}return e}var c=class extends l{constructor(){super(...arguments);this.reader=new y(k(this,["walksLocation"],["walksIndex"]))}static{this.capabilities=["getFeatures","getRefNames"]}async referenceSample(t){let{references:e}=await this.reader.header(t);return e[0]??""}async getRefNames(t={}){let e=await this.reader.referenceSequences(t),s=await this.referenceSample(t),a=e.filter(o=>h(o,s)).map(o=>g(o));return a.length>0?[...new Set(a)]:e}pinned(){let t=b(this.getConf("pinned"));if(!t)throw new Error("WalkFormsAdapter needs `pinned`, the window its forms come from: { refName, start, end }");return t}forms(t){if(!this.formsRead){let e=this.pinned(),s=`${JSON.stringify(this.getConf("walksLocation"))} ${e.refName}:${e.start}-${e.end}`,a=this.getConf("walkByteBudget"),o=L(`${s} ${a}`,()=>u("Cutting walks",t.statusCallback,()=>S(this.reader,e,{byteBudget:a,partial:!1}).catch(n=>{throw T(n,e)}))).then(n=>B(n,{window:e,floorBp:x(this.getConf("floorBp")),exclude:this.getConf("exclude")}));o.catch(()=>{this.formsRead===o&&(this.formsRead=void 0)}),this.formsRead=o}return this.formsRead}maxForms(){return this.getConf("maxForms")}async getSourcesAndWarnings(t={}){let e=await this.forms(t),s=R(this.pinned());return{sources:f(e,this.maxForms()),warnings:v(e,this.maxForms()).map(a=>s+a)}}async getSources(t,e={}){return f(await this.forms(e),this.maxForms())}async onPinnedSequence(t,e){let s=await this.referenceSample(e),[a,o]=await Promise.all([this.reader.sequenceFor(s,t,e),this.reader.sequenceFor(s,this.pinned().refName,e)]);return a!==void 0&&a===o}getFeatures(t,e={}){return $(async s=>{let a=await this.forms(e),o=await this.onPinnedSequence(t.refName,e)?N(a,this.maxForms()).filter(n=>n.start<t.end&&n.end>t.start):[];for(let n of o)s.next(new d({uniqueId:`forms-${a.floorBp}-${n.id}`,refName:t.refName,start:n.start,end:n.end,name:n.name,description:n.description,type:n.type,svType:n.svType,consequence:n.consequence,REF:"N",ALT:[n.alt],INFO:{SVTYPE:[n.svType],SVLEN:[n.mark.delta]},mark:n.mark,genotypes:n.genotypes}));s.complete()},e.signal)}};export{c as default};
2
+ //# sourceMappingURL=WalkFormsAdapter-5ALR4RU4.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/WalkFormsAdapter/WalkFormsAdapter.ts"],
4
+ "sourcesContent": ["import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { SimpleFeature, updateStatus } from '@jbrowse/core/util'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\nimport {\n ExpansionTooLargeError,\n RegionTooLargeError,\n WalkReader,\n bpString,\n formsCut,\n panSNContig,\n panSNMatchesPrefix,\n structuralForms,\n} from '@jbrowse/graph-walks'\n\nimport { formSources, formVariants, formWarnings } from './formRows.ts'\nimport { floorOf, pinnedLocus, pinnedOf, warningPrefix } from './pinned.ts'\nimport { openTabixSlot } from '../panSNTabix.ts'\n\nimport type { WalkFormsAdapterConfig } from './configSchema.ts'\nimport type { Pinned } from './pinned.ts'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { Feature } from '@jbrowse/core/util'\nimport type { Region } from '@jbrowse/core/util/types'\nimport type { HaplotypeDepartures, StructuralForms } from '@jbrowse/graph-walks'\n\nconst megabytes = (bytes: number) => `${(bytes / 1_000_000).toFixed(1)} MB`\n\nconst millions = (n: number) => `${(n / 1_000_000).toFixed(1)} M`\n\n// A zoom-in notice would mislead, since the view's zoom does not move the\n// pinned window\nfunction pinnedTooLarge(error: unknown, pinned: Pinned) {\n if (!(error instanceof RegionTooLargeError)) {\n return error\n }\n const window = pinnedLocus(pinned)\n if (error instanceof ExpansionTooLargeError) {\n return new Error(\n `The pinned window ${window} is too large to read every walk in full for structural forms: its walks take ${millions(error.steps)} steps, over the ${millions(error.limit)} step budget, and about ${bpString(error.fitsBp)} of it fits. Pin a narrower window`,\n )\n }\n const budget = `walkByteBudget, ${megabytes(error.limit)}`\n return new Error(\n `The pinned window ${window} is too large to cut for structural forms: ${\n error.zoomHelps\n ? `about ${bpString(error.fitsBp)} of it fits in ${budget}. Pin a narrower window or raise walkByteBudget`\n : `its cut fetches ${megabytes(error.bytes ?? 0)}, over ${budget}. Raise walkByteBudget`\n }`,\n )\n}\n\n// The departures of each pinned window, shared across adapter instances:\n// dataAdapterCache keys an adapter on its whole config, so a new floor or\n// exclude list makes a new adapter, which regroups these without a new cut.\n// A cut at the MHC takes 8 s.\nconst CUTS_KEPT = 8\nconst cuts = new Map<string, Promise<HaplotypeDepartures[]>>()\n\nfunction cachedCut(key: string, cut: () => Promise<HaplotypeDepartures[]>) {\n const kept = cuts.get(key)\n const read = kept ?? cut()\n cuts.delete(key)\n cuts.set(key, read)\n if (!kept) {\n read.catch(() => {\n if (cuts.get(key) === read) {\n cuts.delete(key)\n }\n })\n for (const old of cuts.keys()) {\n if (cuts.size <= CUTS_KEPT) {\n break\n }\n cuts.delete(old)\n }\n }\n return read\n}\n\nexport default class WalkFormsAdapter extends BaseFeatureDataAdapter<WalkFormsAdapterConfig> {\n public static capabilities = ['getFeatures', 'getRefNames']\n\n private readonly reader = new WalkReader(\n openTabixSlot(this, ['walksLocation'], ['walksIndex']),\n )\n\n private formsRead: Promise<StructuralForms> | undefined\n\n private async referenceSample(opts: BaseOptions) {\n const { references } = await this.reader.header(opts)\n return references[0] ?? ''\n }\n\n // The reference sample's contigs, as the assembly names them\n async getRefNames(opts: BaseOptions = {}) {\n const names = await this.reader.referenceSequences(opts)\n const sample = await this.referenceSample(opts)\n const contigs = names\n .filter(n => panSNMatchesPrefix(n, sample))\n .map(n => panSNContig(n))\n return contigs.length > 0 ? [...new Set(contigs)] : names\n }\n\n private pinned() {\n const pinned = pinnedOf(this.getConf('pinned'))\n if (!pinned) {\n throw new Error(\n 'WalkFormsAdapter needs `pinned`, the window its forms come from: { refName, start, end }',\n )\n }\n return pinned\n }\n\n // Read once per adapter, and so once per floor and exclude list. The cut\n // takes no caller's signal, since every later caller shares it. A partial\n // expansion would leave some walks as net changes over a whole chunk, so a\n // window too large to read them all errors instead.\n private forms(opts: BaseOptions) {\n if (!this.formsRead) {\n const pinned = this.pinned()\n const key = `${JSON.stringify(this.getConf('walksLocation'))}\\t${pinned.refName}:${pinned.start}-${pinned.end}`\n const byteBudget = this.getConf('walkByteBudget')\n const read = cachedCut(`${key}\\t${byteBudget}`, () =>\n updateStatus('Cutting walks', opts.statusCallback, () =>\n formsCut(this.reader, pinned, { byteBudget, partial: false }).catch(\n (error: unknown) => {\n throw pinnedTooLarge(error, pinned)\n },\n ),\n ),\n ).then(departures =>\n structuralForms(departures, {\n window: pinned,\n floorBp: floorOf(this.getConf('floorBp')),\n exclude: this.getConf('exclude'),\n }),\n )\n read.catch(() => {\n if (this.formsRead === read) {\n this.formsRead = undefined\n }\n })\n this.formsRead = read\n }\n return this.formsRead\n }\n\n private maxForms() {\n return this.getConf('maxForms')\n }\n\n /**\n * One source per form up to maxForms, which core's multi-sample variant\n * display draws as a row, and warnings naming the haplotypes left\n * abridged, unplaced or in the \"other forms\" row\n */\n async getSourcesAndWarnings(opts: BaseOptions = {}) {\n const result = await this.forms(opts)\n const prefix = warningPrefix(this.pinned())\n return {\n sources: formSources(result, this.maxForms()),\n warnings: formWarnings(result, this.maxForms()).map(w => prefix + w),\n }\n }\n\n async getSources(_regions: Region[], opts: BaseOptions = {}) {\n return formSources(await this.forms(opts), this.maxForms())\n }\n\n private async onPinnedSequence(refName: string, opts: BaseOptions) {\n const sample = await this.referenceSample(opts)\n const [query, pinned] = await Promise.all([\n this.reader.sequenceFor(sample, refName, opts),\n this.reader.sequenceFor(sample, this.pinned().refName, opts),\n ])\n return query !== undefined && query === pinned\n }\n\n getFeatures(query: Region, opts: BaseOptions = {}) {\n return ObservableCreate<Feature>(async observer => {\n const result = await this.forms(opts)\n const variants = (await this.onPinnedSequence(query.refName, opts))\n ? formVariants(result, this.maxForms()).filter(\n v => v.start < query.end && v.end > query.start,\n )\n : []\n for (const v of variants) {\n observer.next(\n new SimpleFeature({\n uniqueId: `forms-${result.floorBp}-${v.id}`,\n refName: query.refName,\n start: v.start,\n end: v.end,\n name: v.name,\n description: v.description,\n type: v.type,\n svType: v.svType,\n consequence: v.consequence,\n REF: 'N',\n ALT: [v.alt],\n INFO: { SVTYPE: [v.svType], SVLEN: [v.mark.delta] },\n mark: v.mark,\n genotypes: v.genotypes,\n }),\n )\n }\n observer.complete()\n }, opts.signal)\n }\n}\n"],
5
+ "mappings": "uZAyBA,IAAMA,EAAaC,GAAkB,IAAIA,EAAQ,KAAW,QAAQ,CAAC,CAAC,MAEhEC,EAAYC,GAAc,IAAIA,EAAI,KAAW,QAAQ,CAAC,CAAC,KAI7D,SAASC,EAAeC,EAAgBC,EAAgB,CACtD,GAAI,EAAED,aAAiBE,GACrB,OAAOF,EAET,IAAMG,EAASC,EAAYH,CAAM,EACjC,GAAID,aAAiBK,EACnB,OAAO,IAAI,MACT,qBAAqBF,CAAM,iFAAiFN,EAASG,EAAM,KAAK,CAAC,oBAAoBH,EAASG,EAAM,KAAK,CAAC,2BAA2BM,EAASN,EAAM,MAAM,CAAC,oCAC7N,EAEF,IAAMO,EAAS,mBAAmBZ,EAAUK,EAAM,KAAK,CAAC,GACxD,OAAO,IAAI,MACT,qBAAqBG,CAAM,8CACzBH,EAAM,UACF,SAASM,EAASN,EAAM,MAAM,CAAC,kBAAkBO,CAAM,kDACvD,mBAAmBZ,EAAUK,EAAM,OAAS,CAAC,CAAC,UAAUO,CAAM,wBACpE,EACF,CACF,CAMA,IAAMC,EAAY,EACZC,EAAO,IAAI,IAEjB,SAASC,EAAUC,EAAaC,EAA2C,CACzE,IAAMC,EAAOJ,EAAK,IAAIE,CAAG,EACnBG,EAAOD,GAAQD,EAAI,EAGzB,GAFAH,EAAK,OAAOE,CAAG,EACfF,EAAK,IAAIE,EAAKG,CAAI,EACd,CAACD,EAAM,CACTC,EAAK,MAAM,IAAM,CACXL,EAAK,IAAIE,CAAG,IAAMG,GACpBL,EAAK,OAAOE,CAAG,CAEnB,CAAC,EACD,QAAWI,KAAON,EAAK,KAAK,EAAG,CAC7B,GAAIA,EAAK,MAAQD,EACf,MAEFC,EAAK,OAAOM,CAAG,CACjB,CACF,CACA,OAAOD,CACT,CAEA,IAAqBE,EAArB,cAA8CC,CAA+C,CAA7F,kCAGE,KAAiB,OAAS,IAAIC,EAC5BC,EAAc,KAAM,CAAC,eAAe,EAAG,CAAC,YAAY,CAAC,CACvD,EAJA,YAAc,aAAe,CAAC,cAAe,aAAa,EAQ1D,MAAc,gBAAgBC,EAAmB,CAC/C,GAAM,CAAE,WAAAC,CAAW,EAAI,MAAM,KAAK,OAAO,OAAOD,CAAI,EACpD,OAAOC,EAAW,CAAC,GAAK,EAC1B,CAGA,MAAM,YAAYD,EAAoB,CAAC,EAAG,CACxC,IAAME,EAAQ,MAAM,KAAK,OAAO,mBAAmBF,CAAI,EACjDG,EAAS,MAAM,KAAK,gBAAgBH,CAAI,EACxCI,EAAUF,EACb,OAAOxB,GAAK2B,EAAmB3B,EAAGyB,CAAM,CAAC,EACzC,IAAIzB,GAAK4B,EAAY5B,CAAC,CAAC,EAC1B,OAAO0B,EAAQ,OAAS,EAAI,CAAC,GAAG,IAAI,IAAIA,CAAO,CAAC,EAAIF,CACtD,CAEQ,QAAS,CACf,IAAMrB,EAAS0B,EAAS,KAAK,QAAQ,QAAQ,CAAC,EAC9C,GAAI,CAAC1B,EACH,MAAM,IAAI,MACR,0FACF,EAEF,OAAOA,CACT,CAMQ,MAAMmB,EAAmB,CAC/B,GAAI,CAAC,KAAK,UAAW,CACnB,IAAMnB,EAAS,KAAK,OAAO,EACrBU,EAAM,GAAG,KAAK,UAAU,KAAK,QAAQ,eAAe,CAAC,CAAC,IAAKV,EAAO,OAAO,IAAIA,EAAO,KAAK,IAAIA,EAAO,GAAG,GACvG2B,EAAa,KAAK,QAAQ,gBAAgB,EAC1Cd,EAAOJ,EAAU,GAAGC,CAAG,IAAKiB,CAAU,GAAI,IAC9CC,EAAa,gBAAiBT,EAAK,eAAgB,IACjDU,EAAS,KAAK,OAAQ7B,EAAQ,CAAE,WAAA2B,EAAY,QAAS,EAAM,CAAC,EAAE,MAC3D5B,GAAmB,CAClB,MAAMD,EAAeC,EAAOC,CAAM,CACpC,CACF,CACF,CACF,EAAE,KAAK8B,GACLC,EAAgBD,EAAY,CAC1B,OAAQ9B,EACR,QAASgC,EAAQ,KAAK,QAAQ,SAAS,CAAC,EACxC,QAAS,KAAK,QAAQ,SAAS,CACjC,CAAC,CACH,EACAnB,EAAK,MAAM,IAAM,CACX,KAAK,YAAcA,IACrB,KAAK,UAAY,OAErB,CAAC,EACD,KAAK,UAAYA,CACnB,CACA,OAAO,KAAK,SACd,CAEQ,UAAW,CACjB,OAAO,KAAK,QAAQ,UAAU,CAChC,CAOA,MAAM,sBAAsBM,EAAoB,CAAC,EAAG,CAClD,IAAMc,EAAS,MAAM,KAAK,MAAMd,CAAI,EAC9Be,EAASC,EAAc,KAAK,OAAO,CAAC,EAC1C,MAAO,CACL,QAASC,EAAYH,EAAQ,KAAK,SAAS,CAAC,EAC5C,SAAUI,EAAaJ,EAAQ,KAAK,SAAS,CAAC,EAAE,IAAIK,GAAKJ,EAASI,CAAC,CACrE,CACF,CAEA,MAAM,WAAWC,EAAoBpB,EAAoB,CAAC,EAAG,CAC3D,OAAOiB,EAAY,MAAM,KAAK,MAAMjB,CAAI,EAAG,KAAK,SAAS,CAAC,CAC5D,CAEA,MAAc,iBAAiBqB,EAAiBrB,EAAmB,CACjE,IAAMG,EAAS,MAAM,KAAK,gBAAgBH,CAAI,EACxC,CAACsB,EAAOzC,CAAM,EAAI,MAAM,QAAQ,IAAI,CACxC,KAAK,OAAO,YAAYsB,EAAQkB,EAASrB,CAAI,EAC7C,KAAK,OAAO,YAAYG,EAAQ,KAAK,OAAO,EAAE,QAASH,CAAI,CAC7D,CAAC,EACD,OAAOsB,IAAU,QAAaA,IAAUzC,CAC1C,CAEA,YAAYyC,EAAetB,EAAoB,CAAC,EAAG,CACjD,OAAOuB,EAA0B,MAAMC,GAAY,CACjD,IAAMV,EAAS,MAAM,KAAK,MAAMd,CAAI,EAC9ByB,EAAY,MAAM,KAAK,iBAAiBH,EAAM,QAAStB,CAAI,EAC7D0B,EAAaZ,EAAQ,KAAK,SAAS,CAAC,EAAE,OACpCa,GAAKA,EAAE,MAAQL,EAAM,KAAOK,EAAE,IAAML,EAAM,KAC5C,EACA,CAAC,EACL,QAAWK,KAAKF,EACdD,EAAS,KACP,IAAII,EAAc,CAChB,SAAU,SAASd,EAAO,OAAO,IAAIa,EAAE,EAAE,GACzC,QAASL,EAAM,QACf,MAAOK,EAAE,MACT,IAAKA,EAAE,IACP,KAAMA,EAAE,KACR,YAAaA,EAAE,YACf,KAAMA,EAAE,KACR,OAAQA,EAAE,OACV,YAAaA,EAAE,YACf,IAAK,IACL,IAAK,CAACA,EAAE,GAAG,EACX,KAAM,CAAE,OAAQ,CAACA,EAAE,MAAM,EAAG,MAAO,CAACA,EAAE,KAAK,KAAK,CAAE,EAClD,KAAMA,EAAE,KACR,UAAWA,EAAE,SACf,CAAC,CACH,EAEFH,EAAS,SAAS,CACpB,EAAGxB,EAAK,MAAM,CAChB,CACF",
6
+ "names": ["megabytes", "bytes", "millions", "n", "pinnedTooLarge", "error", "pinned", "RegionTooLargeError", "window", "pinnedLocus", "ExpansionTooLargeError", "bpString", "budget", "CUTS_KEPT", "cuts", "cachedCut", "key", "cut", "kept", "read", "old", "WalkFormsAdapter", "BaseFeatureDataAdapter", "WalkReader", "openTabixSlot", "opts", "references", "names", "sample", "contigs", "panSNMatchesPrefix", "panSNContig", "pinnedOf", "byteBudget", "updateStatus", "formsCut", "departures", "structuralForms", "floorOf", "result", "prefix", "warningPrefix", "formSources", "formWarnings", "w", "_regions", "refName", "query", "ObservableCreate", "observer", "variants", "formVariants", "v", "SimpleFeature"]
7
+ }
@@ -1,2 +1,2 @@
1
- import{a as ee}from"./chunk-ZBFIEBO6.js";import{a as V,b as Z,d as q,e as J,f as B,g as Q,h as Y}from"./chunk-LFQFVYNY.js";import"./chunk-APSXG7SV.js";import{a as K}from"./chunk-V55TK2NP.js";import{p as L,q as H,r as U}from"./chunk-M2D7NUOY.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import{E as z,F as G,i as X}from"./chunk-GLSUAMGV.js";import"./chunk-YBLNN5FU.js";import"./chunk-QUDJ7AM3.js";import{a as E,c as T,d as F,g as x,h as A,i as O}from"./chunk-KBOVZ3GI.js";import"./chunk-AGUEPVOR.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-FLKXKTS2.js";import{o as M}from"./chunk-TC265JAP.js";var ce=50;function fe(r){let o=[];for(let e=0;e<r.length;e++){let[t,a]=r[e],[s,n]=r[e+1]??[];a===n&&a<=ce&&(t==="I"&&s==="D"||t==="D"&&s==="I")?(o.push(["X",a]),e++):o.push([t,a])}return o}function R(r){return Array.from(r.ids,(o,e)=>2*o+r.rev[e])}function P(r,o){let e=r.get(o);return e===void 0?0:e.end-e.start}function te(r){let o=new Map,e=s=>{let n=P(r,s),i=o.get(n);return i===void 0&&(i="N".repeat(n),o.set(n,i)),i},t=new Map,a=s=>{let n=t.get(s);return n===void 0&&(n=R(s),t.set(s,n)),n};return(s,n)=>H({query:a(s),target:a(n),sequenceOf:e,bases:!1})}var _=100;function I(r,o,e){let t=r.at(-1);e>0&&(t?.[0]===o?t[1]+=e:r.push([o,e]))}function ae(r){let o=t=>P(r,t>>1),e=t=>{let a=new Float64Array(t.length+1);return t.forEach((s,n)=>{a[n+1]=a[n]+o(s)}),a};return(t,a)=>{let s=R(a),n=R(t),[i,c]=L(n,s,o),[g,d]=L(n.map(y=>y^1).reverse(),s,o),l=d>c,f=l?g:i,b=Math.max(c,d);if(b<_)return[];let p=e(s),h=e(n),u=y=>l?n.length-1-f[y][0]:f[y][0],k=[];f.forEach(([,y],w)=>{if(w>0){let[v,m]=[u(w-1),u(w)].sort((W,C)=>W-C);I(k,"I",h[m]-h[v+1]),I(k,"D",p[y]-p[f[w-1][1]+1])}I(k,"=",o(s[y]))});let[N,S]=[u(0),u(f.length-1)].sort((y,w)=>y-w);return[{queryStart:h[N],queryEnd:h[S+1],targetStart:p[f[0][1]],targetEnd:p[f.at(-1)[1]+1],strand:l?"-":"+",edits:k,sharedBases:b}]}}function pe(r){let o=new Map,e=new Set;r.ids.forEach((t,a)=>{o.has(t)?e.add(t):o.set(t,r.rev[a])});for(let t of e)o.delete(t);return o}function ne(r){let o=new Map,e=t=>{let a=o.get(t);return a===void 0&&(a=pe(t),o.set(t,a)),a};return(t,a)=>{let s=e(a),n=0,i=0;for(let[c,g]of e(t)){let d=s.get(c);d===g?n+=P(r,c):d!==void 0&&(i+=P(r,c))}return{same:n,opposite:i}}}function se(r){let o=ae(r),e=te(r),t=ne(r);return(a,s)=>{let{same:n,opposite:i}=t(a,s);return n>=_&&i>=_?e(a,s):o(a,s)}}var ue=1e4;function re(r){let o=ae(r),e=te(r),t=ne(r);return(a,s)=>{let n=o(a,s),i=n[0]?.strand,{same:c,opposite:g}=t(a,s);return i===void 0||Math.min(c,g)<ue?n:[...n,...e(a,s).filter(d=>d.strand!==i)]}}function $({chain:r,target:o,query:e,assemblyName:t,refName:a,mateAssemblyName:s}){let n=fe(r.edits);return Y({target:{name:o.name,assemblyName:t,refName:a,start:o.hapStart+r.targetStart,end:o.hapStart+r.targetEnd},query:{name:e.name,assemblyName:s,refName:F(e.name),start:e.hapStart+r.queryStart,end:e.hapStart+r.queryEnd},strand:r.strand,cigar:U(n),matches:n.reduce((i,[c,g])=>i+(c==="="?g:0),0),columns:n.reduce((i,[,c])=>i+c,0)})}function ie(r,o,e,t,a){let s=a==="leave",n=i=>i.kind==="elsewhere"&&(s?i.chunk.start>=r.refStart:i.chunk.start<r.refStart);for(let i of e){let{name:c,fragStart:g,hapStart:d,ids:l,rev:f,before:b,after:p}=i;if(c===r.name&&g===r.fragStart){let h=d;for(let u=0;u<l.length;u++){let k=t.get(l[u]),N=k===void 0?0:k.end-k.start;if(k?.rank===0&&k.refName===o&&(s?k.end===r.refStart:k.start===r.refEnd)){let S=n(p)!==n(b)?n(p):u>0!=u<l.length-1?u>0:s!==(f[u]===1);return{skip:r,at:S?h+N:h,strand:S===s?"+":"-"}}h+=N}}}}function oe({crossing:r,refName:o,assemblyName:e,mateAssemblyName:t}){let{skip:a,at:s,strand:n}=r;return le({id:`${a.name}:${a.fragStart}:${a.piece}:skip`,assemblyName:e,refName:o,start:a.refStart,end:a.refEnd,reverse:n==="-",mate:{refName:F(a.name),start:s,end:s,assemblyName:t}})}function me({fragment:r,crossing:o,refName:e,assemblyName:t,mateAssemblyName:a}){let{name:s,fragStart:n,hapStart:i,hapEnd:c}=r;return le({id:`${s}:${n}:${i}:crossing`,assemblyName:t,refName:e,start:o.refStart,end:o.refEnd,reverse:o.reverse,mate:{refName:F(s),start:i,end:c,assemblyName:a}})}function le({id:r,assemblyName:o,refName:e,start:t,end:a,reverse:s,mate:n}){return new V({uniqueId:r,assemblyName:o,refName:e,start:t,end:a,type:"skip",strand:s?-1:1,syntenyId:r,spansWindow:!0,mate:n})}var j=({name:r})=>T(r)??r,D=class extends Z{constructor(){super(...arguments);this.walks=new ee(z(this,["walksLocation"],["walksIndex"]),this);this.refNames=new G(this.walks.file,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){return this.walks.haplotypeNames(e)}async getHeader(e={}){let{haplotypes:t}=await this.walks.reader.header(e),{anchor:a}=this,s=A(this,a),n=O(this);return{hasCoarseTier:!1,anchorAssemblyName:a,lanes:t.filter(i=>i!==s&&E(i)!==s).map(i=>({name:B(n,i),label:i,group:E(i)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}async getSubgraph(e,t={}){let a=await this.refNames.resolveForCut(e,{signal:t.signal});return this.walks.subgraph(a,e,t)}async laneWalks(e,t,a,s,n){let i=X(a,e);return M(n,s.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.budgets(),signal:s.signal,keep:i,expand:i,links:!1}).catch(c=>{throw Q(c,t.end-t.start)}))}async skipCrossings(e,t,a){let s=[],n=t;for(let i of["leave","rejoin"]){let c=await this.sideCrossings(e,n,i,a);for(let d of c)s.push(d);let g=new Set(c.map(d=>d.skip));n=n.filter(d=>!g.has(d))}return s}async sideCrossings(e,t,a,s){let{signal:n}=s,{chunk:i}=await this.walks.reader.header({signal:n}),c=l=>a==="leave"?l.refStart-1:l.refEnd,g=new Map;for(let l of t){let f=c(l),b=Math.floor(f/i),p=g.get(b);p?(p.group.push(l),p.start=Math.min(p.start,f),p.end=Math.max(p.end,f+1)):g.set(b,{group:[l],start:f,end:f+1})}return(await Promise.all([...g.values()].map(async({group:l,start:f,end:b})=>{let p=new Set(l.map(u=>u.name)),h=u=>p.has(u);try{let{graph:u,fragments:k}=await this.walks.reader.cut(e,{start:f,end:b},{...this.walks.budgets(),signal:n,keep:h,expand:h,context:0,contained:!0,links:!1});return l.map(N=>ie(N,e,k,u.nodes,a))}catch(u){if(n?.aborted)throw u;return[]}}))).flat().filter(l=>l!==void 0)}async anchorFeatures(e,t,a){let s=a.haplotypes?.length?a.haplotypes.map(m=>A(this,m)):void 0,n=A(this,a.targetAssemblyName),i=n===void 0?s:s===void 0||s.some(m=>x(n,m)||x(m,n))?[n]:[];if(i?.length===0)return[];let{start:c,end:g}=t,d=`Reading walks ${t.refName}:${c.toLocaleString()}-${g.toLocaleString()}`,{graph:l,fragments:f,skips:b}=await this.laneWalks(e,t,i,a,d),p=({name:m})=>i===void 0?0:i.findIndex(W=>x(m,W)),h=new Set(f.map(j)),u=await M(d,a.statusCallback,()=>this.skipCrossings(e,b.filter(m=>p(m)>=0&&!h.has(j(m))&&m.refStart<=c&&m.refEnd>=g),a)),k=re(l.nodes),N=O(this),S=m=>B(N,j(m)),y=f.filter(m=>m.name===e),w=f.filter(m=>m.name!==e&&p(m)>=0).map(m=>({rank:p(m),features:m.crossing?[me({fragment:m,crossing:m.crossing,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:S(m)})]:y.flatMap(W=>k(m,W).map(C=>$({chain:C,target:W,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:S(m)})))})),v=u.map(m=>({rank:p(m.skip),features:[oe({crossing:m,refName:t.refName,assemblyName:t.assemblyName,mateAssemblyName:S(m.skip)})]}));return[...w,...v].sort((m,W)=>m.rank-W.rank).flatMap(m=>m.features)}async pairFeatures(e,t,a,s){let n=a.map(l=>({pair:l,featurePrefix:A(this,l.queryAssemblyName),matePrefix:A(this,l.targetAssemblyName)})),{graph:i,fragments:c}=await this.laneWalks(e,t,n.flatMap(l=>[l.featurePrefix,l.matePrefix]),s,J(a)),g=se(i.nodes),d=l=>c.filter(f=>x(f.name,l));return n.flatMap(({pair:l,featurePrefix:f,matePrefix:b})=>d(f).flatMap(p=>d(b).flatMap(h=>g(h,p).map(u=>$({chain:u,target:p,query:h,assemblyName:l.queryAssemblyName,refName:F(p.name),mateAssemblyName:l.targetAssemblyName})))))}getFeatures(e,t={}){return K(async a=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let n=q(t),i=n.length>0?await this.pairFeatures(s,e,n,t):await this.anchorFeatures(s,e,t);for(let c of i)a.next(c)}a.complete()},t.signal)}};export{D as default};
2
- //# sourceMappingURL=WalkTabixSyntenyAdapter-PBWN53PE.js.map
1
+ import{a as ee}from"./chunk-VQVV42DS.js";import{a as V,b as Z,d as q,e as J,f as B,g as Q,h as Y}from"./chunk-BHRMUIK6.js";import"./chunk-APSXG7SV.js";import{a as K}from"./chunk-V55TK2NP.js";import{p as L,q as H,r as U}from"./chunk-M2D7NUOY.js";import"./chunk-YBLNN5FU.js";import"./chunk-A27SW7X7.js";import"./chunk-SKB4GSET.js";import{E as z,F as G,i as X}from"./chunk-3WUOWIYO.js";import"./chunk-YBLNN5FU.js";import"./chunk-T7NMFIRW.js";import{a as E,c as T,d as F,g as x,h as A,i as O}from"./chunk-KBOVZ3GI.js";import"./chunk-FQI75MV6.js";import"./chunk-TMM73K4C.js";import"./chunk-D6TY2QEG.js";import"./chunk-FLKXKTS2.js";import{o as M}from"./chunk-TC265JAP.js";var ce=50;function fe(r){let o=[];for(let e=0;e<r.length;e++){let[t,a]=r[e],[s,n]=r[e+1]??[];a===n&&a<=ce&&(t==="I"&&s==="D"||t==="D"&&s==="I")?(o.push(["X",a]),e++):o.push([t,a])}return o}function R(r){return Array.from(r.ids,(o,e)=>2*o+r.rev[e])}function P(r,o){let e=r.get(o);return e===void 0?0:e.end-e.start}function te(r){let o=new Map,e=s=>{let n=P(r,s),i=o.get(n);return i===void 0&&(i="N".repeat(n),o.set(n,i)),i},t=new Map,a=s=>{let n=t.get(s);return n===void 0&&(n=R(s),t.set(s,n)),n};return(s,n)=>H({query:a(s),target:a(n),sequenceOf:e,bases:!1})}var _=100;function I(r,o,e){let t=r.at(-1);e>0&&(t?.[0]===o?t[1]+=e:r.push([o,e]))}function ae(r){let o=t=>P(r,t>>1),e=t=>{let a=new Float64Array(t.length+1);return t.forEach((s,n)=>{a[n+1]=a[n]+o(s)}),a};return(t,a)=>{let s=R(a),n=R(t),[i,c]=L(n,s,o),[g,d]=L(n.map(y=>y^1).reverse(),s,o),l=d>c,f=l?g:i,b=Math.max(c,d);if(b<_)return[];let p=e(s),h=e(n),u=y=>l?n.length-1-f[y][0]:f[y][0],k=[];f.forEach(([,y],w)=>{if(w>0){let[v,m]=[u(w-1),u(w)].sort((W,C)=>W-C);I(k,"I",h[m]-h[v+1]),I(k,"D",p[y]-p[f[w-1][1]+1])}I(k,"=",o(s[y]))});let[N,S]=[u(0),u(f.length-1)].sort((y,w)=>y-w);return[{queryStart:h[N],queryEnd:h[S+1],targetStart:p[f[0][1]],targetEnd:p[f.at(-1)[1]+1],strand:l?"-":"+",edits:k,sharedBases:b}]}}function pe(r){let o=new Map,e=new Set;r.ids.forEach((t,a)=>{o.has(t)?e.add(t):o.set(t,r.rev[a])});for(let t of e)o.delete(t);return o}function ne(r){let o=new Map,e=t=>{let a=o.get(t);return a===void 0&&(a=pe(t),o.set(t,a)),a};return(t,a)=>{let s=e(a),n=0,i=0;for(let[c,g]of e(t)){let d=s.get(c);d===g?n+=P(r,c):d!==void 0&&(i+=P(r,c))}return{same:n,opposite:i}}}function se(r){let o=ae(r),e=te(r),t=ne(r);return(a,s)=>{let{same:n,opposite:i}=t(a,s);return n>=_&&i>=_?e(a,s):o(a,s)}}var ue=1e4;function re(r){let o=ae(r),e=te(r),t=ne(r);return(a,s)=>{let n=o(a,s),i=n[0]?.strand,{same:c,opposite:g}=t(a,s);return i===void 0||Math.min(c,g)<ue?n:[...n,...e(a,s).filter(d=>d.strand!==i)]}}function $({chain:r,target:o,query:e,assemblyName:t,refName:a,mateAssemblyName:s}){let n=fe(r.edits);return Y({target:{name:o.name,assemblyName:t,refName:a,start:o.hapStart+r.targetStart,end:o.hapStart+r.targetEnd},query:{name:e.name,assemblyName:s,refName:F(e.name),start:e.hapStart+r.queryStart,end:e.hapStart+r.queryEnd},strand:r.strand,cigar:U(n),matches:n.reduce((i,[c,g])=>i+(c==="="?g:0),0),columns:n.reduce((i,[,c])=>i+c,0)})}function ie(r,o,e,t,a){let s=a==="leave",n=i=>i.kind==="elsewhere"&&(s?i.chunk.start>=r.refStart:i.chunk.start<r.refStart);for(let i of e){let{name:c,fragStart:g,hapStart:d,ids:l,rev:f,before:b,after:p}=i;if(c===r.name&&g===r.fragStart){let h=d;for(let u=0;u<l.length;u++){let k=t.get(l[u]),N=k===void 0?0:k.end-k.start;if(k?.rank===0&&k.refName===o&&(s?k.end===r.refStart:k.start===r.refEnd)){let S=n(p)!==n(b)?n(p):u>0!=u<l.length-1?u>0:s!==(f[u]===1);return{skip:r,at:S?h+N:h,strand:S===s?"+":"-"}}h+=N}}}}function oe({crossing:r,refName:o,assemblyName:e,mateAssemblyName:t}){let{skip:a,at:s,strand:n}=r;return le({id:`${a.name}:${a.fragStart}:${a.piece}:skip`,assemblyName:e,refName:o,start:a.refStart,end:a.refEnd,reverse:n==="-",mate:{refName:F(a.name),start:s,end:s,assemblyName:t}})}function me({fragment:r,crossing:o,refName:e,assemblyName:t,mateAssemblyName:a}){let{name:s,fragStart:n,hapStart:i,hapEnd:c}=r;return le({id:`${s}:${n}:${i}:crossing`,assemblyName:t,refName:e,start:o.refStart,end:o.refEnd,reverse:o.reverse,mate:{refName:F(s),start:i,end:c,assemblyName:a}})}function le({id:r,assemblyName:o,refName:e,start:t,end:a,reverse:s,mate:n}){return new V({uniqueId:r,assemblyName:o,refName:e,start:t,end:a,type:"skip",strand:s?-1:1,syntenyId:r,spansWindow:!0,mate:n})}var j=({name:r})=>T(r)??r,D=class extends Z{constructor(){super(...arguments);this.walks=new ee(z(this,["walksLocation"],["walksIndex"]),this);this.refNames=new G(this.walks.file,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){return this.walks.haplotypeNames(e)}async getHeader(e={}){let{haplotypes:t}=await this.walks.reader.header(e),{anchor:a}=this,s=A(this,a),n=O(this);return{hasCoarseTier:!1,anchorAssemblyName:a,lanes:t.filter(i=>i!==s&&E(i)!==s).map(i=>({name:B(n,i),label:i,group:E(i)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}async getSubgraph(e,t={}){let a=await this.refNames.resolveForCut(e,{signal:t.signal});return this.walks.subgraph(a,e,t)}async laneWalks(e,t,a,s,n){let i=X(a,e);return M(n,s.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.budgets(),signal:s.signal,keep:i,expand:i,links:!1}).catch(c=>{throw Q(c,t.end-t.start)}))}async skipCrossings(e,t,a){let s=[],n=t;for(let i of["leave","rejoin"]){let c=await this.sideCrossings(e,n,i,a);for(let d of c)s.push(d);let g=new Set(c.map(d=>d.skip));n=n.filter(d=>!g.has(d))}return s}async sideCrossings(e,t,a,s){let{signal:n}=s,{chunk:i}=await this.walks.reader.header({signal:n}),c=l=>a==="leave"?l.refStart-1:l.refEnd,g=new Map;for(let l of t){let f=c(l),b=Math.floor(f/i),p=g.get(b);p?(p.group.push(l),p.start=Math.min(p.start,f),p.end=Math.max(p.end,f+1)):g.set(b,{group:[l],start:f,end:f+1})}return(await Promise.all([...g.values()].map(async({group:l,start:f,end:b})=>{let p=new Set(l.map(u=>u.name)),h=u=>p.has(u);try{let{graph:u,fragments:k}=await this.walks.reader.cut(e,{start:f,end:b},{...this.walks.budgets(),signal:n,keep:h,expand:h,context:0,contained:!0,links:!1});return l.map(N=>ie(N,e,k,u.nodes,a))}catch(u){if(n?.aborted)throw u;return[]}}))).flat().filter(l=>l!==void 0)}async anchorFeatures(e,t,a){let s=a.haplotypes?.length?a.haplotypes.map(m=>A(this,m)):void 0,n=A(this,a.targetAssemblyName),i=n===void 0?s:s===void 0||s.some(m=>x(n,m)||x(m,n))?[n]:[];if(i?.length===0)return[];let{start:c,end:g}=t,d=`Reading walks ${t.refName}:${c.toLocaleString()}-${g.toLocaleString()}`,{graph:l,fragments:f,skips:b}=await this.laneWalks(e,t,i,a,d),p=({name:m})=>i===void 0?0:i.findIndex(W=>x(m,W)),h=new Set(f.map(j)),u=await M(d,a.statusCallback,()=>this.skipCrossings(e,b.filter(m=>p(m)>=0&&!h.has(j(m))&&m.refStart<=c&&m.refEnd>=g),a)),k=re(l.nodes),N=O(this),S=m=>B(N,j(m)),y=f.filter(m=>m.name===e),w=f.filter(m=>m.name!==e&&p(m)>=0).map(m=>({rank:p(m),features:m.crossing?[me({fragment:m,crossing:m.crossing,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:S(m)})]:y.flatMap(W=>k(m,W).map(C=>$({chain:C,target:W,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:S(m)})))})),v=u.map(m=>({rank:p(m.skip),features:[oe({crossing:m,refName:t.refName,assemblyName:t.assemblyName,mateAssemblyName:S(m.skip)})]}));return[...w,...v].sort((m,W)=>m.rank-W.rank).flatMap(m=>m.features)}async pairFeatures(e,t,a,s){let n=a.map(l=>({pair:l,featurePrefix:A(this,l.queryAssemblyName),matePrefix:A(this,l.targetAssemblyName)})),{graph:i,fragments:c}=await this.laneWalks(e,t,n.flatMap(l=>[l.featurePrefix,l.matePrefix]),s,J(a)),g=se(i.nodes),d=l=>c.filter(f=>x(f.name,l));return n.flatMap(({pair:l,featurePrefix:f,matePrefix:b})=>d(f).flatMap(p=>d(b).flatMap(h=>g(h,p).map(u=>$({chain:u,target:p,query:h,assemblyName:l.queryAssemblyName,refName:F(p.name),mateAssemblyName:l.targetAssemblyName})))))}getFeatures(e,t={}){return K(async a=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let n=q(t),i=n.length>0?await this.pairFeatures(s,e,n,t):await this.anchorFeatures(s,e,t);for(let c of i)a.next(c)}a.complete()},t.signal)}};export{D as default};
2
+ //# sourceMappingURL=WalkTabixSyntenyAdapter-2SGCZXRI.js.map