"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[5668],{15668:(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var s=r(79460),a=r(56798),n=r(59062),i=r(16979),o=r(71396),c=r(48026),l=r(71631);class d extends a.BaseFeatureDataAdapter{intervalTrees={};static capabilities=["getFeatures","getRefNames"];async loadDataP(e={}){const t=this.pluginManager,r=this.getConf("bedLocation"),a=await(0,n.openLocation)(r,t).readFile(e),i=function(e){return 31===e[0]&&139===e[1]&&8===e[2]}(a)?await(0,l.unzip)(a):a;if(i.length>536870888)throw new Error("Data exceeds maximum string length (512MB)");const o=new TextDecoder("utf8",{fatal:!0}).decode(i).split(/\n|\r\n|\r/).filter((e=>!!e)),c=[];let d=0;for(;d<o.length&&o[d].startsWith("#");d++)c.push(o[d]);const u=c.join("\n"),h={};for(;d<o.length;d++){const e=o[d],t=e.indexOf("\t"),r=e.slice(0,t);h[r]||(h[r]=[]),h[r].push(e)}const f=this.getConf("autoSql");return{header:u,features:h,parser:new s.Z({autoSql:f}),columnNames:this.getConf("columnNames"),scoreColumn:this.getConf("scoreColumn"),colRef:this.getConf("colRef"),colStart:this.getConf("colStart"),colEnd:this.getConf("colEnd")}}async loadData(e={}){return this.bedFeatures||(this.bedFeatures=this.loadDataP(e).catch((e=>{throw this.bedFeatures=void 0,e}))),this.bedFeatures}async getRefNames(e={}){const{features:t}=await this.loadData(e);return Object.keys(t)}async getHeader(e={}){const{header:t}=await this.loadData(e);return t}async getNames(){const{header:e,columnNames:t}=await this.loadData();if(t.length)return t;const r=e.split(/\n|\r\n|\r/).filter((e=>!!e)).at(-1);return r?.includes("\t")?r.slice(1).split("\t").map((e=>e.trim())):void 0}async loadFeatureIntervalTreeHelper(e){const{colRef:t,colStart:r,colEnd:s,features:a,parser:n,scoreColumn:i}=await this.loadData(),l=a[e];if(!l)return;const d=await this.getNames(),u=new c.ZP,h=l.map(((a,c)=>{const l=`${this.id}-${e}-${c}`;return(0,o.P)(a,t,r,s,i,n,l,d)}));for(const e of h)u.insert([e.get("start"),e.get("end")],e);return u}async loadFeatureIntervalTree(e){return this.intervalTrees[e]||(this.intervalTrees[e]=this.loadFeatureIntervalTreeHelper(e).catch((t=>{throw this.intervalTrees[e]=void 0,t}))),this.intervalTrees[e]}getFeatures(e,t={}){return(0,i.ObservableCreate)((async t=>{const{start:r,end:s,refName:a}=e,n=await this.loadFeatureIntervalTree(a);n?.search([r,s]).forEach((e=>t.next(e))),t.complete()}),t.signal)}freeResources(){}}},71396:(e,t,r)=>{r.d(t,{P:()=>n,d:()=>a});var s=r(90872);function a(e){const t=e.children(),r=e.get("thickStart"),a=e.get("thickEnd");if(!r&&!a)return e;const n=t?t.filter((e=>"block"===e.get("type"))).sort(((e,t)=>e.get("start")-t.get("start"))):[],i=[];n.forEach((t=>{const s=t.get("start"),n=t.get("end");if(r>=n){const t=e.get("strand")>0?"five":"three";i.push({type:`${t}_prime_UTR`,start:s,end:n})}else if(r>s&&r<n&&a>=n){const t=e.get("strand")>0?"five":"three";i.push({type:`${t}_prime_UTR`,start:s,end:r},{type:"CDS",start:r,end:n})}else if(r<=s&&a>=n)i.push({type:"CDS",start:s,end:n});else if(r>s&&r<n&&a<n){const t=e.get("strand")>0?"five":"three",o=e.get("strand")>0?"three":"five";i.push({type:`${t}_prime_UTR`,start:s,end:r},{type:"CDS",start:r,end:a},{type:`${o}_prime_UTR`,start:a,end:n})}else if(r<=s&&a>s&&a<n){const t=e.get("strand")>0?"three":"five";i.push({type:"CDS",start:s,end:a},{type:`${t}_prime_UTR`,start:a,end:n})}else if(a<=s){const t=e.get("strand")>0?"three":"five";i.push({type:`${t}_prime_UTR`,start:s,end:n})}}));const o=Object.fromEntries(e.tags().map((t=>[t,e.get(t)])));return o.subfeatures=i,o.type="mRNA",o.uniqueId=e.id(),delete o.chromStarts,delete o.chromStart,delete o.chromEnd,delete o.chrom,delete o.blockStarts,delete o.blockSizes,delete o.blockCount,delete o.thickStart,delete o.thickEnd,new s.SimpleFeature({data:o,id:e.id()})}function n(e,t,r,n,i,o,c,l){const d=e.split("\t"),u=d[t],h=+d[r],f=r===n?1:0,p=+d[n]+f,g=l?function(e,t){return Object.fromEntries(t.split("\t").map(((t,r)=>[e[r],t])))}(l,e):o.parseLine(e,{uniqueId:c}),{blockCount:m,blockSizes:b,blockStarts:w,chromStarts:y}=g;if(m){const e=y||w||[],t=b,r=h;g.subfeatures=[];for(let s=0;s<m;s+=1){const a=(e[s]||0)+r,n=a+(t[s]||0);g.subfeatures.push({uniqueId:`${c}-${s}`,start:a,end:n,type:"block"})}}i&&(g.score=+g[i]),delete g.chrom,delete g.chromStart,delete g.chromEnd;const S=new s.SimpleFeature({...g,start:h,end:p,refName:u,uniqueId:c});return S.get("thickStart")?a(S):S}}}]);
//# sourceMappingURL=5668.c52777bd.chunk.js.map