"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 a=s(46377),n=s(99546),r=s(99834),o=s(66885),i=s(78054);class c 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{statusCallback:t=()=>{}}=e,s=this.getConf("assemblyNames"),a=this.pluginManager,o=(0,r.openLocation)(this.getConf("bed1Location"),a),c=(0,r.openLocation)(this.getConf("bed2Location"),a),u=(0,r.openLocation)(this.getConf("mcscanAnchorsLocation"),a),[l,f,m]=await(0,n.updateStatus)("Downloading data",t,()=>Promise.all([o,c,u].map(t=>(0,i.TA)(t,e)))),p=(0,i.fY)(l),d=(0,i.fY)(f);return{assemblyNames:s,feats:m.split(/\n|\r\n|\r/).filter(e=>!!e&&"###"!==e).map((e,t)=>{const[s,a,n]=e.split("\t"),r=p.get(s),o=d.get(a);if(!r||!o)throw new Error(`feature not found, ${s} ${a} ${r} ${o}`);return[r,o,+n,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)e.add(0===a?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:a,feats:r}=await this.setup(t),o=a.indexOf(e.assemblyName);if(-1!==o){const t=0===o;for(const i of r){const[r,c,u,l]=i,[f,m]=t?[r,c]:[c,r];f.refName===e.refName&&(0,n.doesIntersect2)(e.start,e.end,f.start,f.end)&&s.next(new n.SimpleFeature({...f,uniqueId:`${o}-${l}`,syntenyId:l,strand:f.strand*m.strand,assemblyName:a[+!t],score:u,mate:{...m,assemblyName:a[+t]}}))}}s.complete()})}}},78054:(e,t,s)=>{s.d(t,{TA:()=>r,fY:()=>n,gJ:()=>u,qm:()=>c,xI:()=>i,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){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 c(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 u(e){return e.replaceAll("D","K").replaceAll("I","D").replaceAll("K","I")}}}]);
//# sourceMappingURL=8965.29f5feae.chunk.js.map