jbrowse-plugin-graphgenomeviewer 7.1.11 → 7.1.12
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-2MA3I6BM.js → GbzBaseSyntenyAdapter-RYGR6L75.js} +2 -2
- package/dist/chunks/{WalkTabixSyntenyAdapter-AIC3W7FL.js → WalkTabixSyntenyAdapter-PQ4LGBPO.js} +2 -2
- package/dist/chunks/{chunk-U4U5ZOCH.js → chunk-IJJZC7A4.js} +2 -2
- package/dist/chunks/{chunk-U4U5ZOCH.js.map → chunk-IJJZC7A4.js.map} +2 -2
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +2 -2
- package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/synteny/clipFeatureToRegion.test.ts +23 -0
- package/src/synteny/clipFeatureToRegion.ts +4 -1
- package/src/version.ts +1 -1
- /package/dist/chunks/{GbzBaseSyntenyAdapter-2MA3I6BM.js.map → GbzBaseSyntenyAdapter-RYGR6L75.js.map} +0 -0
- /package/dist/chunks/{WalkTabixSyntenyAdapter-AIC3W7FL.js.map → WalkTabixSyntenyAdapter-PQ4LGBPO.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ae,b as re,c as de,d as oe,e as ie,f as H,g as se}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=GbzBaseSyntenyAdapter-
|
|
1
|
+
import{a as ae,b as re,c as de,d as oe,e as ie,f as H,g as se}from"./chunk-IJJZC7A4.js";import{a as te}from"./chunk-KOB7YIMR.js";import{a as j,b as W,c as Z,d as u,e as M,f as $,g as U,h as k,i as z,k as X}from"./chunk-OBQFV4NL.js";import"./chunk-O7Y7LYN6.js";import{b as E,c as O}from"./chunk-N4WBX2OS.js";import"./chunk-BWP3XYKD.js";import"./chunk-T4HOC6O3.js";import{a as ne}from"./chunk-PFAHNHMM.js";import"./chunk-VDHDEEMF.js";import{a as V,c as L,m as ee}from"./chunk-EDSIYH4H.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{g as F,h as P,i as C}from"./chunk-GUXZESDR.js";import"./chunk-T4R3ZVEM.js";import{d as G,g as Y,h as J,i as K}from"./chunk-IKJZPPOA.js";import"./chunk-7WIBGKBU.js";import{a as N}from"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{e as D,o as I}from"./chunk-TENPGIPX.js";function A(n){let i=/\.gbz\.db$/i;return i.test(n)?n.replace(i,".haplotype-index.db"):void 0}function he(n){return J(n)&&A(Y(n))?K(n,i=>A(i)):void 0}function ue(n){return n instanceof Error&&(/\bHTTP 40[34]\b/.test(n.message)||n.code==="ENOENT")}async function ce(n,i){let t=he(n);if(!t)return{};try{return await N(t,i).stat(),{location:t}}catch(e){return ue(e)?{}:{unreadable:String(e)}}}var ge=5e3,ye=50*2**20,q=class extends Error{constructor(t){super(`this GAF is ${(t/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function be(n,i){if(n.length<=i)return n;let t=n.length/i;return Array.from({length:i},(e,a)=>n[Math.floor(a*t)])}var pe=(n,i)=>n.path.some(t=>i.has(t.name)),v=class{constructor(i,t){this.file=i;this.tabix=t;this.whole=L({setup:async({signal:i})=>{let{size:t}=await this.file.stat();if(t>ye)throw new q(t);let e=await this.file.readFile({signal:i}),a=new TextDecoder().decode(e[0]===31&&e[1]===139?await V(e):e);return O(a)}})}async readIndexed(i,t,e){let a=1/0,r=-1/0;for(let s of t){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:e,lineCallback:s=>{let c=E(s);c&&pe(c,t)&&o.push(c)}}),o}async readsOver(i,{signal:t}={}){let e=this.tabix?await this.readIndexed(this.tabix,i,t):(await this.whole({signal:t})).filter(a=>pe(a,i));return{records:be(e,ge),total:e.length}}};var B=class extends Error{constructor(t){super(t===void 0?"no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation":`the haplotype index beside the graph database could not be checked (${t}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},_=class extends Error{constructor(t,e){super(`the graph is cut on its reference, ${e}; a window on ${t} has no reference coordinates to cut at. Open the graph from a ${e} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function we(n,i){return`${u(n)}#${n.contig}@${i.start.node}.${i.start.offset}`}function xe({alignment:n,assemblyName:i,refName:t,lane:e}){let{refStart:a,refEnd:r,strand:o,cigar:s}=n;if(!(r<=a)){let{name:c,hapStart:p,hapEnd:l}=n,d=we(c,n),g={uniqueId:d,assemblyName:i,refName:t,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:s,syntenyId:d,mate:{refName:c.contig,start:p,end:l,assemblyName:e}};return new ae(g)}}function Se({pair:n,lane:i,mateLane:t}){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:t,refName:n.query.contig,start:n.queryStart,end:n.queryEnd},strand:n.strand,cigar:n.cigar,matches:n.matches,columns:n.columns})}var Pe=12e4;function Ne(n,i){let t=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=t.get(p);l?l.push([o,s]):t.set(p,[[o,s]])}}let e=0;for(let a of t.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Pe&&(e=Math.max(e,o))}}return e}function T(n,i){return n instanceof Z&&(n.message=`Zoom in to about ${D(n.fitsBp)} to see ${i}`),n}var le=n=>({...n,start:Math.floor(n.start),end:Math.ceil(n.end)}),Q=class extends re{constructor(){super(...arguments);this.graph=L({label:"Opening pangenome database",setup:async()=>{let t=this.getConf("gbzDbLocation"),e=this.getConf("haplotypeIndexLocation"),a=G(e)?{location:e}:await ce(t,this.pluginManager),r=a.location,o=await W.open({source:N(t,this.pluginManager),haplotypeIndex:r?N(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 $(o),p=U({configured:this.getConf("referenceSample"),anchorPrefix:P(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 t=this.getConf("readsLocation"),e=this.getConf(["readsIndex","location"]);return G(t)?new v(N(t,this.pluginManager),G(e)?ee(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(t,e){let{db:a,referenceSample:r}=await this.graph(e);return k(a,r,t)}async getHaplotypes(t={}){let{db:e,referenceSamples:a}=await this.graph(t),r=new Map;for(let o of await e.paths()){let 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(t={}){let{anchor:e,referenceSample:a}=await this.graph(t),r=C(this),o=[];for(let s of await this.getHaplotypes(t))s.sample!==a&&o.push({name:H(r,s.prefix),label:s.prefix,group:s.sample});return{hasCoarseTier:!1,anchorAssemblyName:e,lanes:o}}async getRefNames(t={}){let{db:e,anchor:a,referenceSample:r}=await this.graph(t),{assemblyName:o}=t,s=o===a?void 0:P(this,o),c=(await e.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(t,e){let a=t===void 0||t.length===0?void 0:t.map(r=>P(this,r));return a===void 0&&e===void 0?void 0:r=>M(r,a)&&(e===void 0||F(u(r),e))}async getSubgraph(t,e={}){let{signal:a}=e,{db:r,anchor:o,referenceSample:s,unreadableIndex:c}=await this.graph({signal:a}),{assemblyName:p,refName:l,start:d,end:g}=le(t);if(p!==o)throw new _(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 w=this.keepPredicate(e.haplotypes);if(w!==void 0&&!r.hasHaplotypeIndex)throw new B(c);let f=await X(r,y,d,g,{context:this.getConf("context"),snarls:e.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:e.signal,keep:w}).catch(x=>{throw T(x,"the graph")});return typeof f=="string"?f:ne(f,{start:d,end:g},e.walkRows)}async getReads(t,e={}){let a=await this.gaf(e);return a?a.readsOver(new Set(t),e):{records:[],total:0}}async laneHaplotypes(t,e){let a=P(this,t);return(await this.getHaplotypes(e)).filter(r=>F(r.prefix,a))}async anchorFeatures(t,e){let{db:a}=await this.graph(e),{assemblyName:r,refName:o,start:s,end:c}=t,p=P(this,e.targetAssemblyName),l=C(this),d=this.keepPredicate(e.haplotypes,p),g=await this.referenceQuery(o,e),y=this.getConf("nodeLimit");return(g?await I(`Reading graph ${o}:${s.toLocaleString()}-${c.toLocaleString()}`,e.statusCallback,()=>a.getAlignments({path:g,start:s,end:c,context:this.getConf("context"),haplotypes:"all",limit:y,signal:e.signal,keep:d}).catch(f=>{throw T(z(f,y,c-s)??f,"lanes")})):[]).flatMap(f=>{let x=f.resolved?xe({alignment:f,assemblyName:r,refName:o,lane:H(l,u(f.name))}):void 0;return x===void 0?[]:[x]})}async pairFeatures(t,e,a){let{db:r}=await this.graph(a),{refName:o,start:s,end:c}=t,l=(await Promise.all(e.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),d=new Set(l.flatMap(({featureSide:m,mateSide:h})=>[...m,...h].map(u))),g=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),w=this.getConf("context"),f=(m,h)=>r.getSubgraphs({path:m,start:s,end:c,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:S=>d.has(u(S))}),x=async m=>{let h=await f(m,w).catch(b=>{throw T(z(b,y,c-s)??b,"lanes")}),S=Ne(h,d),R=Math.ceil(S/2)+2e3;return S>0&&R>w?f(m,R).catch(b=>{if(b instanceof j)return h;throw b}):h};return(g&&l.length>0?await I(ie(e),a.statusCallback,()=>x(g)):[]).flatMap(m=>l.flatMap(({pair:h,featureSide:S,mateSide:R})=>S.flatMap(b=>R.flatMap(me=>m.pairAlignments({target:b,query:me,bases:!1}).map(fe=>Se({pair:fe,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(t,e={}){let a=le(t);return te(async r=>{let{db:o,anchor:s,unreadableIndex:c}=await this.graph(e);if(!o.hasHaplotypeIndex)throw new B(c);if(a.assemblyName===s){let p=oe(e),l=p.length>0?await this.pairFeatures(a,p,e):await this.anchorFeatures(a,e);for(let d of l)r.next(d)}r.complete()},e.signal)}};export{B as NoHaplotypeIndexError,de as PairTargetError,Q as default,Ne as widestWalkGap};
|
|
2
|
+
//# sourceMappingURL=GbzBaseSyntenyAdapter-RYGR6L75.js.map
|
package/dist/chunks/{WalkTabixSyntenyAdapter-AIC3W7FL.js → WalkTabixSyntenyAdapter-PQ4LGBPO.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as G}from"./chunk-ZNT7TQLN.js";import{a as z}from"./chunk-PJ43KEV6.js";import{b as j,d as H,e as D,f as E,g as X}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=WalkTabixSyntenyAdapter-
|
|
1
|
+
import{a as G}from"./chunk-ZNT7TQLN.js";import{a as z}from"./chunk-PJ43KEV6.js";import{b as j,d as H,e as D,f as E,g as X}from"./chunk-IJJZC7A4.js";import{a as $}from"./chunk-KOB7YIMR.js";import{p as W,q as R,r as I}from"./chunk-T4HOC6O3.js";import"./chunk-PFAHNHMM.js";import"./chunk-VDHDEEMF.js";import{e as q,m as T,o as _}from"./chunk-EDSIYH4H.js";import"./chunk-YBLNN5FU.js";import"./chunk-MVVXRZXV.js";import{a as F,c as v,d as S,g as P,h as k,i as x}from"./chunk-GUXZESDR.js";import"./chunk-T4R3ZVEM.js";import"./chunk-7WIBGKBU.js";import"./chunk-OGQ6OQDN.js";import"./chunk-NDRLCGPC.js";import{o as C}from"./chunk-TENPGIPX.js";var ee=50;function te(i){let o=[];for(let e=0;e<i.length;e++){let[t,s]=i[e],[n,a]=i[e+1]??[];s===a&&s<=ee&&(t==="I"&&n==="D"||t==="D"&&n==="I")?(o.push(["X",s]),e++):o.push([t,s])}return o}function M(i){return Array.from(i.ids,(o,e)=>2*o+i.rev[e])}function K(i,o){let e=i.get(o);return e===void 0?0:e.end-e.start}function U(i){let o=new Map,e=n=>{let a=K(i,n),r=o.get(a);return r===void 0&&(r="N".repeat(a),o.set(a,r)),r},t=new Map,s=n=>{let a=t.get(n);return a===void 0&&(a=M(n),t.set(n,a)),a};return(n,a)=>R({query:s(n),target:s(a),sequenceOf:e,bases:!1})}var ae=100;function O(i,o,e){let t=i.at(-1);e>0&&(t?.[0]===o?t[1]+=e:i.push([o,e]))}function J(i){let o=t=>K(i,t>>1),e=t=>{let s=new Float64Array(t.length+1);return t.forEach((n,a)=>{s[a+1]=s[a]+o(n)}),s};return(t,s)=>{let n=M(s),a=M(t),[r,f]=W(a,n,o),[g,y]=W(a.map(u=>u^1).reverse(),n,o),l=y>f,p=l?g:r,N=Math.max(f,y);if(N<ae)return[];let h=e(n),c=e(a),b=u=>l?a.length-1-p[u][0]:p[u][0],m=[];p.forEach(([,u],w)=>{if(w>0){let[Q,V]=[b(w-1),b(w)].sort((Y,Z)=>Y-Z);O(m,"I",c[V]-c[Q+1]),O(m,"D",h[u]-h[p[w-1][1]+1])}O(m,"=",o(n[u]))});let[d,A]=[b(0),b(p.length-1)].sort((u,w)=>u-w);return[{queryStart:c[d],queryEnd:c[A+1],targetStart:h[p[0][1]],targetEnd:h[p.at(-1)[1]+1],strand:l?"-":"+",edits:m,sharedBases:N}]}}function B({chain:i,target:o,query:e,assemblyName:t,refName:s,mateAssemblyName:n}){let a=te(i.edits);return X({target:{name:o.name,assemblyName:t,refName:s,start:o.hapStart+i.targetStart,end:o.hapStart+i.targetEnd},query:{name:e.name,assemblyName:n,refName:S(e.name),start:e.hapStart+i.queryStart,end:e.hapStart+i.queryEnd},strand:i.strand,cigar:I(a),matches:a.reduce((r,[f,g])=>r+(f==="="?g:0),0),columns:a.reduce((r,[,f])=>r+f,0)})}var ne=i=>v(i.name)??i.name,L=class extends j{constructor(){super(...arguments);this.walks=new G(T(this,["walksLocation"],["walksIndex"]),this);this.refNames=new _(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:s}=this,n=k(this,s),a=x(this);return{hasCoarseTier:!1,anchorAssemblyName:s,lanes:t.filter(r=>r!==n&&F(r)!==n).map(r=>({name:E(a,r),label:r,group:F(r)}))}}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 s=await this.refNames.resolve(e,{signal:t.signal});if(s===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; the graph is cut on ${this.anchor}, mapped to its PanSN prefix in assemblyNameToPanSN`);return this.walks.subgraph(s,e,t)}async laneWalks(e,t,s,n,a){return C(a,n.statusCallback,()=>this.walks.reader.cut(e,t,{...this.walks.budgets(),signal:n.signal,keep:q(s,e),links:!1}).catch(r=>{throw z(r)&&r instanceof Error&&(r.message=r.message.replace("to see the graph","to see lanes")),r}))}async anchorFeatures(e,t,s){let n=s.haplotypes?.length?s.haplotypes.map(m=>k(this,m)):void 0,a=k(this,s.targetAssemblyName),r=a===void 0?n:n===void 0||n.some(m=>P(a,m)||P(m,a))?[a]:[];if(r?.length===0)return[];let{start:f,end:g}=t,{graph:y,fragments:l}=await this.laneWalks(e,t,r,s,`Reading walks ${t.refName}:${f.toLocaleString()}-${g.toLocaleString()}`),p=J(y.nodes),N=x(this),h=l.filter(m=>m.name===e),c=m=>r===void 0?0:r.findIndex(d=>P(m.name,d));return l.filter(m=>m.name!==e&&c(m)>=0).sort((m,d)=>c(m)-c(d)).flatMap(m=>h.flatMap(d=>p(m,d).map(A=>B({chain:A,target:d,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:E(N,ne(m))}))))}async pairFeatures(e,t,s,n){let a=s.map(l=>({pair:l,featurePrefix:k(this,l.queryAssemblyName),matePrefix:k(this,l.targetAssemblyName)})),{graph:r,fragments:f}=await this.laneWalks(e,t,a.flatMap(l=>[l.featurePrefix,l.matePrefix]),n,D(s)),g=U(r.nodes),y=l=>f.filter(p=>P(p.name,l));return a.flatMap(({pair:l,featurePrefix:p,matePrefix:N})=>y(p).flatMap(h=>y(N).flatMap(c=>g(c,h).map(b=>B({chain:b,target:h,query:c,assemblyName:l.queryAssemblyName,refName:S(h.name),mateAssemblyName:l.targetAssemblyName})))))}getFeatures(e,t={}){return $(async s=>{let n=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(n!==void 0){let a=H(t),r=a.length>0?await this.pairFeatures(n,e,a,t):await this.anchorFeatures(n,e,t);for(let f of r)s.next(f)}s.complete()},t.signal)}};export{L as default};
|
|
2
|
+
//# sourceMappingURL=WalkTabixSyntenyAdapter-PQ4LGBPO.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{b as ze}from"./chunk-EDSIYH4H.js";import{a as He}from"./chunk-GUXZESDR.js";import{a as $e,c as Ye}from"./chunk-TENPGIPX.js";function Ve(e){let r=[],t=0,o;for(let n=0,i=e.length;n<i;n++){let a=e.charCodeAt(n);if(a>=48&&a<=57)t=t*10+a-48;else if(a===58)o=t,t=0;else{let f=e[n];f==="M"||f==="="||f==="X"?r.push({own:o===void 0?t:o,mate:t,op:"M"}):f==="I"?r.push({own:0,mate:t,op:f}):(f==="D"||f==="N")&&r.push({own:t,mate:0,op:f}),o=void 0,t=0}}return r}function Ae(e){let r="";for(let{own:t,mate:o,op:n}of Ve(e))r+=n==="M"?t===0?`${o}I`:o===0?`${t}D`:`${t}M`:`${n==="I"?o:t}${n}`;return r}var Se=2**28-1;function ve(e,r,t){for(let o=r;o>0;o-=Se)e.push((Math.min(o,Se)<<4|t)>>>0)}function Nr(e,r,t){if(r===t)ve(e,r,0);else{let o=Math.ceil(Math.max(r,t)/Se);for(let n=0;n<o;n++){let i=Math.floor(r*(n+1)/o)-Math.floor(r*n/o),a=Math.floor(t*(n+1)/o)-Math.floor(t*n/o);e.push((i<<4|9)>>>0,(a<<4|9)>>>0)}}}function _e(e){let r=[];for(let{own:t,mate:o,op:n}of Ve(e))n==="M"?Nr(r,t,o):n==="I"?ve(r,o,1):ve(r,t,n==="N"?3:2);return Uint32Array.from(r)}function kr(e){return e>=48&&e<=57}function Gr(e){return e!==void 0&&/[A-Za-z]/.test(e)}function qe(e,r){let t=r;for(;t<e.length&&Gr(e[t]);)t++;return t}function Qe(e,r){let t=r,o=0;for(;t<e.length&&kr(e.charCodeAt(t));)o=o*10+(e.charCodeAt(t)-48),t++;return{value:o,next:t}}function er(e,r){let t=0;for(;t<e.length;){let o=e[t];if(o===":"){let{value:n,next:i}=Qe(e,t+1);r(":",n,n,t+1,i),t=i}else if(o==="="){let n=qe(e,t+1),i=n-t-1;r("=",i,i,t+1,n),t=n}else if(o==="*")r("*",1,1,t+1,Math.min(t+3,e.length)),t+=3;else if(o==="+"||o==="-"){let n=qe(e,t+1),i=n-t-1;r(o,o==="-"?i:0,o==="+"?i:0,t+1,n),t=n}else if(o==="~"){let{value:n,next:i}=Qe(e,t+3),a=Math.min(i+2,e.length);r("~",n,0,t+1,a),t=a}else t++}}function Ce(e,r,t,o){let n=t??Number.NEGATIVE_INFINITY,i=o??Number.POSITIVE_INFINITY,a=0;er(e,(f,p,s,c,u)=>{if(f==="*")a>=n&&a<i&&r(88,a,1,e[c+1]??"",-1,0,0);else if(f==="+"){if(a>=n&&a<=i){let m=e.slice(c,u);r(73,a,s,m,-1,0,s)}}else(f==="-"||f==="~")&&a<i&&a+p>n&&r(f==="-"?68:78,a,p,"",-1,0,0);a+=p})}function rr(e,r,t,o){let n=0,i=0,a=[],f=t&&r;for(let p=0,s=e.length;p<s;p++){let c=e[p],u=c>>>4,m=c&15;if(m===0||m===7){if(f)for(let l=0;l<u;l++)(r.charCodeAt(i+l)|32)!==(t.charCodeAt(n+l)|32)&&a.push({start:n+l,type:"mismatch",base:r[i+l],altbase:t[n+l],length:1});i+=u,n+=u}else if(m===1)a.push({start:n,type:"insertion",insertlen:u,insertedBases:r?.slice(i,i+u),length:0}),i+=u;else if(m===2)a.push({start:n,type:"deletion",length:u}),n+=u;else if(m===3)a.push({start:n,type:"skip",length:u}),n+=u;else if(m===8){for(let l=0;l<u;l++)a.push({start:n+l,type:"mismatch",base:r?.[i+l]||"X",qual:o?.[i+l],length:1});i+=u,n+=u}else m===5?a.push({start:n,type:"hardclip",cliplen:u,length:1}):m===4&&(a.push({start:n,type:"softclip",cliplen:u,length:1}),i+=u)}return a}function tr(e,r,t,o,n){if(!r)return[];let i=[],a=r.length,f=o.length,p=n!==void 0,s=t.length,c=!1;for(let b=0;b<s;b++)if(t[b].type==="skip"){c=!0;break}let u=0,m=0,l=0,y=0,d=0,x=0,g=e.length;for(;x<g;){let b=e.charCodeAt(x);if(b>=48&&b<=57){let v=0;for(;x<g;){let S=e.charCodeAt(x);if(S>=48&&S<=57)v=v*10+(S-48),x++;else break}u+=v}else if(b===94)for(x++;x<g&&e.charCodeAt(x)>=65;)x++,u++;else if(b>=65){let v=e[x];if(x++,c&&s>0)for(let I=d;I<s;I++){let R=t[I];R.type==="skip"&&u>=R.start&&(u+=R.length,d=I+1)}let S=l,C=y;for(let I=m;I<a&&C<=u;I++,m=I){let R=r[I],L=R>>>4,A=R&15;A===4||A===1?S+=L:A===2||A===6||A===3?C+=L:A!==5&&(S+=L,C+=L)}l=S,y=C;let F=S-(C-u),q=F<f?o[F]:"X";i.push({start:u,base:q,qual:p?n[F]:void 0,altbase:v,length:1,type:"mismatch"}),u++}else x++}return i}var or={77:0,73:1,68:2,78:3,83:4,72:5,80:6,61:7,88:8};function nr(e=""){let r=0,t=[];for(let o=0,n=e.length;o<n;o++){let i=e.charCodeAt(o);if(i>=48&&i<=57)r=r*10+(i-48);else{let a=or[i];t.push(r<<4|a),r=0}}return t}function Te(e=""){let r=0;for(let i=0,a=e.length;i<a;i++){let f=e.charCodeAt(i);(f<48||f>57)&&r++}let t=new Uint32Array(r),o=0,n=0;for(let i=0,a=e.length;i<a;i++){let f=e.charCodeAt(i);f>=48&&f<=57?o=o*10+(f-48):(t[n++]=o<<4|or[f],o=0)}return t}function Z(e,r,t,o,n){let i=nr(e),a=e?rr(i,t,o,n):[];return r&&t?a.concat(tr(r,i,a,t,n)):a}var P=class extends $e{get(r){return r==="mismatches"?Z(this.walkableCigar):r==="clipLengthAtStartOfRead"?this.clipLengthAtStartOfRead:r==="name"?super.get("name")??this.mate?.refName:super.get(r)}get mate(){return super.get("mate")}get walkableCigar(){let r=super.get("CIGAR"),t=super.get("coarseCigar");return typeof r=="string"?r:typeof t=="string"?Ae(t):void 0}get clipLengthAtStartOfRead(){return this.mate?.start??0}forEachMismatch(r,t){let o=this.get("start"),n=t?.start===void 0?void 0:t.start-o,i=t?.end===void 0?void 0:t.end-o,a=this.get("cs");if(a)Ce(a,r,n,i);else{let f=n??Number.NEGATIVE_INFINITY,p=i??Number.POSITIVE_INFINITY;for(let s of Z(this.walkableCigar))(s.type==="deletion"||s.type==="skip"?s.start<p&&s.start+s.length>f:s.start>=f&&s.start<=p)&&(s.type==="mismatch"?r(88,s.start,s.length,s.base,s.qual??-1,0,0):s.type==="insertion"?r(73,s.start,s.length,s.insertedBases??"",-1,0,s.insertlen):s.type==="deletion"?r(68,s.start,s.length,"",-1,0,0):s.type==="skip"&&r(78,s.start,s.length,"",-1,0,0))}}};var we=function(e,r){return we=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])},we(e,r)};function H(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");we(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}function ir(e,r,t,o){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function f(c){try{s(o.next(c))}catch(u){a(u)}}function p(c){try{s(o.throw(c))}catch(u){a(u)}}function s(c){c.done?i(c.value):n(c.value).then(f,p)}s((o=o.apply(e,r||[])).next())})}function ee(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=f(0),a.throw=f(1),a.return=f(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function f(s){return function(c){return p([s,c])}}function p(s){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(t=0)),t;)try{if(o=1,n&&(i=s[0]&2?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[s[0]&2,i.value]),s[0]){case 0:case 1:i=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,n=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1],i=s;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(s);break}i[2]&&t.ops.pop(),t.trys.pop();continue}s=r.call(e,t)}catch(c){s=[6,c],n=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function N(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],o=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function D(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var o=t.call(e),n,i=[],a;try{for(;(r===void 0||r-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(f){a={error:f}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(a)throw a.error}}return i}function j(e,r,t){if(t||arguments.length===2)for(var o=0,n=r.length,i;o<n;o++)(i||!(o in r))&&(i||(i=Array.prototype.slice.call(r,0,o)),i[o]=r[o]);return e.concat(i||Array.prototype.slice.call(r))}function k(e){return this instanceof k?(this.v=e,this):new k(e)}function ar(e,r,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=t.apply(e,r||[]),n,i=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),f("next"),f("throw"),f("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(l){return function(y){return Promise.resolve(y).then(l,u)}}function f(l,y){o[l]&&(n[l]=function(d){return new Promise(function(x,g){i.push([l,d,x,g])>1||p(l,d)})},y&&(n[l]=y(n[l])))}function p(l,y){try{s(o[l](y))}catch(d){m(i[0][3],d)}}function s(l){l.value instanceof k?Promise.resolve(l.value.v).then(c,u):m(i[0][2],l)}function c(l){p("next",l)}function u(l){p("throw",l)}function m(l,y){l(y),i.shift(),i.length&&p(i[0][0],i[0][1])}}function sr(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e[Symbol.asyncIterator],t;return r?r.call(e):(e=typeof N=="function"?N(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(i){t[i]=e[i]&&function(a){return new Promise(function(f,p){a=e[i](a),n(f,p,a.done,a.value)})}}function n(i,a,f,p){Promise.resolve(p).then(function(s){i({value:s,done:f})},a)}}function h(e){return typeof e=="function"}function fr(e){var r=function(o){Error.call(o),o.stack=new Error().stack},t=e(r);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var re=fr(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
2
2
|
`+t.map(function(o,n){return n+1+") "+o.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=t}});function Oe(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var te=(function(){function e(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var r,t,o,n,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var f=N(a),p=f.next();!p.done;p=f.next()){var s=p.value;s.remove(this)}}catch(d){r={error:d}}finally{try{p&&!p.done&&(t=f.return)&&t.call(f)}finally{if(r)throw r.error}}else a.remove(this);var c=this.initialTeardown;if(h(c))try{c()}catch(d){i=d instanceof re?d.errors:[d]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var m=N(u),l=m.next();!l.done;l=m.next()){var y=l.value;try{pr(y)}catch(d){i=i??[],d instanceof re?i=j(j([],D(i)),D(d.errors)):i.push(d)}}}catch(d){o={error:d}}finally{try{l&&!l.done&&(n=m.return)&&n.call(m)}finally{if(o)throw o.error}}}if(i)throw new re(i)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)pr(r);else{if(r instanceof e){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(r)}},e.prototype._hasParent=function(r){var t=this._parentage;return t===r||Array.isArray(t)&&t.includes(r)},e.prototype._addParent=function(r){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(r),t):t?[t,r]:r},e.prototype._removeParent=function(r){var t=this._parentage;t===r?this._parentage=null:Array.isArray(t)&&Oe(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&Oe(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=(function(){var r=new e;return r.closed=!0,r})(),e})();var Kt=te.EMPTY;function oe(e){return e instanceof te||e&&"closed"in e&&h(e.remove)&&h(e.add)&&h(e.unsubscribe)}function pr(e){h(e)?e():e.unsubscribe()}var w={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var U={setTimeout:function(e,r){for(var t=[],o=2;o<arguments.length;o++)t[o-2]=arguments[o];var n=U.delegate;return n?.setTimeout?n.setTimeout.apply(n,j([e,r],D(t))):setTimeout.apply(void 0,j([e,r],D(t)))},clearTimeout:function(e){var r=U.delegate;return(r?.clearTimeout||clearTimeout)(e)},delegate:void 0};function ne(e){U.setTimeout(function(){var r=w.onUnhandledError;if(r)r(e);else throw e})}function Re(){}var cr=(function(){return Me("C",void 0,void 0)})();function ur(e){return Me("E",void 0,e)}function lr(e){return Me("N",e,void 0)}function Me(e,r,t){return{kind:e,value:r,error:t}}var G=null;function mr(e){if(w.useDeprecatedSynchronousErrorHandling){var r=!G;if(r&&(G={errorThrown:!1,error:null}),e(),r){var t=G,o=t.errorThrown,n=t.error;if(G=null,o)throw n}}else e()}function dr(e){w.useDeprecatedSynchronousErrorHandling&&G&&(G.errorThrown=!0,G.error=e)}var z=(function(e){H(r,e);function r(t){var o=e.call(this)||this;return o.isStopped=!1,t?(o.destination=t,oe(t)&&t.add(o)):o.destination=$r,o}return r.create=function(t,o,n){return new ae(t,o,n)},r.prototype.next=function(t){this.isStopped?Le(lr(t),this):this._next(t)},r.prototype.error=function(t){this.isStopped?Le(ur(t),this):(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped?Le(cr,this):(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r})(te);var Ur=Function.prototype.bind;function Fe(e,r){return Ur.call(e,r)}var Br=(function(){function e(r){this.partialObserver=r}return e.prototype.next=function(r){var t=this.partialObserver;if(t.next)try{t.next(r)}catch(o){ie(o)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(o){ie(o)}else ie(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){ie(t)}},e})(),ae=(function(e){H(r,e);function r(t,o,n){var i=e.call(this)||this,a;if(h(t)||!t)a={next:t??void 0,error:o??void 0,complete:n??void 0};else{var f;i&&w.useDeprecatedNextContext?(f=Object.create(t),f.unsubscribe=function(){return i.unsubscribe()},a={next:t.next&&Fe(t.next,f),error:t.error&&Fe(t.error,f),complete:t.complete&&Fe(t.complete,f)}):a=t}return i.destination=new Br(a),i}return r})(z);function ie(e){w.useDeprecatedSynchronousErrorHandling?dr(e):ne(e)}function Wr(e){throw e}function Le(e,r){var t=w.onStoppedNotification;t&&U.setTimeout(function(){return t(e,r)})}var $r={closed:!0,next:Re,error:Wr,complete:Re};var B=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function xr(e){return e}function hr(e){return e.length===0?xr:e.length===1?e[0]:function(t){return e.reduce(function(o,n){return n(o)},t)}}var _=(function(){function e(r){r&&(this._subscribe=r)}return e.prototype.lift=function(r){var t=new e;return t.source=this,t.operator=r,t},e.prototype.subscribe=function(r,t,o){var n=this,i=Hr(r)?r:new ae(r,t,o);return mr(function(){var a=n,f=a.operator,p=a.source;i.add(f?f.call(i,p):p?n._subscribe(i):n._trySubscribe(i))}),i},e.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){r.error(t)}},e.prototype.forEach=function(r,t){var o=this;return t=yr(t),new t(function(n,i){var a=new ae({next:function(f){try{r(f)}catch(p){i(p),a.unsubscribe()}},error:i,complete:n});o.subscribe(a)})},e.prototype._subscribe=function(r){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(r)},e.prototype[B]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return hr(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=yr(r),new r(function(o,n){var i;t.subscribe(function(a){return i=a},function(a){return n(a)},function(){return o(i)})})},e.create=function(r){return new e(r)},e})();function yr(e){var r;return(r=e??w.Promise)!==null&&r!==void 0?r:Promise}function Yr(e){return e&&h(e.next)&&h(e.error)&&h(e.complete)}function Hr(e){return e&&e instanceof z||Yr(e)&&oe(e)}function zr(e){return h(e?.lift)}function E(e){return function(r){if(zr(r))return r.lift(function(t){try{return e(t,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function M(e,r,t,o,n){return new Vr(e,r,t,o,n)}var Vr=(function(e){H(r,e);function r(t,o,n,i,a,f){var p=e.call(this,t)||this;return p.onFinalize=a,p.shouldUnsubscribe=f,p._next=o?function(s){try{o(s)}catch(c){t.error(c)}}:e.prototype._next,p._error=i?function(s){try{i(s)}catch(c){t.error(c)}finally{this.unsubscribe()}}:e.prototype._error,p._complete=n?function(){try{n()}catch(s){t.error(s)}finally{this.unsubscribe()}}:e.prototype._complete,p}return r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;e.prototype.unsubscribe.call(this),!o&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},r})(z);var se=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function fe(e){return h(e?.then)}function pe(e){return h(e[B])}function ce(e){return Symbol.asyncIterator&&h(e?.[Symbol.asyncIterator])}function ue(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function qr(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var le=qr();function me(e){return h(e?.[le])}function de(e){return ar(this,arguments,function(){var t,o,n,i;return ee(this,function(a){switch(a.label){case 0:t=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,k(t.read())];case 3:return o=a.sent(),n=o.value,i=o.done,i?[4,k(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,k(n)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function xe(e){return h(e?.getReader)}function O(e){if(e instanceof _)return e;if(e!=null){if(pe(e))return Qr(e);if(se(e))return Kr(e);if(fe(e))return Xr(e);if(ce(e))return gr(e);if(me(e))return Jr(e);if(xe(e))return Zr(e)}throw ue(e)}function Qr(e){return new _(function(r){var t=e[B]();if(h(t.subscribe))return t.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Kr(e){return new _(function(r){for(var t=0;t<e.length&&!r.closed;t++)r.next(e[t]);r.complete()})}function Xr(e){return new _(function(r){e.then(function(t){r.closed||(r.next(t),r.complete())},function(t){return r.error(t)}).then(null,ne)})}function Jr(e){return new _(function(r){var t,o;try{for(var n=N(e),i=n.next();!i.done;i=n.next()){var a=i.value;if(r.next(a),r.closed)return}}catch(f){t={error:f}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(t)throw t.error}}r.complete()})}function gr(e){return new _(function(r){et(e,r).catch(function(t){return r.error(t)})})}function Zr(e){return gr(de(e))}function et(e,r){var t,o,n,i;return ir(this,void 0,void 0,function(){var a,f;return ee(this,function(p){switch(p.label){case 0:p.trys.push([0,5,6,11]),t=sr(e),p.label=1;case 1:return[4,t.next()];case 2:if(o=p.sent(),!!o.done)return[3,4];if(a=o.value,r.next(a),r.closed)return[2];p.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return f=p.sent(),n={error:f},[3,11];case 6:return p.trys.push([6,,9,10]),o&&!o.done&&(i=t.return)?[4,i.call(t)]:[3,8];case 7:p.sent(),p.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})}function T(e,r,t,o,n){o===void 0&&(o=0),n===void 0&&(n=!1);var i=r.schedule(function(){t(),n?e.add(this.schedule(null,o)):this.unsubscribe()},o);if(e.add(i),!n)return i}function he(e,r){return r===void 0&&(r=0),E(function(t,o){t.subscribe(M(o,function(n){return T(o,e,function(){return o.next(n)},r)},function(){return T(o,e,function(){return o.complete()},r)},function(n){return T(o,e,function(){return o.error(n)},r)}))})}function ye(e,r){return r===void 0&&(r=0),E(function(t,o){o.add(e.schedule(function(){return t.subscribe(o)},r))})}function br(e,r){return O(e).pipe(ye(r),he(r))}function Sr(e,r){return O(e).pipe(ye(r),he(r))}function vr(e,r){return new _(function(t){var o=0;return r.schedule(function(){o===e.length?t.complete():(t.next(e[o++]),t.closed||this.schedule())})})}function Ar(e,r){return new _(function(t){var o;return T(t,r,function(){o=e[le](),T(t,r,function(){var n,i,a;try{n=o.next(),i=n.value,a=n.done}catch(f){t.error(f);return}a?t.complete():t.next(i)},0,!0)}),function(){return h(o?.return)&&o.return()}})}function ge(e,r){if(!e)throw new Error("Iterable cannot be null");return new _(function(t){T(t,r,function(){var o=e[Symbol.asyncIterator]();T(t,r,function(){o.next().then(function(n){n.done?t.complete():t.next(n.value)})},0,!0)})})}function _r(e,r){return ge(de(e),r)}function Cr(e,r){if(e!=null){if(pe(e))return br(e,r);if(se(e))return vr(e,r);if(fe(e))return Sr(e,r);if(ce(e))return ge(e,r);if(me(e))return Ar(e,r);if(xe(e))return _r(e,r)}throw ue(e)}function Pe(e,r){return r?Cr(e,r):O(e)}function V(e,r){return E(function(t,o){var n=0;t.subscribe(M(o,function(i){o.next(e.call(r,i,n++))}))})}function Ir(e,r,t,o,n,i,a,f){var p=[],s=0,c=0,u=!1,m=function(){u&&!p.length&&!s&&r.complete()},l=function(d){return s<o?y(d):p.push(d)},y=function(d){i&&r.next(d),s++;var x=!1;O(t(d,c++)).subscribe(M(r,function(g){n?.(g),i?l(g):r.next(g)},function(){x=!0},void 0,function(){if(x)try{s--;for(var g=function(){var b=p.shift();a?T(r,a,function(){return y(b)}):y(b)};p.length&&s<o;)g();m()}catch(b){r.error(b)}}))};return e.subscribe(M(r,l,function(){u=!0,m()})),function(){f?.()}}function W(e,r,t){return t===void 0&&(t=1/0),h(r)?W(function(o,n){return V(function(i,a){return r(o,i,n,a)})(O(e(o,n)))},t):(typeof r=="number"&&(t=r),E(function(o,n){return Ir(o,n,e,t)}))}function Er(e,r,t,o,n){return function(i,a){var f=t,p=r,s=0;i.subscribe(M(a,function(c){var u=s++;p=f?e(p,c,u):(f=!0,c),o&&a.next(p)},n&&(function(){f&&a.next(p),a.complete()})))}}function Tr(e,r){return E(Er(e,r,arguments.length>=2,!1,!0))}var rt=function(e,r){return e.push(r),e};function be(){return E(function(e,r){Tr(rt,[])(e).subscribe(r)})}var tt=397,ot=387,nt=385;function wr(e){return(1<<e&tt)!==0}function Or(e){return(1<<e&ot)!==0}function Rr(e){return(1<<e&nt)!==0}function Ne(e,r,t,o,n,i,a){let f=n===-1?-1:1,p=r,s=n===-1?o:t,c=[],u=1/0,m=-1/0,l=1/0,y=-1/0,d=(x,g)=>{l=Math.min(l,x,g),y=Math.max(y,x,g)};for(let x=0;x<e.length;x++){let g=e[x],b=g>>>4,v=g&15,S=v===9,C=S||wr(v)?b:0,F=S?e[++x]>>>4:Or(v)?b:0,q=p+C,I=s+F*f,R=p,L=q;if(L>=i&&R<=a)if(C>0){let A=Math.max(R,i),$=Math.min(L,a);if($>A)if(u=Math.min(u,A),m=Math.max(m,$),S){let je=F/b,Ue=$-A,Be=Math.round(Ue*je),We=Math.round(s+(A-p)*je*f);c.push(Ue<<4|9,Be<<4|9),d(We,We+Be*f)}else c.push($-A<<4|v),Rr(v)?d(s+(A-p)*f,s+($-p)*f):d(s,s)}else F>0&&(S?c.push(g,e[x]):c.push(g),u=Math.min(u,p),m=Math.max(m,p),d(s,I));if(p=q,s=I,p>a)break}if(c.length!==0)return{start:u,end:m,mateStart:l,mateEnd:y,cigar:Uint32Array.from(c)}}function it(e){return e===1||e===2||e===3}function ke(e,r,t,o,n,i){let a=n===-1?-1:1,f=[],p=r,s=n===-1?o:t,c,u=!1,m=()=>{c!==void 0&&u&&c.qHi>c.qLo&&f.push({start:c.qLo,end:c.qHi,mateStart:c.tLo,mateEnd:c.tHi,cigar:Uint32Array.from(c.ops)}),c=void 0,u=!1};for(let l=0;l<e.length;l++){let y=e[l],d=y>>>4,x=y&15,g=x===9,b=g?e[++l]:void 0,v=g||wr(x)?d:0,S=b!==void 0?b>>>4:Or(x)?d:0,C=s+S*a;it(x)&&d>=i?m():(v>0||S>0)&&(c===void 0&&(c={qLo:p,qHi:p,tLo:s,tHi:s,ops:[]}),c.qHi=p+v,c.tLo=Math.min(c.tLo,s,C),c.tHi=Math.max(c.tHi,s,C),c.ops.push(y),b!==void 0&&c.ops.push(b),u=u||g||Rr(x)),p+=v,s=C}return m(),f}function Mr(e){let r=e.get("CIGAR");return typeof r=="string"?r:void 0}function Fr(e){let r=e.get("coarseCigar");return typeof r=="string"?r:void 0}function Ge(e){let r=Mr(e),t=r===void 0?Fr(e):void 0;return r!==void 0?Te(r):t!==void 0?_e(t):void 0}var at=["CIGAR","cs","coarseCigar","cg","cr"];function st(e){return typeof e=="object"&&e!==null&&"refName"in e&&"start"in e&&"end"in e&&typeof e.refName=="string"&&typeof e.start=="number"&&typeof e.end=="number"}function ft(e){let r=e.get("mate");return st(r)?r:void 0}function pt(e,r,t,o){let n=Math.max(e.start,o.start),i=Math.min(e.end,o.end),a=(r.end-r.start)/Math.max(e.end-e.start,1),f=c=>t===-1?r.end-(c-e.start)*a:r.start+(c-e.start)*a,p=Math.round(f(n)),s=Math.round(f(i));return i>n?{start:n,end:i,mateStart:Math.min(p,s),mateEnd:Math.max(p,s)}:void 0}function ct(e,r,t,o,n){let i={start:e.get("start"),end:e.get("end")},a=e.get("strand")===-1?-1:1,f=i.start>=t.start&&i.end<=t.end,p=f&&o===void 0&&!n?void 0:Ge(e);if(p===void 0){let s=f?{...i,mateStart:r.start,mateEnd:r.end}:pt(i,r,a,t);return s===void 0?[]:[s]}else return(o===void 0?[{...i,mateStart:r.start,mateEnd:r.end,cigar:p}]:ke(p,i.start,r.start,r.end,a,o)).flatMap(c=>{let u=Ne(c.cigar,c.start,c.mateStart,c.mateEnd,a,t.start,t.end);return u===void 0?[]:[u]})}function ut(e,r,t,o,n,i){let a=`:${o.start}-${o.end}${n}`,f=e.toJSON(),p={...f,uniqueId:`${e.id()}${a}`,start:t.start,end:t.end,mate:{...r,start:t.mateStart,end:t.mateEnd}};f.syntenyId!==void 0&&(p.syntenyId=`${String(f.syntenyId)}${a}`);for(let s of at)delete p[s];return i&&t.cigar&&(p.alignmentOps=t.cigar),new P(p)}function Lr(e,r,t,o=!1){let n=ft(e);if(n===void 0)return[e];{let i=ct(e,n,r,t,o);return i.map((a,f)=>ut(e,n,a,r,i.length>1?`/${f}`:"",o))}}var Pr=class extends ze{constructor(){super(...arguments);this.recordsAreAlignments=!0}static{this.capabilities=["getFeatures","getRefNames"]}async hasDataForRefName(){return!0}getFeaturesInMultipleRegions(t,o={}){let{clipToRegion:n,splitAtGapBp:i,keepAlignment:a,...f}=o,p=n&&this.recordsAreAlignments,s=Ye(f.statusCallback);return Pe(t).pipe(W((c,u)=>this.getFeatures(c,{...f,statusCallback:s()}).pipe(W(m=>p?Lr(m,m.get("assemblyName")===c.assemblyName?c:{start:m.get("start"),end:m.get("end")},i,a):[m]),be(),V(m=>({index:u,features:m})))),be(),W(c=>c.sort((u,m)=>u.index-m.index).flatMap(u=>u.features)))}};var De=class extends Error{constructor(t){super(`a pair query names both lanes: queryAssemblyName ${t} came without a targetAssemblyName`);this.name="PairTargetError"}};function Qi(e){let{lanePairs:r,queryAssemblyName:t,targetAssemblyName:o}=e;if(r?.length)return r;if(t===void 0)return[];if(o===void 0)throw new De(t);return[{queryAssemblyName:t,targetAssemblyName:o}]}function Ki(e){let[r]=e;return e.length===1&&r?`Reading ${r.queryAssemblyName} against ${r.targetAssemblyName}`:`Reading ${e.length} lane pairs`}function Xi(e,r){return e[r]??e[He(r)]??r}function ea({target:e,query:r,strand:t,cigar:o,matches:n,columns:i}){let a=`${e.name}:${e.start}-${e.end}|${r.name}:${r.start}-${r.end}`;return new P({uniqueId:a,assemblyName:e.assemblyName,refName:e.refName,start:e.start,end:e.end,type:"match",strand:t==="-"?-1:1,CIGAR:o,syntenyId:a,identity:n/Math.max(i,1),numMatches:n,blockLen:i,mate:{refName:r.refName,start:r.start,end:r.end,assemblyName:r.assemblyName}})}export{P as a,Pr as b,De as c,Qi as d,Ki as e,Xi as f,ea as g};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=t}});function Oe(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var te=(function(){function e(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var r,t,o,n,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var f=N(a),p=f.next();!p.done;p=f.next()){var s=p.value;s.remove(this)}}catch(d){r={error:d}}finally{try{p&&!p.done&&(t=f.return)&&t.call(f)}finally{if(r)throw r.error}}else a.remove(this);var c=this.initialTeardown;if(h(c))try{c()}catch(d){i=d instanceof re?d.errors:[d]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var m=N(u),l=m.next();!l.done;l=m.next()){var y=l.value;try{pr(y)}catch(d){i=i??[],d instanceof re?i=j(j([],D(i)),D(d.errors)):i.push(d)}}}catch(d){o={error:d}}finally{try{l&&!l.done&&(n=m.return)&&n.call(m)}finally{if(o)throw o.error}}}if(i)throw new re(i)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)pr(r);else{if(r instanceof e){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(r)}},e.prototype._hasParent=function(r){var t=this._parentage;return t===r||Array.isArray(t)&&t.includes(r)},e.prototype._addParent=function(r){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(r),t):t?[t,r]:r},e.prototype._removeParent=function(r){var t=this._parentage;t===r?this._parentage=null:Array.isArray(t)&&Oe(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&Oe(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=(function(){var r=new e;return r.closed=!0,r})(),e})();var Kt=te.EMPTY;function oe(e){return e instanceof te||e&&"closed"in e&&h(e.remove)&&h(e.add)&&h(e.unsubscribe)}function pr(e){h(e)?e():e.unsubscribe()}var w={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var U={setTimeout:function(e,r){for(var t=[],o=2;o<arguments.length;o++)t[o-2]=arguments[o];var n=U.delegate;return n?.setTimeout?n.setTimeout.apply(n,j([e,r],D(t))):setTimeout.apply(void 0,j([e,r],D(t)))},clearTimeout:function(e){var r=U.delegate;return(r?.clearTimeout||clearTimeout)(e)},delegate:void 0};function ne(e){U.setTimeout(function(){var r=w.onUnhandledError;if(r)r(e);else throw e})}function Re(){}var cr=(function(){return Me("C",void 0,void 0)})();function ur(e){return Me("E",void 0,e)}function lr(e){return Me("N",e,void 0)}function Me(e,r,t){return{kind:e,value:r,error:t}}var G=null;function mr(e){if(w.useDeprecatedSynchronousErrorHandling){var r=!G;if(r&&(G={errorThrown:!1,error:null}),e(),r){var t=G,o=t.errorThrown,n=t.error;if(G=null,o)throw n}}else e()}function dr(e){w.useDeprecatedSynchronousErrorHandling&&G&&(G.errorThrown=!0,G.error=e)}var z=(function(e){H(r,e);function r(t){var o=e.call(this)||this;return o.isStopped=!1,t?(o.destination=t,oe(t)&&t.add(o)):o.destination=$r,o}return r.create=function(t,o,n){return new ae(t,o,n)},r.prototype.next=function(t){this.isStopped?Le(lr(t),this):this._next(t)},r.prototype.error=function(t){this.isStopped?Le(ur(t),this):(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped?Le(cr,this):(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r})(te);var Ur=Function.prototype.bind;function Fe(e,r){return Ur.call(e,r)}var Br=(function(){function e(r){this.partialObserver=r}return e.prototype.next=function(r){var t=this.partialObserver;if(t.next)try{t.next(r)}catch(o){ie(o)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(o){ie(o)}else ie(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){ie(t)}},e})(),ae=(function(e){H(r,e);function r(t,o,n){var i=e.call(this)||this,a;if(h(t)||!t)a={next:t??void 0,error:o??void 0,complete:n??void 0};else{var f;i&&w.useDeprecatedNextContext?(f=Object.create(t),f.unsubscribe=function(){return i.unsubscribe()},a={next:t.next&&Fe(t.next,f),error:t.error&&Fe(t.error,f),complete:t.complete&&Fe(t.complete,f)}):a=t}return i.destination=new Br(a),i}return r})(z);function ie(e){w.useDeprecatedSynchronousErrorHandling?dr(e):ne(e)}function Wr(e){throw e}function Le(e,r){var t=w.onStoppedNotification;t&&U.setTimeout(function(){return t(e,r)})}var $r={closed:!0,next:Re,error:Wr,complete:Re};var B=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function xr(e){return e}function hr(e){return e.length===0?xr:e.length===1?e[0]:function(t){return e.reduce(function(o,n){return n(o)},t)}}var _=(function(){function e(r){r&&(this._subscribe=r)}return e.prototype.lift=function(r){var t=new e;return t.source=this,t.operator=r,t},e.prototype.subscribe=function(r,t,o){var n=this,i=Hr(r)?r:new ae(r,t,o);return mr(function(){var a=n,f=a.operator,p=a.source;i.add(f?f.call(i,p):p?n._subscribe(i):n._trySubscribe(i))}),i},e.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){r.error(t)}},e.prototype.forEach=function(r,t){var o=this;return t=yr(t),new t(function(n,i){var a=new ae({next:function(f){try{r(f)}catch(p){i(p),a.unsubscribe()}},error:i,complete:n});o.subscribe(a)})},e.prototype._subscribe=function(r){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(r)},e.prototype[B]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return hr(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=yr(r),new r(function(o,n){var i;t.subscribe(function(a){return i=a},function(a){return n(a)},function(){return o(i)})})},e.create=function(r){return new e(r)},e})();function yr(e){var r;return(r=e??w.Promise)!==null&&r!==void 0?r:Promise}function Yr(e){return e&&h(e.next)&&h(e.error)&&h(e.complete)}function Hr(e){return e&&e instanceof z||Yr(e)&&oe(e)}function zr(e){return h(e?.lift)}function E(e){return function(r){if(zr(r))return r.lift(function(t){try{return e(t,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function M(e,r,t,o,n){return new Vr(e,r,t,o,n)}var Vr=(function(e){H(r,e);function r(t,o,n,i,a,f){var p=e.call(this,t)||this;return p.onFinalize=a,p.shouldUnsubscribe=f,p._next=o?function(s){try{o(s)}catch(c){t.error(c)}}:e.prototype._next,p._error=i?function(s){try{i(s)}catch(c){t.error(c)}finally{this.unsubscribe()}}:e.prototype._error,p._complete=n?function(){try{n()}catch(s){t.error(s)}finally{this.unsubscribe()}}:e.prototype._complete,p}return r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;e.prototype.unsubscribe.call(this),!o&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},r})(z);var se=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function fe(e){return h(e?.then)}function pe(e){return h(e[B])}function ce(e){return Symbol.asyncIterator&&h(e?.[Symbol.asyncIterator])}function ue(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function qr(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var le=qr();function me(e){return h(e?.[le])}function de(e){return ar(this,arguments,function(){var t,o,n,i;return ee(this,function(a){switch(a.label){case 0:t=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,k(t.read())];case 3:return o=a.sent(),n=o.value,i=o.done,i?[4,k(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,k(n)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function xe(e){return h(e?.getReader)}function O(e){if(e instanceof _)return e;if(e!=null){if(pe(e))return Qr(e);if(se(e))return Kr(e);if(fe(e))return Xr(e);if(ce(e))return gr(e);if(me(e))return Jr(e);if(xe(e))return Zr(e)}throw ue(e)}function Qr(e){return new _(function(r){var t=e[B]();if(h(t.subscribe))return t.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Kr(e){return new _(function(r){for(var t=0;t<e.length&&!r.closed;t++)r.next(e[t]);r.complete()})}function Xr(e){return new _(function(r){e.then(function(t){r.closed||(r.next(t),r.complete())},function(t){return r.error(t)}).then(null,ne)})}function Jr(e){return new _(function(r){var t,o;try{for(var n=N(e),i=n.next();!i.done;i=n.next()){var a=i.value;if(r.next(a),r.closed)return}}catch(f){t={error:f}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(t)throw t.error}}r.complete()})}function gr(e){return new _(function(r){et(e,r).catch(function(t){return r.error(t)})})}function Zr(e){return gr(de(e))}function et(e,r){var t,o,n,i;return ir(this,void 0,void 0,function(){var a,f;return ee(this,function(p){switch(p.label){case 0:p.trys.push([0,5,6,11]),t=sr(e),p.label=1;case 1:return[4,t.next()];case 2:if(o=p.sent(),!!o.done)return[3,4];if(a=o.value,r.next(a),r.closed)return[2];p.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return f=p.sent(),n={error:f},[3,11];case 6:return p.trys.push([6,,9,10]),o&&!o.done&&(i=t.return)?[4,i.call(t)]:[3,8];case 7:p.sent(),p.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})}function T(e,r,t,o,n){o===void 0&&(o=0),n===void 0&&(n=!1);var i=r.schedule(function(){t(),n?e.add(this.schedule(null,o)):this.unsubscribe()},o);if(e.add(i),!n)return i}function he(e,r){return r===void 0&&(r=0),E(function(t,o){t.subscribe(M(o,function(n){return T(o,e,function(){return o.next(n)},r)},function(){return T(o,e,function(){return o.complete()},r)},function(n){return T(o,e,function(){return o.error(n)},r)}))})}function ye(e,r){return r===void 0&&(r=0),E(function(t,o){o.add(e.schedule(function(){return t.subscribe(o)},r))})}function br(e,r){return O(e).pipe(ye(r),he(r))}function Sr(e,r){return O(e).pipe(ye(r),he(r))}function vr(e,r){return new _(function(t){var o=0;return r.schedule(function(){o===e.length?t.complete():(t.next(e[o++]),t.closed||this.schedule())})})}function Ar(e,r){return new _(function(t){var o;return T(t,r,function(){o=e[le](),T(t,r,function(){var n,i,a;try{n=o.next(),i=n.value,a=n.done}catch(f){t.error(f);return}a?t.complete():t.next(i)},0,!0)}),function(){return h(o?.return)&&o.return()}})}function ge(e,r){if(!e)throw new Error("Iterable cannot be null");return new _(function(t){T(t,r,function(){var o=e[Symbol.asyncIterator]();T(t,r,function(){o.next().then(function(n){n.done?t.complete():t.next(n.value)})},0,!0)})})}function _r(e,r){return ge(de(e),r)}function Cr(e,r){if(e!=null){if(pe(e))return br(e,r);if(se(e))return vr(e,r);if(fe(e))return Sr(e,r);if(ce(e))return ge(e,r);if(me(e))return Ar(e,r);if(xe(e))return _r(e,r)}throw ue(e)}function Pe(e,r){return r?Cr(e,r):O(e)}function V(e,r){return E(function(t,o){var n=0;t.subscribe(M(o,function(i){o.next(e.call(r,i,n++))}))})}function Ir(e,r,t,o,n,i,a,f){var p=[],s=0,c=0,u=!1,m=function(){u&&!p.length&&!s&&r.complete()},l=function(d){return s<o?y(d):p.push(d)},y=function(d){i&&r.next(d),s++;var x=!1;O(t(d,c++)).subscribe(M(r,function(g){n?.(g),i?l(g):r.next(g)},function(){x=!0},void 0,function(){if(x)try{s--;for(var g=function(){var b=p.shift();a?T(r,a,function(){return y(b)}):y(b)};p.length&&s<o;)g();m()}catch(b){r.error(b)}}))};return e.subscribe(M(r,l,function(){u=!0,m()})),function(){f?.()}}function W(e,r,t){return t===void 0&&(t=1/0),h(r)?W(function(o,n){return V(function(i,a){return r(o,i,n,a)})(O(e(o,n)))},t):(typeof r=="number"&&(t=r),E(function(o,n){return Ir(o,n,e,t)}))}function Er(e,r,t,o,n){return function(i,a){var f=t,p=r,s=0;i.subscribe(M(a,function(c){var u=s++;p=f?e(p,c,u):(f=!0,c),o&&a.next(p)},n&&(function(){f&&a.next(p),a.complete()})))}}function Tr(e,r){return E(Er(e,r,arguments.length>=2,!1,!0))}var rt=function(e,r){return e.push(r),e};function be(){return E(function(e,r){Tr(rt,[])(e).subscribe(r)})}var tt=397,ot=387,nt=385;function wr(e){return(1<<e&tt)!==0}function Or(e){return(1<<e&ot)!==0}function Rr(e){return(1<<e&nt)!==0}function Ne(e,r,t,o,n,i,a){let f=n===-1?-1:1,p=r,s=n===-1?o:t,c=[],u=1/0,m=-1/0,l=1/0,y=-1/0,d=(x,g)=>{l=Math.min(l,x,g),y=Math.max(y,x,g)};for(let x=0;x<e.length;x++){let g=e[x],b=g>>>4,v=g&15,S=v===9,C=S||wr(v)?b:0,F=S?e[++x]>>>4:Or(v)?b:0,q=p+C,I=s+F*f,R=p,L=q;if(L>=i&&R<=a)if(C>0){let A=Math.max(R,i),$=Math.min(L,a);if($>A)if(u=Math.min(u,A),m=Math.max(m,$),S){let je=F/b,Ue=$-A,Be=Math.round(Ue*je),We=Math.round(s+(A-p)*je*f);c.push(Ue<<4|9,Be<<4|9),d(We,We+Be*f)}else c.push($-A<<4|v),Rr(v)?d(s+(A-p)*f,s+($-p)*f):d(s,s)}else F>0&&(S?c.push(g,e[x]):c.push(g),u=Math.min(u,p),m=Math.max(m,p),d(s,I));if(p=q,s=I,p>a)break}if(c.length!==0)return{start:u,end:m,mateStart:l,mateEnd:y,cigar:Uint32Array.from(c)}}function it(e){return e===1||e===2||e===3}function ke(e,r,t,o,n,i){let a=n===-1?-1:1,f=[],p=r,s=n===-1?o:t,c,u=!1,m=()=>{c!==void 0&&u&&c.qHi>c.qLo&&f.push({start:c.qLo,end:c.qHi,mateStart:c.tLo,mateEnd:c.tHi,cigar:Uint32Array.from(c.ops)}),c=void 0,u=!1};for(let l=0;l<e.length;l++){let y=e[l],d=y>>>4,x=y&15,g=x===9,b=g?e[++l]:void 0,v=g||wr(x)?d:0,S=b!==void 0?b>>>4:Or(x)?d:0,C=s+S*a;it(x)&&d>=i?m():(v>0||S>0)&&(c===void 0&&(c={qLo:p,qHi:p,tLo:s,tHi:s,ops:[]}),c.qHi=p+v,c.tLo=Math.min(c.tLo,s,C),c.tHi=Math.max(c.tHi,s,C),c.ops.push(y),b!==void 0&&c.ops.push(b),u=u||g||Rr(x)),p+=v,s=C}return m(),f}function Mr(e){let r=e.get("CIGAR");return typeof r=="string"?r:void 0}function Fr(e){let r=e.get("coarseCigar");return typeof r=="string"?r:void 0}function Ge(e){let r=Mr(e),t=r===void 0?Fr(e):void 0;return r!==void 0?Te(r):t!==void 0?_e(t):void 0}var at=["CIGAR","cs","coarseCigar","cg","cr"];function st(e){return typeof e=="object"&&e!==null&&"refName"in e&&"start"in e&&"end"in e&&typeof e.refName=="string"&&typeof e.start=="number"&&typeof e.end=="number"}function ft(e){let r=e.get("mate");return st(r)?r:void 0}function pt(e,r,t,o){let n=Math.max(e.start,o.start),i=Math.min(e.end,o.end),a=(r.end-r.start)/Math.max(e.end-e.start,1),f=c=>t===-1?r.end-(c-e.start)*a:r.start+(c-e.start)*a,p=Math.round(f(n)),s=Math.round(f(i));return i>n?{start:n,end:i,mateStart:Math.min(p,s),mateEnd:Math.max(p,s)}:void 0}function ct(e,r,t,o,n){let i={start:e.get("start"),end:e.get("end")},a=e.get("strand")===-1?-1:1,f=i.start>=t.start&&i.end<=t.end,p=f&&o===void 0&&!n?void 0:Ge(e);if(p===void 0){let s=f?{...i,mateStart:r.start,mateEnd:r.end}:pt(i,r,a,t);return s===void 0?[]:[s]}else return(o===void 0?[{...i,mateStart:r.start,mateEnd:r.end,cigar:p}]:ke(p,i.start,r.start,r.end,a,o)).flatMap(c=>{let u=Ne(c.cigar,c.start,c.mateStart,c.mateEnd,a,t.start,t.end);return u===void 0?[]:[u]})}function ut(e,r,t,o,n,i){let a=`:${o.start}-${o.end}${n}`,f=e.toJSON(),p={...f,uniqueId:`${e.id()}${a}`,recordId:f.recordId??e.id(),start:t.start,end:t.end,mate:{...r,start:t.mateStart,end:t.mateEnd}};f.syntenyId!==void 0&&(p.syntenyId=`${String(f.syntenyId)}${a}`);for(let s of at)delete p[s];return i&&t.cigar&&(p.alignmentOps=t.cigar),new P(p)}function Lr(e,r,t,o=!1){let n=ft(e);if(n===void 0)return[e];{let i=ct(e,n,r,t,o);return i.map((a,f)=>ut(e,n,a,r,i.length>1?`/${f}`:"",o))}}var Pr=class extends ze{constructor(){super(...arguments);this.recordsAreAlignments=!0}static{this.capabilities=["getFeatures","getRefNames"]}async hasDataForRefName(){return!0}getFeaturesInMultipleRegions(t,o={}){let{clipToRegion:n,splitAtGapBp:i,keepAlignment:a,...f}=o,p=n&&this.recordsAreAlignments,s=Ye(f.statusCallback);return Pe(t).pipe(W((c,u)=>this.getFeatures(c,{...f,statusCallback:s()}).pipe(W(m=>p?Lr(m,m.get("assemblyName")===c.assemblyName?c:{start:m.get("start"),end:m.get("end")},i,a):[m]),be(),V(m=>({index:u,features:m})))),be(),W(c=>c.sort((u,m)=>u.index-m.index).flatMap(u=>u.features)))}};var De=class extends Error{constructor(t){super(`a pair query names both lanes: queryAssemblyName ${t} came without a targetAssemblyName`);this.name="PairTargetError"}};function Qi(e){let{lanePairs:r,queryAssemblyName:t,targetAssemblyName:o}=e;if(r?.length)return r;if(t===void 0)return[];if(o===void 0)throw new De(t);return[{queryAssemblyName:t,targetAssemblyName:o}]}function Ki(e){let[r]=e;return e.length===1&&r?`Reading ${r.queryAssemblyName} against ${r.targetAssemblyName}`:`Reading ${e.length} lane pairs`}function Xi(e,r){return e[r]??e[He(r)]??r}function ea({target:e,query:r,strand:t,cigar:o,matches:n,columns:i}){let a=`${e.name}:${e.start}-${e.end}|${r.name}:${r.start}-${r.end}`;return new P({uniqueId:a,assemblyName:e.assemblyName,refName:e.refName,start:e.start,end:e.end,type:"match",strand:t==="-"?-1:1,CIGAR:o,syntenyId:a,identity:n/Math.max(i,1),numMatches:n,blockLen:i,mate:{refName:r.refName,start:r.start,end:r.end,assemblyName:r.assemblyName}})}export{P as a,Pr as b,De as c,Qi as d,Ki as e,Xi as f,ea as g};
|
|
4
|
+
//# sourceMappingURL=chunk-IJJZC7A4.js.map
|