"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[9449,5904],{29449:(e,t,n)=>{n.r(t),n.d(t,{default:()=>i});var a=n(99834),s=n(7706),r=n(99546),o=n(35904),c=n(78054);class i extends o.default{async setupPre(e){const t=(0,a.openLocation)(this.getConf("outLocation"),this.pluginManager),n=await t.readFile(e),o=(0,r.isGzip)(n)?await(0,s.unzip)(n):n;return(0,c.PX)(o,u)}}function u(e){const t=e.split(" ");if(t.length<9)throw new Error(`improperly formatted line: ${e}`);const[n,,a,s,r,o,,c,i,u]=t;return{tname:o,tstart:+c,tend:+i,qname:n,qstart:+a,qend:+s,strand:"-"===r?-1:1,extra:{mappingQual:+u}}}},35904:(e,t,n)=>{n.r(t),n.d(t,{default:()=>h});var a=n(46377),s=n(32595),r=n(99834),o=n(66885),c=n(99546),i=n(68584),u=n(7706),l=n(25350),m=n(72147),f=n(78054);function p(e){const[t,n]=e.reduce((([e,t],[n,a])=>[e+n*a,t+a]),[0,0]);return t/n}const{parseCigar:d}=l.aF;class h extends a.BaseFeatureDataAdapter{static capabilities=["getFeatures","getRefNames"];async setup(e){return this.setupP||(this.setupP=this.setupPre(e).catch((e=>{throw this.setupP=void 0,e}))),this.setupP}async setupPre(e){const t=this.pluginManager,n=(0,r.openLocation)(this.getConf("pafLocation"),t),a=await n.readFile(e),s=(0,c.isGzip)(a)?await(0,u.unzip)(a):a;return(0,f.PX)(s,f.xI)}async hasDataForRefName(){return!0}getAssemblyNames(){const e=this.getConf("assemblyNames");return 0===e.length?[this.getConf("queryAssembly"),this.getConf("targetAssembly")]:e}async getRefNames(e={}){const t=e.regions?.[0].assemblyName,n=await this.setup(e),a=this.getAssemblyNames().indexOf(t);if(-1!==a){const e=new Set;for(const t of n)e.add(0===a?t.qname:t.tname);return[...e]}return console.warn("Unable to do ref renaming on adapter"),[]}getFeatures(e,t={}){return(0,o.ObservableCreate)((async n=>{let a=await this.setup(t);const{config:r}=t;r&&"meanQueryIdentity"===(0,i.readConfObject)(r,"colorBy")&&(a=function(e){const t={};for(const n of e){const e=`${n.qname}-${n.tname}`;t[e]||(t[e]={quals:[],len:[]}),t[e].quals.push(n.extra.mappingQual),t[e].len.push(n.extra.blockLen||1)}const n=Object.fromEntries(Object.entries(t).map((([e,t])=>[e,p((0,f.yU)(t.quals,t.len))])));for(const t of e){const e=`${t.qname}-${t.tname}`;t.extra.meanScore=n[e]}let a=1e4,s=0;for(const t of e)a=Math.min(t.extra.meanScore||0,a),s=Math.max(t.extra.meanScore||0,s);for(const t of e){const e=t.extra.meanScore||0;t.extra.meanScore=(e-a)/(s-a)}return e}(a));const o=this.getAssemblyNames(),{start:c,end:u,refName:l,assemblyName:h}=e,g=o.indexOf(h),b=0===g;-1===g&&(console.warn(`${h} not found in this adapter`),n.complete());for(let e=0;e<a.length;e++){const t=a[e];let r=0,i=0,p="",g="",y=0,w=0;b?(r=t.qstart,i=t.qend,p=t.qname,g=t.tname,y=t.tstart,w=t.tend):(r=t.tstart,i=t.tend,p=t.tname,g=t.qname,y=t.qstart,w=t.qend);const{extra:x,strand:q}=t;if(p===l&&(0,s.R6)(c,u,r,i)){const{numMatches:t=0,blockLen:a=1,cg:s,...c}=x;let u=x.cg;x.cg&&(b&&-1===q?u=(0,f.qm)(d(x.cg)).join(""):b&&(u=(0,f.gJ)(x.cg))),n.next(new m.A({uniqueId:e+h,assemblyName:h,start:r,end:i,type:"match",refName:p,strand:q,...c,CIGAR:u,syntenyId:e,identity:t/a,numMatches:t,blockLen:a,mate:{start:y,end:w,refName:g,assemblyName:o[+b]}}))}}n.complete()}))}freeResources(){}}},72147:(e,t,n)=>{n.d(t,{A:()=>o});var a=n(99546),s=n(25350);const{getMismatches:r}=s.aF;class o extends a.SimpleFeature{get(e){return"mismatches"===e?r(this.get("CIGAR")):super.get(e)}}},78054:(e,t,n)=>{n.d(t,{PX:()=>u,TA:()=>o,fY:()=>r,gJ:()=>f,qm:()=>m,xI:()=>l,yU:()=>c});var a=n(7706),s=n(99546);function r(e){return new Map(e.split(/\n|\r\n|\r/).filter((e=>!!e||e.startsWith("#"))).map((e=>{const[t,n,a,s,r,o]=e.split("\t");return[s,{refName:t,start:+n,end:+a,score:+r,name:s,strand:"-"===o?-1:1}]})))}async function o(e,t){const n=await e.readFile(t);return new TextDecoder("utf8",{fatal:!0}).decode((0,s.isGzip)(n)?await(0,a.unzip)(n):n)}function c(e,t){return e.map(((e,n)=>[e,t[n]]))}const i="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function u(e,t){let n=0;const a=[];for(;n<e.length;){const s=e.indexOf("\n",n);if(-1===s)break;const r=e.subarray(n,s),o=(i?.decode(r)||r.toString()).trim();o&&a.push(t(o)),n=s+1}return a}function l(e){const[t,,n,a,s,r,,o,c,i,u,l,...m]=e.split("\t");return{tname:r,tstart:+o,tend:+c,qname:t,qstart:+n,qend:+a,strand:"-"===s?-1:1,extra:{numMatches:+i,blockLen:+u,mappingQual:+l,...Object.fromEntries(m.map((e=>{const t=e.indexOf(":");return[e.slice(0,t),e.slice(t+3)]})))}}}function m(e){const t=[];for(let n=e.length-2;n>=0;n-=2){t.push(e[n]);const a=e[n+1];"D"===a?t.push("I"):"I"===a?t.push("D"):t.push(a)}return t}function f(e){return e.replaceAll("D","K").replaceAll("I","D").replaceAll("K","I")}}}]);
//# sourceMappingURL=9449.6511494b.chunk.js.map