From 7b4ba6076ef6fafe5866e7a75aab7dc95b0af282 Mon Sep 17 00:00:00 2001 From: Mark Keller <7525285+keller-mark@users.noreply.github.com> Date: Mon, 11 Sep 2023 17:48:14 -0400 Subject: [PATCH 1/8] Update package.json --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7fcc0d8..dab6b6f 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ "author": "Mark Keller", "license": "MIT", "dependencies": { - "zarr": "^0.4.0" + "@zarrita/core": "^0.0.3", + "@zarrita/storage": "^0.0.2", + "@zarrita/indexing": "^0.0.3" }, "devDependencies": { "@babel/core": "^7.9.0", From f0dea27b05074fd7ab98c45d75f6a75ace83c6b6 Mon Sep 17 00:00:00 2001 From: Mark Keller <7525285+keller-mark@users.noreply.github.com> Date: Mon, 11 Sep 2023 17:56:59 -0400 Subject: [PATCH 2/8] Update ZarrMultivecDataFetcher.js --- src/ZarrMultivecDataFetcher.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/ZarrMultivecDataFetcher.js b/src/ZarrMultivecDataFetcher.js index 03aae60..46fa799 100644 --- a/src/ZarrMultivecDataFetcher.js +++ b/src/ZarrMultivecDataFetcher.js @@ -1,4 +1,6 @@ -import { HTTPStore, openArray, slice } from 'zarr'; +import { FetchStore } from '@zarrita/storage'; +import { open as zarrOpen, root as zarrRoot } from '@zarrita/core'; +import { slice, get as zarrGet } from '@zarrita/indexing'; function multivecChunksToTileDenseArray(chunks, tileShape, isRow) { // Allocate a Float32Array for the tile (with length tile_size). @@ -55,7 +57,8 @@ const ZarrMultivecDataFetcher = function ZarrMultivecDataFetcher(HGC, ...args) { if (dataConfig.url) { // console.assert(dataConfig.url.endsWith('.zarr')); // S3 bucket must have a CORS policy to allow reading from any origin. - this.store = new HTTPStore(dataConfig.url, { supportedMethods: ['GET'] }); + this.store = new FetchStore(dataConfig.url); + this.storeRoot = zarrRoot(this.store); } if(dataConfig.row !== undefined) { @@ -67,14 +70,10 @@ const ZarrMultivecDataFetcher = function ZarrMultivecDataFetcher(HGC, ...args) { this.tilesetInfoLoading = true; // Use the tileset_info stored as JSON in file.zarr/.zattrs - return this.store - .getItem('.zattrs') - .then(bytes => { - const decoder = new TextDecoder('utf-8'); - const json = JSON.parse(decoder.decode(bytes)); - return json; - }) - .then(attrs => { + return this.storeRoot + .then(root => zarrOpen(root)) + .then(grp => { + const attrs = grp.attrs; this.tilesetInfoLoading = false; const chromSizes = attrs.multiscales.map(d => ([d.name, d.metadata.chromsize])); @@ -142,7 +141,7 @@ const ZarrMultivecDataFetcher = function ZarrMultivecDataFetcher(HGC, ...args) { } tile(z, x, tileId) { - const { store } = this; + const { storeRoot } = this; return this.tilesetInfo().then(tsInfo => { // const multiscales = tsInfo.multiscales; @@ -186,13 +185,11 @@ const ZarrMultivecDataFetcher = function ZarrMultivecDataFetcher(HGC, ...args) { // since data for each chromosome is stored in a separate zarr array. return Promise.all( chrChunks.map(([chrName, zStart, zEnd]) => { - return openArray({ - store, - path: `/chromosomes/${chrName}/${resolution}/`, - mode: 'r', - }).then(arr => (this.row !== undefined - ? arr.getRaw([this.row, slice(zStart, zEnd)]) - : arr.get([null, slice(zStart, zEnd)]) + return (await storeRoot) + .then(root => zarrOpen(root.resolve(`/chromosomes/${chrName}/${resolution}/`), { kind: "array" })) + .then(arr => (this.row !== undefined + ? zarrGet(arr, [this.row, slice(zStart, zEnd)]) + : zarrGet(arr, [null, slice(zStart, zEnd)]) )); }), ).then(chunks => { From 345255264bba841c7a3dd465a24c2a34ac2730ce Mon Sep 17 00:00:00 2001 From: Mark Keller <7525285+keller-mark@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:38:23 -0400 Subject: [PATCH 3/8] Use same config as higlass-bigwig-datafetchers --- .gitignore | 3 +- babel.config.js | 22 - bundle.mjs | 19 + src/demo/viewconfig.js => index.html | 68 +- package-lock.json | 4288 ++++++++++++ package.json | 72 +- rollup.demo.config.js | 141 - rollup.demo.utils.js | 22 - rollup.pkg.config.js | 88 - src/ZarrMultivecDataFetcher.js | 17 +- src/demo/Demo.js | 16 - src/demo/index.js | 11 - src/demo/index.scss | 3 - vite-demo.config.js | 6 + vite-test.config.js | 34 + yarn.lock | 9175 -------------------------- 16 files changed, 4459 insertions(+), 9526 deletions(-) delete mode 100644 babel.config.js create mode 100644 bundle.mjs rename src/demo/viewconfig.js => index.html (69%) create mode 100644 package-lock.json delete mode 100644 rollup.demo.config.js delete mode 100644 rollup.demo.utils.js delete mode 100644 rollup.pkg.config.js delete mode 100644 src/demo/Demo.js delete mode 100644 src/demo/index.js delete mode 100644 src/demo/index.scss create mode 100644 vite-demo.config.js create mode 100644 vite-test.config.js delete mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index 1e98f09..ca23b5b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ .DS_Store build-demo/ -build-pkg/ \ No newline at end of file +build-pkg/ +dist/ \ No newline at end of file diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index d262a58..0000000 --- a/babel.config.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = { - env: { - test: { - presets: [ - ["@babel/preset-env", { modules: "commonjs" }], - "@babel/preset-react" - ] - }, - production: { - presets: [ - ["@babel/preset-env", { modules: false }], - "@babel/preset-react" - ] - }, - development: { - presets: [ - ["@babel/preset-env", { modules: false }], - "@babel/preset-react" - ] - } - } -}; \ No newline at end of file diff --git a/bundle.mjs b/bundle.mjs new file mode 100644 index 0000000..643a286 --- /dev/null +++ b/bundle.mjs @@ -0,0 +1,19 @@ +import * as esbuild from "esbuild"; + +const env = process.env.APP_ENV || 'development'; + +import { NodeGlobalsPolyfillPlugin as globals } from '@esbuild-plugins/node-globals-polyfill'; +import { NodeModulesPolyfillPlugin as builtins } from '@esbuild-plugins/node-modules-polyfill'; + +esbuild.build({ + entryPoints: ["src/index.js"], + target: 'es2020', + format: 'esm', + sourcemap: true, + bundle: true, + minify: env === 'production', + outfile: env === 'production' ? 'dist/index.min.js' : 'dist/index.js', + plugins: [], + external: ['zarrita'], + watch: process.env.ESBUILD_MODE === 'watch', +}); \ No newline at end of file diff --git a/src/demo/viewconfig.js b/index.html similarity index 69% rename from src/demo/viewconfig.js rename to index.html index c5af6e9..7f2c334 100644 --- a/src/demo/viewconfig.js +++ b/index.html @@ -1,4 +1,58 @@ -const viewconfig = { + +
+ + +