"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[8965],{28965:(e,t,s)=>{s.r(t),s.d(t,{default:()=>i});var n=s(46377),a=s(99546),r=s(99834),o=s(66885),c=s(78054);class i 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{statusCallback:t=()=>{}}=e,s=this.getConf("assemblyNames"),n=this.pluginManager,o=(0,r.openLocation)(this.getConf("bed1Location"),n),i=(0,r.openLocation)(this.getConf("bed2Location"),n),l=(0,r.openLocation)(this.getConf("mcscanAnchorsLocation"),n),[u,f,m]=await(0,a.updateStatus)("Downloading data",t,(()=>Promise.all([o,i,l].map((t=>(0,c.TA)(t,e)))))),p=(0,c.fY)(u),d=(0,c.fY)(f);return{assemblyNames:s,feats:m.split(/\n|\r\n|\r/).filter((e=>!!e&&"###"!==e)).map(((e,t)=>{const[s,n,a]=e.split("\t"),r=p.get(s),o=d.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;for(const c of r){const[r,i,l,u]=c,[f,m]=t?[r,i]:[i,r];f.refName===e.refName&&(0,a.doesIntersect2)(e.start,e.end,f.start,f.end)&&s.next(new a.SimpleFeature({...f,uniqueId:`${o}-${u}`,syntenyId:u,strand:f.strand*m.strand,assemblyName:n[+!t],score:l,mate:{...m,assemblyName:n[+t]}}))}}s.complete()}))}}},78054:(e,t,s)=>{s.d(t,{PX:()=>c,TA:()=>r,fY:()=>a,gJ:()=>u,qm:()=>l,xI:()=>i,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 c(e,t,s){const{statusCallback:a=()=>{}}=s||{};let r=0;const o=[],c=new TextDecoder("utf8");let i=0,l=performance.now();for(;r<e.length;){const s=e.indexOf(10,r);if(-1===s)break;const u=e.subarray(r,s),f=c.decode(u).trim();if(f){const e=t(f);e&&o.push(e)}i++%1e4==0&&performance.now()-l>50&&(a(`Loading ${(0,n.getProgressDisplayStr)(r,e.length)}`),l=performance.now()),r=s+1}return a(""),o}function i(e){const t=e.split("\t"),s=t.slice(12),n={numMatches:+t[9],blockLen:+t[10],mappingQual:+t[11]};if(s.length)for(const e of s){const t=e.indexOf(":");n[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:n}}function l(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 u(e){return e.replaceAll("D","K").replaceAll("I","D").replaceAll("K","I")}}}]);
//# sourceMappingURL=8965.9a00813d.chunk.js.map