"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[6834],{6834:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var s=r(89238),a=r(60972),n=r(46377),i=r(99834),c=r(66885),o=r(6434),d=r(84747),u=r(34796),f=r(4101);class h extends n.BaseFeatureDataAdapter{async configurePre(e){const t=this.pluginManager,r=new s.C({filehandle:(0,i.openLocation)(this.getConf("bigBedLocation"),t)}),n=await r.getHeader(e);return{bigbed:r,header:n,parser:new a.A({autoSql:n.autoSql})}}async configure(e){return this.cached||(this.cached=this.configurePre(e).catch((e=>{throw this.cached=void 0,e}))),this.cached}async getRefNames(e){const{header:t}=await this.configure(e);return Object.keys(t.refsByName)}async getHeader(e){const{parser:t,header:r}=await this.configure(e),{version:s,fileType:a}=r,{fields:n,...i}=t.autoSql;return{version:s,fileType:a,autoSql:{...i},fields:Object.fromEntries(n.map((({name:e,comment:t})=>[e,t])))}}getFeatures(e,t={}){const{refName:r,start:s,end:a}=e,{signal:n}=t;return(0,c.ObservableCreate)((async e=>{try{const{parser:i,bigbed:c}=await this.configure(t);(await c.getFeatureStream(r,s,a,{signal:n,basesPerSpan:a-s})).pipe((0,d.U)(),(0,u.T)((e=>{const t=i.parseLine(`${r}\t${e.start}\t${e.end}\t${e.rest}`,{uniqueId:e.uniqueId}),{blockCount:s,blockSizes:a,blockStarts:n,chromStarts:c}=t;if(s){const r=c||n||[],i=a,o=e.start;t.subfeatures=[];for(let a=0;a<s;a+=1){const s=(r[a]||0)+o,n=s+(i[a]||0);t.subfeatures.push({uniqueId:`${e.uniqueId}-${a}`,start:s,end:n,type:"block"})}}if(void 0===e.uniqueId)throw new Error("invalid bbi feature");const{chromStart:d,chromEnd:u,chrom:h,...l}=t,p=new o.A({id:`${this.id}-${e.uniqueId}`,data:{...l,start:e.start,end:e.end,refName:r}});return function(e){return e.get("thickStart")&&e.get("blockCount")&&0!==e.get("strand")}(p)?(0,f.B)(p):p}))).subscribe(e)}catch(t){e.error(t)}}),t.signal)}freeResources(){}}},4101:(e,t,r)=>{r.d(t,{B:()=>a,d:()=>n});var s=r(99546);function a(e){const t=e.children(),r=e.get("thickStart"),a=e.get("thickEnd"),n=e.get("refName");if(!r&&!a)return e;const i=t?t.filter((e=>"block"===e.get("type"))).sort(((e,t)=>e.get("start")-t.get("start"))):[],c=[];i.forEach((t=>{const s=t.get("start"),i=t.get("end");if(r>=i){const t=e.get("strand")>0?"five":"three";c.push({type:`${t}_prime_UTR`,start:s,end:i,refName:n})}else if(r>s&&r<i&&a>=i){const t=e.get("strand")>0?"five":"three";c.push({type:`${t}_prime_UTR`,start:s,end:r,refName:n},{type:"CDS",start:r,end:i,refName:n})}else if(r<=s&&a>=i)c.push({type:"CDS",start:s,end:i,refName:n});else if(r>s&&r<i&&a<i){const t=e.get("strand")>0?"five":"three",o=e.get("strand")>0?"three":"five";c.push({type:`${t}_prime_UTR`,start:s,end:r,refName:n},{type:"CDS",start:r,end:a,refName:n},{type:`${o}_prime_UTR`,start:a,end:i,refName:n})}else if(r<=s&&a>s&&a<i){const t=e.get("strand")>0?"three":"five";c.push({type:"CDS",start:s,end:a,refName:n},{type:`${t}_prime_UTR`,start:a,end:i,refName:n})}else if(a<=s){const t=e.get("strand")>0?"three":"five";c.push({type:`${t}_prime_UTR`,start:s,end:i,refName:n})}}));const o=Object.fromEntries(e.tags().map((t=>[t,e.get(t)])));return o.subfeatures=c,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,c,o,d){const u=e.split("\t"),f=u[t],h=+u[r],l=r===n?1:0,p=+u[n]+l,m=d?function(e,t){return Object.fromEntries(t.split("\t").map(((t,r)=>[e[r],t])))}(d,e):c.parseLine(e,{uniqueId:o}),{blockCount:b,blockSizes:g,blockStarts:S,chromStarts:k}=m;if(b){const e=k||S||[],t=g,r=h;m.subfeatures=[];for(let s=0;s<b;s+=1){const a=(e[s]||0)+r,n=a+(t[s]||0);m.subfeatures.push({uniqueId:`${o}-${s}`,start:a,end:n,refName:f,type:"block"})}}i&&(m.score=+m[i]),delete m.chrom,delete m.chromStart,delete m.chromEnd;const y=new s.SimpleFeature({...m,start:h,end:p,refName:f,uniqueId:o});return y.get("thickStart")?a(y):y}}}]);
//# sourceMappingURL=6834.53cb1fb3.chunk.js.map