@jbrowse/plugin-sequence 3.0.3 → 3.0.5

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.
@@ -1,7 +1,7 @@
1
1
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
2
2
  import type { Feature, Region } from '@jbrowse/core/util';
3
3
  import type { Theme } from '@mui/material';
4
- declare const DivSequenceRendering: (props: {
4
+ declare const DivSequenceRendering: ({ exportSVG, features, regions, colorByCDS, bpPerPx, rowHeight, sequenceHeight, theme, showForward, showReverse, showTranslation, }: {
5
5
  exportSVG?: {
6
6
  rasterizeLayers: boolean;
7
7
  };
@@ -5,7 +5,7 @@ const react_1 = require("react");
5
5
  const ui_1 = require("@jbrowse/core/ui");
6
6
  const util_1 = require("@jbrowse/core/util");
7
7
  const mobx_react_1 = require("mobx-react");
8
- function Translation({ codonTable, seq, frame, bpPerPx, colorByCDS, region, seqStart, height, y, reverse = false, theme, }) {
8
+ function Translation({ codonTable, seq, frame, width, bpPerPx, colorByCDS, region, seqStart, height, y, reverse = false, theme, }) {
9
9
  var _a, _b;
10
10
  const normalizedFrame = Math.abs(frame) - 1;
11
11
  const seqFrame = seqStart % 3;
@@ -23,7 +23,6 @@ function Translation({ codonTable, seq, frame, bpPerPx, colorByCDS, region, seqS
23
23
  codon: normalizedCodon.toUpperCase(),
24
24
  });
25
25
  }
26
- const width = (region.end - region.start) / bpPerPx;
27
26
  const codonWidth = (1 / bpPerPx) * 3;
28
27
  const renderLetter = 1 / bpPerPx >= 12;
29
28
  const frameOffset = frameShift / bpPerPx;
@@ -64,7 +63,7 @@ function Sequence({ bpPerPx, region, feature, sequenceType, theme, height, seq,
64
63
  return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("rect", { x: x, y: y, width: w, height: height, fill: color ? color.main : '#aaa', stroke: render ? '#555' : 'none' }), render ? ((0, jsx_runtime_1.jsx)("text", { x: x + w / 2, y: y + height / 2, dominantBaseline: "middle", textAnchor: "middle", fontSize: height - 2, fill: color ? theme.palette.getContrastText(color.main) : 'black', children: letter })) : null] }, `${letter}-${index}`));
65
64
  }) }));
66
65
  }
67
- function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new Map(), showReverse = true, showForward = true, showTranslation = true, sequenceType = 'dna', bpPerPx, rowHeight, }) {
66
+ function SequenceSVG({ regions, width, theme: configTheme, colorByCDS, features = new Map(), showReverse = true, showForward = true, showTranslation = true, sequenceType = 'dna', bpPerPx, rowHeight, }) {
68
67
  const region = regions[0];
69
68
  const theme = (0, ui_1.createJBrowseTheme)(configTheme);
70
69
  const codonTable = (0, util_1.generateCodonTable)(util_1.defaultCodonTable);
@@ -83,7 +82,7 @@ function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new M
83
82
  const [topFrames, bottomFrames] = region.reversed
84
83
  ? [reverseFrames.toReversed(), forwardFrames.toReversed()]
85
84
  : [forwardFrames, reverseFrames];
86
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [topFrames.map(index => ((0, jsx_runtime_1.jsx)(Translation, { colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: region.reversed }, `translation-${index}`))), showForward && showSequence ? ((0, jsx_runtime_1.jsx)(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? (0, util_1.complement)(seq) : seq, bpPerPx: bpPerPx, theme: theme })) : null, showReverse && showSequence ? ((0, jsx_runtime_1.jsx)(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? seq : (0, util_1.complement)(seq), bpPerPx: bpPerPx, theme: theme })) : null, bottomFrames.map(index => ((0, jsx_runtime_1.jsx)(Translation, { colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: !region.reversed }, `rev-translation-${index}`)))] }));
85
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [topFrames.map(index => ((0, jsx_runtime_1.jsx)(Translation, { width: width, colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: region.reversed }, `translation-${index}`))), showForward && showSequence ? ((0, jsx_runtime_1.jsx)(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? (0, util_1.complement)(seq) : seq, bpPerPx: bpPerPx, theme: theme })) : null, showReverse && showSequence ? ((0, jsx_runtime_1.jsx)(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? seq : (0, util_1.complement)(seq), bpPerPx: bpPerPx, theme: theme })) : null, bottomFrames.map(index => ((0, jsx_runtime_1.jsx)(Translation, { width: width, colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: !region.reversed }, `rev-translation-${index}`)))] }));
87
86
  }
