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