Mercurial > repos > fubar > jbrowse2
view x/static/js/3525.e74d3ff0.chunk.js @ 125:49f3d3878413 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5ea1f9c1eef1de76232e69aa6d34cda77d90d566
author | fubar |
---|---|
date | Sat, 05 Oct 2024 23:58:05 +0000 |
parents | |
children |
line wrap: on
line source
(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[3525],{33525:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>S});var r=s(16308),a=s.n(r),i=s(47046),n=s(15396),o=s.n(n);async function c(t,e,s={}){const{defaultContent:r={}}=s;let a;try{return a=await e(t,{encoding:"utf8"}),JSON.parse(a)}catch(t){if("ENOENT"===t.code||404===t.status||t.message.includes("404")||t.message.includes("ENOENT"))return r;throw t}}function h(t,e="."){return o()(t,e)}class l{constructor({readFile:t,cacheSize:e=100}){if(this.topList=[],this.chunkCache=new i.A({cache:new(a())({maxSize:e}),fill:this.readChunkItems.bind(this)}),this.readFile=t,!this.readFile)throw new Error('must provide a "readFile" function')}importExisting(t,e,s,r,a){this.topList=t,this.attrs=e,this.start=e.makeFastGetter("Start"),this.end=e.makeFastGetter("End"),this.lazyClass=a,this.baseURL=s,this.lazyUrlTemplate=r}binarySearch(t,e,s){let r,a=-1,i=t.length;for(;i-a>1;)r=a+i>>>1,s(t[r])>=e?i=r:a=r;return s===this.end?i:a}readChunkItems(t){return c(h(this.lazyUrlTemplate.replace(/\{Chunk\}/gi,t),this.baseURL),this.readFile,{defaultContent:[]})}async*iterateSublist(t,e,s,r,a,i,n){const o=this.attrs.makeGetter("Chunk"),c=this.attrs.makeGetter("Sublist"),h=[];for(let l=this.binarySearch(t,e,a);l<t.length&&l>=0&&r*i(t[l])<r*s;l+=r){if(t[l][0]===this.lazyClass){const e=o(t[l]),s=this.chunkCache.get(e,e).then((t=>[t,e]));h.push(s)}else yield[t[l],n.concat(l)];const u=c(t[l]);u&&(yield*this.iterateSublist(u,e,s,r,a,i,n.concat(l)))}for(let t=0;t<h.length;t+=1){const[o,c]=await h[t];o&&(yield*this.iterateSublist(o,e,s,r,a,i,[...n,c]))}}async*iterate(t,e){const s=t>e?-1:1,r=t>e?this.start:this.end,a=t>e?this.end:this.start;this.topList.length>0&&(yield*this.iterateSublist(this.topList,t,e,s,r,a,[0]))}async histogram(t,e,s){const r=new Array(s);r.fill(0);const a=(e-t)/s;for await(const i of this.iterate(t,e)){const e=Math.max(0,(this.start(i)-t)/a|0),n=Math.min(s,(this.end(i)-t)/a|0);for(let t=e;t<=n;t+=1)r[t]+=1}return r}}const u=class{constructor(t){this.classes=t,this.fields=[];for(let e=0;e<t.length;e+=1){this.fields[e]={};for(let s=0;s<t[e].attributes.length;s+=1)this.fields[e][t[e].attributes[s]]=s+1;void 0===t[e].proto&&(t[e].proto={}),void 0===t[e].isArrayAttr&&(t[e].isArrayAttr={})}}attrIndices(t){return this.classes.map((e=>e.attributes.indexOf(t)+1||e.attributes.indexOf(t.toLowerCase())+1||void 0))}get(t,e){if(e in this.fields[t[0]])return t[this.fields[t[0]][e]];const s=e.toLowerCase();if(s in this.fields[t[0]])return t[this.fields[t[0]][s]];const r=this.classes[t[0]].attributes.length+1;return r>=t.length||!(e in t[r])?e in this.classes[t[0]].proto?this.classes[t[0]].proto[e]:void 0:t[r][e]}makeSetter(t){return(e,s)=>{this.set(e,t,s)}}makeGetter(t){return e=>this.get(e,t)}makeFastGetter(t){const e=this.attrIndices(t);return function(t){if(void 0!==e[t[0]])return t[e[t[0]]]}}accessors(){return this._accessors||(this._accessors=this._makeAccessors()),this._accessors}_makeAccessors(){const t={},e={get(t){const e=this.get.field_accessors[t.toLowerCase()];if(e)return e.call(this)},set(t,e){const s=this.set.field_accessors[t];if(s)return s.call(this,e)},tags(){return s[this[0]]||[]}};e.get.field_accessors={},e.set.field_accessors={},this.classes.forEach(((e,s)=>{(e.attributes||[]).forEach(((e,r)=>{t[e]=t[e]||[],t[e][s]=r+1,e=e.toLowerCase(),t[e]=t[e]||[],t[e][s]=r+1}))}));const s=this.classes.map((t=>t.attributes));return Object.keys(t).forEach((s=>{const r=t[s];e.get.field_accessors[s]=r?function(){return this[r[this[0]]]}:function(){}})),e}};class d{constructor({urlTemplate:t,chunkSize:e,length:s,cacheSize:r=100,readFile:n},o){if(this.urlTemplate=t,this.chunkSize=e,this.length=s,this.baseUrl=void 0===o?"":o,this.readFile=n,!n)throw new Error("must provide readFile callback");this.chunkCache=new i.A({cache:new(a())({maxSize:r}),fill:this.getChunk.bind(this)})}index(t,e,s){this.range(t,t,e,void 0,s)}async*range(t,e){t=Math.max(0,t),e=Math.min(e,this.length-1);const s=Math.floor(t/this.chunkSize),r=Math.floor(e/this.chunkSize),a=[];for(let t=s;t<=r;t+=1)a.push(this.chunkCache.get(t,t));for(let s=0;s<a.length;s+=1){const[r,i]=await a[s];yield*this.filterChunkData(t,e,r,i)}}async getChunk(t){let e=this.urlTemplate.replace(/\{Chunk\}/gi,t);return this.baseUrl&&(e=h(e,this.baseUrl)),[t,await c(e,this.readFile)]}*filterChunkData(t,e,s,r){const a=s*this.chunkSize,i=Math.max(0,t-a),n=Math.min(e-a,this.chunkSize-1);for(let t=i;t<=n;t+=1)yield[t+a,r[t]]}}function f(){return this._uniqueID}function g(){return this._parent}function b(){return this.get("subfeatures")}const m=class{constructor({baseUrl:t,urlTemplate:e,readFile:s,cacheSize:r=10}){if(this.baseUrl=t,this.urlTemplates={root:e},this.readFile=s,!this.readFile)throw new Error('must provide a "readFile" function argument');this.dataRootCache=new i.A({cache:new(a())({maxSize:r}),fill:this.fetchDataRoot.bind(this)})}makeNCList(){return new l({readFile:this.readFile})}loadNCList(t,e,s){t.nclist.importExisting(e.intervals.nclist,t.attrs,s,e.intervals.urlTemplate,e.intervals.lazyClass)}getDataRoot(t){return this.dataRootCache.get(t,t)}fetchDataRoot(t){const e=h(this.urlTemplates.root.replace(/{\s*refseq\s*}/g,t),this.baseUrl);return c(e,this.readFile).then((t=>this.parseTrackInfo(t,e)))}parseTrackInfo(t,e){const s={nclist:this.makeNCList(),stats:{featureCount:t.featureCount||0}};t.intervals&&(s.attrs=new u(t.intervals.classes),this.loadNCList(s,t,e));const{histograms:r}=t;if(r&&r.meta){for(let t=0;t<r.meta.length;t+=1)r.meta[t].lazyArray=new d({...r.meta[t].arrayParams,readFile:this.readFile},e);s._histograms=r}return s._histograms&&Object.keys(s._histograms).forEach((t=>{s._histograms[t].forEach((t=>{Object.keys(t).forEach((e=>{"string"==typeof t[e]&&String(Number(t[e]))===t[e]&&(t[e]=Number(t[e]))}))}))})),s}async getRegionStats(t){return(await this.getDataRoot(t.ref)).stats}async getRegionFeatureDensities({refName:t,start:e,end:s,numBins:r,basesPerBin:a}){const i=await this.getDataRoot(t);if(r)a=(s-e)/r;else{if(!a)throw new TypeError("numBins or basesPerBin arg required for getRegionFeatureDensities");r=Math.ceil((s-e)/a)}const n=(i._histograms.stats||[]).find((t=>t.basesPerBin>=a));let o=i._histograms.meta[0];for(let t=0;t<i._histograms.meta.length;t+=1)a>=i._histograms.meta[t].basesPerBin&&(o=i._histograms.meta[t]);let c=a/o.basesPerBin;if(c>.9&&Math.abs(c-Math.round(c))<1e-4){const t=Math.floor(e/o.basesPerBin);c=Math.round(c);const s=[];for(let t=0;t<r;t+=1)s[t]=0;for await(const[e,a]of o.lazyArray.range(t,t+c*r-1))s[Math.floor((e-t)/c)]+=a;return{bins:s,stats:n}}return{bins:await i.nclist.histogram(e,s,r),stats:n}}async*getFeatures({refName:t,start:e,end:s}){const r=await this.getDataRoot(t),a=r.attrs&&r.attrs.accessors();for await(const[i,n]of r.nclist.iterate(e,s)){if(!i.decorated){const e=n.join(",");this.decorateFeature(a,i,`${t},${e}`)}yield i}}decorateFeature(t,e,s,r){e.get=t.get,e.tags=t.tags,e._uniqueID=s,e.id=f,e._parent=r,e.parent=g,e.children=b,(e.get("subfeatures")||[]).forEach(((r,a)=>{this.decorateFeature(t,r,`${s}-${a}`,e)})),e.decorated=!0}};var p=s(46377),w=s(66885),y=s(99546),k=s(45834);const C={refName:"seq_id"},F={seq_id:"refName"};class T{constructor(t,e,s){this.ncFeature=t,this.uniqueId=s||t.id(),this.parentHandle=e}set(){throw new Error("not implemented")}jb2TagToJb1Tag(t){return(C[t]||t).toLowerCase()}jb1TagToJb2Tag(t){const e=t.toLowerCase();return F[e]||e}get(t){const e=this.ncFeature.get(this.jb2TagToJb1Tag(t));return e&&"subfeatures"===t?e.map((t=>new T(t,this))):e}tags(){return this.ncFeature.tags().map((t=>this.jb1TagToJb2Tag(t)))}id(){return this.uniqueId}parent(){return this.parentHandle}children(){return this.get("subfeatures")}toJSON(){const t={uniqueId:this.id()};return this.ncFeature.tags().forEach((e=>{const s=this.jb1TagToJb2Tag(e),r=this.ncFeature.get(e);"subfeatures"===s?t.subfeatures=(r||[]).map((t=>new T(t,this).toJSON())):t[s]=r})),t}}class S extends p.BaseFeatureDataAdapter{constructor(t,e,s){super(t,e,s);const r=this.getConf("refNames"),a=this.getConf("rootUrlTemplate");this.configRefNames=r,this.nclist=new m({baseUrl:"",urlTemplate:a.uri,readFile:t=>new k.Tx(String(a.baseUri?new URL(t,a.baseUri).toString():t)).readFile()})}getFeatures(t,e={}){return(0,w.ObservableCreate)((async s=>{const{signal:r}=e;for await(const a of this.nclist.getFeatures(t,e))(0,y.checkAbortSignal)(r),s.next(this.wrapFeature(a));s.complete()}))}wrapFeature(t){return new T(t,void 0,`${this.id}-${t.id()}`)}async hasDataForRefName(t){const e=await this.nclist.getDataRoot(t);return!!e?.stats?.featureCount}async getRefNames(){return this.configRefNames||[]}freeResources(){}}},47046:(t,e,s)=>{"use strict";s.d(e,{A:()=>n});class r{}class a{constructor(){this.signals=new Set,this.abortController=new AbortController}addSignal(t=new r){if(this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(t),t.aborted?this.handleAborted(t):"function"==typeof t.addEventListener&&t.addEventListener("abort",(()=>{this.handleAborted(t)}))}handleAborted(t){this.signals.delete(t),0===this.signals.size&&this.abortController.abort()}get signal(){return this.abortController.signal}abort(){this.abortController.abort()}}class i{constructor(){this.callbacks=new Set}addCallback(t=()=>{}){this.callbacks.add(t),t(this.currentMessage)}callback(t){this.currentMessage=t;for(const e of this.callbacks)e(t)}}class n{constructor({fill:t,cache:e}){if("function"!=typeof t)throw new TypeError("must pass a fill function");if("object"!=typeof e)throw new TypeError("must pass a cache object");if("function"!=typeof e.get||"function"!=typeof e.set||"function"!=typeof e.delete)throw new TypeError("cache must implement get(key), set(key, val), and and delete(key)");this.cache=e,this.fillCallback=t}static isAbortException(t){return"AbortError"===t.name||"ERR_ABORTED"===t.code||"AbortError: aborted"===t.message||"Error: aborted"===t.message}evict(t,e){this.cache.get(t)===e&&this.cache.delete(t)}fill(t,e,s,r){const n=new a,o=new i;o.addCallback(r);const c={aborter:n,promise:this.fillCallback(e,n.signal,(t=>{o.callback(t)})),settled:!1,statusReporter:o,get aborted(){return this.aborter.signal.aborted}};c.aborter.addSignal(s),c.aborter.signal.addEventListener("abort",(()=>{c.settled||this.evict(t,c)})),c.promise.then((()=>{c.settled=!0}),(()=>{c.settled=!0,this.evict(t,c)})).catch((t=>{throw console.error(t),t})),this.cache.set(t,c)}static checkSinglePromise(t,e){function s(){if(null==e?void 0:e.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return t.then((t=>(s(),t)),(t=>{throw s(),t}))}has(t){return this.cache.has(t)}get(t,e,s,r){if(!s&&e instanceof AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");const a=this.cache.get(t);return a?a.aborted&&!a.settled?(this.evict(t,a),this.get(t,e,s,r)):a.settled?a.promise:(a.aborter.addSignal(s),a.statusReporter.addCallback(r),n.checkSinglePromise(a.promise,s)):(this.fill(t,e,s,r),n.checkSinglePromise(this.cache.get(t).promise,s))}delete(t){const e=this.cache.get(t);e&&(e.settled||e.aborter.abort(),this.cache.delete(t))}clear(){const t=this.cache.keys();let e=0;for(let s=t.next();!s.done;s=t.next())this.delete(s.value),e+=1;return e}}},15396:function(t){t.exports=function(){"use strict";const t=/^[\w+.-]+:\/\//,e=/^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,s=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function r(t){return t.startsWith("/")}function a(t){return/^[.?#]/.test(t)}function i(t){const s=e.exec(t);return n(s[1],s[2]||"",s[3],s[4]||"",s[5]||"/",s[6]||"",s[7]||"")}function n(t,e,s,r,a,i,n){return{scheme:t,user:e,host:s,port:r,path:a,query:i,hash:n,type:7}}function o(e){if(function(t){return t.startsWith("//")}(e)){const t=i("http:"+e);return t.scheme="",t.type=6,t}if(r(e)){const t=i("http://foo.com"+e);return t.scheme="",t.host="",t.type=5,t}if(function(t){return t.startsWith("file:")}(e))return function(t){const e=s.exec(t),a=e[2];return n("file:","",e[1]||"","",r(a)?a:"/"+a,e[3]||"",e[4]||"")}(e);if(function(e){return t.test(e)}(e))return i(e);const a=i("http://foo.com/"+e);return a.scheme="",a.host="",a.type=e?e.startsWith("?")?3:e.startsWith("#")?2:4:1,a}function c(t,e){const s=e<=4,r=t.path.split("/");let a=1,i=0,n=!1;for(let t=1;t<r.length;t++){const e=r[t];e?(n=!1,"."!==e&&(".."!==e?(r[a++]=e,i++):i?(n=!0,i--,a--):s&&(r[a++]=e))):n=!0}let o="";for(let t=1;t<a;t++)o+="/"+r[t];(!o||n&&!o.endsWith("/.."))&&(o+="/"),t.path=o}return function(t,e){if(!t&&!e)return"";const s=o(t);let r=s.type;if(e&&7!==r){const t=o(e),a=t.type;switch(r){case 1:s.hash=t.hash;case 2:s.query=t.query;case 3:case 4:!function(t,e){c(e,e.type),"/"===t.path?t.path=e.path:t.path=function(t){if(t.endsWith("/.."))return t;const e=t.lastIndexOf("/");return t.slice(0,e+1)}(e.path)+t.path}(s,t);case 5:s.user=t.user,s.host=t.host,s.port=t.port;case 6:s.scheme=t.scheme}a>r&&(r=a)}c(s,r);const i=s.query+s.hash;switch(r){case 2:case 3:return i;case 4:{const r=s.path.slice(1);return r?a(e||t)&&!a(r)?"./"+r+i:r+i:i||"."}case 5:return s.path+i;default:return s.scheme+"//"+s.user+s.host+s.port+s.path+i}}}()}}]); //# sourceMappingURL=3525.e74d3ff0.chunk.js.map