"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[5904,9449],{18340:(e,t,n)=>{n.d(t,{P:()=>s});var a=n(99546);function s(e,t,n=()=>{}){const s=new TextDecoder("utf8");let r=0,o=0;for(;r<e.length;){const c=e.indexOf(10,r),i=-1===c?e.length:c,l=e.subarray(r,i),u=s.decode(l).trim();if(u&&!1===t(u,o))break;o++%1e4==0&&n(`Loading ${(0,a.getProgressDisplayStr)(r,e.length)}`),r=i+1}}},29449:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c});var a=n(99546),s=n(99834),r=n(18340),o=n(35904);class c extends o.default{async setupPre(e){const t=[];return(0,r.P)(await(0,a.fetchAndMaybeUnzip)((0,s.openLocation)(this.getConf("outLocation"),this.pluginManager),e),e=>(t.push(function(e){const t=e.split(" ");if(t.length<9)throw new Error(`improperly formatted line: ${e}`);const[n,,a,s,r,o,,c,i,l]=t;return{tname:o,tstart:+c,tend:+i,qname:n,qstart:+a,qend:+s,strand:"-"===r?-1:1,extra:{mappingQual:+l}}}(e)),!0),e?.statusCallback),t}}},35904:(e,t,n)=>{n.r(t),n.d(t,{default:()=>d});var a=n(68584),s=n(46377),r=n(99546),o=n(99834),c=n(18340),i=n(32595),l=n(66885),u=n(55689),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:h}=u.aF;class d extends s.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=[];return(0,c.P)(await(0,r.fetchAndMaybeUnzip)((0,o.openLocation)(this.getConf("pafLocation"),this.pluginManager),e),e=>(t.push((0,f.xI)(e)),!0),e?.statusCallback),t}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,l.ObservableCreate)(async n=>{let s=await this.setup(t);const{config:r}=t;r&&"meanQueryIdentity"===(0,a.readConfObject)(r,"colorBy")&&(s=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||1),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}(s));const o=this.getAssemblyNames(),{start:c,end:l,refName:u,assemblyName:d}=e,g=o.indexOf(d),b=0===g;-1===g&&(console.warn(`${d} not found in this adapter`),n.complete());for(let e=0;e<s.length;e++){const t=s[e];let a=0,r=0,p="",g="",y=0,x=0;b?(a=t.qstart,r=t.qend,p=t.qname,g=t.tname,y=t.tstart,x=t.tend):(a=t.tstart,r=t.tend,p=t.tname,g=t.qname,y=t.qstart,x=t.qend);const{extra:q,strand:w}=t;if(p===u&&(0,i.R6)(c,l,a,r)){const{numMatches:t=0,blockLen:s=1,cg:c,...i}=q;let l=q.cg;q.cg&&(b&&-1===w?l=(0,f.qm)(h(q.cg)).join(""):b&&(l=(0,f.gJ)(q.cg))),n.next(new m.A({uniqueId:e+d,assemblyName:d,start:a,end:r,type:"match",refName:p,strand:w,...i,CIGAR:l,syntenyId:e,identity:t/s,numMatches:t,blockLen:s,mate:{start:y,end:x,refName:g,assemblyName:o[+b]}}))}}n.complete()})}}},72147:(e,t,n)=>{n.d(t,{A:()=>o});var a=n(99546),s=n(55689);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,{TA:()=>r,fY:()=>s,gJ:()=>l,qm:()=>i,xI:()=>c,yU:()=>o});var a=n(99546);function s(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 r(e,t){return(0,a.fetchAndMaybeUnzipText)(e,t)}function o(e,t){return e.map((e,n)=>[e,t[n]])}function c(e){const t=e.split("\t"),n=t.slice(12),a={numMatches:+t[9],blockLen:+t[10],mappingQual:+t[11]};if(n.length)for(const e of n){const t=e.indexOf(":");a[e.slice(0,t)]=e.slice(t+3)}return{tname:t[5],tstart:+t[7],tend:+t[8],qname:t[0],qstart:+t[2],qend:+t[3],strand:"-"===t[4]?-1:1,extra:a}}function i(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 l(e){return e.replaceAll("D","K").replaceAll("I","D").replaceAll("K","I")}}}]);
//# sourceMappingURL=9449.1c5ab9db.chunk.js.map