jbrowse-plugin-graphgenomeviewer 8.3.6 → 8.3.7
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/dist/chunks/{GbzBaseSyntenyAdapter-BG6FNGHY.js → GbzBaseSyntenyAdapter-4FATZPZG.js} +2 -2
- package/dist/chunks/{GbzBaseSyntenyAdapter-BG6FNGHY.js.map → GbzBaseSyntenyAdapter-4FATZPZG.js.map} +1 -1
- package/dist/chunks/{GraphGenomeView-JJNU2432.js → GraphGenomeView-H2Z5NQW4.js} +2 -2
- package/dist/chunks/{GraphTrackSettingsDialog-7NGUPDUJ.js → GraphTrackSettingsDialog-LFFJHC7F.js} +2 -2
- package/dist/chunks/{HighlightColorDialog-KFXSZXTC.js → HighlightColorDialog-76RJSXSV.js} +2 -2
- package/dist/chunks/{LinearGraphDisplay-K3AT3S7J.js → LinearGraphDisplay-VYPF26DJ.js} +2 -2
- package/dist/chunks/{MinigraphBubbleAdapter-P66QLENP.js → MinigraphBubbleAdapter-WQUZTNDM.js} +2 -2
- package/dist/chunks/{RgfaTabixAdapter-CQJROUIP.js → RgfaTabixAdapter-K763K62E.js} +2 -2
- package/dist/chunks/{WalkFormsAdapter-YSYANJD5.js → WalkFormsAdapter-WJTEKIOB.js} +2 -2
- package/dist/chunks/{WalkTabixSyntenyAdapter-7COETKFB.js → WalkTabixSyntenyAdapter-PHRULBP7.js} +2 -2
- package/dist/chunks/{chunk-L372SDUG.js → chunk-3M3UH5JQ.js} +1 -1
- package/dist/chunks/{chunk-L372SDUG.js.map → chunk-3M3UH5JQ.js.map} +1 -1
- package/dist/chunks/{chunk-KVZIGTH3.js → chunk-477HYXB2.js} +2 -2
- package/dist/chunks/{chunk-HQ7FQACT.js → chunk-47KLT4FL.js} +2 -2
- package/dist/chunks/{chunk-HQ7FQACT.js.map → chunk-47KLT4FL.js.map} +1 -1
- package/dist/chunks/{chunk-LD6RX4AZ.js → chunk-6NR64IXK.js} +1 -1
- package/dist/chunks/{chunk-LD6RX4AZ.js.map → chunk-6NR64IXK.js.map} +1 -1
- package/dist/chunks/{chunk-C5YAQNOO.js → chunk-6YK4U5LT.js} +2 -2
- package/dist/chunks/{chunk-C5YAQNOO.js.map → chunk-6YK4U5LT.js.map} +2 -2
- package/dist/chunks/{chunk-4B3GQTHX.js → chunk-75WJWJ45.js} +2 -2
- package/dist/chunks/{chunk-4B3GQTHX.js.map → chunk-75WJWJ45.js.map} +1 -1
- package/dist/chunks/{chunk-YS3R3J2I.js → chunk-AILGRHTE.js} +2 -2
- package/dist/chunks/{chunk-YS3R3J2I.js.map → chunk-AILGRHTE.js.map} +1 -1
- package/dist/chunks/{chunk-DKQFTMWL.js → chunk-CI6VQ2KV.js} +2 -2
- package/dist/chunks/{chunk-DKQFTMWL.js.map → chunk-CI6VQ2KV.js.map} +1 -1
- package/dist/chunks/{chunk-HLWIFWDZ.js → chunk-DFWLOMRU.js} +2 -2
- package/dist/chunks/{chunk-NFPLX56S.js → chunk-HVDE2ZKA.js} +1 -1
- package/dist/chunks/{chunk-NFPLX56S.js.map → chunk-HVDE2ZKA.js.map} +1 -1
- package/dist/chunks/{chunk-QB5JERW4.js → chunk-IICQFAGJ.js} +1 -1
- package/dist/chunks/{chunk-QB5JERW4.js.map → chunk-IICQFAGJ.js.map} +1 -1
- package/dist/chunks/{chunk-HICKAMKK.js → chunk-PVRRW4PM.js} +2 -2
- package/dist/chunks/{chunk-HICKAMKK.js.map → chunk-PVRRW4PM.js.map} +1 -1
- package/dist/chunks/chunk-SQBD75UZ.js +2 -0
- package/dist/chunks/{chunk-EVKN4Y3R.js → chunk-SVF6WK42.js} +2 -2
- package/dist/chunks/{chunk-EVKN4Y3R.js.map → chunk-SVF6WK42.js.map} +1 -1
- package/dist/chunks/chunk-UOWS2HEQ.js +2 -0
- package/dist/chunks/chunk-UOWS2HEQ.js.map +7 -0
- package/dist/chunks/{chunk-RCJQCBBI.js → chunk-VEI7EAE6.js} +2 -2
- package/dist/chunks/{chunk-NBS4FGQ6.js → chunk-VZNECPSI.js} +2 -2
- package/dist/chunks/{chunk-DAF7EWRF.js → chunk-XK4HHKSP.js} +2 -2
- package/dist/chunks/{chunk-3S33TTXF.js → chunk-XTEZPFP4.js} +2 -2
- package/dist/chunks/{chunk-3S33TTXF.js.map → chunk-XTEZPFP4.js.map} +1 -1
- package/dist/chunks/chunk-YDJ6SDQM.js +3 -0
- package/dist/chunks/chunk-YDJ6SDQM.js.map +7 -0
- package/dist/chunks/{renderSvg-2YULK24A.js → renderSvg-W2VIM3IT.js} +2 -2
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +2 -2
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +2 -2
- package/package.json +2 -2
- package/src/RgfaTabixAdapter/walkFiles.test.ts +7 -3
- package/src/version.ts +1 -1
- package/dist/chunks/chunk-3HS6N7WB.js +0 -2
- package/dist/chunks/chunk-3HS6N7WB.js.map +0 -7
- package/dist/chunks/chunk-CNFMSSE2.js +0 -3
- package/dist/chunks/chunk-CNFMSSE2.js.map +0 -7
- package/dist/chunks/chunk-SYKOZDP6.js +0 -2
- /package/dist/chunks/{GraphGenomeView-JJNU2432.js.map → GraphGenomeView-H2Z5NQW4.js.map} +0 -0
- /package/dist/chunks/{GraphTrackSettingsDialog-7NGUPDUJ.js.map → GraphTrackSettingsDialog-LFFJHC7F.js.map} +0 -0
- /package/dist/chunks/{HighlightColorDialog-KFXSZXTC.js.map → HighlightColorDialog-76RJSXSV.js.map} +0 -0
- /package/dist/chunks/{LinearGraphDisplay-K3AT3S7J.js.map → LinearGraphDisplay-VYPF26DJ.js.map} +0 -0
- /package/dist/chunks/{MinigraphBubbleAdapter-P66QLENP.js.map → MinigraphBubbleAdapter-WQUZTNDM.js.map} +0 -0
- /package/dist/chunks/{RgfaTabixAdapter-CQJROUIP.js.map → RgfaTabixAdapter-K763K62E.js.map} +0 -0
- /package/dist/chunks/{WalkFormsAdapter-YSYANJD5.js.map → WalkFormsAdapter-WJTEKIOB.js.map} +0 -0
- /package/dist/chunks/{WalkTabixSyntenyAdapter-7COETKFB.js.map → WalkTabixSyntenyAdapter-PHRULBP7.js.map} +0 -0
- /package/dist/chunks/{chunk-KVZIGTH3.js.map → chunk-477HYXB2.js.map} +0 -0
- /package/dist/chunks/{chunk-HLWIFWDZ.js.map → chunk-DFWLOMRU.js.map} +0 -0
- /package/dist/chunks/{chunk-SYKOZDP6.js.map → chunk-SQBD75UZ.js.map} +0 -0
- /package/dist/chunks/{chunk-RCJQCBBI.js.map → chunk-VEI7EAE6.js.map} +0 -0
- /package/dist/chunks/{chunk-NBS4FGQ6.js.map → chunk-VZNECPSI.js.map} +0 -0
- /package/dist/chunks/{chunk-DAF7EWRF.js.map → chunk-XK4HHKSP.js.map} +0 -0
- /package/dist/chunks/{renderSvg-2YULK24A.js.map → renderSvg-W2VIM3IT.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ne,b as ae,c as ue,d as re,e as oe,f as O,g as ie,h as se}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=GbzBaseSyntenyAdapter-
|
|
1
|
+
import{a as ne,b as ae,c as ue,d as re,e as oe,f as O,g as ie,h as se}from"./chunk-DFWLOMRU.js";import{a as te}from"./chunk-SQBD75UZ.js";import{a as ee}from"./chunk-KOB7YIMR.js";import{a as Q,b as D,c as Z,d as u,e as k,f as M,g as j,h as $,i as W,k as U}from"./chunk-SVF6WK42.js";import"./chunk-M2D7NUOY.js";import{h as z,i as E}from"./chunk-47KLT4FL.js";import"./chunk-YBLNN5FU.js";import"./chunk-UOWS2HEQ.js";import"./chunk-PVRRW4PM.js";import{E as V,a as K,c as L}from"./chunk-XK4HHKSP.js";import"./chunk-YBLNN5FU.js";import"./chunk-ROZPEXN4.js";import{g as F,h as N,i as C}from"./chunk-3M3UH5JQ.js";import"./chunk-OTBDKJEA.js";import"./chunk-3VGXCEMQ.js";import{e as G,h as X,i as Y,j as J}from"./chunk-6VNDP3UB.js";import{a as P}from"./chunk-OGQ6OQDN.js";import"./chunk-3WG3GF2A.js";import{e as _,o as B}from"./chunk-J5RMHLFJ.js";function A(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function ge(n){return Y(n)&&A(X(n))?J(n,i=>A(i)):void 0}function ye(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function ce(n,i){let e=ge(n);if(!e)return{};try{return await P(e,i).stat(),{location:e}}catch(t){return ye(t)?{}:{unreadable:String(t)}}}var be=5e3,we=50*2**20,H=class extends Error{constructor(e){super(`this GAF is ${(e/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function xe(n,i){if(n.length<=i)return n;let e=n.length/i;return Array.from({length:i},(t,a)=>n[Math.floor(a*e)])}var pe=(n,i)=>n.path.some(e=>i.has(e.name)),v=class{constructor(i,e){this.file=i;this.tabix=e;this.whole=L({setup:async({signal:i})=>{let{size:e}=await this.file.stat();if(e>we)throw new H(e);let t=await this.file.readFile({signal:i}),a=new TextDecoder().decode(t[0]===31&&t[1]===139?await K(t):t);return E(a)}})}async readIndexed(i,e,t){let a=1/0,r=-1/0;for(let s of e){let c=Number(s);Number.isInteger(c)&&(a=Math.min(a,c),r=Math.max(r,c))}let o=[];return a<=r&&await i.getLines("{node}",a,r+1,{signal:t,lineCallback:s=>{let c=z(s);c&&pe(c,e)&&o.push(c)}}),o}async readsOver(i,{signal:e}={}){let t=this.tabix?await this.readIndexed(this.tabix,i,e):(await this.whole({signal:e})).filter(a=>pe(a,i));return{records:xe(t,be),total:t.length}}};var I=class extends Error{constructor(e){super(e===void 0?"no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation":`the haplotype index beside the graph database could not be checked (${e}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},q=class extends Error{constructor(e,t){super(`the graph is cut on its reference, ${t}; a window on ${e} has no reference coordinates to cut at. Open the graph from a ${t} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function Se(n,i){return`${u(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function Ne({alignment:n,assemblyName:i,refName:e,lane:t}){let{refStart:a,refEnd:r,strand:o,cigar:s}=n;if(!(r<=a)){let{name:c,hapStart:p,hapEnd:l}=n,f=Se(c,n),g={uniqueId:f,assemblyName:i,refName:e,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:s,syntenyId:f,mate:{refName:c.contig,start:p,end:l,assemblyName:t}};return new ne(g)}}function Pe({pair:n,lane:i,mateLane:e}){return se({target:{name:`${u(n.target)}#${n.target.contig}`,assemblyName:i,refName:n.target.contig,start:n.targetStart,end:n.targetEnd},query:{name:`${u(n.query)}#${n.query.contig}`,assemblyName:e,refName:n.query.contig,start:n.queryStart,end:n.queryEnd},strand:n.strand,cigar:n.cigar,matches:n.matches,columns:n.columns})}var Le=12e4;function Re(n,i){let e=new Map;for(let a of n)for(let{name:r,start:o,end:s}of a.walkSpans()){let c=u(r);if(i.has(c)){let p=`${c}#${r.contig}`,l=e.get(p);l?l.push([o,s]):e.set(p,[[o,s]])}}let t=0;for(let a of e.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Le&&(t=Math.max(t,o))}}return t}function fe(n,i){return n instanceof Z&&(n.message=`Zoom in to about ${_(n.fitsBp)} to see ${i}`),n}var le=(n,i,e)=>ie(fe(W(n,i,e)??n,"lanes"),e),me=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),T=class extends ae{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let e=this.getConf("gbzDbLocation"),t=this.getConf("haplotypeIndexLocation"),a=G(t)?{location:t}:await ce(e,this.pluginManager),r=a.location,o=await D.open({source:P(e,this.pluginManager),haplotypeIndex:r?P(r,this.pluginManager):void 0}),s=this.getConf("assemblyNames")[0];if(s===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let c=await M(o),p=j({configured:this.getConf("referenceSample"),anchorPrefix:N(this,s),referenceSamples:c});return{db:o,anchor:s,referenceSample:p,referenceSamples:c,unreadableIndex:a.unreadable}}});this.gaf=L({label:"Opening reads",setup:async()=>{let e=this.getConf("readsLocation"),t=this.getConf(["readsIndex","location"]);return G(e)?new v(P(e,this.pluginManager),G(t)?V(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(e,t){let{db:a,referenceSample:r}=await this.graph(t);return $(a,r,e)}async getHaplotypes(e={}){let{db:t,referenceSamples:a}=await this.graph(e),r=new Map;for(let o of await t.paths()){let s=u(o.name),c=r.get(s);c?c.contigs.includes(o.name.contig)||c.contigs.push(o.name.contig):r.set(s,{prefix:s,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(e={}){let{anchor:t,referenceSample:a}=await this.graph(e),r=C(this),o=[];for(let s of await this.getHaplotypes(e))s.sample!==a&&o.push({name:O(r,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:t,lanes:o}}async getRefNames(e={}){let{db:t,anchor:a,referenceSample:r}=await this.graph(e),{assemblyName:o}=e,s=o===a?void 0:N(this,o),c=(await t.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:F(u(p.name),s)).map(p=>p.name.contig);return[...new Set(c)]}keepPredicate(e,t){let a=e===void 0||e.length===0?void 0:e.map(r=>N(this,r));return a===void 0&&t===void 0?void 0:r=>k(r,a)&&(t===void 0||F(u(r),t))}async getSubgraph(e,t={}){let{signal:a}=t,{db:r,anchor:o,referenceSample:s,unreadableIndex:c}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:f,end:g}=me(e);if(p!==o)throw new q(p,o);let y=await this.referenceQuery(l,{signal:a});if(!y)throw new Error(`${s} has no indexed path ${l} in this graph`);let b=this.keepPredicate(t.haplotypes);if(b!==void 0&&!r.hasHaplotypeIndex)throw new I(c);let d=await U(r,y,f,g,{context:this.getConf("context"),snarls:t.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:t.signal,keep:b}).catch(w=>{throw fe(w,"the graph")});return typeof d=="string"?d:te(d,{start:f,end:g},t.walkRows)}async getReads(e,t={}){let a=await this.gaf(t);return a?a.readsOver(new Set(e),t):{records:[],total:0}}async laneHaplotypes(e,t){let a=N(this,e);return(await this.getHaplotypes(t)).filter(r=>F(r.prefix,a))}async anchorFeatures(e,t){let{db:a}=await this.graph(t),{assemblyName:r,refName:o,start:s,end:c}=e,p=N(this,t.targetAssemblyName),l=C(this),f=this.keepPredicate(t.haplotypes,p),g=await this.referenceQuery(o,t),y=this.getConf("nodeLimit");return(g?await B(`Reading graph ${o}:${s.toLocaleString()}-${c.toLocaleString()}`,t.statusCallback,()=>a.getAlignments({path:g,start:s,end:c,context:this.getConf("context"),haplotypes:"all",limit:y,signal:t.signal,keep:f}).catch(d=>{throw le(d,y,c-s)})):[]).flatMap(d=>{let w=d.resolved?Ne({alignment:d,assemblyName:r,refName:o,lane:O(l,u(d.name))}):void 0;return w===void 0?[]:[w]})}async pairFeatures(e,t,a){let{db:r}=await this.graph(a),{refName:o,start:s,end:c}=e,l=(await Promise.all(t.map(async m=>({pair:m,featureSide:await this.laneHaplotypes(m.queryAssemblyName,a),mateSide:await this.laneHaplotypes(m.targetAssemblyName,a)})))).filter(({featureSide:m,mateSide:h})=>m.length>0&&h.length>0),f=new Set(l.flatMap(({featureSide:m,mateSide:h})=>[...m,...h].map(u))),g=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),b=this.getConf("context"),d=(m,h)=>r.getSubgraphs({path:m,start:s,end:c,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:x=>f.has(u(x))}),w=async m=>{let h=await d(m,b).catch(S=>{throw le(S,y,c-s)}),x=Re(h,f),R=Math.ceil(x/2)+2e3;return x>0&&R>b?d(m,R).catch(S=>{if(S instanceof Q)return h;throw S}):h};return(g&&l.length>0?await B(oe(t),a.statusCallback,()=>w(g)):[]).flatMap(m=>l.flatMap(({pair:h,featureSide:x,mateSide:R})=>x.flatMap(S=>R.flatMap(de=>m.pairAlignments({target:S,query:de,bases:!1}).map(he=>Pe({pair:he,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(e,t={}){let a=me(e);return ee(async r=>{let{db:o,anchor:s,unreadableIndex:c}=await this.graph(t);if(!o.hasHaplotypeIndex)throw new I(c);if(a.assemblyName===s){let p=re(t),l=p.length>0?await this.pairFeatures(a,p,t):await this.anchorFeatures(a,t);for(let f of l)r.next(f)}r.complete()},t.signal)}};export{I as NoHaplotypeIndexError,ue as PairTargetError,T as default,Re as widestWalkGap};
|
|
2
|
+
//# sourceMappingURL=GbzBaseSyntenyAdapter-4FATZPZG.js.map
|
package/dist/chunks/{GbzBaseSyntenyAdapter-BG6FNGHY.js.map → GbzBaseSyntenyAdapter-4FATZPZG.js.map}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@12.
|
|
3
|
+
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@12.4.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-BGEAXWE7.js", "../../src/GbzBaseSyntenyAdapter/companion.ts", "../../src/gaf/gafFile.ts", "../../src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts"],
|
|
4
4
|
"sourcesContent": ["import {\n GBZ_CUT_DEFAULTS,\n NoReferenceSampleError,\n aliasedSample,\n cutWindowGFA,\n haplotypeWanted,\n referencePathQuery,\n referenceSamplesOf\n} from \"./chunk-4NUW2F2Y.js\";\nimport {\n panSNSample\n} from \"./chunk-2JL2JVZ2.js\";\n\n// src/gbzCut.ts\nimport { GBZBase } from \"@gmod/gbz-base\";\nvar HPRC_GBZ = {\n db: \"https://s3-us-west-2.amazonaws.com/human-pangenomics/pangenomes/freeze/release2/minigraph-cactus/v2.1/hprc-v2.1-mc-grch38/hprc-v2.1-mc-grch38.gbz.db\",\n index: \"https://jbrowse.org/demos/hprc/hprc-v2.1-mc-grch38.haplotype-index.f3.db\"\n};\nfunction gbzLocations({ db, index }) {\n return db === \"hprc\" ? { db: HPRC_GBZ.db, index: index ?? HPRC_GBZ.index } : { db, index };\n}\nfunction haplotypeIndexBeside(db) {\n const GBZ_DB = /\\.gbz\\.db$/i;\n return GBZ_DB.test(db) ? db.replace(GBZ_DB, \".haplotype-index.db\") : void 0;\n}\nfunction parseRegion(text) {\n const m = /^\\s*(\\S+?):([\\d,]+)-([\\d,]+)\\s*$/.exec(text);\n if (!m) {\n throw new Error(\n `\"${text}\" is not a 0-based region like chr6:160,614,797-160,647,758`\n );\n }\n const n = (s) => Number(s.replaceAll(\",\", \"\"));\n const region = { refName: m[1], start: n(m[2]), end: n(m[3]) };\n if (region.end <= region.start) {\n throw new Error(`\"${text}\" ends at or before it starts`);\n }\n return region;\n}\nasync function openGbz(db, index) {\n const base = await GBZBase.open({ source: db, haplotypeIndex: index });\n return { base, referenceSamples: await referenceSamplesOf(base) };\n}\nfunction referenceSample(ref, samples) {\n if (ref) {\n return aliasedSample(panSNSample(ref), samples) ?? ref;\n }\n const first = samples[0];\n if (first === void 0) {\n throw new NoReferenceSampleError(\"\", samples);\n }\n return first;\n}\nasync function cutGbzRegion({ base, referenceSamples }, src, signal) {\n const region = parseRegion(src.region);\n const sample = referenceSample(src.referenceSample, referenceSamples);\n const query = await referencePathQuery(base, sample, region.refName);\n if (!query) {\n throw new Error(`${sample} has no indexed path named ${region.refName}`);\n }\n signal?.throwIfAborted();\n const wanted = src.haplotypes?.length ? src.haplotypes : void 0;\n const text = await cutWindowGFA(base, query, region.start, region.end, {\n context: src.context ?? GBZ_CUT_DEFAULTS.context,\n snarls: src.snarls ?? GBZ_CUT_DEFAULTS.snarls,\n limit: GBZ_CUT_DEFAULTS.limit,\n signal,\n keep: wanted ? (name) => haplotypeWanted(name, wanted) : void 0\n });\n return { text, region, sample };\n}\n\nexport {\n HPRC_GBZ,\n gbzLocations,\n haplotypeIndexBeside,\n parseRegion,\n openGbz,\n cutGbzRegion\n};\n", "import { haplotypeIndexBeside } from '@jbrowse/bandage-core/gbzCut'\nimport { openLocation } from '@jbrowse/core/util/io'\n\nimport { locationName, readsSiblings, renamed } from '../locationName'\n\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { FileLocation } from '@jbrowse/core/util/types'\n\nexport function siblingCompanion(gbzDb: FileLocation) {\n return readsSiblings(gbzDb) && haplotypeIndexBeside(locationName(gbzDb))\n ? renamed(gbzDb, name => haplotypeIndexBeside(name)!)\n : undefined\n}\n\n// 404 is a missing file, and so is 403 from a bucket that does not let a\n// reader list it; anything else leaves the file's presence unknown\nfunction isMissing(error: unknown) {\n return (\n error instanceof Error &&\n (/\\bHTTP 40[34]\\b/.test(error.message) ||\n (error as { code?: unknown }).code === 'ENOENT')\n )\n}\n\n// `unreadable` is why a companion that may be there could not be checked, such\n// as a network error, or a server that answers a missing file without CORS\nexport async function findCompanion(\n gbzDb: FileLocation,\n pluginManager?: PluginManager,\n): Promise<{ location?: FileLocation; unreadable?: string }> {\n const candidate = siblingCompanion(gbzDb)\n if (!candidate) {\n return {}\n }\n try {\n await openLocation(candidate, pluginManager).stat()\n return { location: candidate }\n } catch (error) {\n return isMissing(error) ? {} : { unreadable: String(error) }\n }\n}\n", "import { unzip } from '@gmod/bgzf-filehandle'\nimport { parseGaf, parseGafLine } from '@jbrowse/bandage-core/gaf/parseGaf'\nimport { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'\n\nimport type { TabixIndexedFile } from '@gmod/tabix'\nimport type { GafRecord } from '@jbrowse/bandage-core/gaf/parseGaf'\n\ninterface WholeFile {\n stat(): Promise<{ size: number }>\n readFile(opts?: { signal?: AbortSignal }): Promise<Uint8Array>\n}\n\nexport interface GafReads {\n records: GafRecord[]\n // reads over the nodes before sampling\n total: number\n}\n\n// The tube map lays reads out on the main thread at about 40 ms per thousand\nexport const MAX_READS = 5000\n\n// An unindexed GAF is read whole, once, into the worker\nconst MAX_UNINDEXED_BYTES = 50 * 2 ** 20\n\nexport class UnindexedGafTooLargeError extends Error {\n override name = 'UnindexedGafTooLargeError'\n\n constructor(size: number) {\n super(\n `this GAF is ${(size / 2 ** 20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`,\n )\n }\n}\n\n// Evenly spaced, so a pileup thins out rather than losing its right half\nfunction sample(records: GafRecord[], max: number) {\n if (records.length <= max) {\n return records\n }\n const stride = records.length / max\n return Array.from({ length: max }, (_, k) => records[Math.floor(k * stride)]!)\n}\n\nconst touches = (record: GafRecord, names: ReadonlySet<string>) =>\n record.path.some(step => names.has(step.name))\n\n// A GAF over a graph's segments: bgzipped and indexed with `tabix -p gaf`,\n// which keys each line by its lowest and highest node id and so needs numeric\n// segment names, or plain or gzipped and read whole.\nexport class GafFile {\n // Shared by every window, so the signal is cachedSetup's own, which aborts\n // once no caller is left waiting\n private whole = cachedSetup({\n setup: async ({ signal }) => {\n const { size } = await this.file.stat()\n if (size > MAX_UNINDEXED_BYTES) {\n throw new UnindexedGafTooLargeError(size)\n }\n const bytes = await this.file.readFile({ signal })\n const text = new TextDecoder().decode(\n bytes[0] === 0x1f && bytes[1] === 0x8b ? await unzip(bytes) : bytes,\n )\n return parseGaf(text)\n },\n })\n\n constructor(\n private file: WholeFile,\n private tabix?: TabixIndexedFile,\n ) {}\n\n private async readIndexed(\n tabix: TabixIndexedFile,\n names: ReadonlySet<string>,\n signal?: AbortSignal,\n ) {\n let lo = Infinity\n let hi = -Infinity\n for (const name of names) {\n const id = Number(name)\n if (Number.isInteger(id)) {\n lo = Math.min(lo, id)\n hi = Math.max(hi, id)\n }\n }\n const records: GafRecord[] = []\n if (lo <= hi) {\n // a GAF index ignores the refName, and getLines keeps a read whose node\n // ids span min..max when min < end && max >= start, hence hi + 1\n await tabix.getLines('{node}', lo, hi + 1, {\n signal,\n lineCallback: line => {\n const record = parseGafLine(line)\n if (record && touches(record, names)) {\n records.push(record)\n }\n },\n })\n }\n return records\n }\n\n async readsOver(\n names: ReadonlySet<string>,\n { signal }: { signal?: AbortSignal } = {},\n ): Promise<GafReads> {\n const records = this.tabix\n ? await this.readIndexed(this.tabix, names, signal)\n : (await this.whole({ signal })).filter(r => touches(r, names))\n return { records: sample(records, MAX_READS), total: records.length }\n }\n}\n", "import { GBZBase, SubgraphLimitError } from '@gmod/gbz-base'\nimport {\n NodeLimitError,\n cutWindowTables,\n haplotypePrefix,\n haplotypeWanted,\n nodeLimitError,\n referencePathQuery,\n referenceSamplesOf,\n resolveReferenceSample,\n} from '@jbrowse/bandage-core/gbzWindow'\nimport {\n assemblyByPanSNPrefix,\n panSNMatchesPrefix,\n resolvePanSNPrefix,\n} from '@jbrowse/bandage-core/pansn'\nimport { cachedSetup } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { getBpDisplayStr, updateStatus } from '@jbrowse/core/util'\nimport { openLocation } from '@jbrowse/core/util/io'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\n\nimport { findCompanion } from './companion.ts'\nimport { walkCutFor } from '../RgfaTabixAdapter/walkCut.ts'\nimport { GafFile } from '../gaf/gafFile.ts'\nimport { locationIsSet } from '../locationName.ts'\nimport { openTabixSlot } from '../panSNTabix.ts'\nimport { ComparativeAdapterBase } from '../synteny/ComparativeAdapterBase.ts'\nimport SyntenyFeature from '../synteny/SyntenyFeature.ts'\nimport {\n laneAssemblyName,\n lanePairsStatus,\n requestedPairs,\n} from '../synteny/lanePairs.ts'\nimport { laneZoomNotice } from '../synteny/laneZoomNotice.ts'\nimport { matchFeature } from '../synteny/matchFeature.ts'\n\nimport type { GbzBaseSyntenyAdapterConfig } from './configSchema.ts'\nimport type { SubgraphAdapterOptions } from '../GetSubgraph.ts'\nimport type { GafReads } from '../gaf/gafFile.ts'\nimport type { LaneFeatureOptions, LanePair } from '../synteny/lanePairs.ts'\nimport type {\n HaplotypeAlignment,\n HaplotypeRef,\n PairAlignment,\n PathName,\n PathQuery,\n Subgraph,\n} from '@gmod/gbz-base'\nimport type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter'\nimport type { Feature, SimpleFeatureSerialized } from '@jbrowse/core/util'\nimport type { FileLocation, Region } from '@jbrowse/core/util/types'\n\nexport class NoHaplotypeIndexError extends Error {\n override name = 'NoHaplotypeIndexError'\n\n constructor(unreadable?: string) {\n super(\n unreadable === undefined\n ? 'no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation'\n : `the haplotype index beside the graph database could not be checked (${unreadable}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`,\n )\n }\n}\n\ninterface GbzHaplotype {\n prefix: string\n sample: string\n haplotype: number\n contigs: string[]\n isReference: boolean\n}\n\n/**\n * One lane the header declares, in the shape MultiWaySyntenyDisplay's lane\n * picker reads: `name` is the lane's assembly name, the same string the\n * fetched features' mates carry, `label` its PanSN prefix and `group` its\n * sample, so a diploid sample's two lanes sit together\n */\ninterface GbzHeaderLane {\n name: string\n label: string\n group: string\n}\n\nexport { PairTargetError } from '../synteny/lanePairs.ts'\n\nclass HaplotypeWindowError extends Error {\n override name = 'HaplotypeWindowError'\n\n constructor(assemblyName: string, anchor: string) {\n super(\n `the graph is cut on its reference, ${anchor}; a window on ${assemblyName} has no reference coordinates to cut at. Open the graph from a ${anchor} view, and find this haplotype's lane there`,\n )\n }\n}\n\ntype ResolvedAlignment = Extract<HaplotypeAlignment, { resolved: true }>\n\n/**\n * The id of one haplotype fragment: the walk's GBWT position at its first node\n * in the window, which is a property of the graph, so the same fragment gets\n * the same id on a refetch of the same window and the display's hover and\n * selection survive it. `clipToRegion` suffixes the window.\n */\nfunction fragmentId(name: PathName, alignment: ResolvedAlignment) {\n return `${haplotypePrefix(name)}#${name.contig}@${alignment.start.node}.${alignment.start.offset}`\n}\n\nfunction fragmentFeature({\n alignment,\n assemblyName,\n refName,\n lane,\n}: {\n alignment: ResolvedAlignment\n assemblyName: string\n refName: string\n lane: string\n}) {\n const { refStart, refEnd, strand, cigar } = alignment\n if (refEnd <= refStart) {\n return undefined\n } else {\n const { name, hapStart, hapEnd } = alignment\n const id = fragmentId(name, alignment)\n const data: SimpleFeatureSerialized = {\n uniqueId: id,\n assemblyName,\n refName,\n start: refStart,\n end: refEnd,\n type: 'match',\n strand: strand === '-' ? -1 : 1,\n CIGAR: cigar,\n syntenyId: id,\n mate: {\n refName: name.contig,\n start: hapStart,\n end: hapEnd,\n assemblyName: lane,\n },\n }\n return new SyntenyFeature(data)\n }\n}\n\n// gbz-base writes the CIGAR along the target, which is the side a JBrowse\n// feature is, so it passes through unchanged\nfunction pairFeature({\n pair,\n lane,\n mateLane,\n}: {\n pair: PairAlignment\n lane: string\n mateLane: string\n}) {\n return matchFeature({\n target: {\n name: `${haplotypePrefix(pair.target)}#${pair.target.contig}`,\n assemblyName: lane,\n refName: pair.target.contig,\n start: pair.targetStart,\n end: pair.targetEnd,\n },\n query: {\n name: `${haplotypePrefix(pair.query)}#${pair.query.contig}`,\n assemblyName: mateLane,\n refName: pair.query.contig,\n start: pair.queryStart,\n end: pair.queryEnd,\n },\n strand: pair.strand,\n cigar: pair.cigar,\n matches: pair.matches,\n columns: pair.columns,\n })\n}\n\n// The longest detour a pair cut widens its context to take in\nconst BRIDGE_MAX_BP = 120_000\n\n/**\n * The widest gap, up to `BRIDGE_MAX_BP`, between two pieces of one kept walk:\n * a haplotype that left the cut's nodes for sequence the reference lacks and\n * came back. Two kept haplotypes that share that sequence only align across it\n * once its nodes are in the cut.\n */\nexport function widestWalkGap(subgraphs: Subgraph[], kept: Set<string>) {\n const byPath = new Map<string, [number, number][]>()\n for (const subgraph of subgraphs) {\n for (const { name, start, end } of subgraph.walkSpans()) {\n const prefix = haplotypePrefix(name)\n if (kept.has(prefix)) {\n const key = `${prefix}#${name.contig}`\n const spans = byPath.get(key)\n if (spans) {\n spans.push([start, end])\n } else {\n byPath.set(key, [[start, end]])\n }\n }\n }\n }\n let widest = 0\n for (const spans of byPath.values()) {\n spans.sort((a, b) => a[0] - b[0])\n for (let i = 1; i < spans.length; i++) {\n const gap = spans[i]![0] - spans[i - 1]![1]\n if (gap > 0 && gap <= BRIDGE_MAX_BP) {\n widest = Math.max(widest, gap)\n }\n }\n }\n return widest\n}\n\n// A window past the node limit fails as a zoom-in notice naming a span that\n// fits\nfunction zoomInNotice(error: unknown, what: string) {\n if (error instanceof NodeLimitError) {\n error.message = `Zoom in to about ${getBpDisplayStr(error.fitsBp)} to see ${what}`\n }\n return error\n}\n\nconst laneLimitNotice = (error: unknown, nodeLimit: number, windowBp: number) =>\n laneZoomNotice(\n zoomInNotice(nodeLimitError(error, nodeLimit, windowBp) ?? error, 'lanes'),\n windowBp,\n )\n\n// gbz-base reads whole bp; a view asks at fractional ones\nconst wholeBp = (region: Region) => ({\n ...region,\n start: Math.floor(region.start),\n end: Math.ceil(region.end),\n})\n\nexport default class GbzBaseSyntenyAdapter extends ComparativeAdapterBase<GbzBaseSyntenyAdapterConfig> {\n private graph = cachedSetup({\n label: 'Opening pangenome database',\n setup: async () => {\n const gbzDb: FileLocation = this.getConf('gbzDbLocation')\n const configured: FileLocation = this.getConf('haplotypeIndexLocation')\n const companion = locationIsSet(configured)\n ? { location: configured }\n : await findCompanion(gbzDb, this.pluginManager)\n const indexLocation = companion.location\n const db = await GBZBase.open({\n source: openLocation(gbzDb, this.pluginManager),\n haplotypeIndex: indexLocation\n ? openLocation(indexLocation, this.pluginManager)\n : undefined,\n })\n const anchor = this.getConf('assemblyNames')[0]\n if (anchor === undefined) {\n throw new Error(\n 'GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as',\n )\n }\n const referenceSamples = await referenceSamplesOf(db)\n const referenceSample = resolveReferenceSample({\n configured: this.getConf('referenceSample'),\n anchorPrefix: resolvePanSNPrefix(this, anchor),\n referenceSamples,\n })\n return {\n db,\n anchor,\n referenceSample,\n referenceSamples,\n unreadableIndex: companion.unreadable,\n }\n },\n })\n\n /**\n * The indexed reference path a window on `refName` resolves against, or\n * undefined when the reference sample has no indexed path by that contig.\n */\n private async referenceQuery(\n refName: string,\n opts: BaseOptions,\n ): Promise<PathQuery | undefined> {\n const { db, referenceSample } = await this.graph(opts)\n return referencePathQuery(db, referenceSample, refName)\n }\n\n /**\n * Every haplotype the graph carries a walk for, `sample#haplotype` with its\n * contigs, from the Paths scan the adapter already makes; the lane picker's\n * source list. Reference samples are included and flagged.\n */\n async getHaplotypes(opts: BaseOptions = {}): Promise<GbzHaplotype[]> {\n const { db, referenceSamples } = await this.graph(opts)\n const byPrefix = new Map<string, GbzHaplotype>()\n for (const path of await db.paths()) {\n const prefix = haplotypePrefix(path.name)\n const entry = byPrefix.get(prefix)\n if (entry) {\n if (!entry.contigs.includes(path.name.contig)) {\n entry.contigs.push(path.name.contig)\n }\n } else {\n byPrefix.set(prefix, {\n prefix,\n sample: path.name.sample,\n haplotype: path.name.haplotype,\n contigs: [path.name.contig],\n isReference: referenceSamples.includes(path.name.sample),\n })\n }\n }\n return [...byPrefix.values()]\n }\n\n /**\n * `lanes` is every haplotype but the reference sample's own, which is the\n * anchor rather than a lane, declared up front so the display can offer the\n * whole graph's haplotypes before a fetch has placed any of them.\n */\n async getHeader(opts: BaseOptions = {}) {\n const { anchor, referenceSample } = await this.graph(opts)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const lanes: GbzHeaderLane[] = []\n for (const haplotype of await this.getHaplotypes(opts)) {\n if (haplotype.sample !== referenceSample) {\n lanes.push({\n name: laneAssemblyName(asmByPrefix, haplotype.prefix),\n label: haplotype.prefix,\n group: haplotype.sample,\n })\n }\n }\n return {\n hasCoarseTier: false,\n anchorAssemblyName: anchor,\n lanes,\n }\n }\n\n async getRefNames(opts: BaseOptions = {}) {\n const { db, anchor, referenceSample } = await this.graph(opts)\n const { assemblyName } = opts\n const prefix =\n assemblyName === anchor\n ? undefined\n : resolvePanSNPrefix(this, assemblyName)\n const contigs = (await db.paths())\n .filter(path =>\n assemblyName === anchor\n ? path.isIndexed && path.name.sample === referenceSample\n : panSNMatchesPrefix(haplotypePrefix(path.name), prefix),\n )\n .map(path => path.name.contig)\n return [...new Set(contigs)]\n }\n\n /**\n * The predicate gbz-base builds a window for, from the lanes a fetch asks\n * for. With a companion whose stray rows cover the window gbz-base walks\n * only the wanted haplotypes; otherwise it names every walk and keeps the\n * ones the predicate accepts, and throws rather than guess when a walk has\n * no name. Either way a cut holds those walks, the reference, and the nodes\n * they visit. Undefined when every haplotype is wanted.\n */\n //\n // `targetPrefix` is a pairwise view's one lane, and it belongs in here: left\n // to filter what came back, it handed gbz-base no predicate, and every\n // haplotype in the graph was walked for one to be kept.\n private keepPredicate(\n haplotypes: string[] | undefined,\n targetPrefix?: string,\n ) {\n const wantedPrefixes =\n haplotypes === undefined || haplotypes.length === 0\n ? undefined\n : haplotypes.map(lane => resolvePanSNPrefix(this, lane))\n return wantedPrefixes === undefined && targetPrefix === undefined\n ? undefined\n : (name: PathName) =>\n haplotypeWanted(name, wantedPrefixes) &&\n (targetPrefix === undefined ||\n panSNMatchesPrefix(haplotypePrefix(name), targetPrefix))\n }\n\n /**\n * The graph view's cut of the window, as tables: the reference walk, every\n * top-level snarl contained in it, and one walk per haplotype, PanSN-named\n * when the database (or its companion) carries the haplotype index and\n * `unknown#N` otherwise. The reference walk is the first, which is the one\n * the view anchors on by default. With `haplotypes` the walks are that\n * set's and the nodes those walks visit, the reference walk kept. With\n * `walkRows` the rows' runs come along, as on a walk-file cut.\n *\n * Only a window on the anchor can be cut: a haplotype lane's coordinates\n * are its own contig's, and the graph is indexed for random access on the\n * reference sample's paths alone.\n */\n async getSubgraph(region: Region, opts: SubgraphAdapterOptions = {}) {\n const { signal } = opts\n const { db, anchor, referenceSample, unreadableIndex } = await this.graph({\n signal,\n })\n const { assemblyName, refName, start, end } = wholeBp(region)\n if (assemblyName !== anchor) {\n throw new HaplotypeWindowError(assemblyName, anchor)\n }\n const query = await this.referenceQuery(refName, { signal })\n if (!query) {\n throw new Error(\n `${referenceSample} has no indexed path ${refName} in this graph`,\n )\n }\n const keep = this.keepPredicate(opts.haplotypes)\n if (keep !== undefined && !db.hasHaplotypeIndex) {\n throw new NoHaplotypeIndexError(unreadableIndex)\n }\n const cut = await cutWindowTables(db, query, start, end, {\n context: this.getConf('context'),\n snarls: opts.snarls ?? this.getConf('subgraphSnarls'),\n limit: this.getConf('nodeLimit'),\n signal: opts.signal,\n keep,\n }).catch((error: unknown) => {\n throw zoomInNotice(error, 'the graph')\n })\n return typeof cut === 'string'\n ? cut\n : walkCutFor(cut, { start, end }, opts.walkRows)\n }\n\n private gaf = cachedSetup({\n label: 'Opening reads',\n setup: async () => {\n const location: FileLocation = this.getConf('readsLocation')\n const index: FileLocation = this.getConf(['readsIndex', 'location'])\n return locationIsSet(location)\n ? new GafFile(\n openLocation(location, this.pluginManager),\n locationIsSet(index)\n ? openTabixSlot(this, ['readsLocation'], ['readsIndex'])\n : undefined,\n )\n : undefined\n },\n })\n\n /**\n * The reads over a cut's segments, from `readsLocation`, sampled down to\n * what the tube map lays out at interactive speed\n */\n async getReads(\n nodeNames: string[],\n opts: BaseOptions = {},\n ): Promise<GafReads> {\n const gaf = await this.gaf(opts)\n return gaf\n ? gaf.readsOver(new Set(nodeNames), opts)\n : { records: [], total: 0 }\n }\n\n private async laneHaplotypes(\n assemblyName: string,\n opts: BaseOptions,\n ): Promise<HaplotypeRef[]> {\n const prefix = resolvePanSNPrefix(this, assemblyName)\n return (await this.getHaplotypes(opts)).filter(haplotype =>\n panSNMatchesPrefix(haplotype.prefix, prefix),\n )\n }\n\n private async anchorFeatures(region: Region, opts: LaneFeatureOptions) {\n const { db } = await this.graph(opts)\n const { assemblyName, refName, start, end } = region\n const targetPrefix = resolvePanSNPrefix(this, opts.targetAssemblyName)\n const asmByPrefix = assemblyByPanSNPrefix(this)\n const keep = this.keepPredicate(opts.haplotypes, targetPrefix)\n const query = await this.referenceQuery(refName, opts)\n const nodeLimit: number = this.getConf('nodeLimit')\n const alignments = query\n ? await updateStatus(\n `Reading graph ${refName}:${start.toLocaleString()}-${end.toLocaleString()}`,\n opts.statusCallback,\n () =>\n db\n .getAlignments({\n path: query,\n start,\n end,\n context: this.getConf('context'),\n haplotypes: 'all',\n limit: nodeLimit,\n signal: opts.signal,\n keep,\n })\n .catch((error: unknown) => {\n throw laneLimitNotice(error, nodeLimit, end - start)\n }),\n )\n : []\n return alignments.flatMap(alignment => {\n const feature = alignment.resolved\n ? fragmentFeature({\n alignment,\n assemblyName,\n refName,\n lane: laneAssemblyName(\n asmByPrefix,\n haplotypePrefix(alignment.name),\n ),\n })\n : undefined\n return feature === undefined ? [] : [feature]\n })\n }\n\n /**\n * Each pair's two lanes cut out of the anchor window alone, all pairs in one\n * cut, and each walk of a pair's query lane aligned to each walk of its\n * target lane on the nodes both visit, with no base compared. A pair's\n * records sit on its query lane's contigs, the lane the display draws on top.\n *\n * Whether the index has anchor rows changes only how fast gbz-base finds\n * the walks: both routes cut the same pieces.\n */\n private async pairFeatures(\n region: Region,\n pairs: LanePair[],\n opts: LaneFeatureOptions,\n ) {\n const { db } = await this.graph(opts)\n const { refName, start, end } = region\n const sides = await Promise.all(\n pairs.map(async pair => ({\n pair,\n featureSide: await this.laneHaplotypes(pair.queryAssemblyName, opts),\n mateSide: await this.laneHaplotypes(pair.targetAssemblyName, opts),\n })),\n )\n const answerable = sides.filter(\n ({ featureSide, mateSide }) =>\n featureSide.length > 0 && mateSide.length > 0,\n )\n const kept = new Set(\n answerable.flatMap(({ featureSide, mateSide }) =>\n [...featureSide, ...mateSide].map(haplotypePrefix),\n ),\n )\n const query = await this.referenceQuery(refName, opts)\n const nodeLimit: number = this.getConf('nodeLimit')\n const baseContext: number = this.getConf('context')\n const cut = (path: PathQuery, context: number) =>\n db.getSubgraphs({\n path,\n start,\n end,\n context,\n snarls: this.getConf('subgraphSnarls'),\n haplotypes: 'all',\n limit: nodeLimit,\n signal: opts.signal,\n keep: name => kept.has(haplotypePrefix(name)),\n })\n // a cut past the node limit for the wider context keeps the first one\n const bridged = async (path: PathQuery) => {\n const subgraphs = await cut(path, baseContext).catch((error: unknown) => {\n throw laneLimitNotice(error, nodeLimit, end - start)\n })\n const gap = widestWalkGap(subgraphs, kept)\n const context = Math.ceil(gap / 2) + 2000\n return gap > 0 && context > baseContext\n ? cut(path, context).catch((error: unknown) => {\n if (error instanceof SubgraphLimitError) {\n return subgraphs\n }\n throw error\n })\n : subgraphs\n }\n const subgraphs =\n query && answerable.length > 0\n ? await updateStatus(lanePairsStatus(pairs), opts.statusCallback, () =>\n bridged(query),\n )\n : []\n return subgraphs.flatMap(subgraph =>\n answerable.flatMap(({ pair, featureSide, mateSide }) =>\n featureSide.flatMap(target =>\n mateSide.flatMap(mate =>\n subgraph\n .pairAlignments({ target, query: mate, bases: false })\n .map(alignment =>\n pairFeature({\n pair: alignment,\n lane: pair.queryAssemblyName,\n mateLane: pair.targetAssemblyName,\n }),\n ),\n ),\n ),\n ),\n )\n }\n\n getFeatures(asked: Region, opts: LaneFeatureOptions = {}) {\n const region = wholeBp(asked)\n return ObservableCreate<Feature>(async observer => {\n const { db, anchor, unreadableIndex } = await this.graph(opts)\n if (!db.hasHaplotypeIndex) {\n throw new NoHaplotypeIndexError(unreadableIndex)\n }\n // the graph is indexed on its reference alone, so a window on a\n // haplotype lane has no answer: a lane pair is read inside the anchor's\n if (region.assemblyName === anchor) {\n const pairs = requestedPairs(opts)\n const features =\n pairs.length > 0\n ? await this.pairFeatures(region, pairs, opts)\n : await this.anchorFeatures(region, opts)\n for (const feature of features) {\n observer.next(feature)\n }\n }\n observer.complete()\n }, opts.signal)\n }\n}\n"],
|
|
5
5
|
"mappings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AAE,KAAAhF,EAAM,YAAAiF,EAAa,SAAAC,CAAS,IAChDD,EAAY,QAAQO,GAClBN,EAAS,QAAQO,IACfjF,EACG,eAAe,CAAE,OAAAgF,EAAQ,MAAOC,GAAM,MAAO,EAAM,CAAC,EACpD,IAAIxG,IACHc,GAAY,CACV,KAAMd,GACN,KAAMe,EAAK,kBACX,SAAUA,EAAK,kBACjB,CAAC,CACH,CACJ,CACF,CACF,CACF,CACF,CAEA,YAAY0F,EAAetC,EAA2B,CAAC,EAAG,CACxD,IAAMtB,EAASD,GAAQ6D,CAAK,EAC5B,OAAOC,GAA0B,MAAMC,GAAY,CACjD,GAAM,CAAE,GAAApD,EAAI,OAAA1D,EAAQ,gBAAAuF,CAAgB,EAAI,MAAM,KAAK,MAAMjB,CAAI,EAC7D,GAAI,CAACZ,EAAG,kBACN,MAAM,IAAI9D,EAAsB2F,CAAe,EAIjD,GAAIvC,EAAO,eAAiBhD,EAAQ,CAClC,IAAMiG,EAAQc,GAAezC,CAAI,EAC3B0C,EACJf,EAAM,OAAS,EACX,MAAM,KAAK,aAAajD,EAAQiD,EAAO3B,CAAI,EAC3C,MAAM,KAAK,eAAetB,EAAQsB,CAAI,EAC5C,QAAW0B,KAAWgB,EACpBF,EAAS,KAAKd,CAAO,CAEzB,CACAc,EAAS,SAAS,CACpB,EAAGxC,EAAK,MAAM,CAChB,CACF",
|
|
6
6
|
"names": ["haplotypeIndexBeside", "db", "GBZ_DB", "siblingCompanion", "gbzDb", "readsSiblings", "haplotypeIndexBeside", "locationName", "renamed", "name", "isMissing", "error", "findCompanion", "pluginManager", "candidate", "openLocation", "MAX_READS", "MAX_UNINDEXED_BYTES", "UnindexedGafTooLargeError", "size", "sample", "records", "max", "stride", "_", "k", "touches", "record", "names", "step", "GafFile", "file", "tabix", "cachedSetup", "signal", "bytes", "text", "unzip", "parseGaf", "lo", "hi", "name", "id", "line", "parseGafLine", "r", "NoHaplotypeIndexError", "unreadable", "HaplotypeWindowError", "assemblyName", "anchor", "fragmentId", "name", "alignment", "haplotypePrefix", "fragmentFeature", "refName", "lane", "refStart", "refEnd", "strand", "cigar", "hapStart", "hapEnd", "id", "data", "SyntenyFeature", "pairFeature", "pair", "mateLane", "matchFeature", "BRIDGE_MAX_BP", "widestWalkGap", "subgraphs", "kept", "byPath", "subgraph", "start", "end", "prefix", "key", "spans", "widest", "a", "b", "i", "gap", "zoomInNotice", "error", "what", "NodeLimitError", "getBpDisplayStr", "laneLimitNotice", "nodeLimit", "windowBp", "laneZoomNotice", "nodeLimitError", "wholeBp", "region", "GbzBaseSyntenyAdapter", "ComparativeAdapterBase", "cachedSetup", "gbzDb", "configured", "companion", "locationIsSet", "findCompanion", "indexLocation", "db", "GBZBase", "openLocation", "referenceSamples", "referenceSamplesOf", "referenceSample", "resolveReferenceSample", "resolvePanSNPrefix", "location", "index", "GafFile", "openTabixSlot", "opts", "referencePathQuery", "byPrefix", "path", "entry", "asmByPrefix", "assemblyByPanSNPrefix", "lanes", "haplotype", "laneAssemblyName", "contigs", "panSNMatchesPrefix", "haplotypes", "targetPrefix", "wantedPrefixes", "haplotypeWanted", "signal", "unreadableIndex", "query", "keep", "cut", "cutWindowTables", "walkCutFor", "nodeNames", "gaf", "updateStatus", "feature", "pairs", "answerable", "featureSide", "mateSide", "baseContext", "context", "bridged", "SubgraphLimitError", "lanePairsStatus", "target", "mate", "asked", "ObservableCreate", "observer", "requestedPairs", "features"]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as C}from"./chunk-
|
|
1
|
+
import{b as C}from"./chunk-XTEZPFP4.js";import"./chunk-75WJWJ45.js";import"./chunk-VZNECPSI.js";import"./chunk-6YK4U5LT.js";import{p as d}from"./chunk-HVDE2ZKA.js";import"./chunk-YDJ6SDQM.js";import"./chunk-AILGRHTE.js";import"./chunk-6NR64IXK.js";import"./chunk-CI6VQ2KV.js";import"./chunk-IICQFAGJ.js";import"./chunk-47KLT4FL.js";import"./chunk-YBLNN5FU.js";import"./chunk-UOWS2HEQ.js";import"./chunk-PVRRW4PM.js";import"./chunk-YBLNN5FU.js";import"./chunk-ROZPEXN4.js";import"./chunk-3M3UH5JQ.js";import"./chunk-3VGXCEMQ.js";import"./chunk-6VNDP3UB.js";import"./chunk-3WG3GF2A.js";import"./chunk-J5RMHLFJ.js";import{i as L}from"./chunk-NIEZKWQV.js";import{A as l,F as G,H as p,e as s,j as v,o as n,x as y}from"./chunk-5Z4VIKXZ.js";import{a as h,b as e,c as r,d as i}from"./chunk-JMBDTNUR.js";var N=d()({paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto",display:"flex",flexDirection:"column",gap:12},row:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}}),S=i(function({model:a}){let{classes:t}=N();return!a.error&&!a.loadCanceled?r(l,{className:t.paper,"data-testid":"graph-genome-loading",children:[r("div",{className:t.row,children:[e(v,{variant:"h6",message:a.statusMessage||void 0}),a.canCancelLoad?e(n,{size:"small","data-testid":"graph-genome-cancel",onClick:()=>{a.cancelLoad()},children:"Cancel"}):null]}),e(y,{variant:"indeterminate"})]}):a.error?e(l,{className:t.paper,children:e(s,{error:a.error,onReset:()=>{a.retryLoad()}})}):e(l,{className:t.paper,"data-testid":"graph-genome-load-canceled",children:r("div",{className:t.row,children:[e(p,{variant:"h6",children:"Loading canceled"}),e(n,{variant:"contained",size:"small","data-testid":"graph-genome-retry",onClick:()=>{a.retryLoad()},children:"Retry"})]})})}),f=S;var T=`H VN:Z:1.0
|
|
2
2
|
S 1 ACGT
|
|
3
3
|
S 2 GGCC
|
|
4
4
|
S 3 TTAA
|
|
@@ -7,4 +7,4 @@ L 1 + 2 + 0M
|
|
|
7
7
|
L 1 + 3 + 0M
|
|
8
8
|
L 2 + 4 + 0M
|
|
9
9
|
L 3 + 4 + 0M`,E=d()({column:{display:"flex",flexDirection:"column",gap:8},rowEnd:{display:"flex",gap:8,alignItems:"flex-end"},rowCenter:{display:"flex",gap:8,alignItems:"center"},flex1:{flex:1},paper:{padding:16,margin:8,maxWidth:560,marginInline:"auto"},header:{marginBottom:12},footer:{marginTop:12,display:"flex",justifyContent:"flex-end"}}),F=i(function({model:a}){let{classes:t}=E(),[m,w]=L("");function u(){let o=m.trim();o&&a.openGfaLocation({uri:o,locationType:"UriLocation"})}function M(o){let c=o.target.files?.[0];o.target.value="",c&&a.loadGFAFile(c,c.name)}return r(l,{className:t.paper,children:[e("div",{className:t.header,children:e(p,{variant:"h6",children:"Load a GFA graph"})}),r("div",{className:t.column,children:[r("div",{className:t.rowCenter,children:[r(n,{variant:"outlined",component:"label",size:"small",children:["Choose file",e("input",{type:"file",accept:".gfa,.gfa1,.gfa2,.gz",hidden:!0,onChange:o=>{M(o)}})]}),e(p,{variant:"caption",color:"text.secondary",children:"Whole-file GFA; best for small/medium graphs."})]}),r("div",{className:t.rowEnd,children:[e(G,{size:"small",label:"URL",placeholder:"https://example.com/graph.gfa",value:m,onChange:o=>{w(o.target.value)},onKeyDown:o=>{o.key==="Enter"&&u()},className:t.flex1}),e(n,{variant:"contained",onClick:()=>{u()},disabled:!m.trim(),children:"Open"})]})]}),e("div",{className:t.footer,children:e(n,{size:"small",onClick:()=>{a.loadGFA(T,"Example graph")},children:"Load 4-node example"})}),a.error?e(s,{error:a.error}):null]})}),x=F;var B=i(function({model:a}){return a.hasGraph?e(C,{model:a}):a.canRetryLoad?e(f,{model:a}):r(h,{children:[a.isLoading?e(f,{model:a}):null,e("div",{hidden:a.isLoading,children:e(x,{model:a})})]})}),q=B;export{q as default};
|
|
10
|
-
//# sourceMappingURL=GraphGenomeView-
|
|
10
|
+
//# sourceMappingURL=GraphGenomeView-H2Z5NQW4.js.map
|
package/dist/chunks/{GraphTrackSettingsDialog-7NGUPDUJ.js → GraphTrackSettingsDialog-LFFJHC7F.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as G,b as L}from"./chunk-
|
|
1
|
+
import{a as G,b as L}from"./chunk-75WJWJ45.js";import{b as v,c as x,p as f}from"./chunk-HVDE2ZKA.js";import"./chunk-6NR64IXK.js";import"./chunk-CI6VQ2KV.js";import"./chunk-PVRRW4PM.js";import"./chunk-ROZPEXN4.js";import"./chunk-3M3UH5JQ.js";import"./chunk-3VGXCEMQ.js";import"./chunk-6VNDP3UB.js";import{h as g,i as d}from"./chunk-NIEZKWQV.js";import{F as m,H as h,n as H}from"./chunk-5Z4VIKXZ.js";import{b as p,c as l,d as u}from"./chunk-JMBDTNUR.js";var k=f()({section:{marginBottom:24}}),w=[{value:"0",label:"None"},{value:"1",label:"1 hop"},{value:"2",label:"2 hops"}],F=u(function({model:t}){let{classes:n}=k(),e=t.sourceAdapter;return e?.type==="RgfaTabixAdapter"&&!v(e)?l("div",{className:n.section,children:[p(G,{label:"Graph context",sx:{minWidth:200},value:String(t.subgraphContext),options:w,testId:"graph-context-select",onChange:a=>{t.setSubgraphContext(Number(a)),t.recut()}}),p(h,{variant:"caption",component:"div",color:"text.secondary",children:"How far the cut follows links out of the region. At none, a detour that leaves the window draws as two stubs. No effect on gfa-to-tabix's default anchored index."})]}):null}),M=F;var I=f()({section:{marginBottom:24}});function A(o){return o.split(/[\s,]+/).filter(t=>t!=="")}var N=(o,t)=>o.join(`
|
|
2
2
|
`)===t.join(`
|
|
3
3
|
`);function P(o,t){let n=o.cutHaplotypes??[],[e,a]=d(n);return N(n,e)||(a(n),t()),r=>{N(r,n)||(a(r),o.setSubgraphHaplotypes(r),o.recut())}}var D=u(function({model:t}){let[n,e]=d(t.cutHaplotypes?.join(", ")??""),a=P(t,()=>{e(t.cutHaplotypes?.join(", ")??"")}),r=()=>{a(A(n))};return p(m,{fullWidth:!0,label:"Haplotypes",placeholder:"every haplotype",value:n,slotProps:{htmlInput:{"data-testid":"graph-haplotypes-field"}},onChange:i=>{e(i.target.value)},onBlur:()=>{r()},onKeyDown:i=>{i.key==="Enter"&&r()}})}),B=u(function({model:t,names:n}){let[e,a]=d(t.cutHaplotypes??[]),r=g(e),i=g(""),[S,b]=d(!1),C=P(t,()=>{r.current=t.cutHaplotypes??[],a(r.current)});return p(H,{multiple:!0,freeSolo:!0,disableCloseOnSelect:!0,options:n,value:e,open:S,onOpen:()=>{b(!0)},onInputChange:(c,s)=>{i.current=s},onClose:(c,s)=>{b(!1);let y=i.current.trim();s==="blur"&&y&&!r.current.includes(y)&&(r.current=[...r.current,y],a(r.current)),C(r.current)},onChange:(c,s)=>{r.current=s,a(s),S||C(s)},renderInput:c=>p(m,{...c,label:"Haplotypes",placeholder:e.length===0?"every haplotype":void 0,slotProps:{...c.slotProps,htmlInput:{...c.slotProps.htmlInput,"data-testid":"graph-haplotypes-field"}}})})}),O=u(function({model:t}){let{classes:n}=I(),e=t.haplotypeNames,a=t.sourceAdapter;return a&&x(a)?l("div",{className:n.section,children:[e?p(B,{model:t,names:e}):p(D,{model:t}),l(h,{variant:"caption",component:"div",color:"text.secondary",children:[e?`Which of the graph's ${e.length.toLocaleString()} haplotypes to cut, or a PanSN prefix (HG002 for both).`:"Which haplotypes to cut, as lane assembly names or PanSN prefixes (HG002#1, or HG002 for both) separated by commas."," ","Empty is every haplotype."]})]}):null}),T=O;function R({model:o,onClose:t}){return l(L,{model:o,onClose:t,children:[p(M,{model:o}),p(T,{model:o})]})}export{R as default};
|
|
4
|
-
//# sourceMappingURL=GraphTrackSettingsDialog-
|
|
4
|
+
//# sourceMappingURL=GraphTrackSettingsDialog-LFFJHC7F.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{x as v,y as C}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=HighlightColorDialog-
|
|
1
|
+
import{x as v,y as C}from"./chunk-AILGRHTE.js";import"./chunk-CI6VQ2KV.js";import"./chunk-PVRRW4PM.js";import"./chunk-3M3UH5JQ.js";import{F as g,H as t,d as u,o as y,q as c,r as d,z as s}from"./chunk-5Z4VIKXZ.js";import{a as h,b as l,c as p,d as m}from"./chunk-JMBDTNUR.js";var b=m(function({model:o,onClose:r}){return p(u,{open:!0,onClose:r,title:"Color highlighted haplotypes",children:[p(d,{sx:{display:"grid",gridTemplateColumns:"auto 1fr 1fr",alignItems:"center",gap:1.5},children:[l(t,{variant:"subtitle2",children:"Haplotype"}),l(t,{variant:"subtitle2",children:"Color by"}),l(t,{variant:"subtitle2",children:"Palette"}),o.drawnWalks.map(({name:a,encoding:n})=>l(f,{label:o.walkLabel(a),field:n.field,scheme:n.scheme,onField:e=>{o.setWalkColor(a,{field:e})},onScheme:e=>{o.setWalkColor(a,{scheme:e})}},a))]}),l(c,{children:l(y,{variant:"contained",onClick:r,children:"Done"})})]})});function f({label:i,field:o,scheme:r,onField:a,onScheme:n}){return p(h,{children:[l(t,{variant:"body2",children:i}),l(g,{select:!0,size:"small",value:o,slotProps:{select:{SelectDisplayProps:{"aria-label":`Color ${i} by`}}},onChange:e=>{a(e.target.value)},children:v.map(e=>l(s,{value:e.value,children:e.label},e.value))}),l(g,{select:!0,size:"small",value:r,slotProps:{select:{SelectDisplayProps:{"aria-label":`Palette for ${i}`}}},onChange:e=>{n(e.target.value)},children:C.filter(e=>e.value!=="rainbow"||o==="reference").map(e=>l(s,{value:e.value,children:e.label},e.value))})]})}var P=b;export{P as default};
|
|
2
|
+
//# sourceMappingURL=HighlightColorDialog-76RJSXSV.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=LinearGraphDisplay-
|
|
1
|
+
import{a,b as i}from"./chunk-XTEZPFP4.js";import"./chunk-75WJWJ45.js";import"./chunk-VZNECPSI.js";import"./chunk-6YK4U5LT.js";import"./chunk-HVDE2ZKA.js";import"./chunk-YDJ6SDQM.js";import"./chunk-AILGRHTE.js";import"./chunk-6NR64IXK.js";import"./chunk-CI6VQ2KV.js";import"./chunk-IICQFAGJ.js";import"./chunk-47KLT4FL.js";import"./chunk-YBLNN5FU.js";import"./chunk-UOWS2HEQ.js";import"./chunk-PVRRW4PM.js";import"./chunk-YBLNN5FU.js";import"./chunk-ROZPEXN4.js";import"./chunk-3M3UH5JQ.js";import"./chunk-3VGXCEMQ.js";import"./chunk-6VNDP3UB.js";import"./chunk-3WG3GF2A.js";import"./chunk-J5RMHLFJ.js";import"./chunk-NIEZKWQV.js";import"./chunk-5Z4VIKXZ.js";import{b as o,d as t}from"./chunk-JMBDTNUR.js";var e=JBrowseExports["@jbrowse/display-kit/DisplayChrome"];var s=e&&e.__esModule?e.default:e;var p=t(function({model:r}){return o(s,{model:r,factory:a,testid:"linear-graph-display","data-layout":r.chosenLayoutMode,"data-cut-tier":r.cutTier,"data-recuts":r.recuts,"data-node-count":r.hasGraph?r.nodeCount:void 0,"data-loading":r.isLoading?"":void 0,style:{width:r.paneWidth,height:r.height,overflow:"hidden"},children:n=>o(i,{model:r,handle:n})})}),c=p;export{c as default};
|
|
2
|
+
//# sourceMappingURL=LinearGraphDisplay-VYPF26DJ.js.map
|
package/dist/chunks/{MinigraphBubbleAdapter-P66QLENP.js → MinigraphBubbleAdapter-WQUZTNDM.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as f,d as c,f as d}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=MinigraphBubbleAdapter-
|
|
1
|
+
import{a as f,d as c,f as d}from"./chunk-IICQFAGJ.js";import{a as g}from"./chunk-KOB7YIMR.js";import{E as p,F as u,b,z as m}from"./chunk-XK4HHKSP.js";import"./chunk-YBLNN5FU.js";import"./chunk-ROZPEXN4.js";import"./chunk-3M3UH5JQ.js";import"./chunk-OGQ6OQDN.js";import"./chunk-3WG3GF2A.js";import{a as i,o as l}from"./chunk-J5RMHLFJ.js";var a=class extends b{constructor(){super(...arguments);this.bubbles=p(this,["bubblesLocation"],["index"]);this.refNames=new u(this.bubbles,this)}static{this.capabilities=["getFeatures","getRefNames"]}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async getRegionByteSize(t,s={}){return this.refNames.regionBytes(t,s)}async hasDataForRefName(){return!0}getFeatures(t,s={}){let{signal:n,statusCallback:h}=s;return g(async r=>{let o=await this.refNames.resolveMapped(t,s);o!==void 0&&await l("Downloading bubbles",h,()=>m(this.bubbles,o,t.start,t.end,{signal:n,lineCallback:(N,y)=>{let e=f(N);r.next(new i({uniqueId:`bubble-${y}`,refName:t.refName,start:e.start,end:e.end,name:c(e),description:d(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),r.complete()},n)}};export{a as default};
|
|
2
|
+
//# sourceMappingURL=MinigraphBubbleAdapter-WQUZTNDM.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as F}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=RgfaTabixAdapter-
|
|
1
|
+
import{a as F}from"./chunk-477HYXB2.js";import"./chunk-SQBD75UZ.js";import{a as N}from"./chunk-KOB7YIMR.js";import"./chunk-YBLNN5FU.js";import"./chunk-UOWS2HEQ.js";import"./chunk-PVRRW4PM.js";import{E as p,F as d,b as h,u,v as w,w as k,x,y as b,z as g}from"./chunk-XK4HHKSP.js";import"./chunk-YBLNN5FU.js";import"./chunk-ROZPEXN4.js";import"./chunk-3M3UH5JQ.js";import{e as f}from"./chunk-6VNDP3UB.js";import"./chunk-OGQ6OQDN.js";import"./chunk-3WG3GF2A.js";import{a as l,o as m}from"./chunk-J5RMHLFJ.js";var c=class extends h{constructor(){super(...arguments);this.fine=this.openIndex([])}static{this.capabilities=["getFeatures","getRefNames"]}openIndex(e){let t=this.getConf("walksLocation"),n=e.length===0&&f(t)?new F(p(this,["walksLocation"],["walksIndex"]),this):void 0,r=e.length===0?this.getConf("graphLocation"):this.getConf(["coarse","graphLocation"]);if(f(r)){let s=p(this,[...e,"graphLocation"],[...e,"graphIndex"]);return{graph:s,walks:n,refNames:new d(n?.file??s,this)}}let a=p(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),i=p(this,[...e,"linksLocation"],[...e,"linksIndex"]);return{segments:a,links:i,walks:n,refNames:new d(n?.file??a,this)}}async getHaplotypeNames(e={}){return this.fine.walks?.haplotypeNames(e)}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async getRegionByteSize(e,t={}){let{walks:n,refNames:r}=this.fine;return r.regionBytes(e,t,n&&((a,{start:i,end:s})=>n.reader.queryStart(i,{...t,refName:a,end:s})))}async hasDataForRefName(){return!0}getFeatures(e,t={}){return N(async n=>{let r=await this.fine.refNames.resolveMapped(e,t);if(r!==void 0){let{walks:a}=this.fine,i=s=>{n.next(s)};await(a?this.walkFeatures(a,r,e,t,i):this.segmentFeatures(r,e,t,i))}n.complete()},t.signal)}async walkFeatures(e,t,n,r,a){let i=await m("Downloading walks",r.statusCallback,()=>e.referenceNodes(t,n,r));for(let s of i){let o=String(s.id);a(new l({uniqueId:o,refName:n.refName,start:s.start,end:s.end,name:o,type:"segment",rank:0,stableName:s.refName}))}}async segmentRows(e,t,n,r){let a=this.fine;if("graph"in a){let i=k(await a.graph.getHeaderLines({signal:n.signal}));return g(a.graph,e,t.start,t.end,{signal:n.signal,lineCallback:s=>{let o=x(s,i);o?.kind==="N"&&r(o.segment,i.anchored)}})}return g(a.segments,e,t.start,t.end,{signal:n.signal,lineCallback:i=>{let{segment:s,anchored:o}=u(i);r(s,o)}})}async segmentFeatures(e,t,n,r){await m("Downloading segments",n.statusCallback,()=>this.segmentRows(e,t,n,(a,i)=>{if(i&&a.refName!==e)return;let s=w(a);r(new l({uniqueId:a.id,refName:t.refName,start:a.start,end:a.end,name:a.id,type:"segment",rank:a.rank,stableName:a.refName,...s&&{samples:s,sampleCount:s.length}}))}))}async getSubgraph(e,t={}){let{hops:n,signal:r,tier:a}=t,i=this.index(a),s=await i.refNames.resolveForCut(e,{signal:r});return i.walks?i.walks.subgraph(s,e,t):b(i,{refName:s,start:e.start,end:e.end},{hops:n,signal:r})}};export{c as default};
|
|
2
|
+
//# sourceMappingURL=RgfaTabixAdapter-K763K62E.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as x,b,c as N,d as R,f as c,g as C,h as P,i as T}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=WalkFormsAdapter-
|
|
1
|
+
import{a as x,b,c as N,d as R,f as c,g as C,h as P,i as T}from"./chunk-VEI7EAE6.js";import{a as k}from"./chunk-KOB7YIMR.js";import{E as $,b as l,d as g,e as w,f as h,g as p,k as y,o as B,s as F,t as S}from"./chunk-XK4HHKSP.js";import"./chunk-YBLNN5FU.js";import"./chunk-ROZPEXN4.js";import"./chunk-3M3UH5JQ.js";import"./chunk-OGQ6OQDN.js";import"./chunk-3WG3GF2A.js";import{a as m,o as u}from"./chunk-J5RMHLFJ.js";var v=r=>`${(r/1e6).toFixed(1)} MB`,O=r=>`${(r/1e6).toFixed(1)} M`;function E(r,f){if(!(r instanceof g))return r;let t=N(f);if(r instanceof F)return new Error(`The pinned window ${t} is too large to read every walk in full for structural forms: its walks take ${O(r.steps)} steps, over the ${O(r.limit)} step budget, and about ${p(r.fitsBp)} of it fits. Pin a narrower window`);let e=`walkByteBudget, ${v(r.limit)}`;return new Error(`The pinned window ${t} is too large to cut for structural forms: ${r.zoomHelps?`about ${p(r.fitsBp)} of it fits in ${e}. Pin a narrower window or raise walkByteBudget`:`its cut fetches ${v(r.bytes??0)}, over ${e}. Raise walkByteBudget`}`)}var L=8,i=new Map;function A(r,f){let t=i.get(r),e=t??f();if(i.delete(r),i.set(r,e),!t){e.catch(()=>{i.get(r)===e&&i.delete(r)});for(let s of i.keys()){if(i.size<=L)break;i.delete(s)}}return e}var d=class extends l{constructor(){super(...arguments);this.reader=new y($(this,["walksLocation"],["walksIndex"]))}static{this.capabilities=["getFeatures","getRefNames"]}async referenceSample(t){let{references:e}=await this.reader.header(t);return e[0]??""}async getRefNames(t={}){let e=await this.reader.referenceSequences(t),s=await this.referenceSample(t),a=e.filter(o=>h(o,s)).map(o=>w(o));return a.length>0?[...new Set(a)]:e}pinned(){let t=x(this.getConf("pinned"));if(!t)throw new Error("WalkFormsAdapter needs `pinned`, the window its forms come from: { refName, start, end }");return t}forms(t){if(!this.formsRead){let e=this.pinned(),s=`${JSON.stringify(this.getConf("walksLocation"))} ${e.refName}:${e.start}-${e.end}`,a=this.getConf("walkByteBudget"),o=A(`${s} ${a}`,()=>u("Cutting walks",t.statusCallback,()=>S(this.reader,e,{byteBudget:a,partial:!1}).catch(n=>{throw E(n,e)}))).then(n=>B(n,{window:e,floorBp:b(this.getConf("floorBp")),exclude:this.getConf("exclude")}));o.catch(()=>{this.formsRead===o&&(this.formsRead=void 0)}),this.formsRead=o}return this.formsRead}maxForms(){return this.getConf("maxForms")}async getSourcesAndWarnings(t={}){let e=await this.forms(t),s=R(this.pinned());return{sources:c(e,this.maxForms()),warnings:C(e,this.maxForms()).map(a=>s+a)}}async getSources(t,e={}){return c(await this.forms(e),this.maxForms())}async onPinnedSequence(t,e){let s=await this.referenceSample(e),[a,o]=await Promise.all([this.reader.sequenceFor(s,t,e),this.reader.sequenceFor(s,this.pinned().refName,e)]);return a!==void 0&&a===o}getFeatures(t,e={}){return k(async s=>{let a=await this.forms(e),o=await this.onPinnedSequence(t.refName,e)?T(a,this.maxForms()).filter(n=>n.start<t.end&&n.end>t.start):[];for(let n of o)s.next(new m({uniqueId:`forms-${a.floorBp}-${n.id}`,refName:t.refName,start:n.start,end:n.end,name:n.name,description:n.description,type:n.type,svType:n.svType,consequence:n.consequence,REF:"N",ALT:[n.alt],INFO:{SVTYPE:[n.svType],SVLEN:[n.mark.delta]},mark:n.mark,genotypes:n.genotypes}));if(o.length===0){let n=Math.floor(t.start);s.next(new m({uniqueId:`forms-reference-${t.refName}-${n}`,refName:t.refName,start:n,end:n+1,REF:"N",ALT:["."],genotypes:P(a,this.maxForms())}))}s.complete()},e.signal)}};export{d as default};
|
|
2
|
+
//# sourceMappingURL=WalkFormsAdapter-WJTEKIOB.js.map
|
package/dist/chunks/{WalkTabixSyntenyAdapter-7COETKFB.js → WalkTabixSyntenyAdapter-PHRULBP7.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ee}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=WalkTabixSyntenyAdapter-
|
|
1
|
+
import{a as ee}from"./chunk-477HYXB2.js";import{a as K,b as V,d as Z,e as J,f as B,g as Q,h as Y}from"./chunk-DFWLOMRU.js";import"./chunk-SQBD75UZ.js";import{a as G}from"./chunk-KOB7YIMR.js";import{p as L,q as H,r as q}from"./chunk-M2D7NUOY.js";import"./chunk-YBLNN5FU.js";import"./chunk-UOWS2HEQ.js";import"./chunk-PVRRW4PM.js";import{E as X,F as z,i as U}from"./chunk-XK4HHKSP.js";import"./chunk-YBLNN5FU.js";import"./chunk-ROZPEXN4.js";import{a as O,c as D,d as A,g as x,h as F,i as E}from"./chunk-3M3UH5JQ.js";import"./chunk-OTBDKJEA.js";import"./chunk-3VGXCEMQ.js";import"./chunk-OGQ6OQDN.js";import"./chunk-3WG3GF2A.js";import{o as v}from"./chunk-J5RMHLFJ.js";var me=50;function le(r){let o=[];for(let e=0;e<r.length;e++){let[t,a]=r[e],[s,n]=r[e+1]??[];a===n&&a<=me&&(t==="I"&&s==="D"||t==="D"&&s==="I")?(o.push(["X",a]),e++):o.push([t,a])}return o}function R(r){return Array.from(r.ids,(o,e)=>2*o+r.rev[e])}function P(r,o){let e=r.get(o);return e===void 0?0:e.end-e.start}function te(r){let o=new Map,e=s=>{let n=P(r,s),i=o.get(n);return i===void 0&&(i="N".repeat(n),o.set(n,i)),i},t=new Map,a=s=>{let n=t.get(s);return n===void 0&&(n=R(s),t.set(s,n)),n};return(s,n)=>H({query:a(s),target:a(n),sequenceOf:e,bases:!1})}var _=100;function I(r,o,e){let t=r.at(-1);e>0&&(t?.[0]===o?t[1]+=e:r.push([o,e]))}function ae(r){let o=t=>P(r,t>>1),e=t=>{let a=new Float64Array(t.length+1);return t.forEach((s,n)=>{a[n+1]=a[n]+o(s)}),a};return(t,a)=>{let s=R(a),n=R(t),[i,c]=L(n,s,o),[h,d]=L(n.map(y=>y^1).reverse(),s,o),m=d>c,p=m?h:i,b=Math.max(c,d);if(b<_)return[];let f=e(s),g=e(n),u=y=>m?n.length-1-p[y][0]:p[y][0],k=[];p.forEach(([,y],N)=>{if(N>0){let[M,l]=[u(N-1),u(N)].sort((w,C)=>w-C);I(k,"I",g[l]-g[M+1]),I(k,"D",f[y]-f[p[N-1][1]+1])}I(k,"=",o(s[y]))});let[S,W]=[u(0),u(p.length-1)].sort((y,N)=>y-N);return[{queryStart:g[S],queryEnd:g[W+1],targetStart:f[p[0][1]],targetEnd:f[p.at(-1)[1]+1],strand:m?"-":"+",edits:k,sharedBases:b}]}}function ce(r){let o=new Map,e=new Set;r.ids.forEach((t,a)=>{o.has(t)?e.add(t):o.set(t,r.rev[a])});for(let t of e)o.delete(t);return o}function ne(r){let o=new Map,e=t=>{let a=o.get(t);return a===void 0&&(a=ce(t),o.set(t,a)),a};return(t,a)=>{let s=e(a),n=0,i=0;for(let[c,h]of e(t)){let d=s.get(c);d===h?n+=P(r,c):d!==void 0&&(i+=P(r,c))}return{same:n,opposite:i}}}function se(r){let o=ae(r),e=te(r),t=ne(r);return(a,s)=>{let{same:n,opposite:i}=t(a,s);return n>=_&&i>=_?e(a,s):o(a,s)}}var pe=1e4;function re(r){let o=ae(r),e=te(r),t=ne(r);return(a,s)=>{let n=o(a,s),i=n[0]?.strand,{same:c,opposite:h}=t(a,s);return i===void 0||Math.min(c,h)<pe?n:[...n,...e(a,s).filter(d=>d.strand!==i)]}}function j({chain:r,target:o,query:e,assemblyName:t,refName:a,mateAssemblyName:s}){let n=le(r.edits);return Y({target:{name:o.name,assemblyName:t,refName:a,start:o.hapStart+r.targetStart,end:o.hapStart+r.targetEnd},query:{name:e.name,assemblyName:s,refName:A(e.name),start:e.hapStart+r.queryStart,end:e.hapStart+r.queryEnd},strand:r.strand,cigar:q(n),matches:n.reduce((i,[c,h])=>i+(c==="="?h:0),0),columns:n.reduce((i,[,c])=>i+c,0)})}function ie(r,o,e,t,a){let s=a==="leave",n=i=>i.kind==="elsewhere"&&(s?i.chunk.start>=r.refStart:i.chunk.start<r.refStart);for(let i of e){let{name:c,fragStart:h,hapStart:d,ids:m,rev:p,before:b,after:f}=i;if(c===r.name&&h===r.fragStart){let g=d;for(let u=0;u<m.length;u++){let k=t.get(m[u]),S=k===void 0?0:k.end-k.start;if(k?.rank===0&&k.refName===o&&(s?k.end===r.refStart:k.start===r.refEnd)){let W=n(f)!==n(b)?n(f):u>0!=u<m.length-1?u>0:s!==(p[u]===1);return{skip:r,at:W?g+S:g,strand:W===s?"+":"-"}}g+=S}}}}function oe({crossing:r,refName:o,assemblyName:e,mateAssemblyName:t}){let{skip:a,at:s,strand:n}=r,i=`${a.name}:${a.fragStart}:${a.piece}:skip`;return new K({uniqueId:i,assemblyName:e,refName:o,start:a.refStart,end:a.refEnd,type:"deletion",strand:n==="-"?-1:1,syntenyId:i,spansWindow:!0,mate:{refName:A(a.name),start:s,end:s,assemblyName:t}})}var T=({name:r})=>D(r)??r,$=class extends V{constructor(){super(...arguments);this.walks=new ee(X(this,["walksLocation"],["walksIndex"]),this);this.refNames=new z(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=F(this,a),n=E(this);return{hasCoarseTier:!1,anchorAssemblyName:a,lanes:t.filter(i=>i!==s&&O(i)!==s).map(i=>({name:B(n,i),label:i,group:O(i)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}async getSubgraph(e,t={}){let a=await this.refNames.resolveForCut(e,{signal:t.signal});return this.walks.subgraph(a,e,t)}async laneWalks(e,t,a,s,n){let i=U(a,e);return v(n,s.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.budgets(),signal:s.signal,keep:i,expand:i,links:!1}).catch(c=>{throw Q(c,t.end-t.start)}))}async skipCrossings(e,t,a){let s=[],n=t;for(let i of["leave","rejoin"]){let c=await this.sideCrossings(e,n,i,a);for(let d of c)s.push(d);let h=new Set(c.map(d=>d.skip));n=n.filter(d=>!h.has(d))}return s}async sideCrossings(e,t,a,s){let{signal:n}=s,{chunk:i}=await this.walks.reader.header({signal:n}),c=m=>a==="leave"?m.refStart-1:m.refEnd,h=new Map;for(let m of t){let p=c(m),b=Math.floor(p/i),f=h.get(b);f?(f.group.push(m),f.start=Math.min(f.start,p),f.end=Math.max(f.end,p+1)):h.set(b,{group:[m],start:p,end:p+1})}return(await Promise.all([...h.values()].map(async({group:m,start:p,end:b})=>{let f=new Set(m.map(u=>u.name)),g=u=>f.has(u);try{let{graph:u,fragments:k}=await this.walks.reader.cut(e,{start:p,end:b},{...this.walks.budgets(),signal:n,keep:g,expand:g,context:0,contained:!0,links:!1});return m.map(S=>ie(S,e,k,u.nodes,a))}catch(u){if(n?.aborted)throw u;return[]}}))).flat().filter(m=>m!==void 0)}async anchorFeatures(e,t,a){let s=a.haplotypes?.length?a.haplotypes.map(l=>F(this,l)):void 0,n=F(this,a.targetAssemblyName),i=n===void 0?s:s===void 0||s.some(l=>x(n,l)||x(l,n))?[n]:[];if(i?.length===0)return[];let{start:c,end:h}=t,d=`Reading walks ${t.refName}:${c.toLocaleString()}-${h.toLocaleString()}`,{graph:m,fragments:p,skips:b}=await this.laneWalks(e,t,i,a,d),f=({name:l})=>i===void 0?0:i.findIndex(w=>x(l,w)),g=new Set(p.map(T)),u=await v(d,a.statusCallback,()=>this.skipCrossings(e,b.filter(l=>f(l)>=0&&!g.has(T(l))&&l.refStart<=c&&l.refEnd>=h),a)),k=re(m.nodes),S=E(this),W=l=>B(S,T(l)),y=p.filter(l=>l.name===e),N=p.filter(l=>l.name!==e&&f(l)>=0).map(l=>({rank:f(l),features:y.flatMap(w=>k(l,w).map(C=>j({chain:C,target:w,query:l,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:W(l)})))})),M=u.map(l=>({rank:f(l.skip),features:[oe({crossing:l,refName:t.refName,assemblyName:t.assemblyName,mateAssemblyName:W(l.skip)})]}));return[...N,...M].sort((l,w)=>l.rank-w.rank).flatMap(l=>l.features)}async pairFeatures(e,t,a,s){let n=a.map(m=>({pair:m,featurePrefix:F(this,m.queryAssemblyName),matePrefix:F(this,m.targetAssemblyName)})),{graph:i,fragments:c}=await this.laneWalks(e,t,n.flatMap(m=>[m.featurePrefix,m.matePrefix]),s,J(a)),h=se(i.nodes),d=m=>c.filter(p=>x(p.name,m));return n.flatMap(({pair:m,featurePrefix:p,matePrefix:b})=>d(p).flatMap(f=>d(b).flatMap(g=>h(g,f).map(u=>j({chain:u,target:f,query:g,assemblyName:m.queryAssemblyName,refName:A(f.name),mateAssemblyName:m.targetAssemblyName})))))}getFeatures(e,t={}){return G(async a=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let n=Z(t),i=n.length>0?await this.pairFeatures(s,e,n,t):await this.anchorFeatures(s,e,t);for(let c of i)a.next(c)}a.complete()},t.signal)}};export{$ as default};
|
|
2
|
+
//# sourceMappingURL=WalkTabixSyntenyAdapter-PHRULBP7.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var e="#";function l(t){return t.split(e)[0]}var r=new Set(["_gbwt_ref"]);function p(t){return r.has(t)}function c(t){let n=t.split(e);return n.length>=3?`${n[0]}${e}${n[1]}`:void 0}function u(t){let n=t.split(e);return n.length>=3?n.slice(2).join(e):n.length===2?n[1]:t}function N(t){let[n="",o="",...s]=t.split(e);return s.length>0?{sample:n,haplotype:+o,contig:s.join(e)}:void 0}function S(t){let n=t.split(e),o=n.length>=2&&n[1]!==""?Number(n[1]):Number.NaN;return{sample:n[0],haplotype:Number.isFinite(o)?o:void 0}}function f(t,n){return n!==void 0&&(t===n||t.startsWith(n+e))}function a(t){return t.getConf("assemblyNameToPanSN")??{}}function h(t,n){return n===void 0?void 0:a(t)[n]??n}var i=new WeakMap;function m(t){let n=i.get(t);if(n===void 0){let o=a(t);n={};for(let s of new Set([...Object.keys(o),...t.getConf("assemblyNames")]))n[o[s]??s]=s;i.set(t,n)}return n}export{l as a,p as b,c,u as d,N as e,S as f,f as g,h,m as i};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
2
|
+
//# sourceMappingURL=chunk-3M3UH5JQ.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@12.
|
|
3
|
+
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@12.4.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-2JL2JVZ2.js"],
|
|
4
4
|
"sourcesContent": ["// src/pansn.ts\nvar SEP = \"#\";\nfunction panSNSample(refName) {\n return refName.split(SEP)[0];\n}\nvar GENERIC_SAMPLES = /* @__PURE__ */ new Set([\"_gbwt_ref\"]);\nfunction isGenericSample(sample) {\n return GENERIC_SAMPLES.has(sample);\n}\nfunction panSNHaplotype(refName) {\n const parts = refName.split(SEP);\n return parts.length >= 3 ? `${parts[0]}${SEP}${parts[1]}` : void 0;\n}\nfunction panSNContig(refName) {\n const parts = refName.split(SEP);\n return parts.length >= 3 ? parts.slice(2).join(SEP) : parts.length === 2 ? parts[1] : refName;\n}\nfunction panSNFields(name) {\n const [sample = \"\", haplotype = \"\", ...contig] = name.split(SEP);\n return contig.length > 0 ? { sample, haplotype: +haplotype, contig: contig.join(SEP) } : void 0;\n}\nfunction parsePanSN(refName) {\n const parts = refName.split(SEP);\n const haplotype = parts.length >= 2 && parts[1] !== \"\" ? Number(parts[1]) : Number.NaN;\n return {\n sample: parts[0],\n haplotype: Number.isFinite(haplotype) ? haplotype : void 0\n };\n}\nfunction panSNMatchesPrefix(refName, prefix) {\n return prefix !== void 0 && (refName === prefix || refName.startsWith(prefix + SEP));\n}\nfunction assemblyNameToPanSN(adapter) {\n return adapter.getConf(\"assemblyNameToPanSN\") ?? {};\n}\nfunction resolvePanSNPrefix(adapter, name) {\n return name === void 0 ? void 0 : assemblyNameToPanSN(adapter)[name] ?? name;\n}\nvar asmByPrefixCache = /* @__PURE__ */ new WeakMap();\nfunction assemblyByPanSNPrefix(adapter) {\n let out = asmByPrefixCache.get(adapter);\n if (out === void 0) {\n const map = assemblyNameToPanSN(adapter);\n out = {};\n for (const asm of /* @__PURE__ */ new Set([\n ...Object.keys(map),\n ...adapter.getConf(\"assemblyNames\")\n ])) {\n out[map[asm] ?? asm] = asm;\n }\n asmByPrefixCache.set(adapter, out);\n }\n return out;\n}\n\nexport {\n panSNSample,\n isGenericSample,\n panSNHaplotype,\n panSNContig,\n panSNFields,\n parsePanSN,\n panSNMatchesPrefix,\n resolvePanSNPrefix,\n assemblyByPanSNPrefix\n};\n"],
|
|
5
5
|
"mappings": "AACA,IAAIA,EAAM,IACV,SAASC,EAAYC,EAAS,CAC5B,OAAOA,EAAQ,MAAMF,CAAG,EAAE,CAAC,CAC7B,CACA,IAAIG,EAAkC,IAAI,IAAI,CAAC,WAAW,CAAC,EAC3D,SAASC,EAAgBC,EAAQ,CAC/B,OAAOF,EAAgB,IAAIE,CAAM,CACnC,CACA,SAASC,EAAeJ,EAAS,CAC/B,IAAMK,EAAQL,EAAQ,MAAMF,CAAG,EAC/B,OAAOO,EAAM,QAAU,EAAI,GAAGA,EAAM,CAAC,CAAC,GAAGP,CAAG,GAAGO,EAAM,CAAC,CAAC,GAAK,MAC9D,CACA,SAASC,EAAYN,EAAS,CAC5B,IAAMK,EAAQL,EAAQ,MAAMF,CAAG,EAC/B,OAAOO,EAAM,QAAU,EAAIA,EA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OAAOA,CACT",
|
|
6
6
|
"names": ["SEP", "panSNSample", "refName", "GENERIC_SAMPLES", "isGenericSample", "sample", "panSNHaplotype", "parts", "panSNContig", "panSNFields", "name", "haplotype", "contig", "parsePanSN", "panSNMatchesPrefix", "prefix", "assemblyNameToPanSN", "adapter", "resolvePanSNPrefix", "asmByPrefixCache", "assemblyByPanSNPrefix", "out", "map", "asm"]
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as B}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as B}from"./chunk-SQBD75UZ.js";import{h as b,i as o,k as f,z as m}from"./chunk-XK4HHKSP.js";import{h as u}from"./chunk-3M3UH5JQ.js";var O={steps:"walkStepBudget",bytes:"walkByteBudget"},y=64,k=class{constructor(e,t){this.file=e;this.adapter=t;this.reader=new f(e)}async haplotypeNames(e={}){let{haplotypes:t}=await this.reader.header(e);return t.length>0?t:void 0}budgets(){return{stepBudget:this.adapter.getConf("walkStepBudget"),byteBudget:this.adapter.getConf("walkByteBudget"),budgetNames:O}}async subgraph(e,t,{signal:i,haplotypes:d,walkRows:s,expand:r,expandSamples:n}){let g=this.budgets(),p=o(d?.map(a=>u(this.adapter,a)),e),l=s&&p&&(d?.length??0)<=y?p:void 0,c=s&&n?.length&&n.length<=y?o(n.map(a=>u(this.adapter,a)),e):void 0,h=r?.length?a=>r.includes(a):void 0,{graph:w,kept:A,fragments:S,skips:x}=await this.reader.cut(e,t,{...g,stepBudget:s?1/0:g.stepBudget,signal:i,keep:p,...l||c||h?{expand:a=>!!l?.(a)||!!c?.(a)||!!h?.(a)}:{}});return B(w.tables(A,S,x),t,s)}async referenceNodes(e,t,i){let d=[];await m(this.file,e,await this.reader.queryStart(t.start,{...i,refName:e,end:t.end}),t.end,{signal:i.signal,lineCallback:r=>{let n=r.split(" ");n[3]==="ref"&&d.push(n)}});let s=new Set;return b(d).filter(r=>r.refName!==e||r.end<=t.start||r.start>=t.end||s.has(r.id)?!1:(s.add(r.id),!0))}};export{k as a};
|
|
2
|
+
//# sourceMappingURL=chunk-477HYXB2.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Z,b as $,f as L,h as M}from"./chunk-
|
|
1
|
+
import{a as Z,b as $,f as L,h as M}from"./chunk-UOWS2HEQ.js";import{b as O,g as G,p as T}from"./chunk-PVRRW4PM.js";import{a as y,b as I,c as C,d as v}from"./chunk-3M3UH5JQ.js";var q=new Map([["hg38","GRCh38"],["hg19","GRCh37"],["hs1","CHM13"],["t2t-chm13","CHM13"],["chm13v2","CHM13"]]);function F(t){return q.get(t.toLowerCase())}function z(t){let s=t.includes("#")?y(t):void 0;return s===void 0||I(s)?void 0:s}function P(t){return C(t)??y(t)}function _(t){let s=new Set((t.anchorPaths??[]).map(n=>n.name));for(let n of t.nodes)n.stable&&s.add(n.stable.refName);let e=new Map;for(let n of s){let r=z(n);r!==void 0&&O(e,r,P(n))}return e}function B(t,s){let e=new Set(t.map(f=>z(f.refName))),[n]=e;if(e.size!==1||n===void 0)return{contigs:t,prefixes:[],named:!1};let r=new Set(t.map(f=>P(f.refName))),i=[...s.get(n)??[]].every(f=>r.has(f)),a=new Set(t.map(f=>C(f.refName))),[o]=a;return{contigs:t,prefixes:[...i?[n]:[],...a.size===1&&o?[o]:[]],named:!0}}function U(t){let s=new Map;for(let n of t.nodes)if(G(n)){let{refName:r,start:i}=n.stable,a=i+n.length,o=s.get(r);o?(o.start=Math.min(o.start,i),o.end=Math.max(o.end,a)):s.set(r,{refName:r,contig:v(r),start:i,end:a})}let e=[...s.values()];return e.length?B(e,_(t)):void 0}function de(t,s){let e=U(t),n=s?v(s.refName):e?.contigs.length===1?e.contigs[0].contig:void 0,r=e?.named?y(e.contigs[0].refName):void 0;return n&&(r?`${r} ${n}`:n)}function H(t,s){let e=a=>[a.name,...a.aliases??[]],n=a=>o=>e(o).some(f=>f.toLowerCase()===a.toLowerCase()),r=[...t?.prefixes??[]].reverse(),i=t?.prefixes.find(a=>!a.includes("#"))?.toLowerCase();for(let a of r){let o=s.find(n(a));if(o)return o}return i===void 0?void 0:s.find(a=>e(a).some(o=>F(o)?.toLowerCase()===i))}function pe(t,s){let e=_(t);return t.anchorPaths?.find(n=>H(B([{refName:n.name,contig:v(n.name),start:n.start,end:n.start+n.length}],e),[s]))}function D(t){let s=t.replace(/^chr/i,""),e=s?/^(M|MT)$/i.test(s)?["M","MT"]:[s]:[];return[...new Set([t,...e.flatMap(n=>[n,`chr${n}`])])]}function K(t,s={}){let e=new Set(t),n=new Map;for(let r of e){let i=v(r),a=s[i];for(let o of new Set([...D(i),...a?[a]:[]]))n.set(o,n.has(o)?void 0:r)}return r=>e.has(r)?r:n.get(r)}function me(t,s,e){let n=K(s.contigs.map(r=>r.refName),e);return t.flatMap(r=>{let i=n(r.refName);return i===void 0?[]:[i===r.refName?r:{...r,refName:i}]})}var Q=62,R=60,j=9,k=48,J=57,V=/^(?:LN:i|SN:Z|SO:i|SR:i):/,X=/^[PEOUFG]\t/,W=t=>t.endsWith("\r")?t.slice(0,-1):t;function Y(){return{nodes:new T(new Int32Array(65536)),reversed:new T(new Uint8Array(65536))}}var ee=class{constructor(){this.names=[],this.byName=new Map,this.byNumber=new Map}has(t){return this.byName.has(t)}add(t){let s=this.names.length;this.byName.set(t,s),this.names.push(t);let e=+t;return Number.isSafeInteger(e)&&String(e)===t&&this.byNumber.set(e,s),s}of(t){return this.byName.get(t)??this.add(t)}ofNumber(t){return this.byNumber.get(t)}};function te(t){let[,s,e="*",...n]=t.split(" ");if(!s||/^\d+$/.test(e))return;let r=e==="*"?0:e.length,i,a,o;for(let u of n){if(!V.test(u))return;let c=u.slice(5),p=u.slice(0,2);p==="LN"?r=+c:p==="SN"?i=c:p==="SO"?a=+c:o=+c}return{name:s,length:r,stable:i!==void 0&&a!==void 0&&o!==void 0?{refName:i,start:a,rank:o}:void 0}}function se(t,s,e,n){let r=0,i=-1,a=0,o=!0,f=c=>{if(i>=0&&c>i){let p=o&&c-i<16&&(c-i===1||t.charCodeAt(i)!==k)?e.ofNumber(a):void 0;n.nodes.push(p??e.of(t.slice(i,c))),n.reversed.push(r)}},u=s;for(;u<t.length;u++){let c=t.charCodeAt(u);if(c===Q||c===R)f(u),r=c===R?1:0,i=u+1,a=0,o=!0;else{if(c===j)break;o&&c>=k&&c<=J?a=a*10+c-k:o=!1}}return f(u),u}function ne(t){let s=[],e=0;for(;s.length<6;){let f=t.indexOf(" ",e);if(f===-1)return;s.push(t.slice(e,f)),e=f+1}let[,n,r,i,a,o]=s;return n&&r&&i&&a&&o&&e<t.length?{sample:n,haplotype:r,contig:i,start:a,end:o,body:e}:void 0}function Ne(t){let s=t.split(`
|
|
2
2
|
`),e=new ee,n=[],r=[],i=[],a=[],o=[],f=new Map;for(let d of s){if(X.test(d))return;if(d.startsWith("S ")){let l=te(W(d));if(!l||e.has(l.name))return;e.add(l.name),n.push(l.length);let h=-1;l.stable&&(h=f.get(l.stable.refName)??o.length,h===o.length&&(o.push(l.stable.refName),f.set(l.stable.refName,h))),r.push(h),i.push(l.stable?.start??0),a.push(l.stable?.rank??0)}}let u=[],c=[],p=[],b=[],x=[],E=[],S=[0],g=Y(),w=new M,A=new M;for(let d of s)if(d.startsWith("L ")){let[,l,h,N,m]=W(d).split(" ");l&&N&&m&&(u.push(e.of(l)),c.push(e.of(N)),p.push((h==="-"?1:0)|(m==="-"?2:0)))}else if(d.startsWith("W ")){let l=W(d),h=ne(l);if(h){b.push(`${h.sample}#${h.haplotype}#${h.contig}`),x.push(h.start==="*"?0:+h.start),E.push(h.end==="*"?-1:+h.end);let N=se(l,h.body,e,g),m=re(l,N);if(m===void 0||(m.before&&w.push(m.before),m.after&&A.push(m.after),g.nodes.length===S.at(-1)))return;S.push(g.nodes.length)}}if(![w.kinds.length,A.kinds.length].some(d=>d>0&&d<b.length))return{nodes:{names:e.names,lengths:Int32Array.from(n),refs:Int32Array.from(r),starts:Float64Array.from(i),ranks:Int32Array.from(a),refNames:o},links:{from:Int32Array.from(u),to:Int32Array.from(c),strands:Uint8Array.from(p)},walks:{names:b,starts:Float64Array.from(x),ends:Float64Array.from(E),offsets:Int32Array.from(S),steps:g.nodes.data.slice(0,g.nodes.length),reversed:g.reversed.data.slice(0,g.reversed.length),...oe(b.length,w,A)}}}function re(t,s){let e={};for(let n of s<t.length?t.slice(s+1).split(" "):[]){let r=n.slice(5);if(n.startsWith(`${Z}:Z:`)){if(e.before=L(r),!e.before)return}else if(n.startsWith(`${$}:Z:`)&&(e.after=L(r),!e.after))return}return e}function oe(t,s,e){return{...s.kinds.length===t&&t>0?{before:s.table()}:{},...e.kinds.length===t&&t>0?{after:e.table()}:{}}}var ae=/([><])([^><]+)/g;function ie(t){if(!t.startsWith(">")&&!t.startsWith("<"))return;let s=[];for(let[,e,n]of t.matchAll(ae))s.push({name:n,strand:e===">"?"+":"-"});return s}function fe(t){let s=t.trimEnd(),e=s.split(" ");if(e.length<12||s.startsWith("#"))return;let n=ie(e[5]);if(!n)return;let r,i=!1;for(let a=12;a<e.length;a++){let o=e[a];o.startsWith("cs:Z:")?r=o.slice(5):o==="tp:A:S"&&(i=!0)}return{name:e[0],queryLength:+e[1],queryStart:+e[2],queryEnd:+e[3],strand:e[4]==="-"?"-":"+",path:n,pathLength:+e[6],pathStart:+e[7],pathEnd:+e[8],matches:+e[9],blockLength:+e[10],mappingQuality:+e[11],secondary:i,...r===void 0?{}:{cs:r}}}function we(t){let s=[];for(let e of t.split(`
|
|
3
3
|
`)){let n=fe(e);n&&s.push(n)}return s}var ce=/:(\d+)|=([A-Za-z]+)|\*[a-zA-Z]([a-zA-Z])|\+([A-Za-z]+)|-([A-Za-z]+)|~[a-z]{2}(\d+)[a-z]{2}/g;function Ae(t){let s=[];for(let e of t.matchAll(ce))e[1]!==void 0?s.push({op:"match",length:+e[1]}):e[2]!==void 0?s.push({op:"match",length:e[2].length}):e[3]!==void 0?s.push({op:"substitution",seq:e[3].toUpperCase()}):e[4]!==void 0?s.push({op:"insertion",seq:e[4].toUpperCase()}):e[5]!==void 0?s.push({op:"deletion",length:e[5].length}):e[6]!==void 0&&s.push({op:"match",length:+e[6]});return s}export{F as a,U as b,de as c,H as d,pe as e,me as f,Ne as g,fe as h,we as i,Ae as j};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-47KLT4FL.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@12.
|
|
3
|
+
"sources": ["../../node_modules/.pnpm/@jbrowse+bandage-core@12.4.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-5ORP7EFJ.js", "../../node_modules/.pnpm/@jbrowse+bandage-core@12.4.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-JQVS4DRW.js", "../../node_modules/.pnpm/@jbrowse+bandage-core@12.4.0/node_modules/@jbrowse/bandage-core/dist/chunks/chunk-5OJZV6YT.js"],
|
|
4
4
|
"sourcesContent": ["import {\n addTo\n} from \"./chunk-BSOZW3FC.js\";\nimport {\n isBackbone\n} from \"./chunk-RJWPJCIB.js\";\nimport {\n isGenericSample,\n panSNContig,\n panSNHaplotype,\n panSNSample\n} from \"./chunk-2JL2JVZ2.js\";\n\n// src/reference.ts\nvar WELL_KNOWN_SAMPLES = /* @__PURE__ */ new Map([\n [\"hg38\", \"GRCh38\"],\n [\"hg19\", \"GRCh37\"],\n [\"hs1\", \"CHM13\"],\n [\"t2t-chm13\", \"CHM13\"],\n [\"chm13v2\", \"CHM13\"]\n]);\nfunction wellKnownSample(assemblyName) {\n return WELL_KNOWN_SAMPLES.get(assemblyName.toLowerCase());\n}\nfunction sampleOf(refName) {\n const sample = refName.includes(\"#\") ? panSNSample(refName) : void 0;\n return sample === void 0 || isGenericSample(sample) ? void 0 : sample;\n}\nfunction haplotypeOf(refName) {\n return panSNHaplotype(refName) ?? panSNSample(refName);\n}\nfunction graphHaplotypes(graph) {\n const refNames = new Set((graph.anchorPaths ?? []).map((p) => p.name));\n for (const node of graph.nodes) {\n if (node.stable) {\n refNames.add(node.stable.refName);\n }\n }\n const bySample = /* @__PURE__ */ new Map();\n for (const refName of refNames) {\n const sample = sampleOf(refName);\n if (sample !== void 0) {\n addTo(bySample, sample, haplotypeOf(refName));\n }\n }\n return bySample;\n}\nfunction backboneFrom(contigs, haplotypes) {\n const samples = new Set(contigs.map((c) => sampleOf(c.refName)));\n const [sample] = samples;\n if (samples.size !== 1 || sample === void 0) {\n return { contigs, prefixes: [], named: false };\n }\n const own = new Set(contigs.map((c) => haplotypeOf(c.refName)));\n const unique = [...haplotypes.get(sample) ?? []].every((h) => own.has(h));\n const shared = new Set(contigs.map((c) => panSNHaplotype(c.refName)));\n const [haplotype] = shared;\n return {\n contigs,\n prefixes: [\n ...unique ? [sample] : [],\n ...shared.size === 1 && haplotype ? [haplotype] : []\n ],\n named: true\n };\n}\nfunction graphBackbone(graph) {\n const spans = /* @__PURE__ */ new Map();\n for (const node of graph.nodes) {\n if (isBackbone(node)) {\n const { refName, start } = node.stable;\n const end = start + node.length;\n const span = spans.get(refName);\n if (span) {\n span.start = Math.min(span.start, start);\n span.end = Math.max(span.end, end);\n } else {\n spans.set(refName, {\n refName,\n contig: panSNContig(refName),\n start,\n end\n });\n }\n }\n }\n const contigs = [...spans.values()];\n return contigs.length ? backboneFrom(contigs, graphHaplotypes(graph)) : void 0;\n}\nfunction referenceLabel(graph, region) {\n const backbone = graphBackbone(graph);\n const contig = region ? panSNContig(region.refName) : backbone?.contigs.length === 1 ? backbone.contigs[0].contig : void 0;\n const sample = backbone?.named ? panSNSample(backbone.contigs[0].refName) : void 0;\n return contig && (sample ? `${sample} ${contig}` : contig);\n}\nfunction backboneAssembly(backbone, assemblies) {\n const names = (a) => [a.name, ...a.aliases ?? []];\n const naming = (prefix) => (a) => names(a).some((n) => n.toLowerCase() === prefix.toLowerCase());\n const prefixes = [...backbone?.prefixes ?? []].reverse();\n const sample = backbone?.prefixes.find((p) => !p.includes(\"#\"))?.toLowerCase();\n for (const prefix of prefixes) {\n const assembly = assemblies.find(naming(prefix));\n if (assembly) {\n return assembly;\n }\n }\n return sample === void 0 ? void 0 : assemblies.find(\n (a) => names(a).some((n) => wellKnownSample(n)?.toLowerCase() === sample)\n );\n}\nfunction assemblyWalk(graph, assembly) {\n const haplotypes = graphHaplotypes(graph);\n return graph.anchorPaths?.find(\n (walk) => backboneAssembly(\n backboneFrom(\n [\n {\n refName: walk.name,\n contig: panSNContig(walk.name),\n start: walk.start,\n end: walk.start + walk.length\n }\n ],\n haplotypes\n ),\n [assembly]\n )\n );\n}\nfunction contigNames(contig) {\n const bare = contig.replace(/^chr/i, \"\");\n const forms = !bare ? [] : /^(M|MT)$/i.test(bare) ? [\"M\", \"MT\"] : [bare];\n return [.../* @__PURE__ */ new Set([contig, ...forms.flatMap((f) => [f, `chr${f}`])])];\n}\nfunction refNameBinding(refNames, aliases = {}) {\n const exact = new Set(refNames);\n const byName = /* @__PURE__ */ new Map();\n for (const refName of exact) {\n const contig = panSNContig(refName);\n const alias = aliases[contig];\n for (const name of /* @__PURE__ */ new Set([\n ...contigNames(contig),\n ...alias ? [alias] : []\n ])) {\n byName.set(name, byName.has(name) ? void 0 : refName);\n }\n }\n return (name) => exact.has(name) ? name : byName.get(name);\n}\nfunction featuresOnBackbone(features, backbone, aliases) {\n const bind = refNameBinding(\n backbone.contigs.map((c) => c.refName),\n aliases\n );\n return features.flatMap((f) => {\n const refName = bind(f.refName);\n return refName === void 0 ? [] : [refName === f.refName ? f : { ...f, refName }];\n });\n}\n\nexport {\n WELL_KNOWN_SAMPLES,\n wellKnownSample,\n graphBackbone,\n referenceLabel,\n backboneAssembly,\n assemblyWalk,\n contigNames,\n refNameBinding,\n featuresOnBackbone\n};\n", "import {\n END_STOP_TAG,\n START_STOP_TAG,\n StopColumns,\n parseStopTag\n} from \"./chunk-VA5U4F23.js\";\nimport {\n Column\n} from \"./chunk-BEUTROKU.js\";\n\n// src/gfa/gfaTables.ts\nvar GT = 62;\nvar LT = 60;\nvar TAB = 9;\nvar ZERO = 48;\nvar NINE = 57;\nvar TABLE_TAG = /^(?:LN:i|SN:Z|SO:i|SR:i):/;\nvar UNTABLED_RECORD = /^[PEOUFG]\\t/;\nvar trimCR = (line) => line.endsWith(\"\\r\") ? line.slice(0, -1) : line;\nfunction stepColumns() {\n return {\n nodes: new Column(new Int32Array(1 << 16)),\n reversed: new Column(new Uint8Array(1 << 16))\n };\n}\nvar SegmentIndex = class {\n constructor() {\n this.names = [];\n this.byName = /* @__PURE__ */ new Map();\n // ids that are plain decimal, so a walk step finds its segment without\n // slicing a string out of the body\n this.byNumber = /* @__PURE__ */ new Map();\n }\n has(name) {\n return this.byName.has(name);\n }\n add(name) {\n const i = this.names.length;\n this.byName.set(name, i);\n this.names.push(name);\n const n = +name;\n if (Number.isSafeInteger(n) && String(n) === name) {\n this.byNumber.set(n, i);\n }\n return i;\n }\n of(name) {\n return this.byName.get(name) ?? this.add(name);\n }\n ofNumber(n) {\n return this.byNumber.get(n);\n }\n};\nfunction readSegment(line) {\n const [, name, sequence = \"*\", ...tags] = line.split(\"\t\");\n if (!name || /^\\d+$/.test(sequence)) {\n return void 0;\n }\n let length = sequence === \"*\" ? 0 : sequence.length;\n let refName;\n let start;\n let rank;\n for (const tag of tags) {\n if (!TABLE_TAG.test(tag)) {\n return void 0;\n }\n const value = tag.slice(5);\n const key = tag.slice(0, 2);\n if (key === \"LN\") {\n length = +value;\n } else if (key === \"SN\") {\n refName = value;\n } else if (key === \"SO\") {\n start = +value;\n } else {\n rank = +value;\n }\n }\n const stable = refName !== void 0 && start !== void 0 && rank !== void 0 ? { refName, start, rank } : void 0;\n return { name, length, stable };\n}\nfunction readWalkBody(line, from, segments, steps) {\n let reversed = 0;\n let start = -1;\n let value = 0;\n let decimal = true;\n const finish = (end) => {\n if (start >= 0 && end > start) {\n const node = decimal && end - start < 16 && (end - start === 1 || line.charCodeAt(start) !== ZERO) ? segments.ofNumber(value) : void 0;\n steps.nodes.push(node ?? segments.of(line.slice(start, end)));\n steps.reversed.push(reversed);\n }\n };\n let i = from;\n for (; i < line.length; i++) {\n const ch = line.charCodeAt(i);\n if (ch === GT || ch === LT) {\n finish(i);\n reversed = ch === LT ? 1 : 0;\n start = i + 1;\n value = 0;\n decimal = true;\n } else if (ch === TAB) {\n break;\n } else if (decimal && ch >= ZERO && ch <= NINE) {\n value = value * 10 + ch - ZERO;\n } else {\n decimal = false;\n }\n }\n finish(i);\n return i;\n}\nfunction walkFields(line) {\n const fields = [];\n let at = 0;\n while (fields.length < 6) {\n const tab = line.indexOf(\"\t\", at);\n if (tab === -1) {\n return void 0;\n }\n fields.push(line.slice(at, tab));\n at = tab + 1;\n }\n const [, sample, haplotype, contig, start, end] = fields;\n return sample && haplotype && contig && start && end && at < line.length ? { sample, haplotype, contig, start, end, body: at } : void 0;\n}\nfunction gfaTables(text) {\n const lines = text.split(\"\\n\");\n const segments = new SegmentIndex();\n const lengths = [];\n const refs = [];\n const starts = [];\n const ranks = [];\n const refNames = [];\n const refIndex = /* @__PURE__ */ new Map();\n for (const raw of lines) {\n if (UNTABLED_RECORD.test(raw)) {\n return void 0;\n }\n if (raw.startsWith(\"S\t\")) {\n const s = readSegment(trimCR(raw));\n if (!s || segments.has(s.name)) {\n return void 0;\n }\n segments.add(s.name);\n lengths.push(s.length);\n let ref = -1;\n if (s.stable) {\n ref = refIndex.get(s.stable.refName) ?? refNames.length;\n if (ref === refNames.length) {\n refNames.push(s.stable.refName);\n refIndex.set(s.stable.refName, ref);\n }\n }\n refs.push(ref);\n starts.push(s.stable?.start ?? 0);\n ranks.push(s.stable?.rank ?? 0);\n }\n }\n const from = [];\n const to = [];\n const strands = [];\n const names = [];\n const walkStarts = [];\n const walkEnds = [];\n const offsets = [0];\n const steps = stepColumns();\n const before = new StopColumns();\n const after = new StopColumns();\n for (const raw of lines) {\n if (raw.startsWith(\"L\t\")) {\n const [, source, strand1, target, strand2] = trimCR(raw).split(\"\t\");\n if (source && target && strand2) {\n from.push(segments.of(source));\n to.push(segments.of(target));\n strands.push((strand1 === \"-\" ? 1 : 0) | (strand2 === \"-\" ? 2 : 0));\n }\n } else if (raw.startsWith(\"W\t\")) {\n const line = trimCR(raw);\n const w = walkFields(line);\n if (w) {\n names.push(`${w.sample}#${w.haplotype}#${w.contig}`);\n walkStarts.push(w.start === \"*\" ? 0 : +w.start);\n walkEnds.push(w.end === \"*\" ? -1 : +w.end);\n const end = readWalkBody(line, w.body, segments, steps);\n const tags = walkTags(line, end);\n if (tags === void 0) {\n return void 0;\n }\n if (tags.before) {\n before.push(tags.before);\n }\n if (tags.after) {\n after.push(tags.after);\n }\n if (steps.nodes.length === offsets.at(-1)) {\n return void 0;\n }\n offsets.push(steps.nodes.length);\n }\n }\n }\n if ([before.kinds.length, after.kinds.length].some(\n (n) => n > 0 && n < names.length\n )) {\n return void 0;\n }\n return {\n nodes: {\n names: segments.names,\n lengths: Int32Array.from(lengths),\n refs: Int32Array.from(refs),\n starts: Float64Array.from(starts),\n ranks: Int32Array.from(ranks),\n refNames\n },\n links: {\n from: Int32Array.from(from),\n to: Int32Array.from(to),\n strands: Uint8Array.from(strands)\n },\n walks: {\n names,\n starts: Float64Array.from(walkStarts),\n ends: Float64Array.from(walkEnds),\n offsets: Int32Array.from(offsets),\n steps: steps.nodes.data.slice(0, steps.nodes.length),\n reversed: steps.reversed.data.slice(0, steps.reversed.length),\n ...stopColumns(names.length, before, after)\n }\n };\n}\nfunction walkTags(line, from) {\n const out = {};\n for (const tag of from < line.length ? line.slice(from + 1).split(\"\t\") : []) {\n const value = tag.slice(5);\n if (tag.startsWith(`${START_STOP_TAG}:Z:`)) {\n out.before = parseStopTag(value);\n if (!out.before) {\n return void 0;\n }\n } else if (tag.startsWith(`${END_STOP_TAG}:Z:`)) {\n out.after = parseStopTag(value);\n if (!out.after) {\n return void 0;\n }\n }\n }\n return out;\n}\nfunction stopColumns(walks, before, after) {\n return {\n ...before.kinds.length === walks && walks > 0 ? { before: before.table() } : {},\n ...after.kinds.length === walks && walks > 0 ? { after: after.table() } : {}\n };\n}\n\nexport {\n gfaTables\n};\n", "// src/gaf/parseGaf.ts\nvar STEP = /([><])([^><]+)/g;\nfunction parseGafPath(column) {\n if (!column.startsWith(\">\") && !column.startsWith(\"<\")) {\n return void 0;\n }\n const steps = [];\n for (const [, arrow, name] of column.matchAll(STEP)) {\n steps.push({ name, strand: arrow === \">\" ? \"+\" : \"-\" });\n }\n return steps;\n}\nfunction parseGafLine(text) {\n const line = text.trimEnd();\n const columns = line.split(\"\t\");\n if (columns.length < 12 || line.startsWith(\"#\")) {\n return void 0;\n }\n const path = parseGafPath(columns[5]);\n if (!path) {\n return void 0;\n }\n let cs;\n let secondary = false;\n for (let i = 12; i < columns.length; i++) {\n const tag = columns[i];\n if (tag.startsWith(\"cs:Z:\")) {\n cs = tag.slice(5);\n } else if (tag === \"tp:A:S\") {\n secondary = true;\n }\n }\n return {\n name: columns[0],\n queryLength: +columns[1],\n queryStart: +columns[2],\n queryEnd: +columns[3],\n strand: columns[4] === \"-\" ? \"-\" : \"+\",\n path,\n pathLength: +columns[6],\n pathStart: +columns[7],\n pathEnd: +columns[8],\n matches: +columns[9],\n blockLength: +columns[10],\n mappingQuality: +columns[11],\n secondary,\n ...cs === void 0 ? {} : { cs }\n };\n}\nfunction parseGaf(text) {\n const records = [];\n for (const line of text.split(\"\\n\")) {\n const record = parseGafLine(line);\n if (record) {\n records.push(record);\n }\n }\n return records;\n}\nvar CS_OP = /:(\\d+)|=([A-Za-z]+)|\\*[a-zA-Z]([a-zA-Z])|\\+([A-Za-z]+)|-([A-Za-z]+)|~[a-z]{2}(\\d+)[a-z]{2}/g;\nfunction parseCs(cs) {\n const ops = [];\n for (const m of cs.matchAll(CS_OP)) {\n if (m[1] !== void 0) {\n ops.push({ op: \"match\", length: +m[1] });\n } else if (m[2] !== void 0) {\n ops.push({ op: \"match\", length: m[2].length });\n } else if (m[3] !== void 0) {\n ops.push({ op: \"substitution\", seq: m[3].toUpperCase() });\n } else if (m[4] !== void 0) {\n ops.push({ op: \"insertion\", seq: m[4].toUpperCase() });\n } else if (m[5] !== void 0) {\n ops.push({ op: \"deletion\", length: m[5].length });\n } else if (m[6] !== void 0) {\n ops.push({ op: \"match\", length: +m[6] });\n }\n }\n return ops;\n}\n\nexport {\n parseGafPath,\n parseGafLine,\n parseGaf,\n parseCs\n};\n"],
|
|
5
5
|
"mappings": "gLAcA,IAAIA,EAAqC,IAAI,IAAI,CAC/C,CAAC,OAAQ,QAAQ,EACjB,CAAC,OAAQ,QAAQ,EACjB,CAAC,MAAO,OAAO,EACf,CAAC,YAAa,OAAO,EACrB,CAAC,UAAW,OAAO,CACrB,CAAC,EACD,SAASC,EAAgBC,EAAc,CACrC,OAAOF,EAAmB,IAAIE,EAAa,YAAY,CAAC,CAC1D,CACA,SAASC,EAASC,EAAS,CACzB,IAAMC,EAASD,EAAQ,SAAS,GAAG,EAAIE,EAAYF,CAAO,EAAI,OAC9D,OAAOC,IAAW,QAAUE,EAAgBF,CAAM,EAAI,OAASA,CACjE,CACA,SAASG,EAAYJ,EAAS,CAC5B,OAAOK,EAAeL,CAAO,GAAKE,EAAYF,CAAO,CACvD,CACA,SAASM,EAAgBC,EAAO,CAC9B,IAAMC,EAAW,IAAI,KAAKD,EAAM,aAAe,CAAC,GAAG,IAAKE,GAAMA,EAAE,IAAI,CAAC,EACrE,QAAWC,KAAQH,EAAM,MACnBG,EAAK,QACPF,EAAS,IAAIE,EAAK,OAAO,OAAO,EAGpC,IAAMC,EAA2B,IAAI,IACrC,QAAWX,KAAWQ,EAAU,CAC9B,IAAMP,EAASF,EAASC,CAAO,EAC3BC,IAAW,QACbW,EAAMD,EAAUV,EAAQG,EAAYJ,CAAO,CAAC,CAEhD,CACA,OAAOW,CACT,CACA,SAASE,EAAaC,EAASC,EAAY,CACzC,IAAMC,EAAU,IAAI,IAAIF,EAAQ,IAAKG,GAAMlB,EAASkB,EAA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U,CAAC,EACjB,QAAWR,KAAQD,EAAK,MAAM;AAAA,CAAI,EAAG,CACnC,IAAMU,EAASX,GAAaE,CAAI,EAC5BS,GACFD,EAAQ,KAAKC,CAAM,CAEvB,CACA,OAAOD,CACT,CACA,IAAIE,GAAQ,8FACZ,SAASC,GAAQR,EAAI,CACnB,IAAMS,EAAM,CAAC,EACb,QAAWC,KAAKV,EAAG,SAASO,EAAK,EAC3BG,EAAE,CAAC,IAAM,OACXD,EAAI,KAAK,CAAE,GAAI,QAAS,OAAQ,CAACC,EAAE,CAAC,CAAE,CAAC,EAC9BA,EAAE,CAAC,IAAM,OAClBD,EAAI,KAAK,CAAE,GAAI,QAAS,OAAQC,EAAE,CAAC,EAAE,MAAO,CAAC,EACpCA,EAAE,CAAC,IAAM,OAClBD,EAAI,KAAK,CAAE,GAAI,eAAgB,IAAKC,EAAE,CAAC,EAAE,YAAY,CAAE,CAAC,EAC/CA,EAAE,CAAC,IAAM,OAClBD,EAAI,KAAK,CAAE,GAAI,YAAa,IAAKC,EAAE,CAAC,EAAE,YAAY,CAAE,CAAC,EAC5CA,EAAE,CAAC,IAAM,OAClBD,EAAI,KAAK,CAAE,GAAI,WAAY,OAAQC,EAAE,CAAC,EAAE,MAAO,CAAC,EACvCA,EAAE,CAAC,IAAM,QAClBD,EAAI,KAAK,CAAE,GAAI,QAAS,OAAQ,CAACC,EAAE,CAAC,CAAE,CAAC,EAG3C,OAAOD,CACT",
|
|
6
6
|
"names": ["WELL_KNOWN_SAMPLES", "wellKnownSample", "assemblyName", "sampleOf", "refName", "sample", "panSNSample", "isGenericSample", "haplotypeOf", "panSNHaplotype", "graphHaplotypes", "graph", "refNames", "p", "node", "bySample", "addTo", "backboneFrom", "contigs", "haplotypes", "samples", "c", "own", "unique", "h", "shared", "haplotype", "graphBackbone", "spans", "isBackbone", "start", "end", "span", "panSNContig", "referenceLabel", "region", "backbone", "contig", "backboneAssembly", "assemblies", "names", "naming", "prefix", "a", "n", "prefixes", "assembly", "assemblyWalk", "walk", "contigNames", "bare", "forms", "f", "refNameBinding", "aliases", "exact", "byName", "alias", "name", "featuresOnBackbone", "features", "bind", "GT", "LT", "TAB", "ZERO", "NINE", "TABLE_TAG", "UNTABLED_RECORD", "trimCR", "line", "stepColumns", "Column", "SegmentIndex", "name", "i", "n", "readSegment", "sequence", "tags", "length", "refName", "start", "rank", "tag", "value", "key", "readWalkBody", "from", "segments", "steps", "reversed", "decimal", "finish", "end", "node", "ch", "walkFields", "fields", "at", "tab", "sample", "haplotype", "contig", "gfaTables", "text", "lines", "lengths", "refs", "starts", "ranks", "refNames", "refIndex", "raw", "s", "ref", "to", "strands", "names", "walkStarts", "walkEnds", "offsets", "before", "StopColumns", "after", "source", "strand1", "target", "strand2", "w", "walkTags", "stopColumns", "out", "START_STOP_TAG", "parseStopTag", "END_STOP_TAG", "walks", "STEP", "parseGafPath", "column", "steps", "arrow", "name", "parseGafLine", "text", "line", "columns", "path", "cs", "secondary", "i", "tag", "parseGaf", "records", "record", "CS_OP", "parseCs", "ops", "m"]
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var tt;function ut(){return tt??(tt=import("./bandage-layout-UZEOCKMS.js").then(o=>o.default()).catch(o=>{throw tt=void 0,o})),tt}async function dt(o){return(await ut()).computeLayout(o.graph,o.options)}var Bt="\0deletion:";var kt=25*Math.PI/180,Pt=.25,St=150,nn=[0,-.35,.35,-.7,.7,-1.05,1.05,-1.4,1.4],pt=[0,1];function _t(o){return o?0:1}function lt(o,t){let n=t.x-o.x,e=t.y-o.y,s=Math.hypot(n,e)||1;return{x:n/s,y:e/s}}function gt(o,t,n){return{x:o.x+(t.x-o.x)*n,y:o.y+(t.y-o.y)*n}}function Dt(o){let t=0,n=0;for(let e of o)t+=e.x,n+=e.y;return{x:t/o.length,y:n/o.length}}function Gt(o){let t=new Float64Array(o.length);for(let n=1;n<o.length;n++)t[n]=t[n-1]+Math.hypot(o[n].x-o[n-1].x,o[n].y-o[n-1].y);return t}function Ut(o){var t;return(t=Gt(o)[o.length-1])!==null&&t!==void 0?t:0}var at=new Map;function en(o){let t=at.get(o);if(t!==void 0)return t;let n=on(o);return at.size>1e4&&at.clear(),at.set(o,n),n}function on(o){let t=1e-6,n=2*Math.PI-1e-6;for(let e=0;e<60;e++){let s=(t+n)/2;s/(2*Math.sin(s/2))<o?t=s:n=s}return(t+n)/2}function sn(o,t){if(o<1e-9)return Math.PI*t;let n=(o*o/4+t*t)/(2*t),e=2*Math.asin(Math.min(1,o/(2*n)));return n*(t>n?2*Math.PI-e:e)}function mt(o,t,n,e){let s=t-2*n,i=o<1e-9?2*Math.PI:en(s/o),r=s/i,l=Math.cos(i/2),d=o/2,c=e+n-r*l;return{at:a=>{if(a<=n)return{u:0,v:e+a};if(a>=t-n)return{u:o,v:e+t-a};let h=(a-n)/r-i/2;return{u:d+r*Math.sin(h),v:c+r*Math.cos(h)}},apex:e+n+r*(1-l),length:t}}function It(o,t,n){if(!n)return o;let e=Math.cos(n),s=Math.sin(n);return{...o,at:i=>{let{u:r,v:l}=o.at(i),d=r-t/2;return{u:t/2+d*e-l*s,v:d*s+l*e}}}}function rn(o){for(let t=0;t<=32;t++)if(o.at(o.length*t/32).v<-1e-6)return!0;return!1}function Ot(o,t,n,e,s){return{at:i=>({u:o+n*i,v:t+e*i}),apex:t+Math.max(0,e)*s,length:s}}var ot=class{constructor(t,n,e=!1){var s;this.pts=t,this.normals=n,this.straight=e,this.arc=Gt(t),this.total=(s=this.arc[t.length-1])!==null&&s!==void 0?s:0}segment(t){let{arc:n}=this,e=1,s=n.length-1;for(;e<s;){let i=e+s>>1;n[i]<t?e=i+1:s=i}return e}fraction(t,n){let e=this.arc[t]-this.arc[t-1];return e>0?(n-this.arc[t-1])/e:0}pointAt(t){let{pts:n}=this,e=n.length-1;if(e===0)return{...n[0]};if(t<=0){let i=lt(n[0],n[1]);return{x:n[0].x+i.x*t,y:n[0].y+i.y*t}}if(t>=this.total){let i=lt(n[e-1],n[e]),r=t-this.total;return{x:n[e].x+i.x*r,y:n[e].y+i.y*r}}let s=this.segment(t);return gt(n[s-1],n[s],this.fraction(s,t))}normalAt(t){let{normals:n}=this;if(n.length===1||t<=0)return n[0];if(t>=this.total)return n[n.length-1];let e=this.segment(t),{x:s,y:i}=gt(n[e-1],n[e],this.fraction(e,t)),r=Math.hypot(s,i)||1;return{x:s/r,y:i/r}}};function an(o,t){let n=Dt(o);return o.map((e,s)=>{let i=lt(o[Math.max(0,s-1)],o[Math.min(o.length-1,s+1)]),r={x:-i.y,y:i.x},l=e.x-n.x,d=e.y-n.y,c=Math.hypot(l,d),a=r.x*l+r.y*d,h=t[s],f=c>1e-9&&Math.abs(a)>.3*c?Math.sign(a):Math.sign(r.x*h.x+r.y*h.y)||1;return{x:r.x*f,y:r.y*f}})}function xt(o,t,n,e,s){let i=Math.min(s,Math.max(e.length/24,.5)),r=[],l=[];for(let d=0;d<=e.length+1e-9;d+=i){let{u:c,v:a}=e.at(Math.min(d,e.length)),h=o.pointAt(t+c),f=o.normalAt(t+c),u=f.x*n,g=f.y*n;r.push({x:h.x+u*a,y:h.y+g*a}),l.push({x:u,y:g})}return{pts:r,refs:l}}var Ft=5,cn=10.5/2;function yt(o,t,n,e,s,i){let r=s,l=xt(o,t,n,e(r),i);if(o.straight)return l;for(let d=0;d<6;d++){let c=Ut(l.pts);if(!(c>0)||Math.abs(c/s-1)<.001)break;r*=s/c,l=xt(o,t,n,e(r),i)}return l}function ct(o,t){return Array.from({length:t},(n,e)=>o+e*15/2)}function Tt(o){if(o.length===0)return 1/0;let t=1/0,n=-1/0;for(let e of o)t=Math.min(t,e.point.x),n=Math.max(n,e.point.x);return n-t}function Rt(o,t){return o*73856093^t*19349663}var ht=class{constructor(t){this.c=t,this.grid=new Map;let{ids:n,first:e,count:s,per:i,seedX:r,seedY:l,backbone:d}=t,c=n.length;this.points=Array.from({length:c},()=>{}),this.params=Array.from({length:c},()=>{}),this.curves=Array.from({length:c},()=>{}),this.links=t.links.map((f,u)=>f.map(g=>g.filter(([M])=>M!==u))),this.route=n.map(f=>f.startsWith(Bt));let a=1/0,h=-1/0;for(let f=0;f<c;f++){let u=e[f];!d[u]||Number.isNaN(r[u])||(a=Math.min(a,r[u]),h=Math.max(h,r[u]+i[f]*(s[f]-1)))}this.backbone=new ot([{x:a,y:0},{x:h,y:0}],[{x:0,y:1},{x:0,y:1}],!0),this.backboneCentroid={x:(a+h)/2,y:0};for(let f=0;f<c;f++){let u=e[f];if(!d[u]||Number.isNaN(r[u]))continue;let g=[],M=[];for(let b=0;b<s[f];b++){let U=r[u]+b*i[f];g.push({x:U,y:l[u]}),M.push(U-a)}this.points[f]=g,this.params[f]=M,this.curves[f]=this.backbone,this.occupy(g,this.backbone)}}static hasBackbone(t){for(let n=0;n<t.ids.length;n++){let e=t.first[n];if(t.backbone[e]&&!Number.isNaN(t.seedX[e]))return!0}return!1}run(){let t=[];for(let e=0;e<this.points.length;e++)this.points[e]||t.push(e);let n=this.componentsOf(t).map(e=>({members:e,anchors:this.anchorsOf(e)})).filter(e=>e.anchors.length).map(e=>({members:e.members,span:Tt(e.anchors),drawn:e.members.reduce((s,i)=>s+this.drawn(i),0),feet:e.anchors.map(s=>`${s.point.x},${s.point.y}`).sort().join(" ")})).sort((e,s)=>e.span-s.span||(e.feet===s.feet?s.drawn-e.drawn:e.drawn-s.drawn));for(let e of n)this.placePiece(e.members,this.backboneCentroid)}write(t,n){let{first:e}=this.c;this.points.forEach((s,i)=>{s?.forEach((r,l)=>{t[e[i]+l]=r.x,n[e[i]+l]=r.y})})}drawn(t){return this.c.per[t]*(this.c.count[t]-1)}endIndex(t,n){return n?this.c.count[t]-1:0}occupy(t,n){for(let e of t){let s=Rt(Math.floor(e.x/10.5),Math.floor(e.y/10.5)),i=this.grid.get(s),r={x:e.x,y:e.y,curve:n};i?i.push(r):this.grid.set(s,[r])}}violations(t,n,e,s){var i;let r=0;for(let l of t){if(e.some(a=>Math.hypot(l.x-a.x,l.y-a.y)<15))continue;let d=Math.floor(l.x/10.5),c=Math.floor(l.y/10.5);for(let a=d-1;a<=d+1;a++)for(let h=c-1;h<=c+1;h++)for(let f of(i=this.grid.get(Rt(a,h)))!==null&&i!==void 0?i:[])if(f.curve!==n&&Math.hypot(l.x-f.x,l.y-f.y)<10.5&&(r++,r>=s))return r}return r}choose(t,n,e){let s,i=1/0;for(let r of t){let l=this.violations(r(cn).pts,n,e,i);if(l===0)return r(Ft);l<i&&(i=l,s=r)}return s(Ft)}anchorsOf(t){let n=new Set(t),e=[];for(let s of t)for(let i of pt)for(let[r,l]of this.links[s][i]){let d=this.points[r];if(n.has(r)||!d)continue;let c=this.endIndex(r,l);e.push({u:s,uSide:i,v:r,vSide:l,point:d[c],curve:this.curves[r],t:this.params[r][c]})}return e}componentsOf(t){let n=new Set(t),e=new Set,s=[];for(let i of t){if(e.has(i))continue;let r=[i];e.add(i);for(let l of r)for(let d of pt)for(let[c]of this.links[l][d])n.has(c)&&!e.has(c)&&(e.add(c),r.push(c));s.push(r)}return s}spinePath(t,n,e,s,i){let r=new Set(t),l=(u,g)=>u*2+g,d=(u,g)=>u===s&&_t(g)===i,c=new Map([[l(n,e),-1]]),a=[[n,e]],h=[n,e];for(let[u,g]of a){if(h=[u,g],s!==void 0&&d(u,g))break;for(let[M,b]of this.links[u][_t(g)])!r.has(M)||c.has(l(M,b))||(c.set(l(M,b),l(u,g)),a.push([M,b]))}if(s!==void 0&&!d(h[0],h[1]))return;let f=[];for(let u=l(h[0],h[1]);u!==-1;u=c.get(u))f.push({k:u>>1,enter:u&1});return f.reverse()}loosePath(t,n,e){let s=new Set(t),i=new Map([[n,-1]]),r=new Map([[n,0]]),l=[n];for(let c of l){if(c===e)break;for(let a of pt)for(let[h,f]of this.links[c][a])!s.has(h)||i.has(h)||(i.set(h,c),r.set(h,f),l.push(h))}let d=[];for(let c=e;c!==-1;c=i.get(c))d.push({k:c,enter:r.get(c)});return d.reverse()}spineLength(t){let{link:n}=this.c;return t.reduce((e,{k:s})=>e+this.drawn(s)+n,n)}layAlong(t,n,e,s){let{count:i,per:r,link:l}=this.c,d=e,c=[];for(let{k:a,enter:h}of t){let f=s??r[a],u=[],g=[];for(let M=0;M<i[a];M++)u.push(n.pointAt(d+M*f)),g.push(d+M*f);h===1&&(u.reverse(),g.reverse()),this.points[a]=u,this.params[a]=g,this.curves[a]=n,c.push(...u),d+=f*(i[a]-1)+l}return c}arcCandidates(t,n,e,s,i){let r=(i-s)/2-1e-6,l=i>2*s?nn:[0],d=[];for(let c of ct(0,8))for(let a of l)for(let h=0;h<=16;h++){let f=r*h/16,u=It(mt(s,i,f,c),s,a);h<16&&u.apex<12||rn(u)||d.push(g=>yt(t,n,e,M=>It(mt(s,M,Math.min(f,(M-s)/2-1e-6),c),s,a),i,g))}return d}placePiece(t,n){var e;let{count:s,link:i}=this.c,r=this.anchorsOf(t);if(r.length===0)return;let l=t.every(x=>this.route[x]),d=r.every(x=>x.curve===r[0].curve)?r[0].curve:void 0,c,a,h,f;if(d)r.sort((x,T)=>x.t-T.t),c=d,a=r[0].t,h=r[r.length-1].t,f=c===this.backbone&&l?-1:1;else{r.sort((q,Q)=>q.point.x-Q.point.x||q.point.y-Q.point.y);let x=r[0].point,T=r[r.length-1].point,W=Math.hypot(T.x-x.x,T.y-x.y),B=W>1e-9?lt(x,T):{x:1,y:0},D={x:-B.y,y:B.x},H=gt(x,T,.5);f=r.some(q=>q.curve===this.backbone)?(l?-1:1)*(Math.sign(D.y)||1):(H.x-n.x)*D.x+(H.y-n.y)*D.y>=0?1:-1,c=new ot([x,T],[D,D],!0),a=0,h=W}let u=r[0],g=r[r.length-1],M=h-a,b=r.length===1||u.u===g.u&&u.uSide===g.uSide&&M<1e-9,U=[u.point,g.point],v=x=>this.choose(x,d,U),N,y,L=i,w;if(b){N=this.spinePath(t,u.u,u.uSide);let x=this.spineLength(N),T=u.vSide?Math.max(0,s[u.v]-2):Math.min(1,s[u.v]-1),B=(u.t>=this.params[u.v][T]?1:-1)*Math.cos(kt),D=Math.sin(kt);y=v(ct(0,12).map(H=>q=>yt(c,a,f,Q=>Ot(0,H,B,D,Q),x,q)))}else{N=(e=this.spinePath(t,u.u,u.uSide,g.u,g.uSide))!==null&&e!==void 0?e:this.loosePath(t,u.u,g.u);let x=this.spineLength(N);if(l){let T=Math.max(12,Math.min(Pt*M,St));y=v(ct(T,12).map(B=>D=>xt(c,a,f,mt(M,sn(M,B),0,0),D)));let W=Ut(y.pts);w=Math.max(.001,(W-2*i)/(s[N[0].k]-1))}else if(x>M+1e-6)y=v(this.arcCandidates(c,a,f,M,x));else{let T=x-2*i,W=Math.max(12,Math.min(Pt*(M-T),St));y=v(ct(W,12).map(B=>D=>yt(c,a,f,H=>Ot(M/2-H/2,B,1,0,H),T,D))),L=0}}let E=new ot(y.pts,an(y.pts,y.refs)),O=this.layAlong(N,E,L,w);this.occupy(O,E);let _=Dt(O),R=t.filter(x=>!this.points[x]),F=this.componentsOf(R).map(x=>({members:x,span:Tt(this.anchorsOf(x))})).sort((x,T)=>x.span-T.span);for(let x of F)this.placePiece(x.members,_)}};function Mt(o){let t=new Float64Array(o.n).fill(NaN),n=new Float64Array(o.n).fill(NaN);if(ht.hasBackbone(o)){let e=new ht(o);e.run(),e.write(t,n)}return{X:t,Y:n}}var ln=[{walks:2,iterations:15},{walks:4,iterations:30},{walks:8,iterations:60},{walks:12,iterations:90},{walks:16,iterations:120}],hn=20,fn=3,wt=.3,un=2,dn=200,pn=.1,mn=.5,yn=o=>{var t;return((t=o.stable)===null||t===void 0?void 0:t.rank)===0};function Ht(o,t){let n=t.at(-1);return(o==="+"||o==="-")&&(n==="+"||n==="-")&&o!==n}function gn(o){let t=Math.imul(o,2654435761)>>>0||1;return()=>(t^=t<<13,t>>>=0,t^=t>>>17,t^=t<<5,t>>>=0,t/4294967296)}function z(o,t){return typeof o=="number"&&Number.isFinite(o)?o:t}function Nt(o,t){return Math.max(z(o.nodeLengthPerMegabase,1e3)*t/1e6,z(o.minimumNodeLength,1))}function Ct(o){let{nodes:t,edges:n}=o.graph,e=o.options,s=z(e.nodeSegmentLength,1),i=z(e.edgeLength,1),r=t.map(w=>w.id),l=new Int32Array(t.length),d=new Int32Array(t.length),c=new Float64Array(t.length),a=0;t.forEach((w,E)=>{let O=Nt(e,w.length),_=Math.max(1,Math.ceil(O/s));l[E]=a,d[E]=_+1,c[E]=O/_,a+=_+1});let h=new Int32Array(a),f=new Int32Array(a),u=new Float64Array(a).fill(NaN),g=new Float64Array(a).fill(NaN),M=new Uint8Array(a),b=Array.from({length:a},()=>[]);t.forEach((w,E)=>{let O=typeof w.x=="number"&&typeof w.y=="number",_=yn(w)?1:0;for(let R=0;R<d[E];R++){let F=l[E]+R;h[F]=E,f[F]=R,M[F]=_,O&&(u[F]=w.x+R*c[E],g[F]=w.y),R>0&&(b[F-1].push([F,c[E]]),b[F].push([F-1,c[E]]))}});let U=new Map(r.map((w,E)=>[w,E])),v=t.map(()=>[[],[]]);for(let w of n){let E=U.get(w.from),O=U.get(w.to);if(E===void 0||O===void 0||E===O&&d[E]<=2)continue;let _=Ht(w.fromStrand,w.from)?0:1,R=Ht(w.toStrand,w.to)?1:0,F=l[E]+(_?d[E]-1:0),x=l[O]+(R?d[O]-1:0);b[F].push([x,i]),b[x].push([F,i]),v[E][_].push([O,R]),v[O][R].push([E,_])}let N=new Int32Array(a+1);for(let w=0;w<a;w++)N[w+1]=N[w]+b[w].length;let y=new Int32Array(N[a]),L=new Float64Array(N[a]);for(let w=0;w<a;w++)b[w].forEach(([E,O],_)=>{y[N[w]+_]=E,L[N[w]+_]=O});return{ids:r,first:l,count:d,per:c,links:v,chainOf:h,indexOf:f,seedX:u,seedY:g,backbone:M,off:N,nb:y,wt:L,n:a,link:i}}function xn(o){let{n:t,off:n,nb:e}=o,s=new Int32Array(t).fill(-1),i=[];for(let r=0;r<t;r++){if(s[r]>=0)continue;let l=[r];s[r]=i.length;for(let d of l)for(let c=n[d];c<n[d+1];c++){let a=e[c];s[a]<0&&(s[a]=i.length,l.push(a))}i.push(l)}return{comp:s,members:i}}function At(o,t={}){var n,e,s;let i=Ct(o),{n:r,off:l,nb:d,wt:c,seedX:a,seedY:h,first:f,count:u,per:g,link:M}=i,b=o.options,U=ln[Math.max(0,Math.min(4,z((n=t.quality)!==null&&n!==void 0?n:b.quality,2)))],v=z((e=t.componentSeparation)!==null&&e!==void 0?e:b.componentSeparation,15),N=gn(z((s=t.seed)!==null&&s!==void 0?s:b.seed,1)),y=new Float64Array(r),L=new Float64Array(r),w={};if(r===0)return{nodePositions:w};let{comp:E,members:O}=xn(i),_=1/0,R=0;for(let p=0;p<d.length;p++)_=Math.min(_,c[p]),R+=c[p];R/=2;let F=!1;for(let p=0;p<r;p++)if(!Number.isNaN(a[p])){F=!0;break}let x=F?Mt(i):void 0,T=Math.sqrt(r)*20;for(let p=0;p<r;p++)x&&!Number.isNaN(x.X[p])?(y[p]=x.X[p],L[p]=x.Y[p]):F&&!Number.isNaN(a[p])?(y[p]=a[p]+N()-.5,L[p]=h[p]+N()-.5):(y[p]=N()*T,L[p]=N()*T);let W=O.map(p=>x!==void 0&&p.every(A=>!Number.isNaN(x.X[A]))),B=[],D=!0;for(let p=0;p<r;p++)W[E[p]]||(B.push(p),D&&(D=!Number.isNaN(a[p])));let H=Math.max(R/4,_*10),q=H*H,Q=pn*_*_,{walks:Jt,iterations:rt}=U,Qt=Math.log(q/Q)/Math.max(1,rt-1),bt=Math.log(_),Zt=Math.log(H),Lt=(p,A,m,k)=>{let S=k/(m*m);S>1&&(S=1);let P=y[p]-y[A],I=L[p]-L[A],V=Math.sqrt(P*P+I*I)||1e-9,G=S*(V-m)/(2*V),j=G*P,C=G*I;y[p]=y[p]-j,L[p]=L[p]-C,y[A]=y[A]+j,L[A]=L[A]+C},et=0,Yt=(p,A)=>{let m=i.chainOf[p],k=i.indexOf[p],S=N()<.5?-1:1,P=A;for(let I=0;I<dn;I++){let V=u[m],G=g[m],j=(S>0?V-1-k:k)*G;if(P<=j){let J=Math.round(P/G);return et=A-P+J*G,f[m]+k+S*J}P-=j;let C=i.links[m][S>0?1:0];if(C.length===0)return et=A-P,f[m]+(S>0?V-1:0);let[Y,$]=C[Math.floor(N()*C.length)];if(P-=M,m=Y,S=$===0?1:-1,k=$===0?0:u[Y]-1,P<=0)return et=A-P,f[m]+k}return-1},Et=(p,A)=>{for(let m=l[p];m<l[p+1];m++){let k=d[m];k>p&&Lt(p,k,c[m],A)}},Z=Int32Array.from(B),Xt=D?Math.floor(mn*rt):0;for(let p=B.length?Xt:rt;p<rt;p++){let A=q*Math.exp(-Qt*p);for(let m=Z.length-1;m>0;m--){let k=Math.floor(N()*(m+1)),S=Z[m];Z[m]=Z[k],Z[k]=S}for(let m of Z){Et(m,A);for(let k=0;k<Jt;k++){let S=Math.exp(bt+N()*(Zt-bt)),P=Yt(m,S);P>=0&&P!==m&&et>0&&Lt(m,P,et,A)}}}let K=fn*M,tn=(p,A)=>Math.floor(p/K)*73856093^Math.floor(A/K)*19349663;for(let p=0;p<(B.length?hn:0);p++){let A=new Map;for(let m of B){let k=tn(y[m],L[m]),S=A.get(k);S?S.push(m):A.set(k,[m])}for(let m of B){let k=Math.floor(y[m]/K),S=Math.floor(L[m]/K);for(let P=k-1;P<=k+1;P++)for(let I=S-1;I<=S+1;I++){let V=A.get(P*73856093^I*19349663);if(V)for(let G of V){if(G<=m)continue;let j=!1;for(let X=l[m];X<l[m+1];X++)if(d[X]===G){j=!0;break}if(j)continue;let C=y[m]-y[G],Y=L[m]-L[G],$=Math.sqrt(C*C+Y*Y);if($>=K)continue;let J,it;if($>1e-6){let X=wt*(K-$)/(2*$);J=X*C,it=X*Y}else J=wt*K*(N()-.5),it=wt*K*(N()-.5);y[m]=y[m]+J,L[m]=L[m]+it,y[G]=y[G]-J,L[G]=L[G]-it}}}for(let m of B)Et(m,1/0)}for(let p=0;p<u.length;p++){let A=f[p],m=u[p];if(!(m<3)){for(let k=0;k<un;k++){let S=y.slice(A,A+m),P=L.slice(A,A+m);for(let I=1;I+1<m;I++)y[A+I]=.5*S[I]+.25*(S[I-1]+S[I+1]),L[A+I]=.5*P[I]+.25*(P[I-1]+P[I+1])}Mn(y,L,A,m,g[p])}}Nn(E,O,y,L,F,v);for(let p=0;p<i.ids.length;p++){let A=[];for(let m=0;m<u[p];m++)A.push({x:y[f[p]+m],y:L[f[p]+m]});w[i.ids[p]]=A}return{nodePositions:w}}function Mn(o,t,n,e,s){wn(o,t,n,e,s*(e-1));let i=new Float64Array(e);for(let a=1;a<e;a++)i[a]=i[a-1]+Math.hypot(o[n+a]-o[n+a-1],t[n+a]-t[n+a-1]);if(!i[e-1])return;let r=i[e-1],l=o.slice(n,n+e),d=t.slice(n,n+e),c=1;for(let a=1;a+1<e;a++){let h=r*a/(e-1);for(;c<e-1&&i[c]<h;)c++;let f=i[c]-i[c-1],u=f>0?(h-i[c-1])/f:0;o[n+a]=l[c-1]+(l[c]-l[c-1])*u,t[n+a]=d[c-1]+(d[c]-d[c-1])*u}}function wn(o,t,n,e,s){let i=n+e-1,r=o[n],l=t[n],d=Math.hypot(o[i]-r,t[i]-l),c=d>1e-9?(o[i]-r)/d:1,a=d>1e-9?(t[i]-l)/d:0,h=new Float64Array(e),f=new Float64Array(e),u=!0;for(let v=0;v<e;v++){let N=o[n+v]-r,y=t[n+v]-l;h[v]=N*c+y*a,f[v]=y*c-N*a,u&&(u=Math.abs(f[v])<1e-6)}let g=v=>{let N=0;for(let y=1;y<e;y++)N+=Math.hypot(h[y]-h[y-1],v*(f[y]-f[y-1]));return N};if(u||g(1)>=s)return;let M=1,b=2;for(;g(b)<s&&b<1e6;)M=b,b*=2;for(let v=0;v<40;v++){let N=(M+b)/2;g(N)<s?M=N:b=N}let U=(M+b)/2;for(let v=1;v+1<e;v++)o[n+v]=r+h[v]*c-U*f[v]*a,t[n+v]=l+h[v]*a+U*f[v]*c}function Nn(o,t,n,e,s,i){if(!s)for(let h of t)An(n,e,h);if(t.length<2)return;let r=new Float64Array(t.length).fill(1/0),l=new Float64Array(t.length).fill(1/0),d=new Float64Array(t.length).fill(-1/0);for(let h=0;h<n.length;h++){let f=o[h];r[f]=Math.min(r[f],n[h]),l[f]=Math.min(l[f],e[h]),d[f]=Math.max(d[f],e[h])}let c=new Float64Array(t.length),a=0;for(let h=0;h<t.length;h++)c[h]=a-l[h],a+=d[h]-l[h]+i;for(let h=0;h<n.length;h++){let f=o[h];n[h]=n[h]-r[f],e[h]=e[h]+c[f]}}function An(o,t,n){if(n.length<3)return;let e=0,s=0;for(let h of n)e+=o[h],s+=t[h];e/=n.length,s/=n.length;let i=0,r=0,l=0;for(let h of n){let f=o[h]-e,u=t[h]-s;i+=f*f,r+=u*u,l+=f*u}let d=-.5*Math.atan2(2*l,i-r),c=Math.cos(d),a=Math.sin(d);for(let h of n){let f=o[h]-e,u=t[h]-s;o[h]=e+c*f-a*u,t[h]=s+a*f+c*u}}var Wt=[{value:"fmmm",label:"Bandage (FMMM)",description:"Bandage's force-directed layout: OGDF's fast multipole multilevel method, compiled to wasm."},{value:"stress",label:"Stress",description:"Plain JS: the reference drawn straight and each variant placed against it, an allele as a lens, a repeat loop as a ring, a deletion as an arch; stress by stochastic gradient descent for components with no reference."}],vn=Wt.map(o=>o.value);var bn=async o=>{let t=performance.now();return{result:o.options.engine==="stress"?At(o):await dt(o),duration:performance.now()-t}};var st=40,Kt=500,ft=5;function Ln(o,t){return Math.max(o.nodeLengthPerMegabase*t/1e6,o.minimumNodeLength)}function Vt(o,t=ft){let e=o.nodes.reduce((i,r)=>i+r.length,0)/1e6,s=Math.max(o.nodes.length*st,Kt);return{nodeLengthPerMegabase:e>0?s/e:1e4,minimumNodeLength:Math.max(ft,t),edgeLength:5,nodeSegmentLength:20}}var nt={power:1,effect:1};function jt(o){return o.power===1&&o.effect===1}function zt(o,t){let n=o.nodes.length,e=o.nodes.reduce((r,l)=>r+l.length,0),s=n>0?e/n:0,i=n>0?Math.max(n*st,Kt)/n:st;return r=>{if(s<=0)return i;let l=(r/s)**t.power;return Math.max(i*((l-1)*t.effect+1),ft)}}var qt=1e3,$t={law:nt,minNodeLength:0};function Qn(o,t=$t){let{law:n,minNodeLength:e}=t,s=Vt(o,e);if(jt(n))return{nodes:o.nodes,opts:s};let i=zt(o,n);return{nodes:o.nodes.map(r=>({...r,length:Math.round(i(r.length)*qt)})),opts:{...s,nodeLengthPerMegabase:1e6/qt,minimumNodeLength:ft}}}function Zn(o,t=$t){if(jt(t.law)){let n=Vt(o,t.minNodeLength);return e=>Ln(n,e)}return zt(o,t.law)}var vt=[{value:"auto",label:"Proportional",description:"Bandage's own scale: a node draws proportional to its length, so a 1 bp allele is a speck.",law:nt,minNodeFactor:0},{value:"open",label:"Open bubbles",description:"Give every allele a drawn length, so a bubble reads as two arms rather than a knot.",law:nt,minNodeFactor:2.5},{value:"wide",label:"Wide bubbles",description:"As open, spread further. Best on a window of a dozen bubbles.",law:nt,minNodeFactor:10},{value:"compress",label:"Compress lengths",description:"Pull the longest and shortest nodes towards the graph\u2019s mean, so a cut spanning kb and bp fits one pane.",law:{power:.5,effect:.5},minNodeFactor:0}],En=vt.map(o=>o.value);function kn(o){let t=vt.find(n=>n.value===o);return{law:t?.law??nt,minNodeLength:(t?.minNodeFactor??0)*st}}export{Bt as a,Wt as b,vn as c,bn as d,Ln as e,Qn as f,Zn as g,vt as h,En as i,kn as j};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
2
|
+
//# sourceMappingURL=chunk-6NR64IXK.js.map
|