"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8965],{28965:(e,t,s)=>{s.r(t),s.d(t,{default:()=>c});var n=s(46377),a=s(99546),r=s(99834),o=s(66885),i=s(78054);class c extends n.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.getConf("assemblyNames"),s=this.pluginManager,n=(0,r.openLocation)(this.getConf("bed1Location"),s),a=(0,r.openLocation)(this.getConf("bed2Location"),s),o=(0,r.openLocation)(this.getConf("mcscanAnchorsLocation"),s),[c,u,f]=await Promise.all([n,a,o].map((t=>(0,i.TA)(t,e)))),l=(0,i.fY)(c),m=(0,i.fY)(u);return{assemblyNames:t,feats:f.split(/\n|\r\n|\r/).filter((e=>!!e&&"###"!==e)).map(((e,t)=>{const[s,n,a]=e.split("\t"),r=l.get(s),o=m.get(n);if(!r||!o)throw new Error(`feature not found, ${s} ${n} ${r} ${o}`);return[r,o,+a,t]}))}}async hasDataForRefName(){return!0}getAssemblyNames(){return this.getConf("assemblyNames")}async getRefNames(e={}){const t=e.regions?.[0].assemblyName,{feats:s}=await this.setup(e),n=this.getAssemblyNames().indexOf(t);if(-1!==n){const e=new Set;for(const t of s)e.add(0===n?t[0].refName:t[1].refName);return[...e]}return console.warn("Unable to do ref renaming on adapter"),[]}getFeatures(e,t={}){return(0,o.ObservableCreate)((async s=>{const{assemblyNames:n,feats:r}=await this.setup(t),o=n.indexOf(e.assemblyName);if(-1!==o){const t=0===o;r.forEach((r=>{const[i,c,u,f]=r,[l,m]=t?[i,c]:[c,i];l.refName===e.refName&&(0,a.doesIntersect2)(e.start,e.end,l.start,l.end)&&s.next(new a.SimpleFeature({...l,uniqueId:`${o}-${f}`,syntenyId:f,strand:l.strand*m.strand,assemblyName:n[+!t],score:u,mate:{...m,assemblyName:n[+t]}}))}))}s.complete()}))}freeResources(){}}},78054:(e,t,s)=>{s.d(t,{PX:()=>i,TA:()=>r,fY:()=>a,gJ:()=>f,qm:()=>u,xI:()=>c,yU:()=>o});var n=s(99546);function a(e){return new Map(e.split(/\n|\r\n|\r/).filter((e=>!!e||e.startsWith("#"))).map((e=>{const[t,s,n,a,r,o]=e.split("\t");return[a,{refName:t,start:+s,end:+n,score:+r,name:a,strand:"-"===o?-1:1}]})))}async function r(e,t){return(0,n.fetchAndMaybeUnzipText)(e,t)}function o(e,t){return e.map(((e,s)=>[e,t[s]]))}function i(e,t){let s=0;const n=[],a=new TextDecoder("utf8");for(;s<e.length;){const r=e.indexOf(10,s);if(-1===r)break;const o=e.subarray(s,r),i=a.decode(o).trim();if(i){const e=t(i);e&&n.push(e)}s=r+1}return n}function c(e){const[t,,s,n,a,r,,o,i,c,u,f,...l]=e.split("\t");return{tname:r,tstart:+o,tend:+i,qname:t,qstart:+s,qend:+n,strand:"-"===a?-1:1,extra:{numMatches:+c,blockLen:+u,mappingQual:+f,...Object.fromEntries(l.map((e=>{const t=e.indexOf(":");return[e.slice(0,t),e.slice(t+3)]})))}}}function u(e){const t=[];for(let s=e.length-2;s>=0;s-=2){t.push(e[s]);const n=e[s+1];"D"===n?t.push("I"):"I"===n?t.push("D"):t.push(n)}return t}function f(e){return e.replaceAll("D","K").replaceAll("I","D").replaceAll("K","I")}}}]);
//# sourceMappingURL=8965.9ece46e2.chunk.js.map