jbrowse-plugin-graphgenomeviewer 7.7.0 → 8.0.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.
- package/README.md +1 -1
- package/dist/chunks/{AddTrackWorkflow-NLSZYK56.js → AddTrackWorkflow-KT6Z6PSW.js} +2 -2
- package/dist/chunks/{ChooseSamplesDialog-JRN4YLBY.js → ChooseSamplesDialog-YUH6SVEZ.js} +2 -2
- package/dist/chunks/{ChooseWalksDialog-SM326TOX.js → ChooseWalksDialog-2QJKRASB.js} +2 -2
- package/dist/chunks/{GbzBaseSyntenyAdapter-HT275FAA.js → GbzBaseSyntenyAdapter-TG2ANRT3.js} +2 -2
- package/dist/chunks/{GbzBaseSyntenyAdapter-HT275FAA.js.map → GbzBaseSyntenyAdapter-TG2ANRT3.js.map} +1 -1
- package/dist/chunks/GraphGenomeView-FCHJASPO.js +10 -0
- package/dist/chunks/{GraphGenomeView-NBLEWVY2.js.map → GraphGenomeView-FCHJASPO.js.map} +1 -1
- package/dist/chunks/{GraphTrackSettingsDialog-63UGAGAC.js → GraphTrackSettingsDialog-TY3TNJNT.js} +2 -2
- package/dist/chunks/{GraphTrackSettingsDialog-63UGAGAC.js.map → GraphTrackSettingsDialog-TY3TNJNT.js.map} +1 -1
- package/dist/chunks/{HighlightColorDialog-MY4MWVCJ.js → HighlightColorDialog-5KLRS7JE.js} +2 -2
- package/dist/chunks/LinearGraphDisplay-HJCT6VYM.js +2 -0
- package/dist/chunks/{LinearGraphDisplay-3LMAWRNR.js.map → LinearGraphDisplay-HJCT6VYM.js.map} +2 -2
- package/dist/chunks/{MinigraphBubbleAdapter-YMI75DAV.js → MinigraphBubbleAdapter-CML6E5IP.js} +2 -2
- package/dist/chunks/{RgfaTabixAdapter-AFNTSA6Y.js → RgfaTabixAdapter-AR6A5GCW.js} +2 -2
- package/dist/chunks/{TrackWarningsDialog-CPAYIP6K.js → TrackWarningsDialog-4YDIV2FN.js} +2 -2
- package/dist/chunks/{TrackWarningsDialog-CPAYIP6K.js.map → TrackWarningsDialog-4YDIV2FN.js.map} +1 -1
- package/dist/chunks/{WalkFormsAdapter-ZPE2JQJU.js → WalkFormsAdapter-Q37XRR7X.js} +2 -2
- package/dist/chunks/{WalkTabixSyntenyAdapter-EOD4RQVU.js → WalkTabixSyntenyAdapter-NWB2OALF.js} +2 -2
- package/dist/chunks/{chunk-E7S7PGEZ.js → chunk-3OALERH2.js} +2 -2
- package/dist/chunks/{chunk-E7S7PGEZ.js.map → chunk-3OALERH2.js.map} +1 -1
- package/dist/chunks/chunk-3VGXCEMQ.js +2 -0
- package/dist/chunks/{chunk-7WIBGKBU.js.map → chunk-3VGXCEMQ.js.map} +3 -3
- package/dist/chunks/chunk-3WG3GF2A.js +2 -0
- package/dist/chunks/{chunk-NDRLCGPC.js.map → chunk-3WG3GF2A.js.map} +3 -3
- package/dist/chunks/chunk-46CNCY7Z.js +2 -0
- package/dist/chunks/chunk-46CNCY7Z.js.map +7 -0
- package/dist/chunks/{chunk-KY6GXBXU.js → chunk-4KVQOJHH.js} +2 -2
- package/dist/chunks/{chunk-KY6GXBXU.js.map → chunk-4KVQOJHH.js.map} +1 -1
- package/dist/chunks/{chunk-UGCNPRKC.js → chunk-5Z4VIKXZ.js} +2 -2
- package/dist/chunks/chunk-5Z4VIKXZ.js.map +7 -0
- package/dist/chunks/{chunk-SXQ6222I.js → chunk-6FH5I6SI.js} +2 -2
- package/dist/chunks/{chunk-EV54SYM7.js → chunk-ACN3SGJ3.js} +2 -2
- package/dist/chunks/{chunk-EV54SYM7.js.map → chunk-ACN3SGJ3.js.map} +1 -1
- package/dist/chunks/chunk-AH5UWTAV.js +2 -0
- package/dist/chunks/{chunk-TYV6UXJA.js.map → chunk-AH5UWTAV.js.map} +2 -2
- package/dist/chunks/{chunk-LIRBZOBX.js → chunk-AJX6ZXCI.js} +2 -2
- package/dist/chunks/{chunk-LIRBZOBX.js.map → chunk-AJX6ZXCI.js.map} +1 -1
- package/dist/chunks/{chunk-22A3MS5J.js → chunk-BH2HG6VX.js} +1 -1
- package/dist/chunks/{chunk-22A3MS5J.js.map → chunk-BH2HG6VX.js.map} +1 -1
- package/dist/chunks/{chunk-TENPGIPX.js → chunk-J5RMHLFJ.js} +1 -1
- package/dist/chunks/chunk-J5RMHLFJ.js.map +7 -0
- package/dist/chunks/chunk-JI7T4PVJ.js +4 -0
- package/dist/chunks/chunk-JI7T4PVJ.js.map +7 -0
- package/dist/chunks/{chunk-3Y2G43HK.js → chunk-JN5A42OJ.js} +3 -3
- package/dist/chunks/chunk-JN5A42OJ.js.map +7 -0
- package/dist/chunks/{chunk-ODQSCM3F.js → chunk-KFZWGL76.js} +1 -1
- package/dist/chunks/{chunk-ODQSCM3F.js.map → chunk-KFZWGL76.js.map} +1 -1
- package/dist/chunks/chunk-LFCGAZIW.js +2 -0
- package/dist/chunks/{chunk-4AXLBI6M.js.map → chunk-LFCGAZIW.js.map} +4 -4
- package/dist/chunks/{chunk-IBWORBGY.js → chunk-LR45N54F.js} +2 -2
- package/dist/chunks/{chunk-DFZ6G452.js → chunk-MLQK7CCL.js} +4 -4
- package/dist/chunks/{chunk-DFZ6G452.js.map → chunk-MLQK7CCL.js.map} +3 -3
- package/dist/chunks/{chunk-PT3WV5ED.js → chunk-NEWN556N.js} +2 -2
- package/dist/chunks/{chunk-PT3WV5ED.js.map → chunk-NEWN556N.js.map} +1 -1
- package/dist/chunks/{chunk-T4R3ZVEM.js → chunk-OTBDKJEA.js} +1 -1
- package/dist/chunks/{chunk-T4R3ZVEM.js.map → chunk-OTBDKJEA.js.map} +1 -1
- package/dist/chunks/{chunk-DDAG445J.js → chunk-OYXKO3SL.js} +3 -3
- package/dist/chunks/chunk-OYXKO3SL.js.map +7 -0
- package/dist/chunks/chunk-Q4UIYMYF.js +2 -0
- package/dist/chunks/{chunk-2QRCU675.js → chunk-QTEWKTFE.js} +2 -2
- package/dist/chunks/{chunk-JRJHXLGP.js → chunk-ROZPEXN4.js} +2 -2
- package/dist/chunks/chunk-ROZPEXN4.js.map +7 -0
- package/dist/chunks/{chunk-Q5H6ETNZ.js → chunk-UDHJGXQV.js} +3 -3
- package/dist/chunks/chunk-UDHJGXQV.js.map +7 -0
- package/dist/chunks/{chunk-GK5YETAZ.js → chunk-UQDZNX5E.js} +2 -2
- package/dist/chunks/{chunk-GK5YETAZ.js.map → chunk-UQDZNX5E.js.map} +1 -1
- package/dist/chunks/{chunk-DSSZIADV.js → chunk-VVGUWP7O.js} +1 -1
- package/dist/chunks/{chunk-DSSZIADV.js.map → chunk-VVGUWP7O.js.map} +1 -1
- package/dist/chunks/{chunk-IFIZMFS6.js → chunk-ZEYVMHUW.js} +2 -2
- package/dist/chunks/{chunk-IFIZMFS6.js.map → chunk-ZEYVMHUW.js.map} +1 -1
- package/dist/chunks/executeDiagonalize-MDMQAC5Z.js +2 -0
- package/dist/chunks/executeDiagonalize-MDMQAC5Z.js.map +7 -0
- package/dist/chunks/renderSvg-QPNRFPLM.js +2 -0
- package/dist/chunks/renderSvg-QPNRFPLM.js.map +7 -0
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +5 -5
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
- package/package.json +11 -11
- package/src/GraphAddTrackWorkflow/buildTrackConfig.test.ts +3 -1
- package/src/GraphAddTrackWorkflow/buildTrackConfig.ts +5 -1
- package/src/GraphGenomeView/model.test.ts +5 -5
- package/src/GraphGenomeView/pane/fitViews.ts +5 -5
- package/src/GraphGenomeView/pane/graphViews.ts +12 -12
- package/src/GraphGenomeView/pane/launchActions.ts +7 -1
- package/src/GraphGenomeView/pane/loadActions.ts +2 -2
- package/src/GraphGenomeView/pane/settingActions.ts +1 -1
- package/src/GraphGenomeView/tubeMapPanels.test.ts +1 -1
- package/src/GraphGenomeView/tubeMapPanels.ts +6 -6
- package/src/GraphGenomeView/viewModel.ts +2 -2
- package/src/GraphGenomeView/walkRowGroups.test.ts +8 -4
- package/src/GraphGenomeView/walkRowGroups.ts +8 -6
- package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +1 -1
- package/src/LinearGraphDisplay/components/GraphStatusChrome.tsx +4 -8
- package/src/LinearGraphDisplay/configSchema.ts +1 -1
- package/src/graphTrackConfig.ts +14 -8
- package/src/launchFromGraph/launchFromGraph.ts +11 -11
- package/src/launchFromGraph/syntenyTracks.test.ts +6 -26
- package/src/launchFromGraph/syntenyTracks.ts +20 -17
- package/src/panSNAliases/trackAdapterConfig.ts +4 -7
- package/src/version.ts +1 -1
- package/dist/chunks/GraphGenomeView-NBLEWVY2.js +0 -10
- package/dist/chunks/LinearGraphDisplay-3LMAWRNR.js +0 -2
- package/dist/chunks/chunk-3Y2G43HK.js.map +0 -7
- package/dist/chunks/chunk-4AXLBI6M.js +0 -2
- package/dist/chunks/chunk-7WIBGKBU.js +0 -2
- package/dist/chunks/chunk-AK3UZI6J.js +0 -4
- package/dist/chunks/chunk-AK3UZI6J.js.map +0 -7
- package/dist/chunks/chunk-DDAG445J.js.map +0 -7
- package/dist/chunks/chunk-JRJHXLGP.js.map +0 -7
- package/dist/chunks/chunk-NDRLCGPC.js +0 -2
- package/dist/chunks/chunk-O6HXOTJN.js +0 -2
- package/dist/chunks/chunk-O6HXOTJN.js.map +0 -7
- package/dist/chunks/chunk-Q5H6ETNZ.js.map +0 -7
- package/dist/chunks/chunk-TENPGIPX.js.map +0 -7
- package/dist/chunks/chunk-TUECGSVJ.js +0 -2
- package/dist/chunks/chunk-TYV6UXJA.js +0 -2
- package/dist/chunks/chunk-UGCNPRKC.js.map +0 -7
- package/dist/chunks/executeDiagonalize-SGJDSTYC.js +0 -2
- package/dist/chunks/executeDiagonalize-SGJDSTYC.js.map +0 -7
- package/dist/chunks/renderSvg-WMFKXKFZ.js +0 -2
- package/dist/chunks/renderSvg-WMFKXKFZ.js.map +0 -7
- /package/dist/chunks/{AddTrackWorkflow-NLSZYK56.js.map → AddTrackWorkflow-KT6Z6PSW.js.map} +0 -0
- /package/dist/chunks/{ChooseSamplesDialog-JRN4YLBY.js.map → ChooseSamplesDialog-YUH6SVEZ.js.map} +0 -0
- /package/dist/chunks/{ChooseWalksDialog-SM326TOX.js.map → ChooseWalksDialog-2QJKRASB.js.map} +0 -0
- /package/dist/chunks/{HighlightColorDialog-MY4MWVCJ.js.map → HighlightColorDialog-5KLRS7JE.js.map} +0 -0
- /package/dist/chunks/{MinigraphBubbleAdapter-YMI75DAV.js.map → MinigraphBubbleAdapter-CML6E5IP.js.map} +0 -0
- /package/dist/chunks/{RgfaTabixAdapter-AFNTSA6Y.js.map → RgfaTabixAdapter-AR6A5GCW.js.map} +0 -0
- /package/dist/chunks/{WalkFormsAdapter-ZPE2JQJU.js.map → WalkFormsAdapter-Q37XRR7X.js.map} +0 -0
- /package/dist/chunks/{WalkTabixSyntenyAdapter-EOD4RQVU.js.map → WalkTabixSyntenyAdapter-NWB2OALF.js.map} +0 -0
- /package/dist/chunks/{chunk-SXQ6222I.js.map → chunk-6FH5I6SI.js.map} +0 -0
- /package/dist/chunks/{chunk-IBWORBGY.js.map → chunk-LR45N54F.js.map} +0 -0
- /package/dist/chunks/{chunk-TUECGSVJ.js.map → chunk-Q4UIYMYF.js.map} +0 -0
- /package/dist/chunks/{chunk-2QRCU675.js.map → chunk-QTEWKTFE.js.map} +0 -0
package/dist/chunks/{WalkTabixSyntenyAdapter-EOD4RQVU.js → WalkTabixSyntenyAdapter-NWB2OALF.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as K}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=WalkTabixSyntenyAdapter-
|
|
1
|
+
import{a as K}from"./chunk-QTEWKTFE.js";import{b as $,d as U,e as X,f as O,g as z,h as G}from"./chunk-OYXKO3SL.js";import"./chunk-Q4UIYMYF.js";import{a as q}from"./chunk-KOB7YIMR.js";import{p as M,q as _,r as T}from"./chunk-M2D7NUOY.js";import"./chunk-YBLNN5FU.js";import"./chunk-UQDZNX5E.js";import"./chunk-AJX6ZXCI.js";import{C as D,D as H,i as j}from"./chunk-UDHJGXQV.js";import"./chunk-YBLNN5FU.js";import"./chunk-ROZPEXN4.js";import{a as S,c as I,d as W,g as F,h as w,i as x}from"./chunk-KFZWGL76.js";import"./chunk-OTBDKJEA.js";import"./chunk-3VGXCEMQ.js";import"./chunk-OGQ6OQDN.js";import"./chunk-3WG3GF2A.js";import{o as R}from"./chunk-J5RMHLFJ.js";var se=50;function re(r){let i=[];for(let e=0;e<r.length;e++){let[t,a]=r[e],[s,n]=r[e+1]??[];a===n&&a<=se&&(t==="I"&&s==="D"||t==="D"&&s==="I")?(i.push(["X",a]),e++):i.push([t,a])}return i}function E(r){return Array.from(r.ids,(i,e)=>2*i+r.rev[e])}function A(r,i){let e=r.get(i);return e===void 0?0:e.end-e.start}function V(r){let i=new Map,e=s=>{let n=A(r,s),o=i.get(n);return o===void 0&&(o="N".repeat(n),i.set(n,o)),o},t=new Map,a=s=>{let n=t.get(s);return n===void 0&&(n=E(s),t.set(s,n)),n};return(s,n)=>_({query:a(s),target:a(n),sequenceOf:e,bases:!1})}var B=100;function v(r,i,e){let t=r.at(-1);e>0&&(t?.[0]===i?t[1]+=e:r.push([i,e]))}function Z(r){let i=t=>A(r,t>>1),e=t=>{let a=new Float64Array(t.length+1);return t.forEach((s,n)=>{a[n+1]=a[n]+i(s)}),a};return(t,a)=>{let s=E(a),n=E(t),[o,l]=M(n,s,i),[u,f]=M(n.map(g=>g^1).reverse(),s,i),c=f>l,p=c?u:o,N=Math.max(l,f);if(N<B)return[];let h=e(s),d=e(n),y=g=>c?n.length-1-p[g][0]:p[g][0],m=[];p.forEach(([,g],k)=>{if(k>0){let[ee,te]=[y(k-1),y(k)].sort((ae,ne)=>ae-ne);v(m,"I",d[te]-d[ee+1]),v(m,"D",h[g]-h[p[k-1][1]+1])}v(m,"=",i(s[g]))});let[b,P]=[y(0),y(p.length-1)].sort((g,k)=>g-k);return[{queryStart:d[b],queryEnd:d[P+1],targetStart:h[p[0][1]],targetEnd:h[p.at(-1)[1]+1],strand:c?"-":"+",edits:m,sharedBases:N}]}}function oe(r){let i=new Map,e=new Set;r.ids.forEach((t,a)=>{i.has(t)?e.add(t):i.set(t,r.rev[a])});for(let t of e)i.delete(t);return i}function J(r){let i=new Map,e=t=>{let a=i.get(t);return a===void 0&&(a=oe(t),i.set(t,a)),a};return(t,a)=>{let s=e(a),n=0,o=0;for(let[l,u]of e(t)){let f=s.get(l);f===u?n+=A(r,l):f!==void 0&&(o+=A(r,l))}return{same:n,opposite:o}}}function Q(r){let i=Z(r),e=V(r),t=J(r);return(a,s)=>{let{same:n,opposite:o}=t(a,s);return n>=B&&o>=B?e(a,s):i(a,s)}}var ie=1e4;function Y(r){let i=Z(r),e=V(r),t=J(r);return(a,s)=>{let n=i(a,s),o=n[0]?.strand,{same:l,opposite:u}=t(a,s);return o===void 0||Math.min(l,u)<ie?n:[...n,...e(a,s).filter(f=>f.strand!==o)]}}function C({chain:r,target:i,query:e,assemblyName:t,refName:a,mateAssemblyName:s}){let n=re(r.edits);return G({target:{name:i.name,assemblyName:t,refName:a,start:i.hapStart+r.targetStart,end:i.hapStart+r.targetEnd},query:{name:e.name,assemblyName:s,refName:W(e.name),start:e.hapStart+r.queryStart,end:e.hapStart+r.queryEnd},strand:r.strand,cigar:T(n),matches:n.reduce((o,[l,u])=>o+(l==="="?u:0),0),columns:n.reduce((o,[,l])=>o+l,0)})}var me=r=>I(r.name)??r.name,L=class extends ${constructor(){super(...arguments);this.walks=new K(D(this,["walksLocation"],["walksIndex"]),this);this.refNames=new H(this.walks.file,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){return this.walks.haplotypeNames(e)}async getHeader(e={}){let{haplotypes:t}=await this.walks.reader.header(e),{anchor:a}=this,s=w(this,a),n=x(this);return{hasCoarseTier:!1,anchorAssemblyName:a,lanes:t.filter(o=>o!==s&&S(o)!==s).map(o=>({name:O(n,o),label:o,group:S(o)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}async getSubgraph(e,t={}){let a=await this.refNames.resolveForCut(e,{signal:t.signal});return this.walks.subgraph(a,e,t)}async laneWalks(e,t,a,s,n){let o=j(a,e);return R(n,s.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.budgets(),signal:s.signal,keep:o,expand:o,links:!1}).catch(l=>{throw z(l,t.end-t.start)}))}async anchorFeatures(e,t,a){let s=a.haplotypes?.length?a.haplotypes.map(m=>w(this,m)):void 0,n=w(this,a.targetAssemblyName),o=n===void 0?s:s===void 0||s.some(m=>F(n,m)||F(m,n))?[n]:[];if(o?.length===0)return[];let{start:l,end:u}=t,{graph:f,fragments:c}=await this.laneWalks(e,t,o,a,`Reading walks ${t.refName}:${l.toLocaleString()}-${u.toLocaleString()}`),p=Y(f.nodes),N=x(this),h=c.filter(m=>m.name===e),d=m=>o===void 0?0:o.findIndex(b=>F(m.name,b));return c.filter(m=>m.name!==e&&d(m)>=0).sort((m,b)=>d(m)-d(b)).flatMap(m=>h.flatMap(b=>p(m,b).map(P=>C({chain:P,target:b,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:O(N,me(m))}))))}async pairFeatures(e,t,a,s){let n=a.map(c=>({pair:c,featurePrefix:w(this,c.queryAssemblyName),matePrefix:w(this,c.targetAssemblyName)})),{graph:o,fragments:l}=await this.laneWalks(e,t,n.flatMap(c=>[c.featurePrefix,c.matePrefix]),s,X(a)),u=Q(o.nodes),f=c=>l.filter(p=>F(p.name,c));return n.flatMap(({pair:c,featurePrefix:p,matePrefix:N})=>f(p).flatMap(h=>f(N).flatMap(d=>u(d,h).map(y=>C({chain:y,target:h,query:d,assemblyName:c.queryAssemblyName,refName:W(h.name),mateAssemblyName:c.targetAssemblyName})))))}getFeatures(e,t={}){return q(async a=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let n=U(t),o=n.length>0?await this.pairFeatures(s,e,n,t):await this.anchorFeatures(s,e,t);for(let l of o)a.next(l)}a.complete()},t.signal)}};export{L as default};
|
|
2
|
+
//# sourceMappingURL=WalkTabixSyntenyAdapter-NWB2OALF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{i as B,l as F,p as M}from"./chunk-46CNCY7Z.js";import{b as _,h as A}from"./chunk-BH2HG6VX.js";import{K as b,Q as W,V as S}from"./chunk-ACN3SGJ3.js";import{e as O}from"./chunk-YU7T5WOQ.js";import{D as P,E as R,H as m,d as C,o as I,q as L,r as w,s as N,t as D,w as E,y as G,z as x}from"./chunk-5Z4VIKXZ.js";import{b as t,c as r,d as T}from"./chunk-JMBDTNUR.js";var f=[{value:0,label:"Fastest"},{value:1,label:"Fast"},{value:2,label:"Default"},{value:3,label:"Fine"},{value:4,label:"Best"}];function y({label:o,value:n,options:e,testId:s,size:d,sx:p,disabled:a,title:h,shown:g,onChange:Q}){let v=O();return r(N,{size:d,sx:p,disabled:a,title:h,children:[t(E,{id:v,shrink:!0,children:o}),t(P,{labelId:v,value:n,label:o,notched:!0,displayEmpty:!0,"data-testid":s,renderValue:i=>g??e.find(z=>z.value===i)?.label??i,onChange:i=>{Q(i.target.value)},children:e.map(i=>t(x,{value:i.value,disabled:i.disabled,title:i.disabled?void 0:i.description,children:t(G,{primary:i.label,secondary:i.disabled?i.description:void 0})},i.value))})]})}var u=M()({section:{marginBottom:24},group:{marginBottom:16},heading:{marginBottom:8}});function l({warn:o=!1,children:n}){return t(m,{variant:"caption",component:"div",color:o?"warning.main":"text.secondary",children:n})}function k({title:o,children:n}){let{classes:e}=u();return r("section",{className:e.group,children:[t(m,{variant:"subtitle1",className:e.heading,children:o}),n]})}function U({label:o,checked:n,onChange:e,children:s}){let{classes:d}=u();return r("div",{className:d.section,children:[t(D,{control:t(R,{checked:n,onChange:p=>{e(p.target.checked)}}),label:o}),s]})}function c({children:o,...n}){let{classes:e}=u();return r("div",{className:e.section,children:[t(y,{sx:{minWidth:200},...n}),o]})}var Y=[5e3,2e4,5e4,1e5];function $(o){return[...new Set([...Y,o])].sort((n,e)=>n-e).map(n=>({value:String(n),label:n.toLocaleString()}))}function H({label:o,choices:n,stored:e,auto:s,testId:d,onChange:p,children:a}){return n.length>0?t(c,{label:o,value:n.some(h=>h.trackId===e)?e:"",options:[{value:"",label:`Automatic (${s?.name??"none"})`},...n.map(({trackId:h,name:g})=>({value:h,label:g}))],testId:d,onChange:p,children:a}):null}var q=T(function(n){let{model:e,onClose:s,children:d}=n,{classes:p}=u();return r(C,{open:!0,onClose:s,title:"Graph settings",children:[r(w,{children:[r(k,{title:"Subgraph",children:[d,t(c,{label:"Node limit",value:String(e.maxGraphNodes),options:$(e.maxGraphNodes),testId:"graph-node-limit-select",onChange:a=>{e.setMaxGraphNodes(Number(a))},children:t(l,{children:"The most nodes a layout draws; past it the graph is declined. Walk rows take no limit."})})]}),r(k,{title:"Drawing",children:[e.anchorPaths.length>1?t(c,{label:"Reference path",value:e.activeReferencePath??"",options:e.anchorPaths.map(({name:a})=>({value:a,label:a})),testId:"graph-reference-path-select",onChange:a=>{e.setReferencePath(a),e.recomputeLayout()},children:t(l,{children:"The path the anchored layouts place x along"})}):null,t(c,{label:"Node width",value:e.nodeWidth,options:W,testId:"graph-node-width-select",onChange:a=>{e.setNodeWidth(a)},children:t(l,{children:"Depth as width. In a cut with walks, depth is how many haplotypes carry the node."})}),t(c,{label:"Link width",value:e.linkWidth,options:S,testId:"graph-link-width-select",onChange:a=>{e.setLinkWidth(a)},children:t(l,{children:"Walks as width, so a common route reads heavy and a private one thin."})}),r(U,{label:"Draw paths",checked:e.drawPaths,onChange:a=>{e.setLayer("paths",a)},children:[t(l,{children:"Color each node by the paths through it, one lane per path"}),e.drawPaths&&!e.effectiveDrawPaths?t(l,{warn:!0,children:e.pathCount>b?`Off: ${e.pathCount.toLocaleString()} paths is past the ${b} this can tell apart`:"Off: this graph states no paths"}):null]}),t(H,{label:"Gene track",choices:e.geneTrackChoices,stored:e.geneTrackId,auto:F(e.geneTrackChoices,""),testId:"graph-gene-track-select",onChange:a=>{e.setGeneTrackId(a)},children:t(l,{children:"Where genes on the backbone come from"})}),t(H,{label:"Repeat track",choices:e.repeatTrackChoices,stored:e.repeatTrackId,auto:B(e.repeatTrackChoices,""),testId:"graph-repeat-track-select",onChange:a=>{e.setRepeatTrackId(a)},children:t(l,{children:"The tandem repeat annotation walk rows measure and tile by"})})]}),r(k,{title:"Force-directed layout",children:[e.hasGraph&&!e.usesLayoutEngine?t("div",{className:p.section,children:t(l,{warn:!0,children:"No effect on the current layout until Layout is Force-directed"})}):null,t(c,{label:"Engine",value:e.layoutEngine,options:_,testId:"graph-layout-engine-select",onChange:a=>{e.setLayoutEngine(a)},children:t(l,{children:"Stress keeps the reference straight, so a zoom keeps the picture; FMMM lets the whole graph settle."})}),t(c,{label:"Layout quality",value:String(e.layoutQuality),options:f.map(a=>({value:String(a.value),label:a.label})),testId:"graph-layout-quality-select",onChange:a=>{e.setLayoutQuality(Number(a))},children:t(l,{children:"The engine's iteration budget; higher is slower"})}),t(c,{label:"Bubble spread",value:e.bubbleSpread,options:A,testId:"graph-bubble-spread-select",onChange:a=>{e.setBubbleSpread(a)},children:t(l,{children:"How far the layout opens a bubble"})}),e.layoutEngine==="stress"?null:t(U,{label:"Linear layout",checked:e.linearLayout,onChange:a=>{e.setLinearLayout(a)},children:t(l,{children:"Keeps a chain of nodes on one line where it can"})})]})]}),t(L,{children:t(I,{variant:"contained",color:"primary",onClick:s,children:"Close"})})]})}),fe=q;export{y as a,fe as b};
|
|
2
|
+
//# sourceMappingURL=chunk-3OALERH2.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@
|
|
3
|
+
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@12.0.1/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-K5SIJGAE.js", "../../src/GraphGenomeView/components/LabelledSelect.tsx", "../../src/GraphGenomeView/components/GraphSettingsDialog.tsx"],
|
|
4
4
|
"sourcesContent": ["// src/layoutQualities.ts\nvar LAYOUT_QUALITIES = [\n { value: 0, label: \"Fastest\" },\n { value: 1, label: \"Fast\" },\n { value: 2, label: \"Default\" },\n { value: 3, label: \"Fine\" },\n { value: 4, label: \"Best\" }\n];\n\nexport {\n LAYOUT_QUALITIES\n};\n", "import { useId } from 'react'\n\nimport {\n FormControl,\n InputLabel,\n ListItemText,\n MenuItem,\n Select,\n} from '@mui/material'\n\nimport type { SxProps } from '@mui/material'\n\ninterface SelectOption<T extends string> {\n value: T\n label: string\n // an option's tooltip, and the reason under a disabled one, whose tooltip\n // cannot open\n description?: string\n disabled?: boolean\n}\n\n// One dropdown with its label tied to it, so a screen reader names the combobox\nexport default function LabelledSelect<T extends string>({\n label,\n value,\n options,\n testId,\n size,\n sx,\n disabled,\n title,\n shown,\n onChange,\n}: {\n label: string\n value: T\n options: readonly SelectOption<T>[]\n testId?: string\n size?: 'small' | 'medium'\n sx?: SxProps\n disabled?: boolean\n title?: string\n // what the closed select reads, when not the picked option's label\n shown?: string\n onChange: (value: T) => void\n}) {\n const labelId = useId()\n return (\n <FormControl size={size} sx={sx} disabled={disabled} title={title}>\n <InputLabel id={labelId} shrink>\n {label}\n </InputLabel>\n <Select\n labelId={labelId}\n value={value}\n label={label}\n notched\n displayEmpty\n data-testid={testId}\n renderValue={picked =>\n shown ?? options.find(o => o.value === picked)?.label ?? picked\n }\n onChange={e => {\n onChange(e.target.value as T)\n }}\n >\n {options.map(o => (\n <MenuItem\n key={o.value}\n value={o.value}\n disabled={o.disabled}\n title={o.disabled ? undefined : o.description}\n >\n <ListItemText\n primary={o.label}\n secondary={o.disabled ? o.description : undefined}\n />\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n )\n}\n", "import type { ReactNode } from 'react'\n\nimport { BUBBLE_SPREADS } from '@jbrowse/bandage-core/bubbleSpreads'\nimport { EDGE_WIDTHS } from '@jbrowse/bandage-core/edgeWidths'\nimport { LAYOUT_ENGINES } from '@jbrowse/bandage-core/layoutEngines'\nimport { LAYOUT_QUALITIES } from '@jbrowse/bandage-core/layoutQualities'\nimport { NODE_WIDTHS } from '@jbrowse/bandage-core/nodeWidths'\nimport { MAX_PATH_COLORS } from '@jbrowse/bandage-core/pathColors'\nimport { Dialog } from '@jbrowse/core/ui'\nimport {\n Button,\n DialogActions,\n DialogContent,\n FormControlLabel,\n Switch,\n Typography,\n} from '@mui/material'\nimport { observer } from 'mobx-react'\nimport { makeStyles } from 'tss-react/mui'\n\nimport LabelledSelect from './LabelledSelect'\nimport { pickGeneTrack } from '../genes/geneFeatures'\nimport { pickRepeatTrack } from '../repeats/repeatFeatures'\n\nimport type { GraphPaneModel } from '../model'\n\nconst useStyles = makeStyles()({\n section: {\n marginBottom: 24,\n },\n group: {\n marginBottom: 16,\n },\n heading: {\n marginBottom: 8,\n },\n})\n\nfunction Caption({\n warn = false,\n children,\n}: {\n warn?: boolean\n children: ReactNode\n}) {\n return (\n <Typography\n variant=\"caption\"\n component=\"div\"\n color={warn ? 'warning.main' : 'text.secondary'}\n >\n {children}\n </Typography>\n )\n}\n\nfunction Group({ title, children }: { title: string; children: ReactNode }) {\n const { classes } = useStyles()\n return (\n <section className={classes.group}>\n <Typography variant=\"subtitle1\" className={classes.heading}>\n {title}\n </Typography>\n {children}\n </section>\n )\n}\n\nfunction SettingSwitch({\n label,\n checked,\n onChange,\n children,\n}: {\n label: string\n checked: boolean\n onChange: (checked: boolean) => void\n children?: ReactNode\n}) {\n const { classes } = useStyles()\n return (\n <div className={classes.section}>\n <FormControlLabel\n control={\n <Switch\n checked={checked}\n onChange={e => {\n onChange(e.target.checked)\n }}\n />\n }\n label={label}\n />\n {children}\n </div>\n )\n}\n\n// one dropdown setting, at the dialog's width, and its caption\nfunction SettingSelect<T extends string>({\n children,\n ...props\n}: Omit<Parameters<typeof LabelledSelect<T>>[0], 'size' | 'sx'> & {\n children?: ReactNode\n}) {\n const { classes } = useStyles()\n return (\n <div className={classes.section}>\n <LabelledSelect sx={{ minWidth: 200 }} {...props} />\n {children}\n </div>\n )\n}\n\nconst NODE_LIMITS = [5000, 20_000, 50_000, 100_000]\n\n// the presets, with a limit a session states among them\nfunction nodeLimitOptions(current: number) {\n return [...new Set([...NODE_LIMITS, current])]\n .sort((a, b) => a - b)\n .map(limit => ({ value: String(limit), label: limit.toLocaleString() }))\n}\n\ninterface NamedTrack {\n trackId: string\n name: string\n}\n\n// '' leaves the pick to the heuristic, so a session can go back to it\nfunction TrackPickSetting({\n label,\n choices,\n stored,\n auto,\n testId,\n onChange,\n children,\n}: {\n label: string\n choices: NamedTrack[]\n stored: string\n auto: NamedTrack | undefined\n testId: string\n onChange: (trackId: string) => void\n children: ReactNode\n}) {\n return choices.length > 0 ? (\n <SettingSelect\n label={label}\n value={choices.some(t => t.trackId === stored) ? stored : ''}\n options={[\n { value: '', label: `Automatic (${auto?.name ?? 'none'})` },\n ...choices.map(({ trackId, name }) => ({\n value: trackId,\n label: name,\n })),\n ]}\n testId={testId}\n onChange={onChange}\n >\n {children}\n </SettingSelect>\n ) : null\n}\n\n// Toggles the menus already offer (halos, genes, color) stay out of here.\n// `children` is the host's own part of the subgraph group.\nconst GraphSettingsDialog = observer(function GraphSettingsDialog(props: {\n model: GraphPaneModel\n onClose: () => void\n children?: ReactNode\n}) {\n const { model, onClose, children } = props\n const { classes } = useStyles()\n\n return (\n <Dialog open onClose={onClose} title=\"Graph settings\">\n <DialogContent>\n <Group title=\"Subgraph\">\n {children}\n <SettingSelect\n label=\"Node limit\"\n value={String(model.maxGraphNodes)}\n options={nodeLimitOptions(model.maxGraphNodes)}\n testId=\"graph-node-limit-select\"\n onChange={limit => {\n model.setMaxGraphNodes(Number(limit))\n }}\n >\n <Caption>\n The most nodes a layout draws; past it the graph is declined. Walk\n rows take no limit.\n </Caption>\n </SettingSelect>\n </Group>\n\n <Group title=\"Drawing\">\n {model.anchorPaths.length > 1 ? (\n <SettingSelect\n label=\"Reference path\"\n value={model.activeReferencePath ?? ''}\n options={model.anchorPaths.map(({ name }) => ({\n value: name,\n label: name,\n }))}\n testId=\"graph-reference-path-select\"\n onChange={name => {\n model.setReferencePath(name)\n void model.recomputeLayout()\n }}\n >\n <Caption>The path the anchored layouts place x along</Caption>\n </SettingSelect>\n ) : null}\n\n <SettingSelect\n label=\"Node width\"\n value={model.nodeWidth}\n options={NODE_WIDTHS}\n testId=\"graph-node-width-select\"\n onChange={width => {\n model.setNodeWidth(width)\n }}\n >\n <Caption>\n Depth as width. In a cut with walks, depth is how many haplotypes\n carry the node.\n </Caption>\n </SettingSelect>\n\n <SettingSelect\n label=\"Link width\"\n value={model.linkWidth}\n options={EDGE_WIDTHS}\n testId=\"graph-link-width-select\"\n onChange={links => {\n model.setLinkWidth(links)\n }}\n >\n <Caption>\n Walks as width, so a common route reads heavy and a private one\n thin.\n </Caption>\n </SettingSelect>\n\n <SettingSwitch\n label=\"Draw paths\"\n checked={model.drawPaths}\n onChange={draw => {\n model.setLayer('paths', draw)\n }}\n >\n <Caption>\n Color each node by the paths through it, one lane per path\n </Caption>\n {model.drawPaths && !model.effectiveDrawPaths ? (\n <Caption warn>\n {model.pathCount > MAX_PATH_COLORS\n ? `Off: ${model.pathCount.toLocaleString()} paths is past the ${MAX_PATH_COLORS} this can tell apart`\n : 'Off: this graph states no paths'}\n </Caption>\n ) : null}\n </SettingSwitch>\n\n <TrackPickSetting\n label=\"Gene track\"\n choices={model.geneTrackChoices}\n stored={model.geneTrackId}\n auto={pickGeneTrack(model.geneTrackChoices, '')}\n testId=\"graph-gene-track-select\"\n onChange={trackId => {\n model.setGeneTrackId(trackId)\n }}\n >\n <Caption>Where genes on the backbone come from</Caption>\n </TrackPickSetting>\n\n <TrackPickSetting\n label=\"Repeat track\"\n choices={model.repeatTrackChoices}\n stored={model.repeatTrackId}\n auto={pickRepeatTrack(model.repeatTrackChoices, '')}\n testId=\"graph-repeat-track-select\"\n onChange={trackId => {\n model.setRepeatTrackId(trackId)\n }}\n >\n <Caption>\n The tandem repeat annotation walk rows measure and tile by\n </Caption>\n </TrackPickSetting>\n </Group>\n\n <Group title=\"Force-directed layout\">\n {model.hasGraph && !model.usesLayoutEngine ? (\n <div className={classes.section}>\n <Caption warn>\n No effect on the current layout until Layout is Force-directed\n </Caption>\n </div>\n ) : null}\n\n <SettingSelect\n label=\"Engine\"\n value={model.layoutEngine}\n options={LAYOUT_ENGINES}\n testId=\"graph-layout-engine-select\"\n onChange={engine => {\n model.setLayoutEngine(engine)\n }}\n >\n <Caption>\n Stress keeps the reference straight, so a zoom keeps the picture;\n FMMM lets the whole graph settle.\n </Caption>\n </SettingSelect>\n\n <SettingSelect\n label=\"Layout quality\"\n value={String(model.layoutQuality)}\n options={LAYOUT_QUALITIES.map(q => ({\n value: String(q.value),\n label: q.label,\n }))}\n testId=\"graph-layout-quality-select\"\n onChange={quality => {\n model.setLayoutQuality(Number(quality))\n }}\n >\n <Caption>\n The engine's iteration budget; higher is slower\n </Caption>\n </SettingSelect>\n\n <SettingSelect\n label=\"Bubble spread\"\n value={model.bubbleSpread}\n options={BUBBLE_SPREADS}\n testId=\"graph-bubble-spread-select\"\n onChange={spread => {\n model.setBubbleSpread(spread)\n }}\n >\n <Caption>How far the layout opens a bubble</Caption>\n </SettingSelect>\n\n {model.layoutEngine === 'stress' ? null : (\n <SettingSwitch\n label=\"Linear layout\"\n checked={model.linearLayout}\n onChange={linear => {\n model.setLinearLayout(linear)\n }}\n >\n <Caption>Keeps a chain of nodes on one line where it can</Caption>\n </SettingSwitch>\n )}\n </Group>\n </DialogContent>\n\n <DialogActions>\n <Button variant=\"contained\" color=\"primary\" onClick={onClose}>\n Close\n </Button>\n </DialogActions>\n </Dialog>\n )\n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AA,CAAM,MAAM,wBACV,UAAA8B,EAAM,UAAY,CAACA,EAAM,iBACxBhC,EAAC,OAAI,UAAWI,EAAQ,QACtB,SAAAJ,EAACH,EAAA,CAAQ,KAAI,GAAC,0EAEd,EACF,EACE,KAEJG,EAACa,EAAA,CACC,MAAM,SACN,MAAOmB,EAAM,aACb,QAASY,EACT,OAAO,6BACP,SAAUC,GAAU,CAClBb,EAAM,gBAAgBa,CAAM,CAC9B,EAEA,SAAA7C,EAACH,EAAA,CAAQ,+GAGT,EACF,EAEAG,EAACa,EAAA,CACC,MAAM,iBACN,MAAO,OAAOmB,EAAM,aAAa,EACjC,QAASc,EAAiB,IAAIC,IAAM,CAClC,MAAO,OAAOA,EAAE,KAAK,EACrB,MAAOA,EAAE,KACX,EAAE,EACF,OAAO,8BACP,SAAUC,GAAW,CACnBhB,EAAM,iBAAiB,OAAOgB,CAAO,CAAC,CACxC,EAEA,SAAAhD,EAACH,EAAA,CAAQ,2DAET,EACF,EAEAG,EAACa,EAAA,CACC,MAAM,gBACN,MAAOmB,EAAM,aACb,QAASiB,EACT,OAAO,6BACP,SAAUC,GAAU,CAClBlB,EAAM,gBAAgBkB,CAAM,CAC9B,EAEA,SAAAlD,EAACH,EAAA,CAAQ,6CAAiC,EAC5C,EAECmC,EAAM,eAAiB,SAAW,KACjChC,EAACM,EAAA,CACC,MAAM,gBACN,QAAS0B,EAAM,aACf,SAAUmB,GAAU,CAClBnB,EAAM,gBAAgBmB,CAAM,CAC9B,EAEA,SAAAnD,EAACH,EAAA,CAAQ,2DAA+C,EAC1D,GAEJ,GACF,EAEAG,EAACoD,EAAA,CACC,SAAApD,EAACqD,EAAA,CAAO,QAAQ,YAAY,MAAM,UAAU,QAASpB,EAAS,iBAE9D,EACF,GACF,CAEJ,CAAC,EAEMqB,GAAQxB",
|
|
6
6
|
"names": ["LAYOUT_QUALITIES", "LabelledSelect", "label", "value", "options", "testId", "size", "sx", "disabled", "title", "shown", "onChange", "labelId", "useId", "jsxs", "FormControl", "jsx", "InputLabel", "Select", "picked", "o", "e", "MenuItem", "ListItemText", "useStyles", "makeStyles", "Caption", "warn", "children", "jsx", "Typography", "Group", "title", "classes", "jsxs", "SettingSwitch", "label", "checked", "onChange", "FormControlLabel", "Switch", "e", "SettingSelect", "props", "LabelledSelect", "NODE_LIMITS", "nodeLimitOptions", "current", "a", "b", "limit", "TrackPickSetting", "choices", "stored", "auto", "testId", "t", "trackId", "name", "GraphSettingsDialog", "observer", "model", "onClose", "Dialog", "DialogContent", "NODE_WIDTHS", "width", "EDGE_WIDTHS", "links", "draw", "MAX_PATH_COLORS", "pickGeneTrack", "pickRepeatTrack", "LAYOUT_ENGINES", "engine", "LAYOUT_QUALITIES", "q", "quality", "BUBBLE_SPREADS", "spread", "linear", "DialogActions", "Button", "GraphSettingsDialog_default"]
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=JBrowseExports["@jbrowse/core/util/tracks"],t=o=>e!=null&&o in Object(e)?e[o]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+o+"' from '@jbrowse/core/util/tracks' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:o});var s=t("getConfAssemblyNamesOrNone");var r=t("getTrackName");var n=t("makeIndexType");var a=t("toTrackConfigEntry");var c=e&&e.__esModule?e.default:e;export{s as a,r as b,n as c,a as d};
|
|
2
|
+
//# sourceMappingURL=chunk-3VGXCEMQ.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["host:@jbrowse/core/util/tracks"],
|
|
4
|
-
"sourcesContent": ["const host = JBrowseExports[\"@jbrowse/core/util/tracks\"]\nconst read = name =>\n host != null && name in Object(host)\n ? host[name]\n : Object.assign(\n function () {\n throw new Error(\n \"This JBrowse does not provide '\" + name + \"' from '\" + \"@jbrowse/core/util/tracks\" + \"' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse\",\n )\n },\n { jbrowseHostMissing: name },\n )\nexport const UNKNOWN = /* @__PURE__ */ read(\"UNKNOWN\")\nexport const UNSUPPORTED = /* @__PURE__ */ read(\"UNSUPPORTED\")\nexport const addAdapterGuesser = /* @__PURE__ */ read(\"addAdapterGuesser\")\nexport const addTrackTypeGuesser = /* @__PURE__ */ read(\"addTrackTypeGuesser\")\nexport const allSessionTracks = /* @__PURE__ */ read(\"allSessionTracks\")\nexport const annotationTrackIds = /* @__PURE__ */ read(\"annotationTrackIds\")\nexport const canonicalAssemblyNames = /* @__PURE__ */ read(\"canonicalAssemblyNames\")\nexport const clearFileFromCache = /* @__PURE__ */ read(\"clearFileFromCache\")\nexport const ensureFileHandleReady = /* @__PURE__ */ read(\"ensureFileHandleReady\")\nexport const expandLooseTrackConfig = /* @__PURE__ */ read(\"expandLooseTrackConfig\")\nexport const filterTracks = /* @__PURE__ */ read(\"filterTracks\")\nexport const findFileHandleIds = /* @__PURE__ */ read(\"findFileHandleIds\")\nexport const generateUnknownTrackConf = /* @__PURE__ */ read(\"generateUnknownTrackConf\")\nexport const generateUnsupportedTrackConf = /* @__PURE__ */ read(\"generateUnsupportedTrackConf\")\nexport const getBlob = /* @__PURE__ */ read(\"getBlob\")\nexport const getBlobMap = /* @__PURE__ */ read(\"getBlobMap\")\nexport const getConfAssemblyNames = /* @__PURE__ */ read(\"getConfAssemblyNames\")\nexport const getConfAssemblyNamesOrNone = /* @__PURE__ */ read(\"getConfAssemblyNamesOrNone\")\nexport const getConfRpcSessionId = /* @__PURE__ */ read(\"getConfRpcSessionId\")\nexport const getFileFromCache = /* @__PURE__ */ read(\"getFileFromCache\")\nexport const getFileName = /* @__PURE__ */ read(\"getFileName\")\nexport const getRpcSessionId = /* @__PURE__ */ read(\"getRpcSessionId\")\nexport const getTrackAssemblyNames = /* @__PURE__ */ read(\"getTrackAssemblyNames\")\nexport const getTrackName = /* @__PURE__ */ read(\"getTrackName\")\nexport const guessAdapter = /* @__PURE__ */ read(\"guessAdapter\")\nexport const guessTabixIndex = /* @__PURE__ */ read(\"guessTabixIndex\")\nexport const guessTrackConf = /* @__PURE__ */ read(\"guessTrackConf\")\nexport const guessTrackConfForLocation = /* @__PURE__ */ read(\"guessTrackConfForLocation\")\nexport const guessTrackType = /* @__PURE__ */ read(\"guessTrackType\")\nexport const hasFileHandlesInCache = /* @__PURE__ */ read(\"hasFileHandlesInCache\")\nexport const hideTrackGeneric = /* @__PURE__ */ read(\"hideTrackGeneric\")\nexport const isLooseTrackConfig = /* @__PURE__ */ read(\"isLooseTrackConfig\")\nexport const isSameAssemblyName = /* @__PURE__ */ read(\"isSameAssemblyName\")\nexport const launchToggleTrackGeneric = /* @__PURE__ */ read(\"launchToggleTrackGeneric\")\nexport const launchTrackGeneric = /* @__PURE__ */ read(\"launchTrackGeneric\")\nexport const makeIndex = /* @__PURE__ */ read(\"makeIndex\")\nexport const makeIndexType = /* @__PURE__ */ read(\"makeIndexType\")\nexport const normalizeTrackInit = /* @__PURE__ */ read(\"normalizeTrackInit\")\nexport const offeredTracks = /* @__PURE__ */ read(\"offeredTracks\")\nexport const openAssemblyInLinearView = /* @__PURE__ */ read(\"openAssemblyInLinearView\")\nexport const openMateLabel = /* @__PURE__ */ read(\"openMateLabel\")\nexport const pickDisplayForView = /* @__PURE__ */ read(\"pickDisplayForView\")\nexport const restoreFileHandles = /* @__PURE__ */ read(\"restoreFileHandles\")\nexport const restoreFileHandlesFromSnapshot = /* @__PURE__ */ read(\"restoreFileHandlesFromSnapshot\")\nexport const setBlobMap = /* @__PURE__ */ read(\"setBlobMap\")\nexport const setFileInCache = /* @__PURE__ */ read(\"setFileInCache\")\nexport const showTrackGeneric = /* @__PURE__ */ read(\"showTrackGeneric\")\nexport const storeBlobLocation = /* @__PURE__ */ read(\"storeBlobLocation\")\nexport const storeFileHandleLocation = /* @__PURE__ */ read(\"storeFileHandleLocation\")\nexport const stripFileExtension = /* @__PURE__ */ read(\"stripFileExtension\")\nexport const stripTrackIds = /* @__PURE__ */ read(\"stripTrackIds\")\nexport const toggleTrackGeneric = /* @__PURE__ */ read(\"toggleTrackGeneric\")\nexport const viewCanDisplayTrack = /* @__PURE__ */ read(\"viewCanDisplayTrack\")\nexport const viewDisplayNames = /* @__PURE__ */ read(\"viewDisplayNames\")\nexport const warmTrackDisplayGeneric = /* @__PURE__ */ read(\"warmTrackDisplayGeneric\")\nexport default host && host.__esModule ? host.default : host"],
|
|
5
|
-
"mappings": "AAAA,IAAMA,EAAO,eAAe,2BAA2B,EACjDC,EAAOC,GACXF,GAAQ,MAAQE,KAAQ,OAAOF,CAAI,EAC/BA,EAAKE,CAAI,EACT,OAAO,OACL,UAAY,CACV,MAAM,IAAI,MACR,kCAAoCA,EAAO,2IAC7C,CACF,EACA,CAAE,mBAAoBA,CAAK,CAC7B,
|
|
6
|
-
"names": ["host", "read", "name", "getTrackName", "read", "makeIndexType", "read", "tracks_default", "host"]
|
|
4
|
+
"sourcesContent": ["const host = JBrowseExports[\"@jbrowse/core/util/tracks\"]\nconst read = name =>\n host != null && name in Object(host)\n ? host[name]\n : Object.assign(\n function () {\n throw new Error(\n \"This JBrowse does not provide '\" + name + \"' from '\" + \"@jbrowse/core/util/tracks\" + \"' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse\",\n )\n },\n { jbrowseHostMissing: name },\n )\nexport const UNKNOWN = /* @__PURE__ */ read(\"UNKNOWN\")\nexport const UNSUPPORTED = /* @__PURE__ */ read(\"UNSUPPORTED\")\nexport const addAdapterGuesser = /* @__PURE__ */ read(\"addAdapterGuesser\")\nexport const addTrackTypeGuesser = /* @__PURE__ */ read(\"addTrackTypeGuesser\")\nexport const allSessionTracks = /* @__PURE__ */ read(\"allSessionTracks\")\nexport const annotationTrackIds = /* @__PURE__ */ read(\"annotationTrackIds\")\nexport const canonicalAssemblyNames = /* @__PURE__ */ read(\"canonicalAssemblyNames\")\nexport const clearFileFromCache = /* @__PURE__ */ read(\"clearFileFromCache\")\nexport const ensureFileHandleReady = /* @__PURE__ */ read(\"ensureFileHandleReady\")\nexport const expandLooseTrackConfig = /* @__PURE__ */ read(\"expandLooseTrackConfig\")\nexport const filterTracks = /* @__PURE__ */ read(\"filterTracks\")\nexport const findFileHandleIds = /* @__PURE__ */ read(\"findFileHandleIds\")\nexport const generateUnknownTrackConf = /* @__PURE__ */ read(\"generateUnknownTrackConf\")\nexport const generateUnsupportedTrackConf = /* @__PURE__ */ read(\"generateUnsupportedTrackConf\")\nexport const getBlob = /* @__PURE__ */ read(\"getBlob\")\nexport const getBlobMap = /* @__PURE__ */ read(\"getBlobMap\")\nexport const getConfAssemblyNames = /* @__PURE__ */ read(\"getConfAssemblyNames\")\nexport const getConfAssemblyNamesOrNone = /* @__PURE__ */ read(\"getConfAssemblyNamesOrNone\")\nexport const getConfRpcSessionId = /* @__PURE__ */ read(\"getConfRpcSessionId\")\nexport const getFileFromCache = /* @__PURE__ */ read(\"getFileFromCache\")\nexport const getFileName = /* @__PURE__ */ read(\"getFileName\")\nexport const getRpcSessionId = /* @__PURE__ */ read(\"getRpcSessionId\")\nexport const getTrackAssemblyNames = /* @__PURE__ */ read(\"getTrackAssemblyNames\")\nexport const getTrackName = /* @__PURE__ */ read(\"getTrackName\")\nexport const guessAdapter = /* @__PURE__ */ read(\"guessAdapter\")\nexport const guessTabixIndex = /* @__PURE__ */ read(\"guessTabixIndex\")\nexport const guessTrackConf = /* @__PURE__ */ read(\"guessTrackConf\")\nexport const guessTrackConfForLocation = /* @__PURE__ */ read(\"guessTrackConfForLocation\")\nexport const guessTrackType = /* @__PURE__ */ read(\"guessTrackType\")\nexport const hasFileHandlesInCache = /* @__PURE__ */ read(\"hasFileHandlesInCache\")\nexport const hideTrackGeneric = /* @__PURE__ */ read(\"hideTrackGeneric\")\nexport const isLooseTrackConfig = /* @__PURE__ */ read(\"isLooseTrackConfig\")\nexport const isSameAssemblyName = /* @__PURE__ */ read(\"isSameAssemblyName\")\nexport const launchToggleTrackGeneric = /* @__PURE__ */ read(\"launchToggleTrackGeneric\")\nexport const launchTrackGeneric = /* @__PURE__ */ read(\"launchTrackGeneric\")\nexport const makeIndex = /* @__PURE__ */ read(\"makeIndex\")\nexport const makeIndexType = /* @__PURE__ */ read(\"makeIndexType\")\nexport const normalizeTrackInit = /* @__PURE__ */ read(\"normalizeTrackInit\")\nexport const offeredTracks = /* @__PURE__ */ read(\"offeredTracks\")\nexport const openAssemblyInLinearView = /* @__PURE__ */ read(\"openAssemblyInLinearView\")\nexport const openMateLabel = /* @__PURE__ */ read(\"openMateLabel\")\nexport const pickDisplayForView = /* @__PURE__ */ read(\"pickDisplayForView\")\nexport const restoreFileHandles = /* @__PURE__ */ read(\"restoreFileHandles\")\nexport const restoreFileHandlesFromSnapshot = /* @__PURE__ */ read(\"restoreFileHandlesFromSnapshot\")\nexport const setBlobMap = /* @__PURE__ */ read(\"setBlobMap\")\nexport const setFileInCache = /* @__PURE__ */ read(\"setFileInCache\")\nexport const showTrackGeneric = /* @__PURE__ */ read(\"showTrackGeneric\")\nexport const storeBlobLocation = /* @__PURE__ */ read(\"storeBlobLocation\")\nexport const storeFileHandleLocation = /* @__PURE__ */ read(\"storeFileHandleLocation\")\nexport const stripFileExtension = /* @__PURE__ */ read(\"stripFileExtension\")\nexport const stripTrackIds = /* @__PURE__ */ read(\"stripTrackIds\")\nexport const toTrackConfigEntry = /* @__PURE__ */ read(\"toTrackConfigEntry\")\nexport const toggleTrackGeneric = /* @__PURE__ */ read(\"toggleTrackGeneric\")\nexport const trackCatalog = /* @__PURE__ */ read(\"trackCatalog\")\nexport const trackCatalogEntry = /* @__PURE__ */ read(\"trackCatalogEntry\")\nexport const trackDisplayType = /* @__PURE__ */ read(\"trackDisplayType\")\nexport const viewCanDisplayTrack = /* @__PURE__ */ read(\"viewCanDisplayTrack\")\nexport const viewDisplayNames = /* @__PURE__ */ read(\"viewDisplayNames\")\nexport const warmTrackDisplayGeneric = /* @__PURE__ */ read(\"warmTrackDisplayGeneric\")\nexport default host && host.__esModule ? host.default : host"],
|
|
5
|
+
"mappings": "AAAA,IAAMA,EAAO,eAAe,2BAA2B,EACjDC,EAAOC,GACXF,GAAQ,MAAQE,KAAQ,OAAOF,CAAI,EAC/BA,EAAKE,CAAI,EACT,OAAO,OACL,UAAY,CACV,MAAM,IAAI,MACR,kCAAoCA,EAAO,2IAC7C,CACF,EACA,CAAE,mBAAoBA,CAAK,CAC7B,EAkBC,IAAMC,EAA6CC,EAAK,4BAA4B,EAMpF,IAAMC,EAA+BC,EAAK,cAAc,EAaxD,IAAMC,EAAgCC,EAAK,eAAe,EAe1D,IAAMC,EAAqCC,EAAK,oBAAoB,EAQ3E,IAAOC,EAAQC,GAAQA,EAAK,WAAaA,EAAK,QAAUA",
|
|
6
|
+
"names": ["host", "read", "name", "getConfAssemblyNamesOrNone", "read", "getTrackName", "read", "makeIndexType", "read", "toTrackConfigEntry", "read", "tracks_default", "host"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=JBrowseExports["mobx-state-tree"],t=o=>e!=null&&o in Object(e)?e[o]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+o+"' from 'mobx-state-tree' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:o}),n=t("addDisposer");var s=t("flow");var r=t("getEnv");var p=t("getRoot");var c=t("isAlive");var i=t("types");var a=e&&e.__esModule?e.default:e;export{n as a,s as b,r as c,p as d,c as e,i as f};
|
|
2
|
+
//# sourceMappingURL=chunk-3WG3GF2A.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["host:@jbrowse/mobx-state-tree"],
|
|
4
|
-
"sourcesContent": ["const host = JBrowseExports[\"mobx-state-tree\"]\nconst read = name =>\n host != null && name in Object(host)\n ? host[name]\n : Object.assign(\n function () {\n throw new Error(\n \"This JBrowse does not provide '\" + name + \"' from '\" + \"mobx-state-tree\" + \"' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse\",\n )\n },\n { jbrowseHostMissing: name },\n )\nexport const addDisposer = /* @__PURE__ */ read(\"addDisposer\")\nexport const addMiddleware = /* @__PURE__ */ read(\"addMiddleware\")\nexport const applyAction = /* @__PURE__ */ read(\"applyAction\")\nexport const applyPatch = /* @__PURE__ */ read(\"applyPatch\")\nexport const applySnapshot = /* @__PURE__ */ read(\"applySnapshot\")\nexport const asArrayType = /* @__PURE__ */ read(\"asArrayType\")\nexport const asMapType = /* @__PURE__ */ read(\"asMapType\")\nexport const asModelType = /* @__PURE__ */ read(\"asModelType\")\nexport const cannotDetermineSubtype = /* @__PURE__ */ read(\"cannotDetermineSubtype\")\nexport const cast = /* @__PURE__ */ read(\"cast\")\nexport const castFlowReturn = /* @__PURE__ */ read(\"castFlowReturn\")\nexport const castToReferenceSnapshot = /* @__PURE__ */ read(\"castToReferenceSnapshot\")\nexport const castToSnapshot = /* @__PURE__ */ read(\"castToSnapshot\")\nexport const clone = /* @__PURE__ */ read(\"clone\")\nexport const createActionTrackingMiddleware = /* @__PURE__ */ read(\"createActionTrackingMiddleware\")\nexport const createActionTrackingMiddleware2 = /* @__PURE__ */ read(\"createActionTrackingMiddleware2\")\nexport const decorate = /* @__PURE__ */ read(\"decorate\")\nexport const destroy = /* @__PURE__ */ read(\"destroy\")\nexport const detach = /* @__PURE__ */ read(\"detach\")\nexport const escapeJsonPath = /* @__PURE__ */ read(\"escapeJsonPath\")\nexport const extendInstance = /* @__PURE__ */ read(\"extendInstance\")\nexport const flow = /* @__PURE__ */ read(\"flow\")\nexport const getChildType = /* @__PURE__ */ read(\"getChildType\")\nexport const getEnv = /* @__PURE__ */ read(\"getEnv\")\nexport const getIdentifier = /* @__PURE__ */ read(\"getIdentifier\")\nexport const getLivelinessChecking = /* @__PURE__ */ read(\"getLivelinessChecking\")\nexport const getMembers = /* @__PURE__ */ read(\"getMembers\")\nexport const getNodeId = /* @__PURE__ */ read(\"getNodeId\")\nexport const getParent = /* @__PURE__ */ read(\"getParent\")\nexport const getParentOfType = /* @__PURE__ */ read(\"getParentOfType\")\nexport const getPath = /* @__PURE__ */ read(\"getPath\")\nexport const getPathParts = /* @__PURE__ */ read(\"getPathParts\")\nexport const getPropertyMembers = /* @__PURE__ */ read(\"getPropertyMembers\")\nexport const getRelativePath = /* @__PURE__ */ read(\"getRelativePath\")\nexport const getRoot = /* @__PURE__ */ read(\"getRoot\")\nexport const getRunningActionContext = /* @__PURE__ */ read(\"getRunningActionContext\")\nexport const getSnapshot = /* @__PURE__ */ read(\"getSnapshot\")\nexport const getType = /* @__PURE__ */ read(\"getType\")\nexport const getUnionSubtypes = /* @__PURE__ */ read(\"getUnionSubtypes\")\nexport const getWrappedType = /* @__PURE__ */ read(\"getWrappedType\")\nexport const hasParent = /* @__PURE__ */ read(\"hasParent\")\nexport const hasParentOfType = /* @__PURE__ */ read(\"hasParentOfType\")\nexport const isActionContextChildOf = /* @__PURE__ */ read(\"isActionContextChildOf\")\nexport const isActionContextThisOrChildOf = /* @__PURE__ */ read(\"isActionContextThisOrChildOf\")\nexport const isAlive = /* @__PURE__ */ read(\"isAlive\")\nexport const isArrayType = /* @__PURE__ */ read(\"isArrayType\")\nexport const isFrozenType = /* @__PURE__ */ read(\"isFrozenType\")\nexport const isIdentifierType = /* @__PURE__ */ read(\"isIdentifierType\")\nexport const isLateType = /* @__PURE__ */ read(\"isLateType\")\nexport const isLiteralType = /* @__PURE__ */ read(\"isLiteralType\")\nexport const isMapType = /* @__PURE__ */ read(\"isMapType\")\nexport const isModelType = /* @__PURE__ */ read(\"isModelType\")\nexport const isOptionalType = /* @__PURE__ */ read(\"isOptionalType\")\nexport const isPrimitiveType = /* @__PURE__ */ read(\"isPrimitiveType\")\nexport const isProtected = /* @__PURE__ */ read(\"isProtected\")\nexport const isReferenceType = /* @__PURE__ */ read(\"isReferenceType\")\nexport const isRefinementType = /* @__PURE__ */ read(\"isRefinementType\")\nexport const isRoot = /* @__PURE__ */ read(\"isRoot\")\nexport const isStateTreeNode = /* @__PURE__ */ read(\"isStateTreeNode\")\nexport const isType = /* @__PURE__ */ read(\"isType\")\nexport const isUnionType = /* @__PURE__ */ read(\"isUnionType\")\nexport const isValidReference = /* @__PURE__ */ read(\"isValidReference\")\nexport const joinJsonPath = /* @__PURE__ */ read(\"joinJsonPath\")\nexport const onAction = /* @__PURE__ */ read(\"onAction\")\nexport const onPatch = /* @__PURE__ */ read(\"onPatch\")\nexport const onSnapshot = /* @__PURE__ */ read(\"onSnapshot\")\nexport const protect = /* @__PURE__ */ read(\"protect\")\nexport const recordActions = /* @__PURE__ */ read(\"recordActions\")\nexport const recordPatches = /* @__PURE__ */ read(\"recordPatches\")\nexport const resolveIdentifier = /* @__PURE__ */ read(\"resolveIdentifier\")\nexport const resolvePath = /* @__PURE__ */ read(\"resolvePath\")\nexport const setDevMode = /* @__PURE__ */ read(\"setDevMode\")\nexport const setLivelinessChecking = /* @__PURE__ */ read(\"setLivelinessChecking\")\nexport const setLivelynessChecking = /* @__PURE__ */ read(\"setLivelynessChecking\")\nexport const setTypeChecking = /* @__PURE__ */ read(\"setTypeChecking\")\nexport const splitJsonPath = /* @__PURE__ */ read(\"splitJsonPath\")\nexport const t = /* @__PURE__ */ read(\"t\")\nexport const toGenerator = /* @__PURE__ */ read(\"toGenerator\")\nexport const toGeneratorFunction = /* @__PURE__ */ read(\"toGeneratorFunction\")\nexport const tryReference = /* @__PURE__ */ read(\"tryReference\")\nexport const tryResolve = /* @__PURE__ */ read(\"tryResolve\")\nexport const typecheck = /* @__PURE__ */ read(\"typecheck\")\nexport const types = /* @__PURE__ */ read(\"types\")\nexport const unescapeJsonPath = /* @__PURE__ */ read(\"unescapeJsonPath\")\nexport const unprotect = /* @__PURE__ */ read(\"unprotect\")\nexport const unwrapType = /* @__PURE__ */ read(\"unwrapType\")\nexport const walk = /* @__PURE__ */ read(\"walk\")\nexport default host && host.__esModule ? host.default : host"],
|
|
5
|
-
"mappings": "AAAA,IAAMA,EAAO,eAAe,iBAAiB,EACvCC,EAAOC,GACXF,GAAQ,MAAQE,KAAQ,OAAOF,CAAI,EAC/BA,EAAKE,CAAI,EACT,OAAO,OACL,UAAY,CACV,MAAM,IAAI,MACR,kCAAoCA,EAAO,iIAC7C,CACF,EACA,CAAE,mBAAoBA,CAAK,CAC7B,EACOC,EAA8BF,EAAK,aAAa,
|
|
6
|
-
"names": ["host", "read", "name", "addDisposer", "flow", "read", "getEnv", "read", "getRoot", "read", "isAlive", "read", "
|
|
4
|
+
"sourcesContent": ["const host = JBrowseExports[\"mobx-state-tree\"]\nconst read = name =>\n host != null && name in Object(host)\n ? host[name]\n : Object.assign(\n function () {\n throw new Error(\n \"This JBrowse does not provide '\" + name + \"' from '\" + \"mobx-state-tree\" + \"' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse\",\n )\n },\n { jbrowseHostMissing: name },\n )\nexport const addDisposer = /* @__PURE__ */ read(\"addDisposer\")\nexport const addMiddleware = /* @__PURE__ */ read(\"addMiddleware\")\nexport const applyAction = /* @__PURE__ */ read(\"applyAction\")\nexport const applyPatch = /* @__PURE__ */ read(\"applyPatch\")\nexport const applySnapshot = /* @__PURE__ */ read(\"applySnapshot\")\nexport const asArrayType = /* @__PURE__ */ read(\"asArrayType\")\nexport const asMapType = /* @__PURE__ */ read(\"asMapType\")\nexport const asModelType = /* @__PURE__ */ read(\"asModelType\")\nexport const cannotDetermineSubtype = /* @__PURE__ */ read(\"cannotDetermineSubtype\")\nexport const cast = /* @__PURE__ */ read(\"cast\")\nexport const castFlowReturn = /* @__PURE__ */ read(\"castFlowReturn\")\nexport const castToReferenceSnapshot = /* @__PURE__ */ read(\"castToReferenceSnapshot\")\nexport const castToSnapshot = /* @__PURE__ */ read(\"castToSnapshot\")\nexport const clone = /* @__PURE__ */ read(\"clone\")\nexport const createActionTrackingMiddleware = /* @__PURE__ */ read(\"createActionTrackingMiddleware\")\nexport const createActionTrackingMiddleware2 = /* @__PURE__ */ read(\"createActionTrackingMiddleware2\")\nexport const decorate = /* @__PURE__ */ read(\"decorate\")\nexport const destroy = /* @__PURE__ */ read(\"destroy\")\nexport const detach = /* @__PURE__ */ read(\"detach\")\nexport const escapeJsonPath = /* @__PURE__ */ read(\"escapeJsonPath\")\nexport const extendInstance = /* @__PURE__ */ read(\"extendInstance\")\nexport const findParent = /* @__PURE__ */ read(\"findParent\")\nexport const flow = /* @__PURE__ */ read(\"flow\")\nexport const getChildType = /* @__PURE__ */ read(\"getChildType\")\nexport const getEnv = /* @__PURE__ */ read(\"getEnv\")\nexport const getIdentifier = /* @__PURE__ */ read(\"getIdentifier\")\nexport const getLivelinessChecking = /* @__PURE__ */ read(\"getLivelinessChecking\")\nexport const getMembers = /* @__PURE__ */ read(\"getMembers\")\nexport const getNodeId = /* @__PURE__ */ read(\"getNodeId\")\nexport const getParent = /* @__PURE__ */ read(\"getParent\")\nexport const getParentOfType = /* @__PURE__ */ read(\"getParentOfType\")\nexport const getPath = /* @__PURE__ */ read(\"getPath\")\nexport const getPathParts = /* @__PURE__ */ read(\"getPathParts\")\nexport const getPropertyMembers = /* @__PURE__ */ read(\"getPropertyMembers\")\nexport const getRelativePath = /* @__PURE__ */ read(\"getRelativePath\")\nexport const getRoot = /* @__PURE__ */ read(\"getRoot\")\nexport const getRunningActionContext = /* @__PURE__ */ read(\"getRunningActionContext\")\nexport const getSnapshot = /* @__PURE__ */ read(\"getSnapshot\")\nexport const getType = /* @__PURE__ */ read(\"getType\")\nexport const getUnionSubtypes = /* @__PURE__ */ read(\"getUnionSubtypes\")\nexport const getWrappedType = /* @__PURE__ */ read(\"getWrappedType\")\nexport const hasParent = /* @__PURE__ */ read(\"hasParent\")\nexport const hasParentOfType = /* @__PURE__ */ read(\"hasParentOfType\")\nexport const isActionContextChildOf = /* @__PURE__ */ read(\"isActionContextChildOf\")\nexport const isActionContextThisOrChildOf = /* @__PURE__ */ read(\"isActionContextThisOrChildOf\")\nexport const isAlive = /* @__PURE__ */ read(\"isAlive\")\nexport const isArrayType = /* @__PURE__ */ read(\"isArrayType\")\nexport const isFrozenType = /* @__PURE__ */ read(\"isFrozenType\")\nexport const isIdentifierType = /* @__PURE__ */ read(\"isIdentifierType\")\nexport const isLateType = /* @__PURE__ */ read(\"isLateType\")\nexport const isLiteralType = /* @__PURE__ */ read(\"isLiteralType\")\nexport const isMapType = /* @__PURE__ */ read(\"isMapType\")\nexport const isModelType = /* @__PURE__ */ read(\"isModelType\")\nexport const isOptionalType = /* @__PURE__ */ read(\"isOptionalType\")\nexport const isPrimitiveType = /* @__PURE__ */ read(\"isPrimitiveType\")\nexport const isProtected = /* @__PURE__ */ read(\"isProtected\")\nexport const isReferenceType = /* @__PURE__ */ read(\"isReferenceType\")\nexport const isRefinementType = /* @__PURE__ */ read(\"isRefinementType\")\nexport const isRoot = /* @__PURE__ */ read(\"isRoot\")\nexport const isStateTreeNode = /* @__PURE__ */ read(\"isStateTreeNode\")\nexport const isType = /* @__PURE__ */ read(\"isType\")\nexport const isUnionType = /* @__PURE__ */ read(\"isUnionType\")\nexport const isValidReference = /* @__PURE__ */ read(\"isValidReference\")\nexport const joinJsonPath = /* @__PURE__ */ read(\"joinJsonPath\")\nexport const onAction = /* @__PURE__ */ read(\"onAction\")\nexport const onPatch = /* @__PURE__ */ read(\"onPatch\")\nexport const onSnapshot = /* @__PURE__ */ read(\"onSnapshot\")\nexport const protect = /* @__PURE__ */ read(\"protect\")\nexport const recordActions = /* @__PURE__ */ read(\"recordActions\")\nexport const recordPatches = /* @__PURE__ */ read(\"recordPatches\")\nexport const resolveIdentifier = /* @__PURE__ */ read(\"resolveIdentifier\")\nexport const resolvePath = /* @__PURE__ */ read(\"resolvePath\")\nexport const setDevMode = /* @__PURE__ */ read(\"setDevMode\")\nexport const setLivelinessChecking = /* @__PURE__ */ read(\"setLivelinessChecking\")\nexport const setLivelynessChecking = /* @__PURE__ */ read(\"setLivelynessChecking\")\nexport const setTypeChecking = /* @__PURE__ */ read(\"setTypeChecking\")\nexport const splitJsonPath = /* @__PURE__ */ read(\"splitJsonPath\")\nexport const t = /* @__PURE__ */ read(\"t\")\nexport const toGenerator = /* @__PURE__ */ read(\"toGenerator\")\nexport const toGeneratorFunction = /* @__PURE__ */ read(\"toGeneratorFunction\")\nexport const tryReference = /* @__PURE__ */ read(\"tryReference\")\nexport const tryResolve = /* @__PURE__ */ read(\"tryResolve\")\nexport const typecheck = /* @__PURE__ */ read(\"typecheck\")\nexport const types = /* @__PURE__ */ read(\"types\")\nexport const unescapeJsonPath = /* @__PURE__ */ read(\"unescapeJsonPath\")\nexport const unprotect = /* @__PURE__ */ read(\"unprotect\")\nexport const unwrapType = /* @__PURE__ */ read(\"unwrapType\")\nexport const walk = /* @__PURE__ */ read(\"walk\")\nexport default host && host.__esModule ? host.default : host"],
|
|
5
|
+
"mappings": "AAAA,IAAMA,EAAO,eAAe,iBAAiB,EACvCC,EAAOC,GACXF,GAAQ,MAAQE,KAAQ,OAAOF,CAAI,EAC/BA,EAAKE,CAAI,EACT,OAAO,OACL,UAAY,CACV,MAAM,IAAI,MACR,kCAAoCA,EAAO,iIAC7C,CACF,EACA,CAAE,mBAAoBA,CAAK,CAC7B,EACOC,EAA8BF,EAAK,aAAa,EAsBtD,IAAMG,EAAuBC,EAAK,MAAM,EAExC,IAAMC,EAAyBC,EAAK,QAAQ,EAW5C,IAAMC,EAA0BC,EAAK,SAAS,EAU9C,IAAMC,EAA0BC,EAAK,SAAS,EAsC9C,IAAMC,EAAwBC,EAAK,OAAO,EAKjD,IAAOC,EAAQC,GAAQA,EAAK,WAAaA,EAAK,QAAUA",
|
|
6
|
+
"names": ["host", "read", "name", "addDisposer", "flow", "read", "getEnv", "read", "getRoot", "read", "isAlive", "read", "types", "read", "mobx_state_tree_default", "host"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as A}from"./chunk-ROZPEXN4.js";import{a as x,d as O}from"./chunk-3VGXCEMQ.js";import{e as I}from"./chunk-IKJZPPOA.js";function G(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function oe(e){let t=x(e).slice(1);return t.length>0?t:void 0}function P(e){return e.type==="WalkTabixSyntenyAdapter"||e.type==="RgfaTabixAdapter"&&(typeof e.walksUri=="string"&&e.walksUri!==""||I(e.walksLocation))}function se(e){return e.type==="GbzBaseSyntenyAdapter"||P(e)}function ie(e){let{defaultHaplotypes:t}=e;return P(e)&&G(t)&&t.length>0?t:void 0}function ae(e){return x(e)[0]}function ce(e){return O(e).adapter}function ue(e,t){return e===void 0||e===t?void 0:`The graph is cut on its reference, ${e}: open it from a view of ${e}`}function i(e,t){return typeof e.get=="function"?e.get(t):e[t]}function T(e,t){return e.find(n=>n.trackId===t)}function g(e){return`${e.trackId} ${e.name??""}`}var U=new Set(["BedAdapter","BedTabixAdapter","BigBedAdapter","VcfAdapter","VcfTabixAdapter"]),R=/repeat|tandem|\bstr\b|vntr|trf|trgt|vamos|expansion|microsat/i;function Ze(e,t){let n=t?T(e,t):void 0;return n||e.filter(o=>U.has(o.adapterType)).find(o=>R.test(g(o)))}var D=/^\w+=[^;]*(;\w+=[^;]*)*$/;function H(e){let t=i(e,"name");if(!(typeof t!="string"||!D.test(t)))return Object.fromEntries(t.split(";").map(n=>{let r=n.indexOf("=");return[n.slice(0,r),n.slice(r+1)]}))}function d(e,t){let n=i(e,t);return n!==void 0?n:i(e,"INFO")?.[t]??H(e)?.[t]}var M=["RUS","MOTIFS","RU","motifs","motif","sequence","consensus"],v=["RUL","period","PERIOD","consensusSize","unit","unitLength"],j=["TRID","REPID","VARID","ID","name","id"];function y(e,t){for(let n of t){let r=d(e,n),o=String((Array.isArray(r)?r[0]:r)??"").split(",")[0].trim();if(o!==""&&o!==".")return o}}var B=/^[ACGTURYSWKMBDHVN]+$/i;function V(e){let t=Number(y(e,v));if(Number.isFinite(t)&&t>0)return Math.round(t);let n=y(e,M);return n&&B.test(n)?n.length:void 0}function m(e){return(Array.isArray(e)?e:String(e??"").split(",")).map(n=>{let r=n===""||n===null||n===void 0?NaN:Number(n);return Number.isFinite(r)?r:void 0})}function N(e){return(Array.isArray(e)?e:String(e??"").split(",")).map(n=>{let r=String(n??"").trim();return r===""||r==="."?void 0:r})}var w="<CNV:TR>";function W(e){let t=N(i(e,"ALT"));if(!t.includes(w))return;let n=m(d(e,"RN")),r=N(d(e,"RUS")),o=m(d(e,"RUL")),s=m(d(e,"RUC")),a=m(d(e,"RB")),c=0;return t.map((u,f)=>{let p=n[f]??(u===w?1:0),h=0,F=0;for(let S=0;S<p;S++,c++){let b=r[c],L=o[c]??(b&&B.test(b)?b.length:void 0),_=s[c],C=a[c]??(L&&_!==void 0?Math.round(L*_):void 0);C!==void 0&&(h+=C,F++)}return u===w&&p>0&&F===p?h:void 0})}function K(e,t,n){let r=e?.includes("|");return(e??"").split(/[/|]/).flatMap((o,s)=>{let a=o===""?NaN:Number(o),c=a>0?t[a-1]:n;return!Number.isInteger(a)||c===void 0?[]:[{bp:c,...r?{haplotype:s+1}:{}}]})}function q(e,t,n){let r=i(e,"samples"),o={};for(let[s,a]of Object.entries(r??{})){let c=m(a.SD),u=m(a.AL).flatMap((p,h)=>p!==void 0&&p>0?[c[h]===void 0?{bp:p}:{bp:p,spanningReads:c[h]}]:[]),f=u.length>0||!t?u:K(N(a.GT)[0],t,n);f.length>0&&(o[s]=f)}return Object.keys(o).length>0?o:void 0}function Y(e,t){let n=d(e,"start"),r=d(e,"end"),o=m(d(e,"SVLEN"))[0];return t&&o!==void 0?{start:n+1,end:n+1+o}:{start:n,end:r}}function en(e){let t=[];for(let n of e){let r=W(n),{start:o,end:s}=Y(n,r!==void 0),a=V(n);if(!(s>o)||a===void 0)continue;let c=d(n,"refName"),u=y(n,M),f=y(n,j);t.push({key:`${c}:${o}-${s}`,name:(f&&!D.test(f)?f:void 0)??(u&&u.length<=12?`(${u})n`:`${c}:${(o+1).toLocaleString("en-US")}-${s.toLocaleString("en-US")}`),refName:c,start:o,end:s,unit:a,motif:u,calls:q(n,r,s-o)})}return t.sort((n,r)=>n.start-r.start)}function k(e){let t=[];for(let n of[...e].sort((r,o)=>r.start-o.start)){let r=t.at(-1);r&&n.start<=r.end?r.end=Math.max(r.end,n.end):t.push({...n})}return t}function E(e){let t=[],n=new Map;for(let r of[...e].sort((o,s)=>o.start-s.start)){let o=`${r.refName} ${r.strand} ${r.name}`,s=n.get(o);if(s&&r.start<s.end)s.end=Math.max(s.end,r.end),s.exons=k([...s.exons,...r.exons]);else{let a={...r,exons:k(r.exons)};t.push(a),n.set(o,a)}}return t}var J=new Set(["Gff3TabixAdapter","Gff3Adapter","BedTabixAdapter","BedAdapter","GtfTabixAdapter","GtfAdapter","BigBedAdapter","NCListAdapter"]),z=/gene|refseq|gencode|ensembl|annotation/i,X=new Set(["BedTabixAdapter","BedAdapter"]);function mn(e,t){let n=t?T(e,t):void 0;if(n)return n;let r=e.filter(o=>J.has(o.adapterType)&&!R.test(g(o)));return r.find(o=>z.test(g(o)))??r.find(o=>!X.has(o.adapterType))}var Q=/\bTEs?\b|transpos/i;function ln(e){return e&&Q.test(g(e))?"TE":"gene"}function gn(e,t){let n=e.tracks?.find(r=>A(r.configuration,"trackId")===t)?.displays[0];return n?A(n.configuration,"filter")??[]:[]}var Z=new Set(["chromosome","region","contig","supercontig","scaffold"]),ee=new Set(["exon","CDS","five_prime_UTR","three_prime_UTR","UTR"]);function $(e,t){let n=i(e,"type");typeof n=="string"&&ee.has(n)&&t.push({start:i(e,"start"),end:i(e,"end")});let r=i(e,"subfeatures");for(let o of r??[])$(o,t)}function hn(e){let t=[];for(let n of e){let r=i(n,"gene_name")??i(n,"name")??i(n,"gene")??i(n,"gene_id"),o=i(n,"start"),s=i(n,"end");if(!r||!(s>o)||Z.has(i(n,"type")))continue;let a=[];$(n,a),t.push({name:r,refName:i(n,"refName"),start:o,end:s,strand:i(n,"strand")??0,exons:a.length?k(a):[{start:o,end:s}]})}return E(t)}var l=JBrowseExports["tss-react/mui"],ne=e=>l!=null&&e in Object(l)?l[e]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+e+"' from 'tss-react/mui' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:e});var Tn=ne("makeStyles"),yn=l&&l.__esModule?l.default:l;export{oe as a,P as b,se as c,ie as d,ae as e,ce as f,ue as g,U as h,Ze as i,en as j,J as k,mn as l,ln as m,gn as n,hn as o,Tn as p};
|
|
2
|
+
//# sourceMappingURL=chunk-46CNCY7Z.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/graphTrackConfig.ts", "../../src/GraphGenomeView/trackFeatures.ts", "../../src/GraphGenomeView/repeats/repeatFeatures.ts", "../../node_modules/.pnpm/@jbrowse+bandage-core@12.0.1/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-EQDQ7P4Y.js", "../../src/GraphGenomeView/genes/geneFeatures.ts", "host:tss-react/mui"],
|
|
4
|
+
"sourcesContent": ["import {\n getConfAssemblyNamesOrNone,\n toTrackConfigEntry,\n} from '@jbrowse/core/util/tracks'\n\nimport { snapshotNamesFile } from './locationName.ts'\n\nimport type { AnyTrackConfig } from '@jbrowse/core/configuration'\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(item => typeof item === 'string')\n}\n\n// The assemblies the track names after its reference, which is what core's\n// MultiWaySyntenyDisplay opens a lane-declaring source on.\nexport function trackLanes(track: AnyTrackConfig) {\n const lanes = getConfAssemblyNamesOrNone(track).slice(1)\n return lanes.length > 0 ? lanes : undefined\n}\n\n// Whether a track names a walk file, by the `walksUri` shorthand as written\n// or the location it expands to: an rGFA track may, and a\n// WalkTabixSyntenyAdapter one does\nexport function walkIndexed(adapterConfig: Record<string, unknown>) {\n return (\n adapterConfig.type === 'WalkTabixSyntenyAdapter' ||\n (adapterConfig.type === 'RgfaTabixAdapter' &&\n ((typeof adapterConfig.walksUri === 'string' &&\n adapterConfig.walksUri !== '') ||\n snapshotNamesFile(adapterConfig.walksLocation)))\n )\n}\n\n// Whether a track's cut reads `haplotypes`: a GBZ cut does, and so does an\n// rGFA one with a walk file\nexport function cutsByHaplotype(adapterConfig: Record<string, unknown>) {\n return (\n adapterConfig.type === 'GbzBaseSyntenyAdapter' || walkIndexed(adapterConfig)\n )\n}\n\n// The haplotypes a walk-indexed track's config names to cut for until the\n// user picks others\nexport function configHaplotypes(adapterConfig: Record<string, unknown>) {\n const { defaultHaplotypes } = adapterConfig\n return walkIndexed(adapterConfig) &&\n isStringArray(defaultHaplotypes) &&\n defaultHaplotypes.length > 0\n ? defaultHaplotypes\n : undefined\n}\n\n// A graph is cut on the first assembly its track names, the rule\n// GbzBaseSyntenyAdapter states for its anchor. Every other assembly the track\n// names holds its sequence as rank>0 alleles off that reference's backbone, so\n// a window on one has no reference coordinates to frame the cut by.\nexport function graphReferenceAssembly(track: AnyTrackConfig) {\n return getConfAssemblyNamesOrNone(track)[0]\n}\n\n// A track's adapter config, from a live node or a session's frozen entry\nexport function trackAdapterSnapshot(track: AnyTrackConfig) {\n return toTrackConfigEntry(track).adapter as Record<string, unknown>\n}\n\nexport function offReferenceProblem(\n referenceAssembly: string | undefined,\n assemblyName: string,\n) {\n return referenceAssembly === undefined || referenceAssembly === assemblyName\n ? undefined\n : `The graph is cut on its reference, ${referenceAssembly}: open it from a view of ${referenceAssembly}`\n}\n", "import type { Feature } from '@jbrowse/core/util'\n\nexport type FeatureLike = Feature | Record<string, unknown>\n\nexport function ownField(f: FeatureLike, name: string): unknown {\n return typeof (f as Feature).get === 'function'\n ? (f as Feature).get(name)\n : (f as Record<string, unknown>)[name]\n}\n\nexport interface TrackChoice {\n trackId: string\n name?: string\n adapterType: string\n}\n\nexport function namedTrack<T extends TrackChoice>(tracks: T[], named: string) {\n return tracks.find(t => t.trackId === named)\n}\n\n// what a track-name hint such as /repeat|tandem/ is matched against\nexport function trackLabel(t: TrackChoice) {\n return `${t.trackId} ${t.name ?? ''}`\n}\n", "import { namedTrack, ownField, trackLabel } from '../trackFeatures'\n\nimport type { FeatureLike, TrackChoice } from '../trackFeatures'\n\nexport interface RepeatCall {\n bp: number\n // TRGT's `SD`. Zero means the allele is a copy of the one the reads did\n // support, so its length states nothing about a second haplotype; absent\n // where the genotyper writes no such field.\n spanningReads?: number\n // the PanSN haplotype a phased genotype puts this allele on\n haplotype?: number\n}\n\n// A tandem repeat array as the walk rows need it: its span on the reference,\n// which is what the bars measure between, and its unit length, which is what\n// they tile by. Read off whatever repeat annotation the session has, since the\n// tools all state the same two facts under different names: VCF 4.5's\n// `<CNV:TR>` allele gives `RUL` and `RUS` (one entry per repeat sequence,\n// grouped by `RN`), UCSC simpleRepeat and TRF give `period` and the consensus\n// `sequence`, TRGT gives `MOTIFS` and `TRID`, ExpansionHunter `RU` and `REPID`,\n// HipSTR and GangSTR `PERIOD`, vamos its `motifs`. A VCF record's INFO is\n// searched as well as its top level, and a list's first entry is the unit the\n// bars tile by: for a compound array that is the first repeat sequence, which\n// is the expanding one at every such locus in the common catalogues.\nexport interface RepeatArray {\n key: string\n name: string\n refName: string\n start: number\n end: number\n unit: number\n motif?: string\n // Each sample's genotyped alleles, from a genotyper's per-sample `AL`\n // (TRGT) or a genotype over VCF 4.5 <CNV:TR> alleles; absent from a\n // catalogue.\n calls?: Record<string, RepeatCall[]>\n}\n\nexport const REPEAT_ADAPTER_TYPES = new Set([\n 'BedAdapter',\n 'BedTabixAdapter',\n 'BigBedAdapter',\n 'VcfAdapter',\n 'VcfTabixAdapter',\n])\n\nexport const REPEAT_TRACK_HINT =\n /repeat|tandem|\\bstr\\b|vntr|trf|trgt|vamos|expansion|microsat/i\n\nexport function pickRepeatTrack<T extends TrackChoice>(\n tracks: T[],\n named: string,\n) {\n const chosen = named ? namedTrack(tracks, named) : undefined\n if (chosen) {\n return chosen\n }\n const candidates = tracks.filter(t => REPEAT_ADAPTER_TYPES.has(t.adapterType))\n return candidates.find(t => REPEAT_TRACK_HINT.test(trackLabel(t)))\n}\n\n// A TRGT repeat catalogue is a BED whose name column packs the record:\n// `ID=HTT;MOTIFS=CAG,CCG;STRUC=(CAG)nCAACAG(CCG)n`. Read as fields when it\n// has that shape.\nconst PACKED_NAME = /^\\w+=[^;]*(;\\w+=[^;]*)*$/\n\nfunction packedName(f: FeatureLike) {\n const name = ownField(f, 'name')\n if (typeof name !== 'string' || !PACKED_NAME.test(name)) {\n return undefined\n }\n return Object.fromEntries(\n name.split(';').map(pair => {\n const i = pair.indexOf('=')\n return [pair.slice(0, i), pair.slice(i + 1)]\n }),\n )\n}\n\n// A field at the feature's top level, in a VCF record's INFO, or in a packed\n// name column, in that order.\nfunction field(f: FeatureLike, name: string): unknown {\n const top = ownField(f, name)\n if (top !== undefined) {\n return top\n }\n const info = ownField(f, 'INFO') as Record<string, unknown> | undefined\n return info?.[name] ?? packedName(f)?.[name]\n}\n\nconst MOTIF_FIELDS = [\n 'RUS',\n 'MOTIFS',\n 'RU',\n 'motifs',\n 'motif',\n 'sequence',\n 'consensus',\n]\nconst PERIOD_FIELDS = [\n 'RUL',\n 'period',\n 'PERIOD',\n 'consensusSize',\n 'unit',\n 'unitLength',\n]\nconst NAME_FIELDS = ['TRID', 'REPID', 'VARID', 'ID', 'name', 'id']\n\n// The first entry of a list-valued field, whether it arrived parsed or as\n// the comma-joined text a VCF INFO or a BED column holds; VCF's missing \".\"\n// counts as absent.\nfunction first(f: FeatureLike, names: string[]) {\n for (const name of names) {\n const value = field(f, name)\n const one = String((Array.isArray(value) ? value[0] : value) ?? '')\n .split(',')[0]!\n .trim()\n if (one !== '' && one !== '.') {\n return one\n }\n }\n return undefined\n}\n\nconst IUPAC = /^[ACGTURYSWKMBDHVN]+$/i\n\n// The unit in bp: a stated period, else the length of the first motif.\nexport function repeatUnitOf(f: FeatureLike) {\n const period = Number(first(f, PERIOD_FIELDS))\n if (Number.isFinite(period) && period > 0) {\n return Math.round(period)\n }\n const motif = first(f, MOTIF_FIELDS)\n return motif && IUPAC.test(motif) ? motif.length : undefined\n}\n\n// A per-sample list field, parsed or as the comma-joined text a VCF column\n// holds. A missing entry stays missing: read as 0, an absent `SD` would make\n// every allele of every genotyper that writes no such field unspanned.\nfunction numbers(value: unknown) {\n const raw: unknown[] = Array.isArray(value)\n ? value\n : String(value ?? '').split(',')\n return raw.map(one => {\n const n =\n one === '' || one === null || one === undefined ? NaN : Number(one)\n return Number.isFinite(n) ? n : undefined\n })\n}\n\nfunction strings(value: unknown) {\n const raw: unknown[] = Array.isArray(value)\n ? value\n : String(value ?? '').split(',')\n return raw.map(one => {\n const text = String(one ?? '').trim()\n return text === '' || text === '.' ? undefined : text\n })\n}\n\nconst TANDEM_REPEAT = '<CNV:TR>'\n\n// Each ALT allele's length, off VCF 4.5's flattened list-of-lists: RN says how\n// many RUS/RUL/RUC/RB entries each allele takes, and the allele's bases are\n// its runs' RB, or unit length times count where RB is missing. An allele that\n// is not <CNV:TR>, or has a run stating neither, has none.\nfunction tandemAlleleBp(f: FeatureLike) {\n const alts = strings(ownField(f, 'ALT'))\n if (!alts.includes(TANDEM_REPEAT)) {\n return undefined\n }\n const rn = numbers(field(f, 'RN'))\n const rus = strings(field(f, 'RUS'))\n const rul = numbers(field(f, 'RUL'))\n const ruc = numbers(field(f, 'RUC'))\n const rb = numbers(field(f, 'RB'))\n let k = 0\n return alts.map((alt, i) => {\n const n = rn[i] ?? (alt === TANDEM_REPEAT ? 1 : 0)\n let bp = 0\n let known = 0\n for (let j = 0; j < n; j++, k++) {\n const motif = rus[k]\n const unitLength =\n rul[k] ?? (motif && IUPAC.test(motif) ? motif.length : undefined)\n const count = ruc[k]\n const runBp =\n rb[k] ??\n (unitLength && count !== undefined\n ? Math.round(unitLength * count)\n : undefined)\n if (runBp !== undefined) {\n bp += runBp\n known++\n }\n }\n return alt === TANDEM_REPEAT && n > 0 && known === n ? bp : undefined\n })\n}\n\n// A sample's alleles through its genotype: 0 is the reference's, an index\n// past it the ALT allele's. A phased genotype's k-th allele is PanSN\n// haplotype k, the order vg deconstruct writes an assembly's haplotypes in.\nfunction genotyped(\n gt: string | undefined,\n alleleBp: (number | undefined)[],\n referenceBp: number,\n) {\n const phased = gt?.includes('|')\n return (gt ?? '').split(/[/|]/).flatMap((index, k): RepeatCall[] => {\n const i = index === '' ? NaN : Number(index)\n const bp = i > 0 ? alleleBp[i - 1] : referenceBp\n if (!Number.isInteger(i) || bp === undefined) {\n return []\n }\n return [{ bp, ...(phased ? { haplotype: k + 1 } : {}) }]\n })\n}\n\nfunction callsOf(\n f: FeatureLike,\n alleleBp: (number | undefined)[] | undefined,\n referenceBp: number,\n) {\n const samples = ownField(f, 'samples') as\n Record<string, Record<string, unknown>> | undefined\n const called: Record<string, RepeatCall[]> = {}\n for (const [sample, fields] of Object.entries(samples ?? {})) {\n const reads = numbers(fields.SD)\n const lengths = numbers(fields.AL).flatMap((bp, i) =>\n bp !== undefined && bp > 0\n ? [reads[i] === undefined ? { bp } : { bp, spanningReads: reads[i] }]\n : [],\n )\n const calls =\n lengths.length > 0 || !alleleBp\n ? lengths\n : genotyped(strings(fields.GT)[0], alleleBp, referenceBp)\n if (calls.length > 0) {\n called[sample] = calls\n }\n }\n return Object.keys(called).length > 0 ? called : undefined\n}\n\n// A <CNV:TR> record's POS is the base before the array and SVLEN the\n// reference allele's length, while a VCF feature starts at that padding base.\nfunction spanOf(f: FeatureLike, tandem: boolean) {\n const start = field(f, 'start') as number\n const end = field(f, 'end') as number\n const svlen = numbers(field(f, 'SVLEN'))[0]\n return tandem && svlen !== undefined\n ? { start: start + 1, end: start + 1 + svlen }\n : { start, end }\n}\n\nexport function repeatArraysFrom(features: FeatureLike[]): RepeatArray[] {\n const arrays: RepeatArray[] = []\n for (const f of features) {\n const alleleBp = tandemAlleleBp(f)\n const { start, end } = spanOf(f, alleleBp !== undefined)\n const unit = repeatUnitOf(f)\n if (!(end > start) || unit === undefined) {\n continue\n }\n const refName = field(f, 'refName') as string\n const motif = first(f, MOTIF_FIELDS)\n const stated = first(f, NAME_FIELDS)\n arrays.push({\n key: `${refName}:${start}-${end}`,\n name:\n (stated && !PACKED_NAME.test(stated) ? stated : undefined) ??\n (motif && motif.length <= 12\n ? `(${motif})n`\n : `${refName}:${(start + 1).toLocaleString('en-US')}-${end.toLocaleString('en-US')}`),\n refName,\n start,\n end,\n unit,\n motif,\n calls: callsOf(f, alleleBp, end - start),\n })\n }\n return arrays.sort((a, b) => a.start - b.start)\n}\n", "// src/genes/geneFiles.ts\nvar GENE_TYPE = /(gene|gene_segment|RNA|transcript)$/i;\nvar isGene = (type) => GENE_TYPE.test(type) || type === \"CDS\" || type === \"exon\";\nfunction mergedIntervals(intervals) {\n const out = [];\n for (const iv of [...intervals].sort((a, b) => a.start - b.start)) {\n const last = out.at(-1);\n if (last && iv.start <= last.end) {\n last.end = Math.max(last.end, iv.end);\n } else {\n out.push({ ...iv });\n }\n }\n return out;\n}\nfunction strandOf(s) {\n return s === \"+\" ? 1 : s === \"-\" ? -1 : 0;\n}\nfunction unescape(value) {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\nfunction attributes(column) {\n const out = /* @__PURE__ */ new Map();\n for (const pair of column.split(\";\")) {\n const eq = pair.indexOf(\"=\");\n if (eq > 0) {\n out.set(pair.slice(0, eq).trim(), unescape(pair.slice(eq + 1).trim()));\n }\n }\n return out;\n}\nfunction gff3Row(line) {\n const cols = line.split(\"\t\");\n const start = Number(cols[3]);\n const end = Number(cols[4]);\n if (cols.length < 9 || !Number.isInteger(start) || !Number.isInteger(end)) {\n return void 0;\n }\n return {\n refName: cols[0],\n type: cols[2],\n start: start - 1,\n end,\n strand: strandOf(cols[6]),\n attrs: attributes(cols[8])\n };\n}\nfunction genesFromGff3Lines(lines) {\n const rows = [];\n for (const line of lines) {\n if (line.startsWith(\"##FASTA\")) {\n break;\n }\n const row = line.startsWith(\"#\") ? void 0 : gff3Row(line);\n if (row) {\n rows.push(row);\n }\n }\n const parentOf = /* @__PURE__ */ new Map();\n for (const { attrs } of rows) {\n const id = attrs.get(\"ID\");\n const parent = attrs.get(\"Parent\")?.split(\",\")[0];\n if (id && parent) {\n parentOf.set(id, parent);\n }\n }\n const rootOf = (row) => {\n let id = row.attrs.get(\"Parent\")?.split(\",\")[0] ?? row.attrs.get(\"ID\");\n if (!id) {\n return row.attrs.get(\"gene_id\");\n }\n const seen = /* @__PURE__ */ new Set();\n while (id && parentOf.has(id) && !seen.has(id)) {\n seen.add(id);\n id = parentOf.get(id);\n }\n return id;\n };\n const groups = /* @__PURE__ */ new Map();\n rows.forEach((row, i) => {\n const root = rootOf(row) ?? `#${i}`;\n const key = `${row.refName}\t${root}`;\n const group = groups.get(key) ?? groups.set(key, { rows: [] }).get(key);\n group.rows.push(row);\n if (!row.attrs.has(\"Parent\") && !group.top) {\n group.top = row;\n }\n });\n const genes = [];\n for (const [key, { top, rows: rows2 }] of groups) {\n if (top && !isGene(top.type)) {\n continue;\n }\n const first = top ?? rows2[0];\n const start = top?.start ?? Math.min(...rows2.map((r) => r.start));\n const end = top?.end ?? Math.max(...rows2.map((r) => r.end));\n const a = first.attrs;\n const spans = (type) => rows2.filter((r) => r.type === type).map((r) => ({ start: r.start, end: r.end }));\n const exons = spans(\"exon\");\n const coding = spans(\"CDS\");\n const transcribed = rows2.some(\n (r) => r !== top && r.type !== \"exon\" && r.type !== \"CDS\"\n );\n genes.push({\n name: a.get(\"Name\") ?? a.get(\"gene_name\") ?? a.get(\"gene\") ?? a.get(\"gene_id\") ?? key.split(\"\t\")[1],\n refName: first.refName,\n start,\n end,\n strand: first.strand,\n // A range read holds only the rows over its window, so a gene with\n // transcripts but no exon or CDS there is intronic in it. Only a gene\n // with no transcripts, as a bacterium's gene and CDS, is one exon.\n exons: exons.length ? mergedIntervals(exons) : transcribed ? mergedIntervals(coding) : [{ start, end }]\n });\n }\n return genes;\n}\nfunction mergeOverlappingByName(genes) {\n const out = [];\n const open = /* @__PURE__ */ new Map();\n for (const g of [...genes].sort((a, b) => a.start - b.start)) {\n const key = `${g.refName}\t${g.strand}\t${g.name}`;\n const last = open.get(key);\n if (last && g.start < last.end) {\n last.end = Math.max(last.end, g.end);\n last.exons = mergedIntervals([...last.exons, ...g.exons]);\n } else {\n const gene = { ...g, exons: mergedIntervals(g.exons) };\n out.push(gene);\n open.set(key, gene);\n }\n }\n return out;\n}\nvar BED_HEADER = /^(#|track\\s|browser\\s)/;\nfunction genesFromBed(text) {\n const rows = [];\n for (const line of text.split(\"\\n\")) {\n const cols = line.replace(/\\r$/, \"\").split(\"\t\");\n const start = Number(cols[1]);\n const end = Number(cols[2]);\n if (BED_HEADER.test(line) || cols.length < 3 || !Number.isInteger(start) || !(end > start)) {\n continue;\n }\n const refName = cols[0];\n const name = cols[3] && cols[3] !== \".\" ? cols[3] : `${refName}:${start + 1}-${end}`;\n const sizes = cols[10]?.split(\",\").filter((s) => s !== \"\").map(Number);\n const starts = cols[11]?.split(\",\").filter((s) => s !== \"\").map(Number);\n const blocks = sizes?.length && sizes.length === starts?.length ? sizes.map((size, i) => ({\n start: start + starts[i],\n end: start + starts[i] + size\n })) : [{ start, end }];\n rows.push({\n name,\n refName,\n start,\n end,\n strand: strandOf(cols[5]),\n exons: blocks\n });\n }\n return mergeOverlappingByName(rows);\n}\nfunction sniffedFormat(text) {\n const first = text.split(\"\\n\", 1e3).find((l) => l.trim() !== \"\" && !BED_HEADER.test(l));\n const cols = first?.split(\"\t\") ?? [];\n return /^\\d+$/.test(cols[1] ?? \"\") && /^\\d+$/.test(cols[2] ?? \"\") ? \"bed\" : \"gff3\";\n}\nfunction genesFromText(text, format = sniffedFormat(text)) {\n return format === \"bed\" ? genesFromBed(text) : genesFromGff3Lines(text.split(/\\r?\\n/));\n}\n\nexport {\n mergedIntervals,\n genesFromGff3Lines,\n mergeOverlappingByName,\n genesFromBed,\n genesFromText\n};\n", "import {\n mergeOverlappingByName,\n mergedIntervals,\n} from '@jbrowse/bandage-core/genes/geneFiles'\nimport { readConfObject } from '@jbrowse/core/configuration'\n\nimport { REPEAT_TRACK_HINT } from '../repeats/repeatFeatures'\nimport { namedTrack, ownField, trackLabel } from '../trackFeatures'\n\nimport type { FeatureLike, TrackChoice } from '../trackFeatures'\nimport type { GeneModel } from '@jbrowse/bandage-core/genes/genePins'\nimport type { AnyConfigurationModel } from '@jbrowse/core/configuration'\n\n// The adapters whose tracks hold gene models, in the order the session's\n// tracks are searched when no track is named.\nexport const GENE_ADAPTER_TYPES = new Set([\n 'Gff3TabixAdapter',\n 'Gff3Adapter',\n 'BedTabixAdapter',\n 'BedAdapter',\n 'GtfTabixAdapter',\n 'GtfAdapter',\n 'BigBedAdapter',\n 'NCListAdapter',\n])\n\nconst GENE_TRACK_HINT = /gene|refseq|gencode|ensembl|annotation/i\n\n// A BED track is as often peaks or repeats as genes, so one counts only where\n// its name says it is annotation\nconst BED_ADAPTER_TYPES = new Set(['BedTabixAdapter', 'BedAdapter'])\n\n// Which of the session's tracks to read genes from: the named one while the\n// assembly has it (a saved pick can name a track since removed), else the\n// first gene-bearing track on the assembly whose name says it is annotation,\n// else the first non-BED gene-bearing track. A track whose name says repeats is\n// never picked unnamed, as \"RepeatMasker annotation\" would be.\nexport function pickGeneTrack<T extends TrackChoice>(\n tracks: T[],\n named: string,\n) {\n const chosen = named ? namedTrack(tracks, named) : undefined\n if (chosen) {\n return chosen\n }\n const candidates = tracks.filter(\n t =>\n GENE_ADAPTER_TYPES.has(t.adapterType) &&\n !REPEAT_TRACK_HINT.test(trackLabel(t)),\n )\n return (\n candidates.find(t => GENE_TRACK_HINT.test(trackLabel(t))) ??\n candidates.find(t => !BED_ADAPTER_TYPES.has(t.adapterType))\n )\n}\n\nconst TE_TRACK_HINT = /\\bTEs?\\b|transpos/i\n\n// What a walk row's boxes are, for the key: TEs where the annotation track's\n// name says so, else genes\nexport function annotationNoun(track: TrackChoice | undefined) {\n return track && TE_TRACK_HINT.test(trackLabel(track)) ? 'TE' : 'gene'\n}\n\ninterface LaneView {\n tracks?: readonly {\n configuration: AnyConfigurationModel\n displays: readonly { configuration: AnyConfigurationModel }[]\n }[]\n}\n\n// The `filter` of the gene track's lane in the view the graph is drawn in, so\n// the chips name what the lane draws. None where the view shows no such lane,\n// or has no tracks, as a graph genome view of its own.\nexport function laneFilters(view: object, trackId: string | undefined) {\n const lane = (view as LaneView).tracks?.find(\n t => readConfObject(t.configuration, 'trackId') === trackId,\n )?.displays[0]\n return lane\n ? ((readConfObject(lane.configuration, 'filter') as string[] | undefined) ??\n [])\n : []\n}\n\n// Records spanning a whole sequence, the types the GFF3 adapter declines to\n// widen a fetch for. RefSeq opens every molecule with a `region` named\n// ANONYMOUS.\nconst WHOLE_SEQUENCE_TYPES = new Set([\n 'chromosome',\n 'region',\n 'contig',\n 'supercontig',\n 'scaffold',\n])\n\n// JBrowse's BED parser splits a coding BED12 block into CDS and UTR parts and\n// keeps `exon` for non-coding ones, so all of them are exon\nconst EXON_PARTS = new Set([\n 'exon',\n 'CDS',\n 'five_prime_UTR',\n 'three_prime_UTR',\n 'UTR',\n])\n\nfunction exonsOf(f: FeatureLike, into: { start: number; end: number }[]) {\n const type = ownField(f, 'type')\n if (typeof type === 'string' && EXON_PARTS.has(type)) {\n into.push({\n start: ownField(f, 'start') as number,\n end: ownField(f, 'end') as number,\n })\n }\n const children = ownField(f, 'subfeatures') as FeatureLike[] | undefined\n for (const child of children ?? []) {\n exonsOf(child, into)\n }\n}\n\n// Genes from a track's features: every top-level feature but a whole-sequence\n// record, named by the first of gene_name, name, gene and gene_id it carries,\n// with the exons found anywhere under it merged. A feature with no exons is one exon,\n// its whole span. A BED track gives one feature per transcript, so a name's\n// overlapping features merge, while its copies down the contig stay apart.\n// UCSC's ncbiRefSeq.gff gene records carry their symbol only as gene_id. A\n// feature with none of those names is left out: its raw ID, RefSeq's\n// `id-NC_000913.3:1978503..1979270`, only restates where it is.\nexport function geneModelsFrom(features: FeatureLike[]): GeneModel[] {\n const genes: GeneModel[] = []\n for (const f of features) {\n const name =\n (ownField(f, 'gene_name') as string | undefined) ??\n (ownField(f, 'name') as string | undefined) ??\n (ownField(f, 'gene') as string | undefined) ??\n (ownField(f, 'gene_id') as string | undefined)\n const start = ownField(f, 'start') as number\n const end = ownField(f, 'end') as number\n if (\n !name ||\n !(end > start) ||\n WHOLE_SEQUENCE_TYPES.has(ownField(f, 'type') as string)\n ) {\n continue\n }\n const exons: { start: number; end: number }[] = []\n exonsOf(f, exons)\n genes.push({\n name,\n refName: ownField(f, 'refName') as string,\n start,\n end,\n strand: (ownField(f, 'strand') as number | undefined) ?? 0,\n exons: exons.length ? mergedIntervals(exons) : [{ start, end }],\n })\n }\n return mergeOverlappingByName(genes)\n}\n", "const host = JBrowseExports[\"tss-react/mui\"]\nconst read = name =>\n host != null && name in Object(host)\n ? host[name]\n : Object.assign(\n function () {\n throw new Error(\n \"This JBrowse does not provide '\" + name + \"' from '\" + \"tss-react/mui\" + \"' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse\",\n )\n },\n { jbrowseHostMissing: name },\n )\nexport const cx = /* @__PURE__ */ read(\"cx\")\nexport const keyframes = /* @__PURE__ */ read(\"keyframes\")\nexport const makeStyles = /* @__PURE__ */ read(\"makeStyles\")\nexport default host && host.__esModule ? host.default : host"],
|
|
5
|
+
"mappings": "+HASA,SAASA,EAAcC,EAAmC,CACxD,OAAO,MAAM,QAAQA,CAAK,GAAKA,EAAM,MAAMC,GAAQ,OAAOA,GAAS,QAAQ,CAC7E,CAIO,SAASC,GAAWC,EAAuB,CAChD,IAAMC,EAAQC,EAA2BF,CAAK,EAAE,MAAM,CAAC,EACvD,OAAOC,EAAM,OAAS,EAAIA,EAAQ,MACpC,CAKO,SAASE,EAAYC,EAAwC,CAClE,OACEA,EAAc,OAAS,2BACtBA,EAAc,OAAS,qBACpB,OAAOA,EAAc,UAAa,UAClCA,EAAc,WAAa,IAC3BC,EAAkBD,EAAc,aAAa,EAErD,CAIO,SAASE,GAAgBF,EAAwC,CACtE,OACEA,EAAc,OAAS,yBAA2BD,EAAYC,CAAa,CAE/E,CAIO,SAASG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,IACRb,EAAqB,IAAIM,EAASH,EAAG,MAAM,CAAW,EAEtD,SAEF,IAAMY,EAA0C,CAAC,EACjDb,EAAQC,EAAGY,CAAK,EAChBJ,EAAM,KAAK,CACT,KAAAC,EACA,QAASN,EAASH,EAAG,SAAS,EAC9B,MAAAU,EACA,IAAAC,EACA,OAASR,EAASH,EAAG,QAAQ,GAA4B,EACzD,MAAOY,EAAM,OAASC,EAAgBD,CAAK,EAAI,CAAC,CAAE,MAAAF,EAAO,IAAAC,CAAI,CAAC,CAChE,CAAC,CACH,CACA,OAAOG,EAAuBN,CAAK,CACrC,CC5JA,IAAMO,EAAO,eAAe,eAAe,EACrCC,GAAOC,GACXF,GAAQ,MAAQE,KAAQ,OAAOF,CAAI,EAC/BA,EAAKE,CAAI,EACT,OAAO,OACL,UAAY,CACV,MAAM,IAAI,MACR,kCAAoCA,EAAO,+HAC7C,CACF,EACA,CAAE,mBAAoBA,CAAK,CAC7B,EAGC,IAAMC,GAA6BC,GAAK,YAAY,EACpDC,GAAQC,GAAQA,EAAK,WAAaA,EAAK,QAAUA",
|
|
6
|
+
"names": ["isStringArray", "value", "item", "trackLanes", "track", "lanes", "getConfAssemblyNamesOrNone", "walkIndexed", "adapterConfig", "snapshotNamesFile", "cutsByHaplotype", "configHaplotypes", "defaultHaplotypes", "graphReferenceAssembly", "trackAdapterSnapshot", "toTrackConfigEntry", "offReferenceProblem", "referenceAssembly", "assemblyName", "ownField", "f", "name", "namedTrack", "tracks", "named", "t", "trackLabel", "REPEAT_ADAPTER_TYPES", "REPEAT_TRACK_HINT", "pickRepeatTrack", "tracks", "named", "chosen", "namedTrack", "t", "trackLabel", "PACKED_NAME", "packedName", "f", "name", "ownField", "pair", "i", "field", "top", "MOTIF_FIELDS", "PERIOD_FIELDS", "NAME_FIELDS", "first", "names", "value", "one", "IUPAC", "repeatUnitOf", "period", "motif", "numbers", "n", "strings", "text", "TANDEM_REPEAT", "tandemAlleleBp", "alts", "rn", "rus", "rul", "ruc", "rb", "k", "alt", "bp", "known", "j", "unitLength", "count", "runBp", "genotyped", "gt", "alleleBp", "referenceBp", "phased", "index", "callsOf", "samples", "called", "sample", "fields", "reads", "lengths", "calls", "spanOf", "tandem", "start", "end", "svlen", "repeatArraysFrom", "features", "arrays", "unit", "refName", "stated", "a", "b", "mergedIntervals", "intervals", "out", "iv", "a", "b", "last", "mergeOverlappingByName", "genes", "out", "open", "g", "a", "b", "key", "last", "mergedIntervals", "gene", "GENE_ADAPTER_TYPES", "GENE_TRACK_HINT", "BED_ADAPTER_TYPES", "pickGeneTrack", "tracks", "named", "chosen", "namedTrack", "candidates", "t", "REPEAT_TRACK_HINT", "trackLabel", "TE_TRACK_HINT", "annotationNoun", "track", "laneFilters", "view", "trackId", "lane", "readConfObject", "WHOLE_SEQUENCE_TYPES", "EXON_PARTS", "exonsOf", "f", "into", "type", "ownField", "children", "child", "geneModelsFrom", "features", "genes", "name", "start", "end", "exons", "mergedIntervals", "mergeOverlappingByName", "host", "read", "name", "makeStyles", "read", "mui_default", "host"]
|
|
7
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as ce,b as N,c as Ee,d as Q,e as ee,f as Ft,g as Ue,h as We,i as qt,j as zt,k as He,l as Oe,m as Pe,n as Dt,o as jt,p as Ut,q as Wt,r as Vt}from"./chunk-M2D7NUOY.js";import{a as _t,g as Tt}from"./chunk-PT3WV5ED.js";import{c as Ot}from"./chunk-LIRBZOBX.js";import{a as Ct,g as Bt}from"./chunk-ODQSCM3F.js";var Ln=4096;function pt(a){let e=[];for(let t of a){let n=e[e.length-1];n&&t-n[1]<=Ln?n[1]=t:e.push([t,t])}return e}var Hn=32768,Gt={mostChosenPaths:32},lt=class{byNode=new Map;get(e){return this.byNode.get(e.node)?.get(e.offset)}set(e,t){let n=this.byNode.get(e.node);n||(n=new Map,this.byNode.set(e.node,n)),n.set(e.offset,t)}},re=class extends Error{};function Ve(a,e,t,n){return a==="forward"?e+t:e-n}function Qt(a,e,t,n){return a==="forward"?e-n:e+t}function Kt(a){return Pe(ee(a.handles[a.handles.length-1]),ee(a.handles[0]))}function Ce(a){return`${a.pathHandle}:${a.hapStart}:${a.hapEnd}`}async function Zt(a){let{db:e,records:t,signal:n}=a,s=performance.now(),o=()=>{let w=performance.now(),S=w-s;return s=w,S},r={spacing:await e.haplotypeAnchorSpacing(),anchors:void 0,anchorsRead:0,chosenPaths:0,scans:[],scanRows:0,strays:void 0,pieces:0,sources:{reference:0,section:0,stray:0,chain:0,twin:0},walks:{},twins:{tried:0,found:0},graphFetches:0,fallback:void 0,ms:{scan:0,walks:0,check:0,twins:0}},i=(w,S)=>{let A=`${w}: ${S}`;r.walks[A]=(r.walks[A]??0)+1},h=await e.haplotypeSampleInterval()??4096,c=new Map,d=async w=>{let S=t.get(w)??c.get(w);if(S)return S;let A=await e.getRecord(w);if(r.graphFetches+=1,!A)throw new Error(`Node record ${w} is missing from the database`);return c.set(w,A),A},f=w=>t.get(w).sequenceLen,p=await e.pathsByHandle(),y=w=>{let S=p.get(w);return S!==void 0&&a.keep(S.name)},g=[],l=new lt,b=new Map,x=new Set,P=new Set,E=async w=>{let S=(await d(w.node)).gbwt().lf(w.offset);return S===void 0||S.node===0?void 0:S},R=async(w,S)=>{let A=(await d(ee(w.node))).gbwt().predecessorAt(w.offset);if(A===void 0||S!==void 0&&!S.has(A))return;let M=(await d(A)).gbwt().offsetTo(w);if(M===void 0)throw new Error(`No offset in ${A} leads to ${w.node}:${w.offset}`);return{node:A,offset:M}},m=(w,S,A,M)=>{let B=A.map(W=>W.pos.node),U=A.map(W=>W.pos.offset),J=0;for(let W of B)J+=f(W);let O=S==="forward"?A[0].left:A[A.length-1].left,L=g.length;g.push({pathHandle:w,orientation:S,handles:B,offsets:U,len:J,hapStart:O,hapEnd:O+J,canonical:Pe(B[0],B[B.length-1]),source:M});for(let W of A)l.set(W.pos,L);let G=b.get(w);return G?G.push(L):b.set(w,[L]),L},I=async(w,S,A,M)=>{let B=[],U=w;for(;;){n?.throwIfAborted();let O=await R(U.pos,t);if(!O)break;U={pos:O,left:Qt(A,U.left,f(U.pos.node),f(O.node))},B.push(U)}B.reverse();let J=[w];for(U=w;;){n?.throwIfAborted();let O=await E(U.pos);if(!O||!t.has(O.node))break;U={pos:O,left:Ve(A,U.left,f(U.pos.node),f(O.node))},J.push(U)}return m(S,A,[...B,...J],M)},$=async(w,S,A,M)=>g[l.get(w.pos)??await I(w,S,A,M)],F=w=>{let S=w.handles[w.handles.length-1];return{pos:{node:S,offset:w.offsets[w.offsets.length-1]},left:w.orientation==="forward"?w.hapEnd-f(S):w.hapStart}},_=w=>{let S=w.handles[0];return{pos:{node:S,offset:w.offsets[0]},left:w.orientation==="forward"?w.hapStart:w.hapEnd-f(S)}},D=await I({pos:a.referencePos,left:a.referenceLeft},a.referenceHandle,"forward","reference"),C=g[D],H=()=>{if(r.fallback!==void 0)return{reference:C,pieces:[],stats:r};let w=new Map;g.forEach((A,M)=>{M!==D&&w.set(Ce(A),[...w.get(Ce(A))??[],A])});let S=[];for(let A of w.values()){let M=new Set;for(let B of A)B.canonical&&!M.has(B.orientation)&&(M.add(B.orientation),S.push(B),r.sources[B.source]+=1)}return r.sources.reference=1,r.pieces=S.length+1,{reference:C,pieces:S,stats:r}},k=async(w,S)=>{let A=S?x:P,M=S?P:x,B=w;for(;;){if(A.has(B))return;A.add(B);let U=g[B],J=S?F(U):_(U),O=0,L;for(;L===void 0;){n?.throwIfAborted();let G=S?await E(J.pos):await R(J.pos);if(!G){L="endmarker";break}let W=(await d(J.pos.node)).sequenceLen,ue=(await d(G.node)).sequenceLen,se=S?Ve(U.orientation,J.left,W,ue):Qt(U.orientation,J.left,W,ue);if(t.has(G.node)){let Y=l.get(G);Y===void 0?(B=await I({pos:G,left:se},U.pathHandle,U.orientation,"chain"),M.add(B),L="landed"):(M.add(Y),L="merge")}else O>Hn?L="bound":(O+=ue,J={pos:G,left:se})}if(i("chain",L),L!=="landed")return}},j=async w=>{if(a.context>w.context)throw new re(`the context of ${a.context} bp exceeds the ${w.context} bp the haplotype index's stray rows cover`);let S=r.spacing;if(S===void 0)throw new re("the haplotype index has no anchors");let{bin:A,bound:M}=w,{fills:B,inserted:U}=a.snarls;if(a.snarls.mode==="overlapping"&&B.length>0)throw new re("the haplotype index's stray rows cover contained snarls only");for(let u of B){if(u.inserted>0&&u.low===u.high)throw new re(`the haplotype index's stray rows leave out the snarl bounded by node ${u.low} at both ends`);if(u.inserted>0&&(w.snarlNodes===void 0||u.nodes>w.snarlNodes))throw new re(w.snarlNodes===void 0?"the haplotype index's stray rows leave snarls out":`a snarl of ${u.nodes} nodes exceeds the ${w.snarlNodes} the haplotype index's stray rows cover`)}let J=Math.floor(a.window.start/A),O=Math.floor((a.window.end-1)/A),L=J*A,G=(O+1)*A,W=new Map,ue=async(u,v)=>{let z=await e.haplotypeAnchorsBetween(a.referenceHandle,u*S,v*S);for(let T of z)W.set(T.anchorOffset/S,T)},se=Math.max(0,Math.floor((L-M)/S)-1),Y=Math.ceil((G+M)/S)+1,[{listed:De,strays:ae}]=await Promise.all([e.haplotypeBinData(a.referenceHandle,J,O),ue(se,Y)]);for(let u of t.keys()){let v=N(u);if(!Q(u)&&!De(v)&&!U.has(v))throw new re(`the haplotype index lists node ${v} of the subgraph in no bin that the window touches`)}r.scans=pt([...t.keys()].sort((u,v)=>u-v));let ie=Promise.all(r.scans.map(([u,v])=>e.haplotypeSamplesInRange(u,v)));for(ie.catch(()=>{});se>0&&(W.get(se)?.pathOffset??Number.POSITIVE_INFINITY)>=L-M;)se-=1,await ue(se,se);for(;W.has(Y)&&W.get(Y).pathOffset<=G+M;)Y+=1,await ue(Y,Y);let pe=[...W.keys()].sort((u,v)=>u-v),ye=W.get(pe[0]??-1);if(!ye)throw new re("the haplotype index has no anchors on this path");let he=u=>W.get(u).pathOffset,Ne=new Map;for(let u of pe){let v=N(W.get(u).node);Ne.set(v,[...Ne.get(v)??[],u])}let ct=[...Ne.keys()],Et=ct.map(u=>W.get(Ne.get(u)[0]).visits);if(!Et[ct.indexOf(N(ye.node))].some(u=>u.pathHandle===a.referenceHandle&&u.orientation==="forward"&&u.pathOffset===ye.pathOffset))throw new Error(`The haplotype index has no anchor row for the reference path ${a.referenceHandle} at offset ${ye.pathOffset} (node ${N(ye.node)}); it does not match this graph`);let kt=pe.filter(u=>he(u)<=a.window.start),$n=pe.filter(u=>he(u)>=a.window.end);r.anchors=[he(kt[kt.length-1]??pe[0]),he($n[0]??pe[pe.length-1])],r.anchorsRead=pe.length;let dt=new Map,vt=new Set;if(ct.forEach((u,v)=>{let z=Ne.get(u),T=z.length===1?z[0]:void 0;for(let q of Et[v])vt.add(q.pathHandle),q.orientation==="forward"&&y(q.pathHandle)&&dt.set(q.pathHandle,[...dt.get(q.pathHandle)??[],{k:T,row:q}])}),r.chosenPaths=[...vt].filter(y).length,r.chosenPaths>Gt.mostChosenPaths)throw new re(`${r.chosenPaths} chosen paths pass the anchors, more than ${Gt.mostChosenPaths}`);let je=[],Ie=Number.POSITIVE_INFINITY,be=0;for(let[u,v]of dt){v.sort((z,T)=>z.row.pathOffset-T.row.pathOffset);for(let z=0;z+1<v.length;z++){let T=v[z],q=v[z+1];if(T.k===void 0||q.k===void 0||Math.abs(T.k-q.k)!==1)continue;let[Z,te]=he(T.k)<=he(q.k)?[T,q]:[q,T],ne=he(Z.k),oe=he(te.k);ne<G&&oe>=L?(je.push({pathHandle:u,from:T.row,to:q.row}),Ie=Math.min(Ie,ne-M),be=Math.max(be,oe+M)):ne>=G&&ne-G<=M?(je.push({pathHandle:u,from:Z.row,to:void 0}),Ie=Math.min(Ie,ne-M),be=Math.max(be,ne+M)):oe<L&&L-oe<=M&&(je.push({pathHandle:u,from:te.row,to:void 0}),Ie=Math.min(Ie,oe-M),be=Math.max(be,oe+M))}}let Rn=new Set(B.map(u=>`${u.low}:${u.high}`)),Nn=ae.filter(u=>y(u.pathHandle)&&(u.snarl===void 0||Rn.has(`${u.snarl[0]}:${u.snarl[1]}`))).sort((u,v)=>u.pathHandle-v.pathHandle||u.pathStart-v.pathStart);r.strays={bins:O-J+1,rows:ae.length,walked:0,outsideBp:0},be>0&&await a.prefetchReferenceRange(a.referenceHandle,Math.max(0,Ie),be+1),r.ms.scan=o();let Pt=8*S+2*(a.window.end-a.window.start),At=r.strays,Me=0,$t=u=>{if(At.outsideBp+=u,Me+=u,Me>Pt)throw new re(`a walk of a chosen path near the window went past its cap of ${Pt} bp`)},ft=new Map,Rt=(u,v,z)=>(ft.get(u)??[]).some(([T,q])=>T<=v&&z<q),Nt=(u,v,z)=>{ft.set(u,[...ft.get(u)??[],[v,z]])},Mt=async(u,v,z,T,q)=>{let Z=v,te=z,ne=te;for(;Z&&te<=T;){n?.throwIfAborted();let oe;if(t.has(Z.node)){let Le=await $({pos:Z,left:te},u,"forward",q),Ht=F(Le);Z=Ht.pos,te=Ht.left,oe=f(Z.node),ne=Math.max(ne,Le.hapEnd)}else oe=(await d(Z.node)).sequenceLen,$t(oe),ne=Math.max(ne,te+oe);Z=await E(Z),te+=oe}return ne},Mn=async(u,v,z,T)=>{let q={pos:v,left:z},Z=z;for(;q.left>T;){n?.throwIfAborted();let te=await R(q.pos);if(!te)break;let ne=(await d(te.node)).sequenceLen,oe=q.left-ne;if(t.has(te.node)){let Le=await $({pos:te,left:oe},u,"forward","section");q=_(Le),Z=Math.min(Z,Le.hapStart)}else $t(ne),q={pos:te,left:oe},Z=Math.min(Z,oe)}return Z};for(let{pathHandle:u,from:v,to:z}of je){let T=v.pathOffset,q=(z??v).pathOffset+M;if(Rt(u,T-M,q))continue;let Z={node:v.node,offset:v.offset};Me=0;let te=await Mt(u,Z,T,q,"section");Me=0;let ne=await Mn(u,Z,T,T-M);Nt(u,Math.min(ne,T-M),Math.max(te,q+1)),i(z?"section":"visit",z?"past the far anchor":"bound")}for(let u of Nn){if(Rt(u.pathHandle,u.pathStart,u.pathEnd))continue;Me=0;let v=await Mt(u.pathHandle,{node:u.node,offset:u.offset},u.pathStart,u.pathEnd,"stray");Nt(u.pathHandle,u.pathStart,Math.max(v,u.pathEnd+1)),At.walked+=1}r.ms.walks=o();let Lt=[];for(let u of await ie)for(let v of u)if(r.scanRows+=1,t.has(v.node)&&y(v.pathHandle)){if(!(b.get(v.pathHandle)??[]).some(z=>{let T=g[z];return T.hapStart<=v.pathOffset&&v.pathOffset<T.hapEnd}))throw new re(`chosen path ${v.pathHandle} has a sample at ${v.pathOffset} on the window's nodes that no walk reached`);v.orientation==="reverse"&&Lt.push(v)}for(let u of Lt)await $({pos:{node:u.node,offset:u.offset},left:u.pathOffset},u.pathHandle,"reverse","twin");r.ms.check=o()},X=async()=>{let w=new Map,S=O=>{let L=Ce(O),G=w.get(L);G?G.add(O.orientation):w.set(L,new Set([O.orientation]))},A=0,M=()=>{for(;A<g.length;A++)S(g[A])};M();let B=O=>(w.get(Ce(O))?.size??0)>1,U=2*h,J=(O,L)=>L===D?y(a.referenceHandle)&&Kt(O):!O.canonical||Kt(O);for(let O=0;O<g.length;O++){let L=g[O];if(B(L)||!J(L,O))continue;r.twins.tried+=1;let G=L.orientation==="forward"?"reverse":"forward",W=F(L),ue=0,se;for(;!se&&ue<=U;){n?.throwIfAborted();let ae=await E(W.pos);if(!ae)break;let ie=(await d(ae.node)).sequenceLen,pe=Ve(L.orientation,W.left,(await d(W.pos.node)).sequenceLen,ie),ye=ee(ae.node);se=(await e.haplotypeSamplesInRange(ye,ye)).find(he=>he.pathHandle===L.pathHandle&&he.orientation===G&&he.pathOffset===pe),ue+=ie,W={pos:ae,left:pe}}let Y=se&&{pos:{node:se.node,offset:se.offset},left:se.pathOffset},De=0;for(;Y&&!B(L)&&De<=U+L.len;){if(n?.throwIfAborted(),t.has(Y.pos.node)){let ae=await $(Y,L.pathHandle,G,"twin"),ie=g.indexOf(ae);await k(ie,!0),await k(ie,!1),M(),Y=F(ae)}if(!B(L)){let ae=(await d(Y.pos.node)).sequenceLen;De+=ae;let ie=await E(Y.pos);Y=ie?{pos:ie,left:Ve(G,Y.left,ae,(await d(ie.node)).sequenceLen)}:void 0}}if(M(),!B(L))throw new re(`piece ${Ce(L)} was found in one orientation where extractPaths keeps the other`);r.twins.found+=1}r.ms.twins=o()};try{let w=await e.haplotypeStrayOptions();if(w===void 0)throw new re("the haplotype index has no stray rows; gbz-haplotype-index 0.2.0 writes them");await j(w),await X()}catch(w){if(!(w instanceof re))throw w;r.fallback=w.message}return H()}function Xt(a,e){return a.handles[0]-e.handles[0]||a.offsets[0]-e.offsets[0]}var On=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),we=(a,e)=>a>>>e|a<<32-e;function Jt(a){let e=Math.ceil((a.length+9)/64),t=new Uint8Array(e*64);t.set(a),t[a.length]=128;let n=new DataView(t.buffer),s=a.length*8;n.setUint32(t.length-8,Math.floor(s/2**32)),n.setUint32(t.length-4,s>>>0);let o=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),r=new Uint32Array(64);for(let c=0;c<e;c++){for(let P=0;P<16;P++)r[P]=n.getUint32(c*64+P*4);for(let P=16;P<64;P++){let E=r[P-15],R=r[P-2],m=we(E,7)^we(E,18)^E>>>3,I=we(R,17)^we(R,19)^R>>>10;r[P]=r[P-16]+m+r[P-7]+I}let d=o[0],f=o[1],p=o[2],y=o[3],g=o[4],l=o[5],b=o[6],x=o[7];for(let P=0;P<64;P++){let E=we(g,6)^we(g,11)^we(g,25),R=g&l^~g&b,m=x+E+R+On[P]+r[P]|0,I=we(d,2)^we(d,13)^we(d,22),$=d&f^d&p^f&p;x=b,b=l,l=g,g=y+m|0,y=p,p=f,f=d,d=m+I+$|0}[d,f,p,y,g,l,b,x].forEach((P,E)=>{o[E]=o[E]+P})}let i=new Uint8Array(32),h=new DataView(i.buffer);for(let c=0;c<8;c++)h.setUint32(c*4,o[c]);return i}function Yt(a,e){let t=new Map;if(a!==void 0)for(let n of a.split(";")){let s=n.split(","),[o,r]=s;if(s.length!==2||!o||!r)throw new Error(`Invalid ${e} relationship: ${n}`);let i=t.get(o);i||(i=new Set,t.set(o,i)),i.add(r)}return t}function nn(a){return{name:a.get("pggname"),subgraph:Yt(a.get("subgraph"),"subgraph"),translation:Yt(a.get("translation"),"translation")}}function en(a,e){for(let[t,n]of e){let s=a.get(t);s||(s=new Set,a.set(t,s));for(let o of n)s.add(o)}}function sn(a,e){let t={name:a,subgraph:new Map,translation:new Map};return e.name!==void 0&&(t.subgraph.set(a,new Set([e.name])),en(t.subgraph,e.subgraph),en(t.translation,e.translation)),t}function tn(a){return[...a.entries()].sort(([e],[t])=>e<t?-1:e>t?1:0).flatMap(([e,t])=>[...t].sort().map(n=>[e,n]))}function on(a){let e=[];a.name!==void 0&&e.push(`H NM:Z:${a.name}`);for(let[t,n]of tn(a.subgraph))e.push(`H SG:Z:${t},${n}`);for(let[t,n]of tn(a.translation))e.push(`H TL:Z:${t},${n}`);return e}async function rn(a){let e=a.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e),n=0;for(let r of a)t.set(r,n),n+=r.length;let s=globalThis.crypto?.subtle;return[...s?new Uint8Array(await s.digest("SHA-256",t)):Jt(t)].map(r=>r.toString(16).padStart(2,"0")).join("")}var Cn="_gbwt_ref";function fe(a){let e=`${a.sample}#${a.haplotype}#${a.contig}`;return a.end===void 0?e:`${e}[${a.fragment}-${a.end}]`}var Bn=/^([^#]+)#(\d+)#([^#]+?)(?:\[\d+-\d+\])?$/,_n=/^([^#]+?)(?:\[\d+-\d+\])?$/;function Tn(a){let e=Bn.exec(a);if(e)return{sample:e[1],haplotype:Number(e[2]),contig:e[3]};let t=_n.exec(a);if(t)return{contig:t[1]};throw new Error(`"${a}" is not a path name; expected "sample#haplotype#contig" or a bare contig`)}function Ae(a){return typeof a=="string"?Tn(a):a}function $e(a,e){return{sample:a.sample??Cn,contig:a.contig,haplotype:a.haplotype??0,fragment:e}}var le=class extends Error{name="SubgraphLimitError";limit;windowBp;walkedBp;constructor(e,t){super(t===void 0?`Subgraph size limit of ${e} nodes exceeded`:`Subgraph size limit of ${e} nodes exceeded ${t.walkedBp} bp into a ${t.windowBp} bp window`),this.limit=e,this.windowBp=t?.windowBp,this.walkedBp=t?.walkedBp}};function ut(a,e){return a[0]<e[0]||a[0]===e[0]&&(a[1]<e[1]||a[1]===e[1]&&a[2]<e[2])}var _e=class{heap=[];push(e,t,n){let s=this.heap;s.push([e,t,n]);let o=s.length-1;for(;o>0;){let r=o-1>>1;if(ut(s[o],s[r]))[s[o],s[r]]=[s[r],s[o]],o=r;else break}}pop(){let e=this.heap,t=e[0],n=e.pop();if(e.length>0&&n!==void 0){e[0]=n;let s=0;for(;;){let o=2*s+1,r=o+1,i=s;if(o<e.length&&ut(e[o],e[i])&&(i=o),r<e.length&&ut(e[r],e[i])&&(i=r),i===s)break;[e[s],e[i]]=[e[i],e[s]],s=i}}return t}get size(){return this.heap.length}};function Fn(a){let e=new Int32Array(a.length),t=new Int32Array(a.length);return a.forEach(([n,s],o)=>{e[o]=n,t[o]=s}),{pathAt:e,refAt:t,count:a.length}}function qn(a,e){let t=0,n=a.length;for(;t<n;){let s=t+n>>1;a[s]>e?n=s:t=s+1}return a[t]}function ke(a){return`${a.node}:${a.offset}`}function Be(a){return a.map(e=>ee(e)).reverse()}function zn(a,e){let t=e.identity.hapStart-a.identity.hapEnd,n=a.strand==="+"?e.refStart-a.refEnd:a.refStart-e.refEnd;return a.strand===e.strand&&t>=0&&n>=0?{insertion:t,deletion:n}:void 0}function Dn(a,e,t){let[n,s]=a.strand==="+"?[a,e]:[e,a],o=n.edits.map(([c,d])=>[c,d]);hn(o,t.insertion,t.deletion);for(let[c,d]of s.edits)K(o,c,d);let r=a.identity.walkForward,[i,h]=r?[a,e]:[e,a];return{strand:a.strand,refStart:n.refStart,refEnd:s.refEnd,edits:o,weight:void 0,path:[...i.path,...h.path],start:i.start,pieces:[...i.pieces,...h.pieces],soloAligned:[...i.soloAligned,...h.soloAligned],identity:{pathHandle:a.identity.pathHandle,name:a.identity.name,hapStart:a.identity.hapStart,hapEnd:e.identity.hapEnd,walkForward:r}}}function jn(a,e,t){if(a.some(r=>r.weight!==void 0))return a;let n=new Map;a.forEach((r,i)=>{if(r.identity){let h=n.get(r.identity.pathHandle);h?h.push(i):n.set(r.identity.pathHandle,[i])}});let s=new Map,o=new Set;for(let r of n.values()){r.sort((d,f)=>a[d].identity.hapStart-a[f].identity.hapStart);let i=r[0],h=a[i],c=[];for(let d of r.slice(1)){let f=a[d],p=c.length===0?zn(h,f):void 0;if(p){h=Dn(h,f,p),o.add(d);continue}if(!e(f)){c.push(d);continue}let y=e(h)?t([h,...c.map(g=>a[g]),f]):void 0;if(y){h=y;for(let g of[...c,d])o.add(g)}else s.set(i,h),i=d,h=f;c=[]}s.set(i,h)}return a.flatMap((r,i)=>o.has(i)?[]:[s.get(i)??r])}function Ge(a,e){return{node:a.path[e],offset:a.offsets[e]}}var Un=32768;function Wn(a){let e=[...a].sort((n,s)=>n-s),t=[];for(let n of e){let s=t[t.length-1];s&&n-s[1]<=Un?s[1]=n:t.push([n,n])}return t}var Te=class a{records=new Map;paths=[];twinStarts=new Set;twinDeferred=!1;unsettled;refId;refPath;refHandle;refInterval;refIndexCache;refPrefixCache;walkedBp;snarlMode="none";snarlFills=[];snarlNodes=new Set;stats={orderedAlignments:0,lcsAlignments:0,snarls:{fills:0,inserted:0},identificationSteps:0,identificationFetches:0,identification:{interval:0,scans:[],windowSamples:0,fragmentLengths:[],companionSeeks:0,companionMisses:0,graphLookups:0,graphFetches:0,chains:[]},keep:void 0};db;limit;signal;constructor(e,t){this.db=e,this.limit=t.limit,this.signal=t.signal}static create(e,t={}){return new a(e,t)}get nodeCount(){return this.records.size/2}get pathCount(){return this.settleDeferred(),this.paths.length}get referenceInterval(){return this.refInterval&&this.refPath?{name:this.refPath,start:this.refPath.fragment+this.refInterval[0],end:this.refPath.fragment+this.refInterval[1]}:void 0}hasNode(e){return this.records.has(ce(e,"forward"))}hasHandle(e){return this.records.has(e)}record(e){let t=this.records.get(e);if(!t)throw new Error(`Subgraph has no record for handle ${e}`);return t}sortedHandles(){return[...this.records.keys()].sort((e,t)=>e-t)}async addNode(e){if(this.signal?.throwIfAborted(),this.limit!==void 0&&this.nodeCount>=this.limit)throw new le(this.limit);let t=await this.db.getRecord(ce(e,"forward")),n=await this.db.getRecord(ce(e,"reverse"));if(!t||!n)throw new Error(`Node ${e} does not exist in the graph`);this.records.set(t.handle,t),this.records.set(n.handle,n)}async ensureNode(e){this.hasNode(e)||await this.addNode(e)}clearPaths(){this.paths=[],this.twinStarts.clear(),this.twinDeferred=!1,this.unsettled=void 0,this.refId=void 0,this.refPath=void 0,this.refHandle=void 0,this.refInterval=void 0,this.refIndexCache=void 0,this.refPrefixCache=void 0}async pathPosition(e){let t=await this.db.findPath(e);if(!t)throw new Error(`Cannot find a path covering offset ${e.fragment} of ${fe(e)}`);if(!t.isIndexed)throw new Error(`The fragment of ${fe(t.name)} at ${t.name.fragment} has not been indexed for random access`);let n=e.fragment-t.name.fragment,s=await this.db.indexedPosition(t.handle,n);if(!s)throw new Error(`The fragment of ${fe(t.name)} at ${t.name.fragment} has not been indexed for random access`);return this.findPathPosition(t,n,s.pathOffset,s.pos)}async findPathPosition(e,t,n,s){let o=n,r=s;for(;;){await this.ensureNode(N(r.node));let i=this.record(r.node);if(o+i.sequenceLen>t)return{position:{seqOffset:t,handle:r.node,nodeOffset:t-o,gbwtOffset:r.offset},name:e.name,handle:e.handle};o+=i.sequenceLen;let h=i.gbwt().lf(r.offset);if(!h)throw new Error(`The fragment of ${fe(e.name)} at ${e.name.fragment} does not contain offset ${t}`);r=h}}async aroundPosition(e,t,n){let s=N(e);await this.ensureNode(s);let o=this.record(e),r=Ee(e),i=new _e;return i.push(t,s,Ue(r)),i.push(o.sequenceLen-t-1,s,We(r)),this.insertContext(i,n)}prefetchReferenceWalk(e,t){return this.prefetchReferenceRange(e.handle,e.position.seqOffset,e.position.seqOffset+t)}async prefetchReferenceRange(e,t,n){let[s,o]=await Promise.all([this.db.indexedPosition(e,t),this.db.indexedPosition(e,n)]);if(s&&o){let r=s.pos.node,i=o.pos.node;if(!await this.db.prefetchRecords([[Math.min(r,i),Math.max(r,i)+1]])){let c=await this.db.indexedPositionsBetween(e,t,n);await this.db.prefetchRecords(Wn(c.map(d=>d.pos.node)).map(([d,f])=>[d,f+2]),!0)}}return s}async aroundInterval(e,t,n){if(!(t>0))throw new Error("Interval length must be greater than 0");this.walkedBp=0;try{return await this.walkInterval(e,t,n)}catch(s){throw s instanceof le&&s.windowBp===void 0?new le(s.limit,{windowBp:t,walkedBp:this.walkedBp}):s}}get referenceWalkedBp(){return this.walkedBp}async walkInterval(e,t,n){let s={node:e.handle,offset:e.gbwtOffset},o=e.nodeOffset,r=t,i=new _e;for(;;){let h=N(s.node),c=Ee(s.node);this.walkedBp=t-r,await this.ensureNode(h);let d=this.record(s.node);if(o>=d.sequenceLen)throw new Error(`Offset ${o} in node ${h} of length ${d.sequenceLen}`);i.push(o,h,Ue(c));let f=d.sequenceLen-o;if(r<=f){i.push(r===f?0:f-r-1,h,We(c));break}i.push(0,h,We(c));let p=d.gbwt().lf(s.offset);if(!p)throw new Error(`No successor for GBWT position (${s.node}, ${s.offset})`);s=p,o=0,r-=f}return this.walkedBp=t,this.insertContext(i,n)}async aroundNodes(e,t){let n=new _e;for(let s of e)await this.ensureNode(s),n.push(0,s,"left"),n.push(0,s,"right");return this.insertContext(n,t)}async insertContext(e,t){this.clearPaths(),this.snarlMode="none",this.snarlFills=[],this.snarlNodes.clear(),this.stats.snarls={fills:0,inserted:0};let n=new Set,s=new Set;for(let r of this.records.keys())s.add(N(r));let o=0;for(;e.size>0;){let[r,i,h]=e.pop(),c=`${i}:${h}`;if(n.has(c))continue;n.add(c),s.delete(i),this.hasNode(i)||(await this.addNode(i),o+=1);let d=Ft(h);if(!n.has(`${i}:${d}`)){let y=this.record(ce(i,qt(h))),g=r+y.sequenceLen-1;g<=t&&e.push(g,i,d)}let f=this.record(ce(i,zt(h))),p=r+1;if(p<=t)for(let y of f.successors()){let g=N(y),l=Ue(Ee(y));n.has(`${g}:${l}`)||e.push(p,g,l)}}for(let r of s)this.records.delete(ce(r,"forward")),this.records.delete(ce(r,"reverse"));return{inserted:o,removed:s.size}}async betweenNodes(e,t){return(await this.fillBetween(e,t)).inserted.length}async fillBetween(e,t){this.clearPaths();let n=[e,ee(t)],s=new Set([N(e),N(t)]),o=[];for(;n.length>0;){let r=n.pop(),i=N(r);this.hasNode(i)||(await this.addNode(i),o.push(i));for(let h of this.record(r).successors()){let c=N(h);s.has(c)||(n.push(h,ee(h)),s.add(c))}}return{inserted:o,nodes:s.size-2}}async extractSnarls(e){let t=0;this.snarlMode=e;for(let[n,s]of await this.overlappingSnarls(e)){let{inserted:o,nodes:r}=await this.fillBetween(n,s),i=N(n),h=N(s);this.snarlFills.push({low:Math.min(i,h),high:Math.max(i,h),nodes:r,inserted:o.length});for(let c of o)this.snarlNodes.add(c);t+=o.length}return this.stats.snarls={fills:this.snarlFills.length,inserted:this.snarlNodes.size},t}async overlappingSnarls(e){let t=[];if(e!=="none"){let n=!1;for(let s of this.sortedHandles()){let o=this.record(s),r=o.next;r!==void 0&&(n=!0,this.hasHandle(r)?He(s,r)&&t.push([s,r]):e==="overlapping"&&this.isSnarlEntryInSubgraph(o)&&t.push([s,r]))}if(!n&&e==="overlapping"&&await this.db.hasChainLinks()){let s=await this.findCoveringSnarl();s&&t.push(s)}}return t}isSnarlEntryInSubgraph(e){let t=e.successors(),n=t.find(s=>this.hasHandle(s));return n===void 0?!1:t.length>1||this.record(ee(n)).successors().length>1}recordReader(e){let t=new Map;return async n=>{let s=this.records.get(n);if(s)return s;let o=t.get(n);if(!o){if(o=await this.db.getRecord(n),e?.(),!o)throw new Error(`Node record ${n} is missing from the database`);t.set(n,o)}return o}}async findCoveringSnarl(){let e=this.recordReader(),t=async h=>{let c=h.successors(),d=c[0];return d===void 0?!1:c.length>1||(await e(ee(d))).successors().length>1},n=async h=>{let c=await e(ee(h));return c.next!==void 0?await t(c)?{kind:"snarl-exit",snarl:[ee(h),c.next]}:{kind:"chain"}:(await e(h)).next!==void 0?{kind:"chain"}:{kind:"regular"}},s=new Set,o=this.sortedHandles().flatMap(h=>this.record(h).successors()),r,i=!1;for(;!i&&o.length>0;){let h=o.shift(),c=N(h);if(!this.hasHandle(h)&&!s.has(c)){s.add(c);let d=await n(h);if(d.kind==="snarl-exit")r=d.snarl,i=!0;else if(d.kind==="chain")i=!0;else for(let f of["forward","reverse"])o.push(...(await e(ce(c,f))).successors())}}return r}extractPaths(e,t){if(this.clearPaths(),t==="none")return;let n=e?.position;this.refPath=e?.name,this.refHandle=e?.handle;let s=this.sortedHandles(),o=s.length,r=new Map;s.forEach((m,I)=>r.set(m,I));let i=new Int32Array(o+1),h=new Int32Array(o),c=[];for(let m=0;m<o;m++){let I=this.record(s[m]),$=I.gbwt().decompressArrays();h[m]=I.sequenceLen,c.push($),i[m+1]=i[m]+$.nodes.length}let d=i[o],f=new Int32Array(d),p=new Int32Array(d),y=new Uint8Array(d);for(let m=0;m<o;m++){let I=c[m];f.set(I.nodes,i[m]),p.set(I.offsets,i[m])}c.length=0;for(let m=0;m<d;m++){let I=r.get(f[m]);I===void 0?f[m]=-1:(f[m]=I,y[i[I]+p[m]]=1)}let g=n===void 0?void 0:r.get(n.handle),l=n?.gbwtOffset,b,x=(m,I,$)=>{let F=[],_=0,D=0,C=-1,H=m,k=I;for(;;){H===g&&k===l&&(C=_),$&&($.push(s[H]),F.push(k)),_+=1,D+=h[H];let j=i[H]+k,X=f[j];if(X<0)break;k=p[j],H=X}return{offsets:F,len:D,refAt:C,last:H}},P=(m,I,$,F)=>{F>=0&&(this.refId=this.paths.length,b=F),this.paths.push({path:m,offsets:I,len:$,weight:void 0,identity:void 0})},E=new Int32Array(o);for(let m=0;m<o;m++){let I=s[m];if(!Q(I)){let $=i[m],F=i[m+1]-$;for(let _=0;_<F;_++)if(y[$+_]===0){let D=[],{offsets:C,len:H,refAt:k,last:j}=x(m,_,D),X=s[j];if(k>=0||Pe(I,X)){if(P(D,C,H,k),!Q(X)){let w=r.get(ee(X));E[w]=E[w]+1}}else this.twinStarts.add(ke({node:I,offset:_}))}}}for(let m=0;m<o;m++){let I=s[m];if(Q(I)){let $=i[m],F=i[m+1]-$,_=0;for(let C=0;C<F;C++)y[$+C]===0&&(_+=1);let D=(g===void 0||b!==void 0)&&_===E[m];for(let C=0;C<F;C++)if(y[$+C]===0){let H=D?void 0:x(m,C,void 0);if(H&&(H.refAt>=0||Pe(I,s[H.last]))){let k=[],{offsets:j,len:X,refAt:w}=x(m,C,k);P(k,j,X,w)}else this.twinStarts.add(ke({node:I,offset:C}))}}}let R=this.refId===void 0?void 0:this.paths[this.refId];if(this.paths.sort((m,I)=>m.path[0]-I.path[0]||m.offsets[0]-I.offsets[0]),R&&(this.refId=this.paths.indexOf(R)),n){if(b===void 0||this.refId===void 0)throw this.clearPaths(),new Error("Could not find the reference path");let m=this.paths[this.refId],I=n.nodeOffset;for(let F of m.path.slice(0,b))I+=this.record(F).sequenceLen;let $=n.seqOffset-I;this.refInterval=[$,$+m.len],m.identity={pathHandle:e.handle,name:e.name,orientation:"forward",hapStart:$,hapEnd:$+m.len}}if(t==="distinct")this.distinctPaths(!0);else if(t==="reference-only"){if(this.refId===void 0)throw new Error("Reference path is required for reference-only output");this.paths=[this.paths[this.refId]],this.refId=0}}distinctPaths(e){let t=this.refId===void 0?void 0:this.paths[this.refId],n=t?.path,s=n&&!Oe(n)?Be(n):void 0,o=c=>s!==void 0&&wt(c,s)===0||Oe(Be(c)),r=e&&this.db.hasHaplotypeIndex;this.twinDeferred=!1,this.paths.sort((c,d)=>wt(c.path,d.path)||c.len-d.len||(c===t?-1:d===t?1:0));let i=[],h;for(let c of this.paths){let d=i[i.length-1],f=r&&c!==t&&o(c.path);this.twinDeferred||=f,d&&wt(d.path,c.path)===0&&!f?d.weight=(d.weight??1)+(c.weight??1):(c===t&&(h=i.length),i.push({...c,weight:c.weight??1}))}this.paths=i,this.refId=h}mergeDistinct(){this.twinDeferred?this.settleDeferred():this.distinctPaths(!1)}settleDeferred(){this.twinDeferred&&(this.unsettled={paths:[...this.paths],refId:this.refId},this.distinctPaths(!1))}dropTwins(){let e=this.refId===void 0?void 0:this.paths[this.refId],t=this.refInterval,n=r=>`${r.pathHandle}:${r.hapStart}-${r.hapEnd}`,s=new Set;e?.identity&&t&&s.add(n({...e.identity,hapStart:t[0],hapEnd:t[1]}));for(let r of this.paths)r!==e&&r.identity?.orientation==="forward"&&s.add(n(r.identity));let o=this.paths.filter(r=>r===e||r.identity?.orientation!=="reverse"||!s.has(n(r.identity)));o.length<this.paths.length&&(this.paths=o,this.refId=e===void 0?void 0:o.indexOf(e)),this.twinDeferred&&this.distinctPaths(!1)}keepHaplotypes(e){if(this.paths.some(r=>r.weight!==void 0))throw new Error("keepHaplotypes needs one walk per haplotype: extract with haplotypes 'all', then call mergeDistinct()");let t=this.paths.filter((r,i)=>i!==this.refId&&r.identity===void 0).length;if(t>0)throw new Error(`${t} of the window's ${this.paths.length} walks have no name, so the haplotypes to keep cannot be told from the rest; call identifyPaths() first, and check that the haplotype index was built for this graph`);let n=this.refId===void 0?void 0:this.paths[this.refId],s=this.paths.filter((r,i)=>i===this.refId||r.identity!==void 0&&e(r.identity.name)),o=new Set;for(let r of s)for(let i of r.path)o.add(N(i));for(let r of[...this.records.keys()])o.has(N(r))||this.records.delete(r);this.paths=s,this.refId=n===void 0?void 0:s.indexOf(n)}async extractChosenPaths(e,t,n,s){this.clearPaths();let o=e.position.seqOffset,r=await Zt({db:this.db,records:this.records,referenceHandle:e.handle,referencePos:{node:e.position.handle,offset:e.position.gbwtOffset},referenceLeft:o-e.position.nodeOffset,window:{start:o,end:o+t},context:s,snarls:{mode:this.snarlMode,fills:this.snarlFills,inserted:this.snarlNodes},keep:n,signal:this.signal,prefetchReferenceRange:(d,f,p)=>this.prefetchReferenceRange(d,f,p)});if(this.stats.keep=r.stats,r.stats.fallback!==void 0)return!1;let i=await this.db.pathsByHandle(),h=d=>({path:d.handles,offsets:d.offsets,len:d.len,weight:void 0,identity:{pathHandle:d.pathHandle,name:d===r.reference?e.name:i.get(d.pathHandle).name,orientation:d.orientation,hapStart:d.hapStart,hapEnd:d.hapEnd}}),c=[r.reference,...r.pieces].sort(Xt);return this.paths=c.map(h),this.refId=c.indexOf(r.reference),this.refPath=e.name,this.refHandle=e.handle,this.refInterval=[r.reference.hapStart,r.reference.hapEnd],this.dropTwins(),!0}async identifyPaths(){if(!this.db.hasHaplotypeIndex)throw new Error("The database has no HaplotypeSamples table; run gbz-haplotype-index on it");this.unsettled&&({paths:this.paths,refId:this.refId}=this.unsettled,this.unsettled=void 0,this.twinDeferred=!0);let e=await this.db.haplotypeSampleGap()??4096,t=pt(this.sortedHandles());if(t.length===0)return;let n=new Map,s=await Promise.all(t.map(([l,b])=>this.db.haplotypeSamplesInRange(l,b)));for(let l of s.flat())n.set(ke(l),l);let o=l=>{let b=0,x=t.length-1;for(;b<x;){let E=b+x+1>>1;t[E][0]<=l?b=E:x=E-1}let P=t[b];return P[0]<=l&&l<=P[1]},r=new Map;this.paths.forEach((l,b)=>{l.path.length>0&&b!==this.refId&&r.set(ke(Ge(l,0)),b)});let i=this.stats.identification;i.interval=e,i.scans=t,i.windowSamples=n.size,this.paths.forEach((l,b)=>{b!==this.refId&&i.fragmentLengths.push(l.len)});let h=this.recordReader(()=>{this.stats.identificationFetches+=1,i.graphFetches+=1}),c=l=>(i.graphLookups+=1,h(l)),d=async(l,b)=>{if(o(l.node))return n.get(ke(l));this.stats.identificationFetches+=1,i.companionSeeks+=1,b.seeks+=1;let x=await this.db.haplotypeSampleAt(l.node,l.offset);return x||(i.companionMisses+=1),x},f=new Map,p=async l=>{let b=f.get(l);if(!b){let x=await this.db.getPath(l);if(!x)throw new Error(`Path ${l} is missing from the database`);b=x.name,f.set(l,b)}return b},y=(l,b,x)=>l.orientation==="forward"?{pathHandle:l.pathHandle,orientation:"forward",base:l.pathOffset-b}:{pathHandle:l.pathHandle,orientation:"reverse",base:l.pathOffset+b+x},g=(l,b)=>l.orientation==="forward"?{pathHandle:l.pathHandle,orientation:"forward",base:l.hapStart-b}:{pathHandle:l.pathHandle,orientation:"reverse",base:l.hapEnd+b};for(let l=0;l<this.paths.length;l++){let b=this.paths[l];if(l===this.refId||b.identity)continue;let x=[],P=new Set,E={fragments:0,steps:0,seeks:0,reentries:0,twinLandings:0,end:"endmarker",pathHandle:void 0};i.chains.push(E);let R,m=0,I=l,$;for(;R===void 0;){if(this.signal?.throwIfAborted(),I!==void 0){if(P.has(I)){E.end="cycle";break}P.add(I);let H=this.paths[I];x.push({index:I,startBp:m}),E.fragments+=1;let k=m;for(let X=0;X<H.path.length;X++){let w=Ge(H,X),S=n.get(ke(w)),A=this.record(w.node).sequenceLen;if(S){R=y(S,k,A);break}k+=A}if(m+=H.len,R){E.end="in-fragment sample";break}let j=Ge(H,H.path.length-1);$=this.record(j.node).gbwt().lf(j.offset),I=void 0}if($===void 0||$.node===0){E.end="endmarker";break}let F=ke($),_=r.get(F);if(_!==void 0){let H=this.paths[_].identity;if(H){R=g(H,m),E.end="identified sibling";break}I=_;continue}this.records.has($.node)&&(E.reentries+=1),this.twinStarts.has(F)&&(E.twinLandings+=1);let D=await d($,E),C=await c($.node);if(D){R=y(D,m,C.sequenceLen),E.end="out-of-window sample";break}if(this.stats.identificationSteps+=1,E.steps+=1,m-x[x.length-1].startBp>4*e+4*C.sequenceLen){E.end="bound";break}m+=C.sequenceLen,$=C.gbwt().lf($.offset)}if(R){E.pathHandle=R.pathHandle;let F=await p(R.pathHandle);for(let{index:_,startBp:D}of x){let C=this.paths[_];C.identity=R.orientation==="forward"?{pathHandle:R.pathHandle,name:F,orientation:"forward",hapStart:R.base+D,hapEnd:R.base+D+C.len}:{pathHandle:R.pathHandle,name:F,orientation:"reverse",hapStart:R.base-D-C.len,hapEnd:R.base-D}}}}this.dropTwins()}refIndex(e){if(this.refIndexCache===void 0){let t=new Map;e.forEach((n,s)=>{let o=t.get(n);o?o.push(s):t.set(n,[s])}),this.refIndexCache=t}return this.refIndexCache}refPrefix(e){if(this.refPrefixCache===void 0){let t=[0];e.forEach((n,s)=>{t.push(t[s]+this.record(n).sequenceLen)}),this.refPrefixCache=t}return this.refPrefixCache}orderedMatches(e,t){let n=this.refIndex(t),s=new Int32Array(e.length),o=new Int32Array(e.length),r=0,i=-1;for(let h=0;h<e.length;h++){let c=n.get(e[h]);if(c){let d=qn(c,i);if(d===void 0)return;s[r]=h,o[r]=d,r+=1,i=d}}return{pathAt:s,refAt:o,count:r}}pathLen(e){let t=0;for(let n of e)t+=this.record(n).sequenceLen;return t}prefixMatches(e,t){let n=0,s=0,o=0,r=0,i=0;for(;s<e.length&&o<t.length;){let h=this.record(e[s]).sequence,c=this.record(t[o]).sequence;for(;r<h.length&&i<c.length;){if(h[r]!==c[i])return n;r+=1,i+=1,n+=1}r===h.length&&(s+=1,r=0),i===c.length&&(o+=1,i=0)}return n}suffixMatches(e,t){let n=0,s=0,o=0,r=0,i=0;for(;s<e.length&&o<t.length;){let h=this.record(e[e.length-s-1]).sequence,c=this.record(t[t.length-o-1]).sequence;for(;r<h.length&&i<c.length;){if(h[h.length-r-1]!==c[c.length-i-1])return n;r+=1,i+=1,n+=1}r===h.length&&(s+=1,r=0),i===c.length&&(o+=1,i=0)}return n}align(e,t,n){let s=this.pathLen(e),o=this.pathLen(t),r=this.prefixMatches(e,t),i=this.suffixMatches(e,t);r+i>s&&(i=s-r),r+i>o&&(i=o-r),K(n,"M",r),hn(n,s-r-i,o-r-i),K(n,"M",i)}sharedWeight(e,t){let n=this.refIndex(t),s=0;for(let o of e)n.has(o)&&(s+=this.record(o).sequenceLen);return s}editsAgainst(e,t){let n=this.orderedMatches(e,t);n?this.stats.orderedAlignments+=1:this.stats.lcsAlignments+=1;let s=n??Fn(Ut(e,t,f=>this.record(f).sequenceLen)[0]),o=[],r=this.refPrefix(t),i=(f,p,y,g)=>{f===p?K(o,"D",r[g]-r[y]):y===g?K(o,"I",this.pathLen(e.slice(f,p))):this.align(e.slice(f,p),t.slice(y,g),o)},h=0,c=0,d=0;for(let f=0;f<s.count;f++){let p=s.pathAt[f],y=s.refAt[f];(c!==p||d!==y)&&i(c,p,d,y);let g=this.record(e[p]).sequenceLen;K(o,"M",g),h+=g,c=p+1,d=y+1}return i(c,e.length,d,t.length),{edits:o,matched:h,matches:s}}alignment(e){let t=this.paths[e];if(this.refId===void 0||e===this.refId||!t)return;let n=this.paths[this.refId].path,s;if(Oe(n)&&(t.identity===void 0||!Oe(Be(t.path))))s={...this.editsAgainst(t.path,n),flipped:!1};else{let o=Be(t.path),r=this.sharedWeight(t.path,n);if(this.sharedWeight(o,n)===0)s={...this.editsAgainst(t.path,n),flipped:!1};else if(r===0)s={...this.editsAgainst(o,n),flipped:!0};else{let h=this.editsAgainst(t.path,n),c=this.editsAgainst(o,n);s=c.matched>h.matched?{...c,flipped:!0}:{...h,flipped:!1}}}return s}alignToRef(e){return this.settleDeferred(),this.alignment(e)?.edits.map(([t,n])=>`${n}${t}`).join("")}alignments(){this.settleDeferred();let e=this.referenceInterval;if(this.refId===void 0||!e)throw new Error("Alignments need a reference path");let t=this.paths[this.refId].path,n=this.refPrefix(t)[t.length],s=(d,f,p,y)=>{let g=Gn(d),l=this.paths[p[0]],b=this.paths[p[p.length-1]],x=l.identity,P=x?.orientation==="forward",[E,R]=P?[l,b]:[b,l];return{strand:f,refStart:e.start+g.leading,refEnd:e.start+n-g.trailing,edits:g.edits,weight:l.weight,path:p.flatMap(m=>this.paths[m].path),start:Ge(l,0),pieces:p,soloAligned:y,identity:x===void 0?void 0:{pathHandle:x.pathHandle,name:x.name,hapStart:x.name.fragment+E.identity.hapStart,hapEnd:x.name.fragment+R.identity.hapEnd,walkForward:P}}},o=d=>d.soloAligned.reduce((f,p)=>f+p,0),r=d=>d.pieces.reduce((f,p)=>f+this.paths[p].len,0),i=d=>2*o(d)>=r(d),h=d=>{let f=d[0],p=d[d.length-1],y=f.identity.walkForward;if(d.some((k,j)=>k.strand!==f.strand||k.identity.walkForward!==y||j>0&&k.identity.hapStart<d[j-1].identity.hapEnd))return;let g=y?d:[...d].reverse(),l=g.flatMap(k=>k.pieces),b=g.flatMap(k=>k.soloAligned),x=f.strand==="+"!==y,P=l.map(k=>this.paths[k]),E=P.slice(1).map((k,j)=>{let X=P[j].identity;return y?k.identity.hapStart-X.hapEnd:X.hapStart-k.identity.hapEnd}),R=x?[...P].reverse():P,m=x?[...E].reverse():E,I=R.flatMap(k=>x?Be(k.path):k.path),{edits:$}=this.editsAgainst(I,t),F=an($,R.map(k=>k.len)),_=new Map((x?[...l].reverse():l).map((k,j)=>[k,F[j]])),D=k=>2*k.pieces.reduce((j,X)=>j+_.get(X),0)>=o(k);if(!D(f)||!D(p))return;let C=[],H=0;return R.slice(0,-1).forEach((k,j)=>{H+=k.len,C.push([H,m[j]])}),s(Qn($,C),f.strand,l,b)},c=[];return this.paths.forEach((d,f)=>{if(f===this.refId)return;let{edits:p,flipped:y}=this.alignment(f),g=d.identity,l=g?g.orientation==="forward"!==y:!y;c.push(s(p,l?"+":"-",[f],an(p,[d.len])))}),jn(c,i,h).map(d=>{let{edits:f,identity:p,pieces:y,soloAligned:g,...l}=d,b={...l,cigar:Kn(f)};return p?{...b,resolved:!0,name:p.name,label:fe({...p.name,fragment:p.hapStart,end:p.hapEnd}),pathHandle:p.pathHandle,hapStart:p.hapStart,hapEnd:p.hapEnd}:{...b,resolved:!1}})}pairAlignments(e){let{target:t,query:n,...s}=e,o=this.paths.flatMap(d=>{let{identity:f}=d;return f?[{name:f.name,start:f.name.fragment+f.hapStart,steps:Ke(d,f)}]:[]}),r=d=>f=>f.sample===d.sample&&f.haplotype===d.haplotype,i=r(t),h=n?r(n):d=>!i(d),c=d=>this.record(ce(d,"forward")).sequence;return o.filter(d=>i(d.name)).flatMap(d=>o.filter(f=>h(f.name)).flatMap(f=>Wt({...s,query:f.steps,target:d.steps,sequenceOf:c}).map(p=>({query:f.name,queryStart:f.start+p.queryStart,queryEnd:f.start+p.queryEnd,strand:p.strand,target:d.name,targetStart:d.start+p.targetStart,targetEnd:d.start+p.targetEnd,cigar:Vt(p.edits),matches:p.edits.reduce((y,[g,l])=>y+(g==="="?l:0),0),columns:p.edits.reduce((y,[,g])=>y+g,0),sharedBases:p.sharedBases}))))}canonicalEdges(e){let t=[];for(let n of["forward","reverse"]){let s=ce(e,n);for(let o of this.record(s).successors())this.hasHandle(o)&&He(s,o)&&t.push([n==="reverse"?1:0,N(o),Q(o)?1:0])}return t.sort((n,s)=>n[0]-s[0]||n[1]-s[1]||n[2]-s[2]),t.filter((n,s)=>s===0||n[0]!==t[s-1][0]||n[1]!==t[s-1][1]||n[2]!==t[s-1][2])}async stableName(){let e=new TextEncoder,t=[];for(let n of this.sortedHandles())if(!Q(n)){let s=N(n),o=`S ${s} ${this.record(n).sequence}
|
|
1
|
+
import{a as ce,b as N,c as Ee,d as Q,e as ee,f as Ft,g as Ue,h as We,i as qt,j as zt,k as He,l as Oe,m as Pe,n as Dt,o as jt,p as Ut,q as Wt,r as Vt}from"./chunk-M2D7NUOY.js";import{a as _t,g as Tt}from"./chunk-NEWN556N.js";import{c as Ot}from"./chunk-AJX6ZXCI.js";import{a as Ct,g as Bt}from"./chunk-KFZWGL76.js";var Ln=4096;function pt(a){let e=[];for(let t of a){let n=e[e.length-1];n&&t-n[1]<=Ln?n[1]=t:e.push([t,t])}return e}var Hn=32768,Gt={mostChosenPaths:32},lt=class{byNode=new Map;get(e){return this.byNode.get(e.node)?.get(e.offset)}set(e,t){let n=this.byNode.get(e.node);n||(n=new Map,this.byNode.set(e.node,n)),n.set(e.offset,t)}},re=class extends Error{};function Ve(a,e,t,n){return a==="forward"?e+t:e-n}function Qt(a,e,t,n){return a==="forward"?e-n:e+t}function Kt(a){return Pe(ee(a.handles[a.handles.length-1]),ee(a.handles[0]))}function Ce(a){return`${a.pathHandle}:${a.hapStart}:${a.hapEnd}`}async function Zt(a){let{db:e,records:t,signal:n}=a,s=performance.now(),o=()=>{let w=performance.now(),S=w-s;return s=w,S},r={spacing:await e.haplotypeAnchorSpacing(),anchors:void 0,anchorsRead:0,chosenPaths:0,scans:[],scanRows:0,strays:void 0,pieces:0,sources:{reference:0,section:0,stray:0,chain:0,twin:0},walks:{},twins:{tried:0,found:0},graphFetches:0,fallback:void 0,ms:{scan:0,walks:0,check:0,twins:0}},i=(w,S)=>{let A=`${w}: ${S}`;r.walks[A]=(r.walks[A]??0)+1},h=await e.haplotypeSampleInterval()??4096,c=new Map,d=async w=>{let S=t.get(w)??c.get(w);if(S)return S;let A=await e.getRecord(w);if(r.graphFetches+=1,!A)throw new Error(`Node record ${w} is missing from the database`);return c.set(w,A),A},f=w=>t.get(w).sequenceLen,p=await e.pathsByHandle(),y=w=>{let S=p.get(w);return S!==void 0&&a.keep(S.name)},g=[],l=new lt,b=new Map,x=new Set,P=new Set,E=async w=>{let S=(await d(w.node)).gbwt().lf(w.offset);return S===void 0||S.node===0?void 0:S},R=async(w,S)=>{let A=(await d(ee(w.node))).gbwt().predecessorAt(w.offset);if(A===void 0||S!==void 0&&!S.has(A))return;let M=(await d(A)).gbwt().offsetTo(w);if(M===void 0)throw new Error(`No offset in ${A} leads to ${w.node}:${w.offset}`);return{node:A,offset:M}},m=(w,S,A,M)=>{let B=A.map(W=>W.pos.node),U=A.map(W=>W.pos.offset),J=0;for(let W of B)J+=f(W);let O=S==="forward"?A[0].left:A[A.length-1].left,L=g.length;g.push({pathHandle:w,orientation:S,handles:B,offsets:U,len:J,hapStart:O,hapEnd:O+J,canonical:Pe(B[0],B[B.length-1]),source:M});for(let W of A)l.set(W.pos,L);let G=b.get(w);return G?G.push(L):b.set(w,[L]),L},I=async(w,S,A,M)=>{let B=[],U=w;for(;;){n?.throwIfAborted();let O=await R(U.pos,t);if(!O)break;U={pos:O,left:Qt(A,U.left,f(U.pos.node),f(O.node))},B.push(U)}B.reverse();let J=[w];for(U=w;;){n?.throwIfAborted();let O=await E(U.pos);if(!O||!t.has(O.node))break;U={pos:O,left:Ve(A,U.left,f(U.pos.node),f(O.node))},J.push(U)}return m(S,A,[...B,...J],M)},$=async(w,S,A,M)=>g[l.get(w.pos)??await I(w,S,A,M)],F=w=>{let S=w.handles[w.handles.length-1];return{pos:{node:S,offset:w.offsets[w.offsets.length-1]},left:w.orientation==="forward"?w.hapEnd-f(S):w.hapStart}},_=w=>{let S=w.handles[0];return{pos:{node:S,offset:w.offsets[0]},left:w.orientation==="forward"?w.hapStart:w.hapEnd-f(S)}},D=await I({pos:a.referencePos,left:a.referenceLeft},a.referenceHandle,"forward","reference"),C=g[D],H=()=>{if(r.fallback!==void 0)return{reference:C,pieces:[],stats:r};let w=new Map;g.forEach((A,M)=>{M!==D&&w.set(Ce(A),[...w.get(Ce(A))??[],A])});let S=[];for(let A of w.values()){let M=new Set;for(let B of A)B.canonical&&!M.has(B.orientation)&&(M.add(B.orientation),S.push(B),r.sources[B.source]+=1)}return r.sources.reference=1,r.pieces=S.length+1,{reference:C,pieces:S,stats:r}},k=async(w,S)=>{let A=S?x:P,M=S?P:x,B=w;for(;;){if(A.has(B))return;A.add(B);let U=g[B],J=S?F(U):_(U),O=0,L;for(;L===void 0;){n?.throwIfAborted();let G=S?await E(J.pos):await R(J.pos);if(!G){L="endmarker";break}let W=(await d(J.pos.node)).sequenceLen,ue=(await d(G.node)).sequenceLen,se=S?Ve(U.orientation,J.left,W,ue):Qt(U.orientation,J.left,W,ue);if(t.has(G.node)){let Y=l.get(G);Y===void 0?(B=await I({pos:G,left:se},U.pathHandle,U.orientation,"chain"),M.add(B),L="landed"):(M.add(Y),L="merge")}else O>Hn?L="bound":(O+=ue,J={pos:G,left:se})}if(i("chain",L),L!=="landed")return}},j=async w=>{if(a.context>w.context)throw new re(`the context of ${a.context} bp exceeds the ${w.context} bp the haplotype index's stray rows cover`);let S=r.spacing;if(S===void 0)throw new re("the haplotype index has no anchors");let{bin:A,bound:M}=w,{fills:B,inserted:U}=a.snarls;if(a.snarls.mode==="overlapping"&&B.length>0)throw new re("the haplotype index's stray rows cover contained snarls only");for(let u of B){if(u.inserted>0&&u.low===u.high)throw new re(`the haplotype index's stray rows leave out the snarl bounded by node ${u.low} at both ends`);if(u.inserted>0&&(w.snarlNodes===void 0||u.nodes>w.snarlNodes))throw new re(w.snarlNodes===void 0?"the haplotype index's stray rows leave snarls out":`a snarl of ${u.nodes} nodes exceeds the ${w.snarlNodes} the haplotype index's stray rows cover`)}let J=Math.floor(a.window.start/A),O=Math.floor((a.window.end-1)/A),L=J*A,G=(O+1)*A,W=new Map,ue=async(u,v)=>{let z=await e.haplotypeAnchorsBetween(a.referenceHandle,u*S,v*S);for(let T of z)W.set(T.anchorOffset/S,T)},se=Math.max(0,Math.floor((L-M)/S)-1),Y=Math.ceil((G+M)/S)+1,[{listed:De,strays:ae}]=await Promise.all([e.haplotypeBinData(a.referenceHandle,J,O),ue(se,Y)]);for(let u of t.keys()){let v=N(u);if(!Q(u)&&!De(v)&&!U.has(v))throw new re(`the haplotype index lists node ${v} of the subgraph in no bin that the window touches`)}r.scans=pt([...t.keys()].sort((u,v)=>u-v));let ie=Promise.all(r.scans.map(([u,v])=>e.haplotypeSamplesInRange(u,v)));for(ie.catch(()=>{});se>0&&(W.get(se)?.pathOffset??Number.POSITIVE_INFINITY)>=L-M;)se-=1,await ue(se,se);for(;W.has(Y)&&W.get(Y).pathOffset<=G+M;)Y+=1,await ue(Y,Y);let pe=[...W.keys()].sort((u,v)=>u-v),ye=W.get(pe[0]??-1);if(!ye)throw new re("the haplotype index has no anchors on this path");let he=u=>W.get(u).pathOffset,Ne=new Map;for(let u of pe){let v=N(W.get(u).node);Ne.set(v,[...Ne.get(v)??[],u])}let ct=[...Ne.keys()],Et=ct.map(u=>W.get(Ne.get(u)[0]).visits);if(!Et[ct.indexOf(N(ye.node))].some(u=>u.pathHandle===a.referenceHandle&&u.orientation==="forward"&&u.pathOffset===ye.pathOffset))throw new Error(`The haplotype index has no anchor row for the reference path ${a.referenceHandle} at offset ${ye.pathOffset} (node ${N(ye.node)}); it does not match this graph`);let kt=pe.filter(u=>he(u)<=a.window.start),$n=pe.filter(u=>he(u)>=a.window.end);r.anchors=[he(kt[kt.length-1]??pe[0]),he($n[0]??pe[pe.length-1])],r.anchorsRead=pe.length;let dt=new Map,vt=new Set;if(ct.forEach((u,v)=>{let z=Ne.get(u),T=z.length===1?z[0]:void 0;for(let q of Et[v])vt.add(q.pathHandle),q.orientation==="forward"&&y(q.pathHandle)&&dt.set(q.pathHandle,[...dt.get(q.pathHandle)??[],{k:T,row:q}])}),r.chosenPaths=[...vt].filter(y).length,r.chosenPaths>Gt.mostChosenPaths)throw new re(`${r.chosenPaths} chosen paths pass the anchors, more than ${Gt.mostChosenPaths}`);let je=[],Ie=Number.POSITIVE_INFINITY,be=0;for(let[u,v]of dt){v.sort((z,T)=>z.row.pathOffset-T.row.pathOffset);for(let z=0;z+1<v.length;z++){let T=v[z],q=v[z+1];if(T.k===void 0||q.k===void 0||Math.abs(T.k-q.k)!==1)continue;let[Z,te]=he(T.k)<=he(q.k)?[T,q]:[q,T],ne=he(Z.k),oe=he(te.k);ne<G&&oe>=L?(je.push({pathHandle:u,from:T.row,to:q.row}),Ie=Math.min(Ie,ne-M),be=Math.max(be,oe+M)):ne>=G&&ne-G<=M?(je.push({pathHandle:u,from:Z.row,to:void 0}),Ie=Math.min(Ie,ne-M),be=Math.max(be,ne+M)):oe<L&&L-oe<=M&&(je.push({pathHandle:u,from:te.row,to:void 0}),Ie=Math.min(Ie,oe-M),be=Math.max(be,oe+M))}}let Rn=new Set(B.map(u=>`${u.low}:${u.high}`)),Nn=ae.filter(u=>y(u.pathHandle)&&(u.snarl===void 0||Rn.has(`${u.snarl[0]}:${u.snarl[1]}`))).sort((u,v)=>u.pathHandle-v.pathHandle||u.pathStart-v.pathStart);r.strays={bins:O-J+1,rows:ae.length,walked:0,outsideBp:0},be>0&&await a.prefetchReferenceRange(a.referenceHandle,Math.max(0,Ie),be+1),r.ms.scan=o();let Pt=8*S+2*(a.window.end-a.window.start),At=r.strays,Me=0,$t=u=>{if(At.outsideBp+=u,Me+=u,Me>Pt)throw new re(`a walk of a chosen path near the window went past its cap of ${Pt} bp`)},ft=new Map,Rt=(u,v,z)=>(ft.get(u)??[]).some(([T,q])=>T<=v&&z<q),Nt=(u,v,z)=>{ft.set(u,[...ft.get(u)??[],[v,z]])},Mt=async(u,v,z,T,q)=>{let Z=v,te=z,ne=te;for(;Z&&te<=T;){n?.throwIfAborted();let oe;if(t.has(Z.node)){let Le=await $({pos:Z,left:te},u,"forward",q),Ht=F(Le);Z=Ht.pos,te=Ht.left,oe=f(Z.node),ne=Math.max(ne,Le.hapEnd)}else oe=(await d(Z.node)).sequenceLen,$t(oe),ne=Math.max(ne,te+oe);Z=await E(Z),te+=oe}return ne},Mn=async(u,v,z,T)=>{let q={pos:v,left:z},Z=z;for(;q.left>T;){n?.throwIfAborted();let te=await R(q.pos);if(!te)break;let ne=(await d(te.node)).sequenceLen,oe=q.left-ne;if(t.has(te.node)){let Le=await $({pos:te,left:oe},u,"forward","section");q=_(Le),Z=Math.min(Z,Le.hapStart)}else $t(ne),q={pos:te,left:oe},Z=Math.min(Z,oe)}return Z};for(let{pathHandle:u,from:v,to:z}of je){let T=v.pathOffset,q=(z??v).pathOffset+M;if(Rt(u,T-M,q))continue;let Z={node:v.node,offset:v.offset};Me=0;let te=await Mt(u,Z,T,q,"section");Me=0;let ne=await Mn(u,Z,T,T-M);Nt(u,Math.min(ne,T-M),Math.max(te,q+1)),i(z?"section":"visit",z?"past the far anchor":"bound")}for(let u of Nn){if(Rt(u.pathHandle,u.pathStart,u.pathEnd))continue;Me=0;let v=await Mt(u.pathHandle,{node:u.node,offset:u.offset},u.pathStart,u.pathEnd,"stray");Nt(u.pathHandle,u.pathStart,Math.max(v,u.pathEnd+1)),At.walked+=1}r.ms.walks=o();let Lt=[];for(let u of await ie)for(let v of u)if(r.scanRows+=1,t.has(v.node)&&y(v.pathHandle)){if(!(b.get(v.pathHandle)??[]).some(z=>{let T=g[z];return T.hapStart<=v.pathOffset&&v.pathOffset<T.hapEnd}))throw new re(`chosen path ${v.pathHandle} has a sample at ${v.pathOffset} on the window's nodes that no walk reached`);v.orientation==="reverse"&&Lt.push(v)}for(let u of Lt)await $({pos:{node:u.node,offset:u.offset},left:u.pathOffset},u.pathHandle,"reverse","twin");r.ms.check=o()},X=async()=>{let w=new Map,S=O=>{let L=Ce(O),G=w.get(L);G?G.add(O.orientation):w.set(L,new Set([O.orientation]))},A=0,M=()=>{for(;A<g.length;A++)S(g[A])};M();let B=O=>(w.get(Ce(O))?.size??0)>1,U=2*h,J=(O,L)=>L===D?y(a.referenceHandle)&&Kt(O):!O.canonical||Kt(O);for(let O=0;O<g.length;O++){let L=g[O];if(B(L)||!J(L,O))continue;r.twins.tried+=1;let G=L.orientation==="forward"?"reverse":"forward",W=F(L),ue=0,se;for(;!se&&ue<=U;){n?.throwIfAborted();let ae=await E(W.pos);if(!ae)break;let ie=(await d(ae.node)).sequenceLen,pe=Ve(L.orientation,W.left,(await d(W.pos.node)).sequenceLen,ie),ye=ee(ae.node);se=(await e.haplotypeSamplesInRange(ye,ye)).find(he=>he.pathHandle===L.pathHandle&&he.orientation===G&&he.pathOffset===pe),ue+=ie,W={pos:ae,left:pe}}let Y=se&&{pos:{node:se.node,offset:se.offset},left:se.pathOffset},De=0;for(;Y&&!B(L)&&De<=U+L.len;){if(n?.throwIfAborted(),t.has(Y.pos.node)){let ae=await $(Y,L.pathHandle,G,"twin"),ie=g.indexOf(ae);await k(ie,!0),await k(ie,!1),M(),Y=F(ae)}if(!B(L)){let ae=(await d(Y.pos.node)).sequenceLen;De+=ae;let ie=await E(Y.pos);Y=ie?{pos:ie,left:Ve(G,Y.left,ae,(await d(ie.node)).sequenceLen)}:void 0}}if(M(),!B(L))throw new re(`piece ${Ce(L)} was found in one orientation where extractPaths keeps the other`);r.twins.found+=1}r.ms.twins=o()};try{let w=await e.haplotypeStrayOptions();if(w===void 0)throw new re("the haplotype index has no stray rows; gbz-haplotype-index 0.2.0 writes them");await j(w),await X()}catch(w){if(!(w instanceof re))throw w;r.fallback=w.message}return H()}function Xt(a,e){return a.handles[0]-e.handles[0]||a.offsets[0]-e.offsets[0]}var On=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),we=(a,e)=>a>>>e|a<<32-e;function Jt(a){let e=Math.ceil((a.length+9)/64),t=new Uint8Array(e*64);t.set(a),t[a.length]=128;let n=new DataView(t.buffer),s=a.length*8;n.setUint32(t.length-8,Math.floor(s/2**32)),n.setUint32(t.length-4,s>>>0);let o=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),r=new Uint32Array(64);for(let c=0;c<e;c++){for(let P=0;P<16;P++)r[P]=n.getUint32(c*64+P*4);for(let P=16;P<64;P++){let E=r[P-15],R=r[P-2],m=we(E,7)^we(E,18)^E>>>3,I=we(R,17)^we(R,19)^R>>>10;r[P]=r[P-16]+m+r[P-7]+I}let d=o[0],f=o[1],p=o[2],y=o[3],g=o[4],l=o[5],b=o[6],x=o[7];for(let P=0;P<64;P++){let E=we(g,6)^we(g,11)^we(g,25),R=g&l^~g&b,m=x+E+R+On[P]+r[P]|0,I=we(d,2)^we(d,13)^we(d,22),$=d&f^d&p^f&p;x=b,b=l,l=g,g=y+m|0,y=p,p=f,f=d,d=m+I+$|0}[d,f,p,y,g,l,b,x].forEach((P,E)=>{o[E]=o[E]+P})}let i=new Uint8Array(32),h=new DataView(i.buffer);for(let c=0;c<8;c++)h.setUint32(c*4,o[c]);return i}function Yt(a,e){let t=new Map;if(a!==void 0)for(let n of a.split(";")){let s=n.split(","),[o,r]=s;if(s.length!==2||!o||!r)throw new Error(`Invalid ${e} relationship: ${n}`);let i=t.get(o);i||(i=new Set,t.set(o,i)),i.add(r)}return t}function nn(a){return{name:a.get("pggname"),subgraph:Yt(a.get("subgraph"),"subgraph"),translation:Yt(a.get("translation"),"translation")}}function en(a,e){for(let[t,n]of e){let s=a.get(t);s||(s=new Set,a.set(t,s));for(let o of n)s.add(o)}}function sn(a,e){let t={name:a,subgraph:new Map,translation:new Map};return e.name!==void 0&&(t.subgraph.set(a,new Set([e.name])),en(t.subgraph,e.subgraph),en(t.translation,e.translation)),t}function tn(a){return[...a.entries()].sort(([e],[t])=>e<t?-1:e>t?1:0).flatMap(([e,t])=>[...t].sort().map(n=>[e,n]))}function on(a){let e=[];a.name!==void 0&&e.push(`H NM:Z:${a.name}`);for(let[t,n]of tn(a.subgraph))e.push(`H SG:Z:${t},${n}`);for(let[t,n]of tn(a.translation))e.push(`H TL:Z:${t},${n}`);return e}async function rn(a){let e=a.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e),n=0;for(let r of a)t.set(r,n),n+=r.length;let s=globalThis.crypto?.subtle;return[...s?new Uint8Array(await s.digest("SHA-256",t)):Jt(t)].map(r=>r.toString(16).padStart(2,"0")).join("")}var Cn="_gbwt_ref";function fe(a){let e=`${a.sample}#${a.haplotype}#${a.contig}`;return a.end===void 0?e:`${e}[${a.fragment}-${a.end}]`}var Bn=/^([^#]+)#(\d+)#([^#]+?)(?:\[\d+-\d+\])?$/,_n=/^([^#]+?)(?:\[\d+-\d+\])?$/;function Tn(a){let e=Bn.exec(a);if(e)return{sample:e[1],haplotype:Number(e[2]),contig:e[3]};let t=_n.exec(a);if(t)return{contig:t[1]};throw new Error(`"${a}" is not a path name; expected "sample#haplotype#contig" or a bare contig`)}function Ae(a){return typeof a=="string"?Tn(a):a}function $e(a,e){return{sample:a.sample??Cn,contig:a.contig,haplotype:a.haplotype??0,fragment:e}}var le=class extends Error{name="SubgraphLimitError";limit;windowBp;walkedBp;constructor(e,t){super(t===void 0?`Subgraph size limit of ${e} nodes exceeded`:`Subgraph size limit of ${e} nodes exceeded ${t.walkedBp} bp into a ${t.windowBp} bp window`),this.limit=e,this.windowBp=t?.windowBp,this.walkedBp=t?.walkedBp}};function ut(a,e){return a[0]<e[0]||a[0]===e[0]&&(a[1]<e[1]||a[1]===e[1]&&a[2]<e[2])}var _e=class{heap=[];push(e,t,n){let s=this.heap;s.push([e,t,n]);let o=s.length-1;for(;o>0;){let r=o-1>>1;if(ut(s[o],s[r]))[s[o],s[r]]=[s[r],s[o]],o=r;else break}}pop(){let e=this.heap,t=e[0],n=e.pop();if(e.length>0&&n!==void 0){e[0]=n;let s=0;for(;;){let o=2*s+1,r=o+1,i=s;if(o<e.length&&ut(e[o],e[i])&&(i=o),r<e.length&&ut(e[r],e[i])&&(i=r),i===s)break;[e[s],e[i]]=[e[i],e[s]],s=i}}return t}get size(){return this.heap.length}};function Fn(a){let e=new Int32Array(a.length),t=new Int32Array(a.length);return a.forEach(([n,s],o)=>{e[o]=n,t[o]=s}),{pathAt:e,refAt:t,count:a.length}}function qn(a,e){let t=0,n=a.length;for(;t<n;){let s=t+n>>1;a[s]>e?n=s:t=s+1}return a[t]}function ke(a){return`${a.node}:${a.offset}`}function Be(a){return a.map(e=>ee(e)).reverse()}function zn(a,e){let t=e.identity.hapStart-a.identity.hapEnd,n=a.strand==="+"?e.refStart-a.refEnd:a.refStart-e.refEnd;return a.strand===e.strand&&t>=0&&n>=0?{insertion:t,deletion:n}:void 0}function Dn(a,e,t){let[n,s]=a.strand==="+"?[a,e]:[e,a],o=n.edits.map(([c,d])=>[c,d]);hn(o,t.insertion,t.deletion);for(let[c,d]of s.edits)K(o,c,d);let r=a.identity.walkForward,[i,h]=r?[a,e]:[e,a];return{strand:a.strand,refStart:n.refStart,refEnd:s.refEnd,edits:o,weight:void 0,path:[...i.path,...h.path],start:i.start,pieces:[...i.pieces,...h.pieces],soloAligned:[...i.soloAligned,...h.soloAligned],identity:{pathHandle:a.identity.pathHandle,name:a.identity.name,hapStart:a.identity.hapStart,hapEnd:e.identity.hapEnd,walkForward:r}}}function jn(a,e,t){if(a.some(r=>r.weight!==void 0))return a;let n=new Map;a.forEach((r,i)=>{if(r.identity){let h=n.get(r.identity.pathHandle);h?h.push(i):n.set(r.identity.pathHandle,[i])}});let s=new Map,o=new Set;for(let r of n.values()){r.sort((d,f)=>a[d].identity.hapStart-a[f].identity.hapStart);let i=r[0],h=a[i],c=[];for(let d of r.slice(1)){let f=a[d],p=c.length===0?zn(h,f):void 0;if(p){h=Dn(h,f,p),o.add(d);continue}if(!e(f)){c.push(d);continue}let y=e(h)?t([h,...c.map(g=>a[g]),f]):void 0;if(y){h=y;for(let g of[...c,d])o.add(g)}else s.set(i,h),i=d,h=f;c=[]}s.set(i,h)}return a.flatMap((r,i)=>o.has(i)?[]:[s.get(i)??r])}function Ge(a,e){return{node:a.path[e],offset:a.offsets[e]}}var Un=32768;function Wn(a){let e=[...a].sort((n,s)=>n-s),t=[];for(let n of e){let s=t[t.length-1];s&&n-s[1]<=Un?s[1]=n:t.push([n,n])}return t}var Te=class a{records=new Map;paths=[];twinStarts=new Set;twinDeferred=!1;unsettled;refId;refPath;refHandle;refInterval;refIndexCache;refPrefixCache;walkedBp;snarlMode="none";snarlFills=[];snarlNodes=new Set;stats={orderedAlignments:0,lcsAlignments:0,snarls:{fills:0,inserted:0},identificationSteps:0,identificationFetches:0,identification:{interval:0,scans:[],windowSamples:0,fragmentLengths:[],companionSeeks:0,companionMisses:0,graphLookups:0,graphFetches:0,chains:[]},keep:void 0};db;limit;signal;constructor(e,t){this.db=e,this.limit=t.limit,this.signal=t.signal}static create(e,t={}){return new a(e,t)}get nodeCount(){return this.records.size/2}get pathCount(){return this.settleDeferred(),this.paths.length}get referenceInterval(){return this.refInterval&&this.refPath?{name:this.refPath,start:this.refPath.fragment+this.refInterval[0],end:this.refPath.fragment+this.refInterval[1]}:void 0}hasNode(e){return this.records.has(ce(e,"forward"))}hasHandle(e){return this.records.has(e)}record(e){let t=this.records.get(e);if(!t)throw new Error(`Subgraph has no record for handle ${e}`);return t}sortedHandles(){return[...this.records.keys()].sort((e,t)=>e-t)}async addNode(e){if(this.signal?.throwIfAborted(),this.limit!==void 0&&this.nodeCount>=this.limit)throw new le(this.limit);let t=await this.db.getRecord(ce(e,"forward")),n=await this.db.getRecord(ce(e,"reverse"));if(!t||!n)throw new Error(`Node ${e} does not exist in the graph`);this.records.set(t.handle,t),this.records.set(n.handle,n)}async ensureNode(e){this.hasNode(e)||await this.addNode(e)}clearPaths(){this.paths=[],this.twinStarts.clear(),this.twinDeferred=!1,this.unsettled=void 0,this.refId=void 0,this.refPath=void 0,this.refHandle=void 0,this.refInterval=void 0,this.refIndexCache=void 0,this.refPrefixCache=void 0}async pathPosition(e){let t=await this.db.findPath(e);if(!t)throw new Error(`Cannot find a path covering offset ${e.fragment} of ${fe(e)}`);if(!t.isIndexed)throw new Error(`The fragment of ${fe(t.name)} at ${t.name.fragment} has not been indexed for random access`);let n=e.fragment-t.name.fragment,s=await this.db.indexedPosition(t.handle,n);if(!s)throw new Error(`The fragment of ${fe(t.name)} at ${t.name.fragment} has not been indexed for random access`);return this.findPathPosition(t,n,s.pathOffset,s.pos)}async findPathPosition(e,t,n,s){let o=n,r=s;for(;;){await this.ensureNode(N(r.node));let i=this.record(r.node);if(o+i.sequenceLen>t)return{position:{seqOffset:t,handle:r.node,nodeOffset:t-o,gbwtOffset:r.offset},name:e.name,handle:e.handle};o+=i.sequenceLen;let h=i.gbwt().lf(r.offset);if(!h)throw new Error(`The fragment of ${fe(e.name)} at ${e.name.fragment} does not contain offset ${t}`);r=h}}async aroundPosition(e,t,n){let s=N(e);await this.ensureNode(s);let o=this.record(e),r=Ee(e),i=new _e;return i.push(t,s,Ue(r)),i.push(o.sequenceLen-t-1,s,We(r)),this.insertContext(i,n)}prefetchReferenceWalk(e,t){return this.prefetchReferenceRange(e.handle,e.position.seqOffset,e.position.seqOffset+t)}async prefetchReferenceRange(e,t,n){let[s,o]=await Promise.all([this.db.indexedPosition(e,t),this.db.indexedPosition(e,n)]);if(s&&o){let r=s.pos.node,i=o.pos.node;if(!await this.db.prefetchRecords([[Math.min(r,i),Math.max(r,i)+1]])){let c=await this.db.indexedPositionsBetween(e,t,n);await this.db.prefetchRecords(Wn(c.map(d=>d.pos.node)).map(([d,f])=>[d,f+2]),!0)}}return s}async aroundInterval(e,t,n){if(!(t>0))throw new Error("Interval length must be greater than 0");this.walkedBp=0;try{return await this.walkInterval(e,t,n)}catch(s){throw s instanceof le&&s.windowBp===void 0?new le(s.limit,{windowBp:t,walkedBp:this.walkedBp}):s}}get referenceWalkedBp(){return this.walkedBp}async walkInterval(e,t,n){let s={node:e.handle,offset:e.gbwtOffset},o=e.nodeOffset,r=t,i=new _e;for(;;){let h=N(s.node),c=Ee(s.node);this.walkedBp=t-r,await this.ensureNode(h);let d=this.record(s.node);if(o>=d.sequenceLen)throw new Error(`Offset ${o} in node ${h} of length ${d.sequenceLen}`);i.push(o,h,Ue(c));let f=d.sequenceLen-o;if(r<=f){i.push(r===f?0:f-r-1,h,We(c));break}i.push(0,h,We(c));let p=d.gbwt().lf(s.offset);if(!p)throw new Error(`No successor for GBWT position (${s.node}, ${s.offset})`);s=p,o=0,r-=f}return this.walkedBp=t,this.insertContext(i,n)}async aroundNodes(e,t){let n=new _e;for(let s of e)await this.ensureNode(s),n.push(0,s,"left"),n.push(0,s,"right");return this.insertContext(n,t)}async insertContext(e,t){this.clearPaths(),this.snarlMode="none",this.snarlFills=[],this.snarlNodes.clear(),this.stats.snarls={fills:0,inserted:0};let n=new Set,s=new Set;for(let r of this.records.keys())s.add(N(r));let o=0;for(;e.size>0;){let[r,i,h]=e.pop(),c=`${i}:${h}`;if(n.has(c))continue;n.add(c),s.delete(i),this.hasNode(i)||(await this.addNode(i),o+=1);let d=Ft(h);if(!n.has(`${i}:${d}`)){let y=this.record(ce(i,qt(h))),g=r+y.sequenceLen-1;g<=t&&e.push(g,i,d)}let f=this.record(ce(i,zt(h))),p=r+1;if(p<=t)for(let y of f.successors()){let g=N(y),l=Ue(Ee(y));n.has(`${g}:${l}`)||e.push(p,g,l)}}for(let r of s)this.records.delete(ce(r,"forward")),this.records.delete(ce(r,"reverse"));return{inserted:o,removed:s.size}}async betweenNodes(e,t){return(await this.fillBetween(e,t)).inserted.length}async fillBetween(e,t){this.clearPaths();let n=[e,ee(t)],s=new Set([N(e),N(t)]),o=[];for(;n.length>0;){let r=n.pop(),i=N(r);this.hasNode(i)||(await this.addNode(i),o.push(i));for(let h of this.record(r).successors()){let c=N(h);s.has(c)||(n.push(h,ee(h)),s.add(c))}}return{inserted:o,nodes:s.size-2}}async extractSnarls(e){let t=0;this.snarlMode=e;for(let[n,s]of await this.overlappingSnarls(e)){let{inserted:o,nodes:r}=await this.fillBetween(n,s),i=N(n),h=N(s);this.snarlFills.push({low:Math.min(i,h),high:Math.max(i,h),nodes:r,inserted:o.length});for(let c of o)this.snarlNodes.add(c);t+=o.length}return this.stats.snarls={fills:this.snarlFills.length,inserted:this.snarlNodes.size},t}async overlappingSnarls(e){let t=[];if(e!=="none"){let n=!1;for(let s of this.sortedHandles()){let o=this.record(s),r=o.next;r!==void 0&&(n=!0,this.hasHandle(r)?He(s,r)&&t.push([s,r]):e==="overlapping"&&this.isSnarlEntryInSubgraph(o)&&t.push([s,r]))}if(!n&&e==="overlapping"&&await this.db.hasChainLinks()){let s=await this.findCoveringSnarl();s&&t.push(s)}}return t}isSnarlEntryInSubgraph(e){let t=e.successors(),n=t.find(s=>this.hasHandle(s));return n===void 0?!1:t.length>1||this.record(ee(n)).successors().length>1}recordReader(e){let t=new Map;return async n=>{let s=this.records.get(n);if(s)return s;let o=t.get(n);if(!o){if(o=await this.db.getRecord(n),e?.(),!o)throw new Error(`Node record ${n} is missing from the database`);t.set(n,o)}return o}}async findCoveringSnarl(){let e=this.recordReader(),t=async h=>{let c=h.successors(),d=c[0];return d===void 0?!1:c.length>1||(await e(ee(d))).successors().length>1},n=async h=>{let c=await e(ee(h));return c.next!==void 0?await t(c)?{kind:"snarl-exit",snarl:[ee(h),c.next]}:{kind:"chain"}:(await e(h)).next!==void 0?{kind:"chain"}:{kind:"regular"}},s=new Set,o=this.sortedHandles().flatMap(h=>this.record(h).successors()),r,i=!1;for(;!i&&o.length>0;){let h=o.shift(),c=N(h);if(!this.hasHandle(h)&&!s.has(c)){s.add(c);let d=await n(h);if(d.kind==="snarl-exit")r=d.snarl,i=!0;else if(d.kind==="chain")i=!0;else for(let f of["forward","reverse"])o.push(...(await e(ce(c,f))).successors())}}return r}extractPaths(e,t){if(this.clearPaths(),t==="none")return;let n=e?.position;this.refPath=e?.name,this.refHandle=e?.handle;let s=this.sortedHandles(),o=s.length,r=new Map;s.forEach((m,I)=>r.set(m,I));let i=new Int32Array(o+1),h=new Int32Array(o),c=[];for(let m=0;m<o;m++){let I=this.record(s[m]),$=I.gbwt().decompressArrays();h[m]=I.sequenceLen,c.push($),i[m+1]=i[m]+$.nodes.length}let d=i[o],f=new Int32Array(d),p=new Int32Array(d),y=new Uint8Array(d);for(let m=0;m<o;m++){let I=c[m];f.set(I.nodes,i[m]),p.set(I.offsets,i[m])}c.length=0;for(let m=0;m<d;m++){let I=r.get(f[m]);I===void 0?f[m]=-1:(f[m]=I,y[i[I]+p[m]]=1)}let g=n===void 0?void 0:r.get(n.handle),l=n?.gbwtOffset,b,x=(m,I,$)=>{let F=[],_=0,D=0,C=-1,H=m,k=I;for(;;){H===g&&k===l&&(C=_),$&&($.push(s[H]),F.push(k)),_+=1,D+=h[H];let j=i[H]+k,X=f[j];if(X<0)break;k=p[j],H=X}return{offsets:F,len:D,refAt:C,last:H}},P=(m,I,$,F)=>{F>=0&&(this.refId=this.paths.length,b=F),this.paths.push({path:m,offsets:I,len:$,weight:void 0,identity:void 0})},E=new Int32Array(o);for(let m=0;m<o;m++){let I=s[m];if(!Q(I)){let $=i[m],F=i[m+1]-$;for(let _=0;_<F;_++)if(y[$+_]===0){let D=[],{offsets:C,len:H,refAt:k,last:j}=x(m,_,D),X=s[j];if(k>=0||Pe(I,X)){if(P(D,C,H,k),!Q(X)){let w=r.get(ee(X));E[w]=E[w]+1}}else this.twinStarts.add(ke({node:I,offset:_}))}}}for(let m=0;m<o;m++){let I=s[m];if(Q(I)){let $=i[m],F=i[m+1]-$,_=0;for(let C=0;C<F;C++)y[$+C]===0&&(_+=1);let D=(g===void 0||b!==void 0)&&_===E[m];for(let C=0;C<F;C++)if(y[$+C]===0){let H=D?void 0:x(m,C,void 0);if(H&&(H.refAt>=0||Pe(I,s[H.last]))){let k=[],{offsets:j,len:X,refAt:w}=x(m,C,k);P(k,j,X,w)}else this.twinStarts.add(ke({node:I,offset:C}))}}}let R=this.refId===void 0?void 0:this.paths[this.refId];if(this.paths.sort((m,I)=>m.path[0]-I.path[0]||m.offsets[0]-I.offsets[0]),R&&(this.refId=this.paths.indexOf(R)),n){if(b===void 0||this.refId===void 0)throw this.clearPaths(),new Error("Could not find the reference path");let m=this.paths[this.refId],I=n.nodeOffset;for(let F of m.path.slice(0,b))I+=this.record(F).sequenceLen;let $=n.seqOffset-I;this.refInterval=[$,$+m.len],m.identity={pathHandle:e.handle,name:e.name,orientation:"forward",hapStart:$,hapEnd:$+m.len}}if(t==="distinct")this.distinctPaths(!0);else if(t==="reference-only"){if(this.refId===void 0)throw new Error("Reference path is required for reference-only output");this.paths=[this.paths[this.refId]],this.refId=0}}distinctPaths(e){let t=this.refId===void 0?void 0:this.paths[this.refId],n=t?.path,s=n&&!Oe(n)?Be(n):void 0,o=c=>s!==void 0&&wt(c,s)===0||Oe(Be(c)),r=e&&this.db.hasHaplotypeIndex;this.twinDeferred=!1,this.paths.sort((c,d)=>wt(c.path,d.path)||c.len-d.len||(c===t?-1:d===t?1:0));let i=[],h;for(let c of this.paths){let d=i[i.length-1],f=r&&c!==t&&o(c.path);this.twinDeferred||=f,d&&wt(d.path,c.path)===0&&!f?d.weight=(d.weight??1)+(c.weight??1):(c===t&&(h=i.length),i.push({...c,weight:c.weight??1}))}this.paths=i,this.refId=h}mergeDistinct(){this.twinDeferred?this.settleDeferred():this.distinctPaths(!1)}settleDeferred(){this.twinDeferred&&(this.unsettled={paths:[...this.paths],refId:this.refId},this.distinctPaths(!1))}dropTwins(){let e=this.refId===void 0?void 0:this.paths[this.refId],t=this.refInterval,n=r=>`${r.pathHandle}:${r.hapStart}-${r.hapEnd}`,s=new Set;e?.identity&&t&&s.add(n({...e.identity,hapStart:t[0],hapEnd:t[1]}));for(let r of this.paths)r!==e&&r.identity?.orientation==="forward"&&s.add(n(r.identity));let o=this.paths.filter(r=>r===e||r.identity?.orientation!=="reverse"||!s.has(n(r.identity)));o.length<this.paths.length&&(this.paths=o,this.refId=e===void 0?void 0:o.indexOf(e)),this.twinDeferred&&this.distinctPaths(!1)}keepHaplotypes(e){if(this.paths.some(r=>r.weight!==void 0))throw new Error("keepHaplotypes needs one walk per haplotype: extract with haplotypes 'all', then call mergeDistinct()");let t=this.paths.filter((r,i)=>i!==this.refId&&r.identity===void 0).length;if(t>0)throw new Error(`${t} of the window's ${this.paths.length} walks have no name, so the haplotypes to keep cannot be told from the rest; call identifyPaths() first, and check that the haplotype index was built for this graph`);let n=this.refId===void 0?void 0:this.paths[this.refId],s=this.paths.filter((r,i)=>i===this.refId||r.identity!==void 0&&e(r.identity.name)),o=new Set;for(let r of s)for(let i of r.path)o.add(N(i));for(let r of[...this.records.keys()])o.has(N(r))||this.records.delete(r);this.paths=s,this.refId=n===void 0?void 0:s.indexOf(n)}async extractChosenPaths(e,t,n,s){this.clearPaths();let o=e.position.seqOffset,r=await Zt({db:this.db,records:this.records,referenceHandle:e.handle,referencePos:{node:e.position.handle,offset:e.position.gbwtOffset},referenceLeft:o-e.position.nodeOffset,window:{start:o,end:o+t},context:s,snarls:{mode:this.snarlMode,fills:this.snarlFills,inserted:this.snarlNodes},keep:n,signal:this.signal,prefetchReferenceRange:(d,f,p)=>this.prefetchReferenceRange(d,f,p)});if(this.stats.keep=r.stats,r.stats.fallback!==void 0)return!1;let i=await this.db.pathsByHandle(),h=d=>({path:d.handles,offsets:d.offsets,len:d.len,weight:void 0,identity:{pathHandle:d.pathHandle,name:d===r.reference?e.name:i.get(d.pathHandle).name,orientation:d.orientation,hapStart:d.hapStart,hapEnd:d.hapEnd}}),c=[r.reference,...r.pieces].sort(Xt);return this.paths=c.map(h),this.refId=c.indexOf(r.reference),this.refPath=e.name,this.refHandle=e.handle,this.refInterval=[r.reference.hapStart,r.reference.hapEnd],this.dropTwins(),!0}async identifyPaths(){if(!this.db.hasHaplotypeIndex)throw new Error("The database has no HaplotypeSamples table; run gbz-haplotype-index on it");this.unsettled&&({paths:this.paths,refId:this.refId}=this.unsettled,this.unsettled=void 0,this.twinDeferred=!0);let e=await this.db.haplotypeSampleGap()??4096,t=pt(this.sortedHandles());if(t.length===0)return;let n=new Map,s=await Promise.all(t.map(([l,b])=>this.db.haplotypeSamplesInRange(l,b)));for(let l of s.flat())n.set(ke(l),l);let o=l=>{let b=0,x=t.length-1;for(;b<x;){let E=b+x+1>>1;t[E][0]<=l?b=E:x=E-1}let P=t[b];return P[0]<=l&&l<=P[1]},r=new Map;this.paths.forEach((l,b)=>{l.path.length>0&&b!==this.refId&&r.set(ke(Ge(l,0)),b)});let i=this.stats.identification;i.interval=e,i.scans=t,i.windowSamples=n.size,this.paths.forEach((l,b)=>{b!==this.refId&&i.fragmentLengths.push(l.len)});let h=this.recordReader(()=>{this.stats.identificationFetches+=1,i.graphFetches+=1}),c=l=>(i.graphLookups+=1,h(l)),d=async(l,b)=>{if(o(l.node))return n.get(ke(l));this.stats.identificationFetches+=1,i.companionSeeks+=1,b.seeks+=1;let x=await this.db.haplotypeSampleAt(l.node,l.offset);return x||(i.companionMisses+=1),x},f=new Map,p=async l=>{let b=f.get(l);if(!b){let x=await this.db.getPath(l);if(!x)throw new Error(`Path ${l} is missing from the database`);b=x.name,f.set(l,b)}return b},y=(l,b,x)=>l.orientation==="forward"?{pathHandle:l.pathHandle,orientation:"forward",base:l.pathOffset-b}:{pathHandle:l.pathHandle,orientation:"reverse",base:l.pathOffset+b+x},g=(l,b)=>l.orientation==="forward"?{pathHandle:l.pathHandle,orientation:"forward",base:l.hapStart-b}:{pathHandle:l.pathHandle,orientation:"reverse",base:l.hapEnd+b};for(let l=0;l<this.paths.length;l++){let b=this.paths[l];if(l===this.refId||b.identity)continue;let x=[],P=new Set,E={fragments:0,steps:0,seeks:0,reentries:0,twinLandings:0,end:"endmarker",pathHandle:void 0};i.chains.push(E);let R,m=0,I=l,$;for(;R===void 0;){if(this.signal?.throwIfAborted(),I!==void 0){if(P.has(I)){E.end="cycle";break}P.add(I);let H=this.paths[I];x.push({index:I,startBp:m}),E.fragments+=1;let k=m;for(let X=0;X<H.path.length;X++){let w=Ge(H,X),S=n.get(ke(w)),A=this.record(w.node).sequenceLen;if(S){R=y(S,k,A);break}k+=A}if(m+=H.len,R){E.end="in-fragment sample";break}let j=Ge(H,H.path.length-1);$=this.record(j.node).gbwt().lf(j.offset),I=void 0}if($===void 0||$.node===0){E.end="endmarker";break}let F=ke($),_=r.get(F);if(_!==void 0){let H=this.paths[_].identity;if(H){R=g(H,m),E.end="identified sibling";break}I=_;continue}this.records.has($.node)&&(E.reentries+=1),this.twinStarts.has(F)&&(E.twinLandings+=1);let D=await d($,E),C=await c($.node);if(D){R=y(D,m,C.sequenceLen),E.end="out-of-window sample";break}if(this.stats.identificationSteps+=1,E.steps+=1,m-x[x.length-1].startBp>4*e+4*C.sequenceLen){E.end="bound";break}m+=C.sequenceLen,$=C.gbwt().lf($.offset)}if(R){E.pathHandle=R.pathHandle;let F=await p(R.pathHandle);for(let{index:_,startBp:D}of x){let C=this.paths[_];C.identity=R.orientation==="forward"?{pathHandle:R.pathHandle,name:F,orientation:"forward",hapStart:R.base+D,hapEnd:R.base+D+C.len}:{pathHandle:R.pathHandle,name:F,orientation:"reverse",hapStart:R.base-D-C.len,hapEnd:R.base-D}}}}this.dropTwins()}refIndex(e){if(this.refIndexCache===void 0){let t=new Map;e.forEach((n,s)=>{let o=t.get(n);o?o.push(s):t.set(n,[s])}),this.refIndexCache=t}return this.refIndexCache}refPrefix(e){if(this.refPrefixCache===void 0){let t=[0];e.forEach((n,s)=>{t.push(t[s]+this.record(n).sequenceLen)}),this.refPrefixCache=t}return this.refPrefixCache}orderedMatches(e,t){let n=this.refIndex(t),s=new Int32Array(e.length),o=new Int32Array(e.length),r=0,i=-1;for(let h=0;h<e.length;h++){let c=n.get(e[h]);if(c){let d=qn(c,i);if(d===void 0)return;s[r]=h,o[r]=d,r+=1,i=d}}return{pathAt:s,refAt:o,count:r}}pathLen(e){let t=0;for(let n of e)t+=this.record(n).sequenceLen;return t}prefixMatches(e,t){let n=0,s=0,o=0,r=0,i=0;for(;s<e.length&&o<t.length;){let h=this.record(e[s]).sequence,c=this.record(t[o]).sequence;for(;r<h.length&&i<c.length;){if(h[r]!==c[i])return n;r+=1,i+=1,n+=1}r===h.length&&(s+=1,r=0),i===c.length&&(o+=1,i=0)}return n}suffixMatches(e,t){let n=0,s=0,o=0,r=0,i=0;for(;s<e.length&&o<t.length;){let h=this.record(e[e.length-s-1]).sequence,c=this.record(t[t.length-o-1]).sequence;for(;r<h.length&&i<c.length;){if(h[h.length-r-1]!==c[c.length-i-1])return n;r+=1,i+=1,n+=1}r===h.length&&(s+=1,r=0),i===c.length&&(o+=1,i=0)}return n}align(e,t,n){let s=this.pathLen(e),o=this.pathLen(t),r=this.prefixMatches(e,t),i=this.suffixMatches(e,t);r+i>s&&(i=s-r),r+i>o&&(i=o-r),K(n,"M",r),hn(n,s-r-i,o-r-i),K(n,"M",i)}sharedWeight(e,t){let n=this.refIndex(t),s=0;for(let o of e)n.has(o)&&(s+=this.record(o).sequenceLen);return s}editsAgainst(e,t){let n=this.orderedMatches(e,t);n?this.stats.orderedAlignments+=1:this.stats.lcsAlignments+=1;let s=n??Fn(Ut(e,t,f=>this.record(f).sequenceLen)[0]),o=[],r=this.refPrefix(t),i=(f,p,y,g)=>{f===p?K(o,"D",r[g]-r[y]):y===g?K(o,"I",this.pathLen(e.slice(f,p))):this.align(e.slice(f,p),t.slice(y,g),o)},h=0,c=0,d=0;for(let f=0;f<s.count;f++){let p=s.pathAt[f],y=s.refAt[f];(c!==p||d!==y)&&i(c,p,d,y);let g=this.record(e[p]).sequenceLen;K(o,"M",g),h+=g,c=p+1,d=y+1}return i(c,e.length,d,t.length),{edits:o,matched:h,matches:s}}alignment(e){let t=this.paths[e];if(this.refId===void 0||e===this.refId||!t)return;let n=this.paths[this.refId].path,s;if(Oe(n)&&(t.identity===void 0||!Oe(Be(t.path))))s={...this.editsAgainst(t.path,n),flipped:!1};else{let o=Be(t.path),r=this.sharedWeight(t.path,n);if(this.sharedWeight(o,n)===0)s={...this.editsAgainst(t.path,n),flipped:!1};else if(r===0)s={...this.editsAgainst(o,n),flipped:!0};else{let h=this.editsAgainst(t.path,n),c=this.editsAgainst(o,n);s=c.matched>h.matched?{...c,flipped:!0}:{...h,flipped:!1}}}return s}alignToRef(e){return this.settleDeferred(),this.alignment(e)?.edits.map(([t,n])=>`${n}${t}`).join("")}alignments(){this.settleDeferred();let e=this.referenceInterval;if(this.refId===void 0||!e)throw new Error("Alignments need a reference path");let t=this.paths[this.refId].path,n=this.refPrefix(t)[t.length],s=(d,f,p,y)=>{let g=Gn(d),l=this.paths[p[0]],b=this.paths[p[p.length-1]],x=l.identity,P=x?.orientation==="forward",[E,R]=P?[l,b]:[b,l];return{strand:f,refStart:e.start+g.leading,refEnd:e.start+n-g.trailing,edits:g.edits,weight:l.weight,path:p.flatMap(m=>this.paths[m].path),start:Ge(l,0),pieces:p,soloAligned:y,identity:x===void 0?void 0:{pathHandle:x.pathHandle,name:x.name,hapStart:x.name.fragment+E.identity.hapStart,hapEnd:x.name.fragment+R.identity.hapEnd,walkForward:P}}},o=d=>d.soloAligned.reduce((f,p)=>f+p,0),r=d=>d.pieces.reduce((f,p)=>f+this.paths[p].len,0),i=d=>2*o(d)>=r(d),h=d=>{let f=d[0],p=d[d.length-1],y=f.identity.walkForward;if(d.some((k,j)=>k.strand!==f.strand||k.identity.walkForward!==y||j>0&&k.identity.hapStart<d[j-1].identity.hapEnd))return;let g=y?d:[...d].reverse(),l=g.flatMap(k=>k.pieces),b=g.flatMap(k=>k.soloAligned),x=f.strand==="+"!==y,P=l.map(k=>this.paths[k]),E=P.slice(1).map((k,j)=>{let X=P[j].identity;return y?k.identity.hapStart-X.hapEnd:X.hapStart-k.identity.hapEnd}),R=x?[...P].reverse():P,m=x?[...E].reverse():E,I=R.flatMap(k=>x?Be(k.path):k.path),{edits:$}=this.editsAgainst(I,t),F=an($,R.map(k=>k.len)),_=new Map((x?[...l].reverse():l).map((k,j)=>[k,F[j]])),D=k=>2*k.pieces.reduce((j,X)=>j+_.get(X),0)>=o(k);if(!D(f)||!D(p))return;let C=[],H=0;return R.slice(0,-1).forEach((k,j)=>{H+=k.len,C.push([H,m[j]])}),s(Qn($,C),f.strand,l,b)},c=[];return this.paths.forEach((d,f)=>{if(f===this.refId)return;let{edits:p,flipped:y}=this.alignment(f),g=d.identity,l=g?g.orientation==="forward"!==y:!y;c.push(s(p,l?"+":"-",[f],an(p,[d.len])))}),jn(c,i,h).map(d=>{let{edits:f,identity:p,pieces:y,soloAligned:g,...l}=d,b={...l,cigar:Kn(f)};return p?{...b,resolved:!0,name:p.name,label:fe({...p.name,fragment:p.hapStart,end:p.hapEnd}),pathHandle:p.pathHandle,hapStart:p.hapStart,hapEnd:p.hapEnd}:{...b,resolved:!1}})}pairAlignments(e){let{target:t,query:n,...s}=e,o=this.paths.flatMap(d=>{let{identity:f}=d;return f?[{name:f.name,start:f.name.fragment+f.hapStart,steps:Ke(d,f)}]:[]}),r=d=>f=>f.sample===d.sample&&f.haplotype===d.haplotype,i=r(t),h=n?r(n):d=>!i(d),c=d=>this.record(ce(d,"forward")).sequence;return o.filter(d=>i(d.name)).flatMap(d=>o.filter(f=>h(f.name)).flatMap(f=>Wt({...s,query:f.steps,target:d.steps,sequenceOf:c}).map(p=>({query:f.name,queryStart:f.start+p.queryStart,queryEnd:f.start+p.queryEnd,strand:p.strand,target:d.name,targetStart:d.start+p.targetStart,targetEnd:d.start+p.targetEnd,cigar:Vt(p.edits),matches:p.edits.reduce((y,[g,l])=>y+(g==="="?l:0),0),columns:p.edits.reduce((y,[,g])=>y+g,0),sharedBases:p.sharedBases}))))}canonicalEdges(e){let t=[];for(let n of["forward","reverse"]){let s=ce(e,n);for(let o of this.record(s).successors())this.hasHandle(o)&&He(s,o)&&t.push([n==="reverse"?1:0,N(o),Q(o)?1:0])}return t.sort((n,s)=>n[0]-s[0]||n[1]-s[1]||n[2]-s[2]),t.filter((n,s)=>s===0||n[0]!==t[s-1][0]||n[1]!==t[s-1][1]||n[2]!==t[s-1][2])}async stableName(){let e=new TextEncoder,t=[];for(let n of this.sortedHandles())if(!Q(n)){let s=N(n),o=`S ${s} ${this.record(n).sequence}
|
|
2
2
|
`;for(let[r,i,h]of this.canonicalEdges(s))o+=`L ${s} ${r?"-":"+"} ${i} ${h?"-":"+"}
|
|
3
3
|
`;t.push(e.encode(o))}return rn(t)}async toGFA(e={}){this.settleDeferred();let t=e.cigar??!1,n=[this.refPath?`H VN:Z:1.1 RS:Z:${this.refPath.sample}`:"H VN:Z:1.1",...on(sn(await this.stableName(),await this.db.graphName()))],s=this.sortedHandles();for(let c of s)Q(c)||n.push(`S ${N(c)} ${this.record(c).sequence}`);let o=c=>Q(c)?"-":"+";for(let c of s)for(let d of this.record(c).successors())this.hasHandle(d)&&He(c,d)&&n.push(`L ${N(c)} ${o(c)} ${N(d)} ${o(d)} 0M`);let r=(c,d,f,p,y)=>{let g=Ke(c,d).map(x=>`${Q(x)?"<":">"}${N(x)}`).join(""),l=c.weight===void 0?"":` WT:i:${c.weight}`,b=y===void 0?"":` CG:Z:${y}`;return`W ${f.sample} ${f.haplotype} ${f.contig} ${f.fragment} ${p} ${g}${l}${b}`},i=this.refPath?.contig??"unknown";this.refId!==void 0&&this.refPath&&this.refInterval&&n.push(r(this.paths[this.refId],void 0,{...this.refPath,fragment:this.refPath.fragment+this.refInterval[0]},this.refPath.fragment+this.refInterval[1],void 0));let h=1;return this.paths.forEach((c,d)=>{if(d!==this.refId){let f=e.names!=="anonymous"?c.identity:void 0,p=t?this.alignToRef(d):void 0;n.push(f?r(c,f,{...f.name,fragment:f.name.fragment+f.hapStart},f.name.fragment+f.hapEnd,p):r(c,void 0,{sample:"unknown",contig:i,haplotype:h,fragment:0},c.len,p)),h+=1}}),`${n.join(`
|
|
4
4
|
`)}
|
|
@@ -6,4 +6,4 @@ import{a as ce,b as N,c as Ee,d as Q,e as ee,f as Ft,g as Ue,h as We,i as qt,j a
|
|
|
6
6
|
`).filter(p=>p!=="")),n=(f,p)=>f.filter(y=>y.startsWith(`${p} `)),s=cs(t.flat()),o=0,r=t.map(f=>{let p=n(f,"W").map(hs),y=o;for(let g of p.filter(l=>l.fields[1]===is)){let l=+g.fields[2]+y;g.fields[2]=String(l),g.name=g.fields.slice(1,4).join(" "),o=Math.max(o,l)}return p}),h=[...Ot([...r.flatMap(f=>f.slice(0,1)),...r.flatMap(f=>f.slice(1))],f=>f.name).values()].flatMap(f=>fs(f,s,e)),c=new Set(t.flatMap(f=>n(f,"L")));for(let f of h)for(let p of ls(f))!c.has(p.forward)&&!c.has(p.reverse)&&c.add(p.forward);return`${[...new Set([...n(t[0],"H"),...t.flatMap(f=>n(f,"S")),...c,...h.map(f=>f.fields.join(" "))])].join(`
|
|
7
7
|
`)}
|
|
8
8
|
`}var In=class extends Error{constructor(a,e){super(e.length===0?`the graph names no reference sample (gbwt_reference_samples) and the anchor "${a}" maps to none; set referenceSample`:`the anchor "${a}" is none of the graph's reference samples (${e.join(", ")}); set referenceSample or map it through assemblyNameToPanSN`),this.name="NoReferenceSampleError"}},En=class extends Error{constructor(a,e,t){super(`this ${e.toLocaleString()} bp window reads more than nodeLimit (${a.toLocaleString()}) graph nodes; zoom in to about ${t.toLocaleString()} bp or raise nodeLimit`),this.fitsBp=t,this.name="NodeLimitError",this.regionTooLarge=!0}};function kn(a){return`${a.sample}#${a.haplotype}`}function ps(a,e){let t=kn(a);return e===void 0||e.some(n=>Bt(t,n))}async function us(a){return(await a.tag("gbwt_reference_samples")??"").split(/\s+/).filter(e=>e!=="")}function vn(a,e){let t=a.toLowerCase(),n=_t(a)?.toLowerCase();return e.find(s=>s===a)??e.find(s=>s.toLowerCase()===t)??e.find(s=>s.toLowerCase()===n)}function ws({configured:a,anchorPrefix:e,referenceSamples:t}){if(a!=="")return a;let n=vn(Ct(e),t)??(t.length===1?t[0]:void 0);if(n===void 0)throw new In(e,t);return n}async function gs(a,e,t){let n=(await a.paths()).find(s=>s.isIndexed&&s.name.sample===e&&s.name.contig===t);return n?{sample:n.name.sample,contig:t,haplotype:n.name.haplotype}:void 0}function Pn(a,e,t){if(a instanceof Error&&(a.name==="SubgraphLimitError"||/^Subgraph size limit of \d+ nodes exceeded/.test(a.message))){let s=a.walkedBp,o=typeof s=="number"&&s>0?Math.floor(s*.8):Math.floor(t/2);return new En(e,t,Math.max(o,1))}else return}var ms={context:1e3,snarls:"contained",limit:1e5};async function ys(a,e,t,n,s){return a.getSubgraphs({...s,path:e,start:t,end:n,haplotypes:"all"}).catch(o=>{throw Pn(o,s.limit,n-t)??o})}async function bs(a,e){let t=await a.paths();return Sn(await Promise.all(e.map(n=>n.toGFA())),(n,s,o,r)=>t.some(({name:i})=>i.sample===n&&i.haplotype===s&&i.contig===o&&i.fragment===r))}async function xs(a,e,t,n,s){if(!e)return"";let o=await ys(a,e,t,n,s);if(o.length===1)return An(o[0].toCompactSubgraph());let r=await bs(a,o);return r&&Tt(r)||r}function Ss(a,e){let t=1/0,n=-1/0;for(let i of a)t=Math.min(t,i),n=Math.max(n,i);let s=n-t+1,o=a.length>0&&s<=16*a.length?new Int32Array(s).fill(-1):void 0,r=new Map;return a.forEach((i,h)=>{o?o[i-t]=h:r.set(i,h)}),i=>{let h=N(i),c=o!==void 0&&h>=t&&h<=n,d=c?o[h-t]:r.get(h)??-1;return d>=0?d:(c?o[h-t]=e.length:r.set(h,e.length),e.push(String(h)),e.length-1)}}var Is=/^(.*)\[(\d+)-(\d+)\]$/;function An(a){let e=Array.from(a.nodeIds,String),t=Ss(a.nodeIds,e),n=a.nodeIds.length,s=a.edges.length/2,o=new Int32Array(s),r=new Int32Array(s),i=new Uint8Array(s);for(let l=0;l<s;l++){let b=a.edges[2*l],x=a.edges[2*l+1];o[l]=t(b),r[l]=t(x),i[l]=(Q(b)?1:0)|(Q(x)?2:0)}let h=a.paths.filter(l=>l.steps.length>0),c=new Int32Array(h.length+1);h.forEach((l,b)=>{c[b+1]=c[b]+l.steps.length});let d=new Int32Array(c[h.length]),f=new Uint8Array(d.length),p=new Float64Array(h.length),y=new Float64Array(h.length),g=h.map((l,b)=>{let x=Is.exec(l.name);p[b]=x?+x[2]:0,y[b]=x?+x[3]:-1;let P=c[b];for(let E of l.steps)d[P]=t(E),f[P++]=Q(E)?1:0;return x?x[1]:l.name});return{nodes:{names:e,lengths:Int32Array.from(a.nodeSequences,l=>l.length),refs:new Int32Array(n).fill(-1),starts:new Float64Array(n),ranks:new Int32Array(n),refNames:[]},links:{from:o,to:r,strands:i},walks:{names:g,starts:p,ends:y,offsets:c,steps:d,reversed:f}}}export{le as a,St as b,En as c,kn as d,ps as e,us as f,ws as g,gs as h,Pn as i,ms as j,xs as k};
|
|
9
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-4KVQOJHH.js.map
|