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