@jbrowse/plugin-hic 2.6.2 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,7 +51,6 @@ class HicAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
51
51
  }
52
52
  async getResolution(bpPerPx, opts) {
53
53
  const { resolutions } = await this.setup(opts);
54
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
55
54
  let chosenResolution = resolutions.at(-1);
56
55
  for (let i = resolutions.length - 1; i >= 0; i -= 1) {
57
56
  const r = resolutions[i];
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
@@ -32,6 +9,7 @@ const offscreenCanvasUtils_1 = require("@jbrowse/core/util/offscreenCanvasUtils"
32
9
  const operators_1 = require("rxjs/operators");
33
10
  const configuration_1 = require("@jbrowse/core/configuration");
34
11
  const dataAdapterCache_1 = require("@jbrowse/core/data_adapters/dataAdapterCache");
12
+ const colord_1 = require("@jbrowse/core/util/colord");
35
13
  class HicRenderer extends ServerSideRendererType_1.default {
36
14
  constructor() {
37
15
  super(...arguments);
@@ -42,17 +20,15 @@ class HicRenderer extends ServerSideRendererType_1.default {
42
20
  const [region] = regions;
43
21
  const { dataAdapter } = await (0, dataAdapterCache_1.getAdapter)(this.pluginManager, sessionId, adapterConfig);
44
22
  const res = await dataAdapter.getResolution(bpPerPx / resolution);
45
- const Color = await Promise.resolve().then(() => __importStar(require('color'))).then(f => f.default);
46
23
  const w = res / (bpPerPx * Math.sqrt(2));
47
- const baseColor = Color((0, configuration_1.readConfObject)(config, 'baseColor'));
24
+ const baseColor = (0, colord_1.colord)((0, configuration_1.readConfObject)(config, 'baseColor'));
48
25
  if (features.length) {
49
26
  const offset = features[0].bin1;
50
27
  let maxScore = 0;
51
28
  let minBin = 0;
52
29
  let maxBin = 0;
53
30
  await (0, util_1.abortBreakPoint)(signal);
54
- for (let i = 0; i < features.length; i++) {
55
- const { bin1, bin2, counts } = features[i];
31
+ for (const { bin1, bin2, counts } of features) {
56
32
  maxScore = Math.max(counts, maxScore);
57
33
  minBin = Math.min(Math.min(bin1, bin2), minBin);
58
34
  maxBin = Math.max(Math.max(bin1, bin2), maxBin);
@@ -68,8 +44,7 @@ class HicRenderer extends ServerSideRendererType_1.default {
68
44
  }
69
45
  ctx.rotate(-Math.PI / 4);
70
46
  let start = Date.now();
71
- for (let i = 0; i < features.length; i++) {
72
- const { bin1, bin2, counts } = features[i];
47
+ for (const { bin1, bin2, counts } of features) {
73
48
  ctx.fillStyle = (0, configuration_1.readConfObject)(config, 'color', {
74
49
  count: counts,
75
50
  maxScore,
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Region } from '@jbrowse/core/util/types';
3
- declare const _default: (props: {
3
+ declare const HicRendering: (props: {
4
4
  blockKey: string;
5
5
  width: number;
6
6
  height: number;
7
7
  regions: Region[];
8
8
  bpPerPx: number;
9
9
  }) => React.JSX.Element;
10
- export default _default;
10
+ export default HicRendering;
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  const ui_1 = require("@jbrowse/core/ui");
8
8
  const mobx_react_1 = require("mobx-react");
9
- exports.default = (0, mobx_react_1.observer)(function HicRendering(props) {
9
+ const HicRendering = (0, mobx_react_1.observer)(function HicRendering(props) {
10
10
  const { width, height } = props;
11
11
  const canvasWidth = Math.ceil(width);
12
12
  // need to call this in render so we get the right observer behavior
13
13
  return (react_1.default.createElement("div", { style: { position: 'relative', width: canvasWidth, height } },
14
14
  react_1.default.createElement(ui_1.PrerenderedCanvas, { ...props, style: { position: 'absolute', left: 0, top: 0 } })));
15
15
  });
16
+ exports.default = HicRendering;
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Plugin_1 = __importDefault(require("@jbrowse/core/Plugin"));
7
+ const colord_1 = require("@jbrowse/core/util/colord");
7
8
  const HicRenderer_1 = __importDefault(require("./HicRenderer"));
8
9
  const HicTrack_1 = __importDefault(require("./HicTrack"));
9
10
  const LinearHicDisplay_1 = __importDefault(require("./LinearHicDisplay"));
@@ -47,9 +48,10 @@ class HicPlugin extends Plugin_1.default {
47
48
  });
48
49
  }
49
50
  configure(pluginManager) {
50
- pluginManager.jexl.addFunction('alpha', (color, value) => color.alpha(value));
51
- pluginManager.jexl.addFunction('hsl', (color) => color.hsl());
52
- pluginManager.jexl.addFunction('colorString', (color) => color.string());
51
+ const { jexl } = pluginManager;
52
+ jexl.addFunction('alpha', (color, n) => color.alpha(n));
53
+ jexl.addFunction('hsl', (color) => (0, colord_1.colord)(color.toHsl()));
54
+ jexl.addFunction('colorString', (color) => color.toHex());
53
55
  }
54
56
  }
55
57
  exports.default = HicPlugin;
@@ -44,7 +44,6 @@ export default class HicAdapter extends BaseFeatureDataAdapter {
44
44
  }
45
45
  async getResolution(bpPerPx, opts) {
46
46
  const { resolutions } = await this.setup(opts);
47
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
48
47
  let chosenResolution = resolutions.at(-1);
49
48
  for (let i = resolutions.length - 1; i >= 0; i -= 1) {
50
49
  const r = resolutions[i];
@@ -4,6 +4,7 @@ import { renderToAbstractCanvas } from '@jbrowse/core/util/offscreenCanvasUtils'
4
4
  import { toArray } from 'rxjs/operators';
5
5
  import { readConfObject } from '@jbrowse/core/configuration';
6
6
  import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache';
7
+ import { colord } from '@jbrowse/core/util/colord';
7
8
  export default class HicRenderer extends ServerSideRendererType {
8
9
  constructor() {
9
10
  super(...arguments);
@@ -14,17 +15,15 @@ export default class HicRenderer extends ServerSideRendererType {
14
15
  const [region] = regions;
15
16
  const { dataAdapter } = await getAdapter(this.pluginManager, sessionId, adapterConfig);
16
17
  const res = await dataAdapter.getResolution(bpPerPx / resolution);
17
- const Color = await import('color').then(f => f.default);
18
18
  const w = res / (bpPerPx * Math.sqrt(2));
19
- const baseColor = Color(readConfObject(config, 'baseColor'));
19
+ const baseColor = colord(readConfObject(config, 'baseColor'));
20
20
  if (features.length) {
21
21
  const offset = features[0].bin1;
22
22
  let maxScore = 0;
23
23
  let minBin = 0;
24
24
  let maxBin = 0;
25
25
  await abortBreakPoint(signal);
26
- for (let i = 0; i < features.length; i++) {
27
- const { bin1, bin2, counts } = features[i];
26
+ for (const { bin1, bin2, counts } of features) {
28
27
  maxScore = Math.max(counts, maxScore);
29
28
  minBin = Math.min(Math.min(bin1, bin2), minBin);
30
29
  maxBin = Math.max(Math.max(bin1, bin2), maxBin);
@@ -40,8 +39,7 @@ export default class HicRenderer extends ServerSideRendererType {
40
39
  }
41
40
  ctx.rotate(-Math.PI / 4);
42
41
  let start = Date.now();
43
- for (let i = 0; i < features.length; i++) {
44
- const { bin1, bin2, counts } = features[i];
42
+ for (const { bin1, bin2, counts } of features) {
45
43
  ctx.fillStyle = readConfObject(config, 'color', {
46
44
  count: counts,
47
45
  maxScore,
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Region } from '@jbrowse/core/util/types';
3
- declare const _default: (props: {
3
+ declare const HicRendering: (props: {
4
4
  blockKey: string;
5
5
  width: number;
6
6
  height: number;
7
7
  regions: Region[];
8
8
  bpPerPx: number;
9
9
  }) => React.JSX.Element;
10
- export default _default;
10
+ export default HicRendering;
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import { PrerenderedCanvas } from '@jbrowse/core/ui';
3
3
  import { observer } from 'mobx-react';
4
- export default observer(function HicRendering(props) {
4
+ const HicRendering = observer(function HicRendering(props) {
5
5
  const { width, height } = props;
6
6
  const canvasWidth = Math.ceil(width);
7
7
  // need to call this in render so we get the right observer behavior
8
8
  return (React.createElement("div", { style: { position: 'relative', width: canvasWidth, height } },
9
9
  React.createElement(PrerenderedCanvas, { ...props, style: { position: 'absolute', left: 0, top: 0 } })));
10
10
  });
11
+ export default HicRendering;
package/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
+ import { colord } from '@jbrowse/core/util/colord';
2
3
  import HicRendererF from './HicRenderer';
3
4
  import HicTrackF from './HicTrack';
4
5
  import LinearHicDisplayF from './LinearHicDisplay';
@@ -42,8 +43,9 @@ export default class HicPlugin extends Plugin {
42
43
  });
43
44
  }
44
45
  configure(pluginManager) {
45
- pluginManager.jexl.addFunction('alpha', (color, value) => color.alpha(value));
46
- pluginManager.jexl.addFunction('hsl', (color) => color.hsl());
47
- pluginManager.jexl.addFunction('colorString', (color) => color.string());
46
+ const { jexl } = pluginManager;
47
+ jexl.addFunction('alpha', (color, n) => color.alpha(n));
48
+ jexl.addFunction('hsl', (color) => colord(color.toHsl()));
49
+ jexl.addFunction('colorString', (color) => color.toHex());
48
50
  }
49
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-hic",
3
- "version": "2.6.2",
3
+ "version": "2.7.0",
4
4
  "description": "JBrowse 2 hic adapters, tracks, etc.",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -36,7 +36,6 @@
36
36
  "clean": "rimraf dist esm *.tsbuildinfo"
37
37
  },
38
38
  "dependencies": {
39
- "color": "^3.1.3",
40
39
  "hic-straw": "^2.0.3"
41
40
  },
42
41
  "peerDependencies": {
@@ -44,7 +43,7 @@
44
43
  "@jbrowse/plugin-linear-genome-view": "^2.0.0",
45
44
  "@mui/material": "^5.0.0",
46
45
  "mobx": "^6.0.0",
47
- "mobx-react": "^7.0.0",
46
+ "mobx-react": "^9.0.0",
48
47
  "mobx-state-tree": "^5.0.0",
49
48
  "react": ">=16.8.0",
50
49
  "rxjs": "^7.0.0"
@@ -55,5 +54,5 @@
55
54
  "publishConfig": {
56
55
  "access": "public"
57
56
  },
58
- "gitHead": "bbea587a402d9974acdd804a33f4b77f31a2fd5f"
57
+ "gitHead": "dbe7fb1af01fc89f833d2744635eb44a17365b41"
59
58
  }