88
87
  function Wrapper({ exportSVG, width, totalHeight, children, }) {
89
88
  return exportSVG ? (children) : ((0, jsx_runtime_1.jsx)("svg", { "data-testid": "sequence_track", width: width, height: totalHeight, style: {
@@ -93,10 +92,9 @@ function Wrapper({ exportSVG, width, totalHeight, children, }) {
93
92
  userSelect: 'none',
94
93
  }, children: children }));
95
94
  }
96
- const DivSequenceRendering = (0, mobx_react_1.observer)(function (props) {
97
- const { regions, bpPerPx, sequenceHeight } = props;
95
+ const DivSequenceRendering = (0, mobx_react_1.observer)(function ({ exportSVG, features, regions, colorByCDS, bpPerPx, rowHeight, sequenceHeight, theme, showForward, showReverse, showTranslation, }) {
98
96
  const region = regions[0];
99
- const width = (region.end - region.start) / bpPerPx;
100
- return ((0, jsx_runtime_1.jsx)(Wrapper, { ...props, totalHeight: sequenceHeight, width: width, children: (0, jsx_runtime_1.jsx)(SequenceSVG, { ...props }) }));
97
+ const width = Math.ceil((region.end - region.start) / bpPerPx);
98
+ return ((0, jsx_runtime_1.jsx)(Wrapper, { exportSVG: exportSVG, totalHeight: sequenceHeight, width: width, children: (0, jsx_runtime_1.jsx)(SequenceSVG, { width: width, showReverse: showReverse, showForward: showForward, theme: theme, showTranslation: showTranslation, colorByCDS: colorByCDS, bpPerPx: bpPerPx, rowHeight: rowHeight, features: features, regions: regions }) }));
101
99
  });
102
100
  exports.default = DivSequenceRendering;
@@ -1,7 +1,7 @@
1
1
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
2
2
  import type { Feature, Region } from '@jbrowse/core/util';
3
3
  import type { Theme } from '@mui/material';
4
- declare const DivSequenceRendering: (props: {
4
+ declare const DivSequenceRendering: ({ exportSVG, features, regions, colorByCDS, bpPerPx, rowHeight, sequenceHeight, theme, showForward, showReverse, showTranslation, }: {
5
5
  exportSVG?: {
6
6
  rasterizeLayers: boolean;
7
7
  };
@@ -3,7 +3,7 @@ import { Fragment } from 'react';
3
3
  import { createJBrowseTheme } from '@jbrowse/core/ui';
4
4
  import { bpSpanPx, complement, defaultCodonTable, defaultStarts, defaultStops, generateCodonTable, revcom, } from '@jbrowse/core/util';
5
5
  import { observer } from 'mobx-react';
6
- function Translation({ codonTable, seq, frame, bpPerPx, colorByCDS, region, seqStart, height, y, reverse = false, theme, }) {
6
+ function Translation({ codonTable, seq, frame, width, bpPerPx, colorByCDS, region, seqStart, height, y, reverse = false, theme, }) {
7
7
  var _a, _b;
8
8
  const normalizedFrame = Math.abs(frame) - 1;
9
9
  const seqFrame = seqStart % 3;
@@ -21,7 +21,6 @@ function Translation({ codonTable, seq, frame, bpPerPx, colorByCDS, region, seqS
21
21
  codon: normalizedCodon.toUpperCase(),
22
22
  });
23
23
  }
24
- const width = (region.end - region.start) / bpPerPx;
25
24
  const codonWidth = (1 / bpPerPx) * 3;
26
25
  const renderLetter = 1 / bpPerPx >= 12;
27
26
  const frameOffset = frameShift / bpPerPx;
@@ -62,7 +61,7 @@ function Sequence({ bpPerPx, region, feature, sequenceType, theme, height, seq,
62
61
  return (_jsxs(Fragment, { children: [_jsx("rect", { x: x, y: y, width: w, height: height, fill: color ? color.main : '#aaa', stroke: render ? '#555' : 'none' }), render ? (_jsx("text", { x: x + w / 2, y: y + height / 2, dominantBaseline: "middle", textAnchor: "middle", fontSize: height - 2, fill: color ? theme.palette.getContrastText(color.main) : 'black', children: letter })) : null] }, `${letter}-${index}`));
63
62
  }) }));
64
63
  }
65
- function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new Map(), showReverse = true, showForward = true, showTranslation = true, sequenceType = 'dna', bpPerPx, rowHeight, }) {
64
+ function SequenceSVG({ regions, width, theme: configTheme, colorByCDS, features = new Map(), showReverse = true, showForward = true, showTranslation = true, sequenceType = 'dna', bpPerPx, rowHeight, }) {
66
65
  const region = regions[0];
67
66
  const theme = createJBrowseTheme(configTheme);
68
67
  const codonTable = generateCodonTable(defaultCodonTable);
@@ -81,7 +80,7 @@ function SequenceSVG({ regions, theme: configTheme, colorByCDS, features = new M
81
80
  const [topFrames, bottomFrames] = region.reversed
82
81
  ? [reverseFrames.toReversed(), forwardFrames.toReversed()]
83
82
  : [forwardFrames, reverseFrames];
84
- return (_jsxs(_Fragment, { children: [topFrames.map(index => (_jsx(Translation, { colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: region.reversed }, `translation-${index}`))), showForward && showSequence ? (_jsx(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? complement(seq) : seq, bpPerPx: bpPerPx, theme: theme })) : null, showReverse && showSequence ? (_jsx(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? seq : complement(seq), bpPerPx: bpPerPx, theme: theme })) : null, bottomFrames.map(index => (_jsx(Translation, { colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: !region.reversed }, `rev-translation-${index}`)))] }));
83
+ return (_jsxs(_Fragment, { children: [topFrames.map(index => (_jsx(Translation, { width: width, colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: region.reversed }, `translation-${index}`))), showForward && showSequence ? (_jsx(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? complement(seq) : seq, bpPerPx: bpPerPx, theme: theme })) : null, showReverse && showSequence ? (_jsx(Sequence, { height: rowHeight, sequenceType: sequenceType, y: (currY += rowHeight), feature: feature, region: region, seq: region.reversed ? seq : complement(seq), bpPerPx: bpPerPx, theme: theme })) : null, bottomFrames.map(index => (_jsx(Translation, { width: width, colorByCDS: colorByCDS, seq: seq, y: (currY += rowHeight), codonTable: codonTable, frame: index, bpPerPx: bpPerPx, region: region, seqStart: feature.get('start'), theme: theme, height: rowHeight, reverse: !region.reversed }, `rev-translation-${index}`)))] }));
85
84
  }
86
85
  function Wrapper({ exportSVG, width, totalHeight, children, }) {
87
86
  return exportSVG ? (children) : (_jsx("svg", { "data-testid": "sequence_track", width: width, height: totalHeight, style: {
@@ -91,10 +90,9 @@ function Wrapper({ exportSVG, width, totalHeight, children, }) {
91
90
  userSelect: 'none',
92
91
  }, children: children }));
93
92
  }
94
- const DivSequenceRendering = observer(function (props) {
95
- const { regions, bpPerPx, sequenceHeight } = props;
93
+ const DivSequenceRendering = observer(function ({ exportSVG, features, regions, colorByCDS, bpPerPx, rowHeight, sequenceHeight, theme, showForward, showReverse, showTranslation, }) {
96
94
  const region = regions[0];
97
- const width = (region.end - region.start) / bpPerPx;
98
- return (_jsx(Wrapper, { ...props, totalHeight: sequenceHeight, width: width, children: _jsx(SequenceSVG, { ...props }) }));
95
+ const width = Math.ceil((region.end - region.start) / bpPerPx);
96
+ return (_jsx(Wrapper, { exportSVG: exportSVG, totalHeight: sequenceHeight, width: width, children: _jsx(SequenceSVG, { width: width, showReverse: showReverse, showForward: showForward, theme: theme, showTranslation: showTranslation, colorByCDS: colorByCDS, bpPerPx: bpPerPx, rowHeight: rowHeight, features: features, regions: regions }) }));
99
97
  });
100
98
  export default DivSequenceRendering;
@@ -1,5 +1,5 @@
1
1
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
- import { default as divSequenceRendererConfigSchema } from '../DivSequenceRenderer/configSchema';
2
+ import divSequenceRendererConfigSchema from '../DivSequenceRenderer/configSchema';
3
3
  function x() { }
4
4
  export const configSchema = ConfigurationSchema('LinearReferenceSequenceDisplay', {
5
5
  renderer: divSequenceRendererConfigSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-sequence",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "JBrowse 2 sequence adapters, tracks, etc.",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -39,9 +39,9 @@
39
39
  "@gmod/abortable-promise-cache": "^2.0.0",
40
40
  "@gmod/indexedfasta": "^3.0.0",
41
41
  "@gmod/twobit": "^4.0.1",
42
- "@jbrowse/core": "^3.0.3",
43
- "@jbrowse/plugin-linear-genome-view": "^3.0.3",
44
- "@jbrowse/plugin-wiggle": "^3.0.3",
42
+ "@jbrowse/core": "^3.0.5",
43
+ "@jbrowse/plugin-linear-genome-view": "^3.0.5",
44
+ "@jbrowse/plugin-wiggle": "^3.0.5",
45
45
  "@mui/material": "^6.0.0",
46
46
  "mobx": "^6.0.0",
47
47
  "mobx-react": "^9.0.0",
@@ -57,5 +57,5 @@
57
57
  "distModule": "esm/index.js",
58
58
  "srcModule": "src/index.ts",
59
59
  "module": "esm/index.js",
60
- "gitHead": "f516540428282351d26e46743e69a724651bfb2c"
60
+ "gitHead": "a03749efe19e51609922272b845a331897346789"
61
61
  }