"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[9409],{69409:(e,t,a)=>{a.r(t),a.d(t,{default:()=>f});var s=a(46377),n=a(99546),r=a(99834),o=a(66885),i=a(6434),c=a(78054);class f 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{statusCallback:t=()=>{}}=e,a=this.getConf("assemblyNames"),s=this.pluginManager,o=(0,r.openLocation)(this.getConf("bed1Location"),s),i=(0,r.openLocation)(this.getConf("bed2Location"),s),f=(0,r.openLocation)(this.getConf("mcscanSimpleAnchorsLocation"),s),[l,m,u]=await(0,n.updateStatus)("Downloading data",t,(()=>Promise.all([o,i,f].map((t=>(0,c.TA)(t,e)))))),d=(0,c.fY)(l),p=(0,c.fY)(m);return{assemblyNames:a,feats:u.split(/\n|\r\n|\r/).filter((e=>!!e&&"###"!==e)).map(((e,t)=>{const[a,s,n,r,o,i]=e.split("\t"),c=d.get(a),f=d.get(s),l=p.get(n),m=p.get(r);if(!(c&&f&&l&&m))throw new Error(`feature not found, ${a} ${s} ${n} ${r} ${c} ${f} ${l} ${m}`);return[c,f,l,m,+o,"-"===i?-1:1,t]}))}}async hasDataForRefName(){return!0}getAssemblyNames(){return this.getConf("assemblyNames")}async getRefNames(e={}){const t=e.regions?.[0].assemblyName,{feats:a}=await this.setup(e),s=this.getAssemblyNames().indexOf(t);if(-1!==s){const e=new Set;for(const t of a)0===s?(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 a=>{const{assemblyNames:s,feats:r}=await this.setup(t),o=s.indexOf(e.assemblyName);if(-1!==o){const t=0===o;for(const o of r){const[r,c,f,l,m,u,d]=o;let p={refName:r.refName,start:Math.min(r.start,c.start),end:Math.max(r.end,c.end)},h={refName:f.refName,start:Math.min(f.start,l.start),end:Math.max(f.end,l.end)};t||([h,p]=[p,h]),p.refName===e.refName&&(0,n.doesIntersect2)(p.start,p.end,e.start,e.end)&&a.next(new i.A({...p,uniqueId:`${d}`,syntenyId:d,assemblyName:s[+!t],score:m,strand:u,mate:{...h,assemblyName:s[+t]}}))}}a.complete()}))}}},78054:(e,t,a)=>{a.d(t,{PX:()=>i,TA:()=>r,fY:()=>n,gJ:()=>l,qm:()=>f,xI:()=>c,yU:()=>o});var s=a(99546);function n(e){return new Map(e.split(/\n|\r\n|\r/).filter((e=>!!e||e.startsWith("#"))).map((e=>{const[t,a,s,n,r,o]=e.split("\t");return[n,{refName:t,start:+a,end:+s,score:+r,name:n,strand:"-"===o?-1:1}]})))}async function r(e,t){return(0,s.fetchAndMaybeUnzipText)(e,t)}function o(e,t){return e.map(((e,a)=>[e,t[a]]))}function i(e,t,a){const{statusCallback:n=()=>{}}=a||{};let r=0;const o=[],i=new TextDecoder("utf8");let c=0,f=performance.now();for(;r<e.length;){const a=e.indexOf(10,r);if(-1===a)break;const l=e.subarray(r,a),m=i.decode(l).trim();if(m){const e=t(m);e&&o.push(e)}c++%1e4==0&&performance.now()-f>50&&(n(`Loading ${(0,s.getProgressDisplayStr)(r,e.length)}`),f=performance.now()),r=a+1}return n(""),o}function c(e){const t=e.split("\t"),a=t.slice(12),s={numMatches:+t[9],blockLen:+t[10],mappingQual:+t[11]};if(a.length)for(const e of a){const t=e.indexOf(":");s[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:s}}function f(e){const t=[];for(let a=e.length-2;a>=0;a-=2){t.push(e[a]);const s=e[a+1];"D"===s?t.push("I"):"I"===s?t.push("D"):t.push(s)}return t}function l(e){return e.replaceAll("D","K").replaceAll("I","D").replaceAll("K","I")}}}]);
//# sourceMappingURL=9409.97cf6c86.chunk.js.map