"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[3167],{23167:(e,t,s)=>{s.r(t),s.d(t,{default:()=>u});var a=s(75466),n=s(46377),r=s(99546),i=s(99834),c=s(66885),o=s(72147),l=s(78054);class u extends n.BaseFeatureDataAdapter{static capabilities=["getFeatures","getRefNames"];constructor(e,t,s){super(e,t,s);const n=this.getConf("pifGzLocation"),r=this.getConf(["index","indexType"]),c=this.getConf(["index","location"]),o=this.pluginManager;this.pif=new a.wD({filehandle:(0,i.openLocation)(n,o),csiFilehandle:"CSI"===r?(0,i.openLocation)(c,o):void 0,tbiFilehandle:"CSI"!==r?(0,i.openLocation)(c,o):void 0,chunkCacheSize:52428800})}async getHeader(e){const{statusCallback:t=()=>{}}=e||{};return(0,r.updateStatus)("Downloading header",t,()=>this.pif.getHeader())}getAssemblyNames(){const e=this.getConf("assemblyNames");return 0===e.length?[this.getConf("queryAssembly"),this.getConf("targetAssembly")]:e}async hasDataForRefName(){return!0}async getRefNames(e={}){const t=e.regions?.[0]?.assemblyName;if(!t)throw new Error("no assembly name provided");const s=this.getAssemblyNames().indexOf(t),a=await this.pif.getReferenceSequenceNames(e);return 0===s?a.filter(e=>e.startsWith("q")).map(e=>e.slice(1)):1===s?a.filter(e=>e.startsWith("t")).map(e=>e.slice(1)):[]}getFeatures(e,t={}){const{statusCallback:s=()=>{}}=t;return(0,c.ObservableCreate)(async a=>{const{assemblyName:n}=e,i=this.getAssemblyNames(),c=0===i.indexOf(n),u=c?"q":"t";await(0,r.updateStatus)("Downloading features",s,()=>this.pif.getLines(u+e.refName,e.start,e.end,{lineCallback:(e,t)=>{const s=(0,l.xI)(e),r=s.qname.slice(1),u=s.qstart,m=s.qend,h=s.tname,d=s.tstart,p=s.tend,{extra:f,strand:g}=s,{numMatches:b=0,blockLen:y=1,cg:C,...w}=f;a.next(new o.A({uniqueId:t+n,assemblyName:n,start:u,end:m,type:"match",refName:r,strand:g,...w,CIGAR:f.cg,syntenyId:t,identity:b/y,numMatches:b,blockLen:y,mate:{start:d,end:p,refName:h,assemblyName:i[+c]}}))},stopToken:t.stopToken})),a.complete()})}}},72147:(e,t,s)=>{s.d(t,{A:()=>i});var a=s(99546),n=s(55689);const{getMismatches:r}=n.aF;class i extends a.SimpleFeature{get(e){return"mismatches"===e?r(this.get("CIGAR")):super.get(e)}}},78054:(e,t,s)=>{s.d(t,{TA:()=>r,fY:()=>n,gJ:()=>l,qm:()=>o,xI:()=>c,yU:()=>i});var a=s(99546);function n(e){return new Map(e.split(/\n|\r\n|\r/).filter(e=>!!e||e.startsWith("#")).map(e=>{const[t,s,a,n,r,i]=e.split("\t");return[n,{refName:t,start:+s,end:+a,score:+r,name:n,strand:"-"===i?-1:1}]}))}async function r(e,t){return(0,a.fetchAndMaybeUnzipText)(e,t)}function i(e,t){return e.map((e,s)=>[e,t[s]])}function c(e){const t=e.split("\t"),s=t.slice(12),a={numMatches:+t[9],blockLen:+t[10],mappingQual:+t[11]};if(s.length)for(const e of s){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 o(e){const t=[];for(let s=e.length-2;s>=0;s-=2){t.push(e[s]);const a=e[s+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=3167.ed06a84f.chunk.js.map