"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[327,8111],{50327:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c});var a=n(59062),s=n(31238),r=n(98111),o=n(85579);class c extends r.default{async setupPre(e){const t=(0,a.openLocation)(this.getConf("outLocation"),this.pluginManager),n=await t.readFile(e),r=function(e){return 31===e[0]&&139===e[1]&&8===e[2]}(n)?await(0,s.unzip)(n):n;return(0,o.WU)(r,i)}}function i(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}}}},98111:(e,t,n)=>{n.r(t),n.d(t,{default:()=>y});var a=n(56798),s=n(19881),r=n(59062),o=n(16979),c=n(43800),i=n(31238),u=n(45627),l=n(90872);const{getMismatches:m}=u.MismatchParser;class d extends l.SimpleFeature{get(e){return"mismatches"===e?m(this.get("CIGAR")):super.get(e)}}var f=n(85579);function p(e){const[t,n]=e.reduce(((e,t)=>{let[n,a]=e,[s,r]=t;return[n+s*r,a+r]}),[0,0]);return t/n}function h(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 g(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}const{parseCigar:b}=u.MismatchParser;class y extends a.BaseFeatureDataAdapter{constructor(){super(...arguments),this.setupP=void 0}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,f.lq)(a)?await(0,i.unzip)(a):a;return(0,f.WU)(s,h)}async hasDataForRefName(){return!0}getAssemblyNames(){const e=this.getConf("assemblyNames");if(0===e.length){return[this.getConf("queryAssembly"),this.getConf("targetAssembly")]}return e}async getRefNames(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=null===(e=t.regions)||void 0===e?void 0:e[0].assemblyName,a=await this.setup(t),s=this.getAssemblyNames().indexOf(n);if(-1!==s){const e=new Set;for(const t of a)e.add(0===s?t.qname:t.tname);return[...e]}return console.warn("Unable to do ref renaming on adapter"),[]}getFeatures(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,o.ObservableCreate)((async n=>{let a=await this.setup(t);const{config:r}=t;r&&"meanQueryIdentity"===(0,c.readConfObject)(r,"colorBy")&&(a=function(e){const t={};for(const r of e){const e=r.qname+"-"+r.tname;t[e]||(t[e]={quals:[],len:[]}),t[e].quals.push(r.extra.mappingQual),t[e].len.push(r.extra.blockLen||1)}const n=Object.fromEntries(Object.entries(t).map((e=>{let[t,n]=e;return[t,p((0,f.$R)(n.quals,n.len))]})));for(const r of e){const e=r.qname+"-"+r.tname;r.extra.meanScore=n[e]}let a=1e4,s=0;for(const r of e)a=Math.min(r.extra.meanScore||0,a),s=Math.max(r.extra.meanScore||0,s);for(const r of e){const e=r.extra.meanScore||0;r.extra.meanScore=(e-a)/(s-a)}return e}(a));const o=this.getAssemblyNames(),i=o.indexOf(e.assemblyName),{start:u,end:l,refName:m,assemblyName:h}=e;-1===i&&(console.warn("".concat(h," not found in this adapter")),n.complete());for(let e=0;e<a.length;e++){const t=a[e];let r=0,c=0,f="",p="",h=0,y=0;const w=0===i,q=o[+!w];0===i?(r=t.qstart,c=t.qend,f=t.qname,p=t.tname,h=t.tstart,y=t.tend):(r=t.tstart,c=t.tend,f=t.tname,p=t.qname,h=t.qstart,y=t.qend);const{extra:x,strand:N}=t;if(f===m&&(0,s.qY)(u,l,r,c)){const{numMatches:t=0,blockLen:a=1,cg:s,...i}=x;let u=x.cg;x.cg&&(w&&-1===N?u=g(b(x.cg)).join(""):w&&(u=x.cg.replaceAll("D","K").replaceAll("I","D").replaceAll("K","I"))),n.next(new d({uniqueId:e+q,assemblyName:q,start:r,end:c,type:"match",refName:f,strand:N,...i,CIGAR:u,syntenyId:e,identity:t/a,numMatches:t,blockLen:a,mate:{start:h,end:y,refName:p,assemblyName:o[+w]}}))}}n.complete()}))}freeResources(){}}y.capabilities=["getFeatures","getRefNames"]},85579:(e,t,n)=>{n.d(t,{$R:()=>c,SN:()=>r,WU:()=>u,lq:()=>s,pJ:()=>o});var a=n(31238);function s(e){return 31===e[0]&&139===e[1]&&8===e[2]}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(s(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.slice(n,s),o=((null===i||void 0===i?void 0:i.decode(r))||r.toString()).trim();o&&a.push(t(o)),n=s+1}return a}}}]);
//# sourceMappingURL=327.551d8a7e.chunk.js.map