@jbrowse/plugin-linear-genome-view 1.6.9 → 1.7.3
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.
- package/dist/BaseLinearDisplay/components/BaseLinearDisplay.d.ts +13 -13
- package/dist/BaseLinearDisplay/components/BaseLinearDisplay.js +232 -0
- package/dist/BaseLinearDisplay/components/Block.d.ts +15 -15
- package/dist/BaseLinearDisplay/components/Block.js +86 -0
- package/dist/BaseLinearDisplay/components/LinearBlocks.d.ts +12 -12
- package/dist/BaseLinearDisplay/components/LinearBlocks.js +110 -0
- package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.d.ts +4 -4
- package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +192 -0
- package/dist/BaseLinearDisplay/index.d.ts +5 -5
- package/dist/BaseLinearDisplay/index.js +41 -0
- package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +227 -230
- package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js +763 -0
- package/dist/BaseLinearDisplay/models/baseLinearDisplayConfigSchema.d.ts +1 -1
- package/dist/BaseLinearDisplay/models/baseLinearDisplayConfigSchema.js +24 -0
- package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.d.ts +96 -96
- package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js +328 -0
- package/dist/LinearBareDisplay/configSchema.d.ts +2 -2
- package/dist/LinearBareDisplay/configSchema.js +19 -0
- package/dist/LinearBareDisplay/index.d.ts +2 -2
- package/dist/LinearBareDisplay/index.js +21 -0
- package/dist/LinearBareDisplay/index.test.js +33 -0
- package/dist/LinearBareDisplay/model.d.ts +192 -192
- package/dist/LinearBareDisplay/model.js +44 -0
- package/dist/LinearBasicDisplay/components/SetMaxHeight.d.ts +10 -10
- package/dist/LinearBasicDisplay/components/SetMaxHeight.js +94 -0
- package/dist/LinearBasicDisplay/configSchema.d.ts +2 -2
- package/dist/LinearBasicDisplay/configSchema.js +25 -0
- package/dist/LinearBasicDisplay/index.d.ts +2 -2
- package/dist/LinearBasicDisplay/index.js +23 -0
- package/dist/LinearBasicDisplay/model.d.ts +213 -213
- package/dist/LinearBasicDisplay/model.js +162 -0
- package/dist/LinearGenomeView/components/CenterLine.d.ts +14 -14
- package/dist/LinearGenomeView/components/CenterLine.js +80 -0
- package/dist/LinearGenomeView/components/ExportSvgDialog.d.ts +6 -6
- package/dist/LinearGenomeView/components/ExportSvgDialog.js +137 -0
- package/dist/LinearGenomeView/components/Header.d.ts +7 -7
- package/dist/LinearGenomeView/components/Header.js +144 -0
- package/dist/LinearGenomeView/components/HelpDialog.d.ts +5 -5
- package/dist/LinearGenomeView/components/HelpDialog.js +48 -0
- package/dist/LinearGenomeView/components/ImportForm.d.ts +7 -7
- package/dist/LinearGenomeView/components/ImportForm.js +330 -0
- package/dist/LinearGenomeView/components/LinearGenomeView.d.ts +7 -7
- package/dist/LinearGenomeView/components/LinearGenomeView.js +129 -0
- package/dist/LinearGenomeView/components/LinearGenomeView.test.js +234 -0
- package/dist/LinearGenomeView/components/LinearGenomeViewSvg.d.ts +4 -4
- package/dist/LinearGenomeView/components/LinearGenomeViewSvg.js +349 -0
- package/dist/LinearGenomeView/components/MiniControls.d.ts +6 -6
- package/dist/LinearGenomeView/components/MiniControls.js +83 -0
- package/dist/LinearGenomeView/components/OverviewRubberBand.d.ts +22 -22
- package/dist/LinearGenomeView/components/OverviewRubberBand.js +310 -0
- package/dist/LinearGenomeView/components/OverviewScaleBar.d.ts +132 -124
- package/dist/LinearGenomeView/components/OverviewScaleBar.js +403 -0
- package/dist/LinearGenomeView/components/RefNameAutocomplete.d.ts +21 -21
- package/dist/LinearGenomeView/components/RefNameAutocomplete.js +331 -0
- package/dist/LinearGenomeView/components/RubberBand.d.ts +9 -20
- package/dist/LinearGenomeView/components/RubberBand.js +309 -0
- package/dist/LinearGenomeView/components/Ruler.d.ts +27 -27
- package/dist/LinearGenomeView/components/Ruler.js +101 -0
- package/dist/LinearGenomeView/components/ScaleBar.d.ts +401 -401
- package/dist/LinearGenomeView/components/ScaleBar.js +184 -0
- package/dist/LinearGenomeView/components/ScaleBar.test.js +180 -0
- package/dist/LinearGenomeView/components/SearchBox.d.ts +8 -8
- package/dist/LinearGenomeView/components/SearchBox.js +201 -0
- package/dist/LinearGenomeView/components/SearchResultsDialog.d.ts +8 -8
- package/dist/LinearGenomeView/components/SearchResultsDialog.js +159 -0
- package/dist/LinearGenomeView/components/SequenceDialog.d.ts +8 -8
- package/dist/LinearGenomeView/components/SequenceDialog.js +304 -0
- package/dist/LinearGenomeView/components/TrackContainer.d.ts +9 -9
- package/dist/LinearGenomeView/components/TrackContainer.js +179 -0
- package/dist/LinearGenomeView/components/TrackLabel.d.ts +44 -44
- package/dist/LinearGenomeView/components/TrackLabel.js +165 -0
- package/dist/LinearGenomeView/components/TracksContainer.d.ts +10 -10
- package/dist/LinearGenomeView/components/TracksContainer.js +214 -0
- package/dist/LinearGenomeView/components/VerticalGuides.d.ts +9 -9
- package/dist/LinearGenomeView/components/VerticalGuides.js +116 -0
- package/dist/LinearGenomeView/components/ZoomControls.d.ts +7 -7
- package/dist/LinearGenomeView/components/ZoomControls.js +92 -0
- package/dist/LinearGenomeView/components/util.d.ts +2 -2
- package/dist/LinearGenomeView/components/util.js +16 -0
- package/dist/LinearGenomeView/index.d.ts +292 -292
- package/dist/LinearGenomeView/index.js +1418 -0
- package/dist/LinearGenomeView/index.test.js +1170 -0
- package/dist/LinearGenomeView/util.d.ts +14 -14
- package/dist/LinearGenomeView/util.js +93 -0
- package/dist/LinearGenomeView/util.test.js +78 -0
- package/dist/index.d.ts +565 -565
- package/dist/index.js +293 -6
- package/package.json +6 -9
- package/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx +2 -0
- package/src/BaseLinearDisplay/models/serverSideRenderedBlock.ts +10 -8
- package/src/LinearBasicDisplay/components/SetMaxHeight.tsx +1 -1
- package/src/LinearBasicDisplay/model.ts +17 -18
- package/src/LinearGenomeView/components/Header.tsx +1 -1
- package/src/LinearGenomeView/components/ImportForm.tsx +10 -4
- package/src/LinearGenomeView/components/LinearGenomeView.test.js +1 -0
- package/src/LinearGenomeView/components/OverviewScaleBar.tsx +2 -2
- package/src/LinearGenomeView/components/RubberBand.tsx +14 -24
- package/src/LinearGenomeView/components/ScaleBar.test.tsx +1 -0
- package/src/LinearGenomeView/components/ScaleBar.tsx +3 -6
- package/src/LinearGenomeView/components/SequenceDialog.tsx +1 -1
- package/src/LinearGenomeView/components/TrackLabel.tsx +1 -1
- package/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap +0 -4
- package/src/LinearGenomeView/index.tsx +2 -3
- package/dist/LinearBareDisplay/index.test.d.ts +0 -1
- package/dist/LinearGenomeView/components/LinearGenomeView.test.d.ts +0 -1
- package/dist/plugin-linear-genome-view.cjs.development.js +0 -8121
- package/dist/plugin-linear-genome-view.cjs.development.js.map +0 -1
- package/dist/plugin-linear-genome-view.cjs.production.min.js +0 -2
- package/dist/plugin-linear-genome-view.cjs.production.min.js.map +0 -1
- package/dist/plugin-linear-genome-view.esm.js +0 -8105
- package/dist/plugin-linear-genome-view.esm.js.map +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
+
|
|
16
|
+
var _core = require("@material-ui/core");
|
|
17
|
+
|
|
18
|
+
var _blockTypes = require("@jbrowse/core/util/blockTypes");
|
|
19
|
+
|
|
20
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
21
|
+
|
|
22
|
+
var _mobxReact = require("mobx-react");
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
|
25
|
+
|
|
26
|
+
var _Block = require("../../BaseLinearDisplay/components/Block");
|
|
27
|
+
|
|
28
|
+
var _util = require("../util");
|
|
29
|
+
|
|
30
|
+
var _excluded = ["model", "style", "className"];
|
|
31
|
+
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
+
|
|
36
|
+
var useStyles = (0, _core.makeStyles)(function (theme) {
|
|
37
|
+
return {
|
|
38
|
+
scaleBarContainer: {
|
|
39
|
+
overflow: 'hidden',
|
|
40
|
+
position: 'relative'
|
|
41
|
+
},
|
|
42
|
+
scaleBarZoomContainer: {
|
|
43
|
+
position: 'relative',
|
|
44
|
+
zIndex: 1
|
|
45
|
+
},
|
|
46
|
+
scaleBar: {
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
display: 'flex',
|
|
49
|
+
pointerEvents: 'none'
|
|
50
|
+
},
|
|
51
|
+
majorTickLabel: {
|
|
52
|
+
fontSize: '11px',
|
|
53
|
+
zIndex: 1,
|
|
54
|
+
background: theme.palette.background.paper,
|
|
55
|
+
lineHeight: 'normal',
|
|
56
|
+
pointerEvents: 'none'
|
|
57
|
+
},
|
|
58
|
+
tick: {
|
|
59
|
+
position: 'absolute',
|
|
60
|
+
width: 0,
|
|
61
|
+
display: 'flex',
|
|
62
|
+
justifyContent: 'center',
|
|
63
|
+
pointerEvents: 'none'
|
|
64
|
+
},
|
|
65
|
+
refLabel: {
|
|
66
|
+
fontSize: '11px',
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
left: '2px',
|
|
69
|
+
top: '-1px',
|
|
70
|
+
fontWeight: 'bold',
|
|
71
|
+
lineHeight: 'normal',
|
|
72
|
+
zIndex: 1,
|
|
73
|
+
pointerEvents: 'none',
|
|
74
|
+
background: theme.palette.background.paper
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
var RenderedRefNameLabels = (0, _mobxReact.observer)(function (_ref) {
|
|
79
|
+
var model = _ref.model;
|
|
80
|
+
var classes = useStyles(); // find the block that needs pinning to the left side for context
|
|
81
|
+
|
|
82
|
+
var lastLeftBlock = 0;
|
|
83
|
+
model.staticBlocks.forEach(function (block, i) {
|
|
84
|
+
if (block.offsetPx - model.offsetPx < 0) {
|
|
85
|
+
lastLeftBlock = i;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, model.staticBlocks.map(function (block, index) {
|
|
89
|
+
return block instanceof _blockTypes.ContentBlock && (block.isLeftEndOfDisplayedRegion || index === lastLeftBlock) ? /*#__PURE__*/_react["default"].createElement(_core.Typography, {
|
|
90
|
+
key: "refLabel-".concat(block.key, "-").concat(index),
|
|
91
|
+
style: {
|
|
92
|
+
left: index === lastLeftBlock ? Math.max(0, -model.offsetPx) : block.offsetPx - model.offsetPx - 1,
|
|
93
|
+
paddingLeft: index === lastLeftBlock ? 0 : 1
|
|
94
|
+
},
|
|
95
|
+
className: classes.refLabel,
|
|
96
|
+
"data-testid": "refLabel-".concat(block.refName)
|
|
97
|
+
}, block.refName) : null;
|
|
98
|
+
}));
|
|
99
|
+
});
|
|
100
|
+
var RenderedScaleBarLabels = (0, _mobxReact.observer)(function (_ref2) {
|
|
101
|
+
var model = _ref2.model;
|
|
102
|
+
var classes = useStyles();
|
|
103
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, model.staticBlocks.map(function (block, index) {
|
|
104
|
+
if (block instanceof _blockTypes.ContentBlock) {
|
|
105
|
+
var ticks = (0, _util.makeTicks)(block.start, block.end, model.bpPerPx, true, false);
|
|
106
|
+
return /*#__PURE__*/_react["default"].createElement(_Block.ContentBlock, {
|
|
107
|
+
key: "".concat(block.key, "-").concat(index),
|
|
108
|
+
block: block
|
|
109
|
+
}, ticks.map(function (tick) {
|
|
110
|
+
if (tick.type === 'major') {
|
|
111
|
+
var x = (block.reversed ? block.end - tick.base : tick.base - block.start) / model.bpPerPx;
|
|
112
|
+
var baseNumber = (tick.base + 1).toLocaleString('en-US');
|
|
113
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
114
|
+
key: tick.base,
|
|
115
|
+
className: classes.tick,
|
|
116
|
+
style: {
|
|
117
|
+
left: x
|
|
118
|
+
}
|
|
119
|
+
}, baseNumber ? /*#__PURE__*/_react["default"].createElement(_core.Typography, {
|
|
120
|
+
className: classes.majorTickLabel
|
|
121
|
+
}, baseNumber) : null);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return null;
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (block instanceof _blockTypes.ElidedBlock) {
|
|
129
|
+
return /*#__PURE__*/_react["default"].createElement(_Block.ElidedBlock, {
|
|
130
|
+
key: block.key,
|
|
131
|
+
width: block.widthPx
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (block instanceof _blockTypes.InterRegionPaddingBlock) {
|
|
136
|
+
return /*#__PURE__*/_react["default"].createElement(_Block.InterRegionPaddingBlock, {
|
|
137
|
+
key: block.key,
|
|
138
|
+
width: block.widthPx,
|
|
139
|
+
style: {
|
|
140
|
+
background: 'none'
|
|
141
|
+
},
|
|
142
|
+
boundary: block.variant === 'boundary'
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return null;
|
|
147
|
+
}));
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
var ScaleBar = /*#__PURE__*/_react["default"].forwardRef(function (_ref3, ref) {
|
|
151
|
+
var model = _ref3.model,
|
|
152
|
+
style = _ref3.style,
|
|
153
|
+
className = _ref3.className,
|
|
154
|
+
other = (0, _objectWithoutProperties2["default"])(_ref3, _excluded);
|
|
155
|
+
var classes = useStyles();
|
|
156
|
+
var offsetLeft = model.staticBlocks.offsetPx - model.offsetPx;
|
|
157
|
+
return /*#__PURE__*/_react["default"].createElement(_core.Paper, (0, _extends2["default"])({
|
|
158
|
+
"data-resizer": "true" // used to avoid click-and-drag scrolls on trackscontainer
|
|
159
|
+
,
|
|
160
|
+
className: (0, _clsx["default"])(classes.scaleBarContainer, className),
|
|
161
|
+
variant: "outlined",
|
|
162
|
+
ref: ref,
|
|
163
|
+
style: style
|
|
164
|
+
}, other), /*#__PURE__*/_react["default"].createElement("div", {
|
|
165
|
+
className: classes.scaleBarZoomContainer,
|
|
166
|
+
style: {
|
|
167
|
+
transform: model.scaleFactor !== 1 ? "scaleX(".concat(model.scaleFactor, ")") : undefined
|
|
168
|
+
}
|
|
169
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
170
|
+
className: classes.scaleBar,
|
|
171
|
+
style: _objectSpread({
|
|
172
|
+
left: offsetLeft - 1,
|
|
173
|
+
width: model.staticBlocks.totalWidthPx
|
|
174
|
+
}, style)
|
|
175
|
+
}, /*#__PURE__*/_react["default"].createElement(RenderedScaleBarLabels, {
|
|
176
|
+
model: model
|
|
177
|
+
}))), /*#__PURE__*/_react["default"].createElement(RenderedRefNameLabels, {
|
|
178
|
+
model: model
|
|
179
|
+
}));
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
var _default = (0, _mobxReact.observer)(ScaleBar);
|
|
183
|
+
|
|
184
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
|
|
9
|
+
var _rootModel = require("@jbrowse/web/src/rootModel");
|
|
10
|
+
|
|
11
|
+
var _ScaleBar = _interopRequireDefault(require("./ScaleBar"));
|
|
12
|
+
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
|
+
jest.mock('@jbrowse/web/src/makeWorkerInstance', function () {
|
|
15
|
+
return function () {};
|
|
16
|
+
});
|
|
17
|
+
describe('ScaleBar genome view component', function () {
|
|
18
|
+
it('renders two regions', function () {
|
|
19
|
+
var session = (0, _rootModel.createTestSession)({
|
|
20
|
+
views: [{
|
|
21
|
+
type: 'LinearGenomeView',
|
|
22
|
+
offsetPx: 0,
|
|
23
|
+
bpPerPx: 1,
|
|
24
|
+
displayedRegions: [{
|
|
25
|
+
assemblyName: 'volvox',
|
|
26
|
+
refName: 'ctgA',
|
|
27
|
+
start: 0,
|
|
28
|
+
end: 100
|
|
29
|
+
}, {
|
|
30
|
+
assemblyName: 'volvox',
|
|
31
|
+
refName: 'ctgB',
|
|
32
|
+
start: 100,
|
|
33
|
+
end: 200
|
|
34
|
+
}],
|
|
35
|
+
tracks: [],
|
|
36
|
+
configuration: {}
|
|
37
|
+
}]
|
|
38
|
+
});
|
|
39
|
+
session.addAssemblyConf({
|
|
40
|
+
name: 'volMyt1',
|
|
41
|
+
sequence: {
|
|
42
|
+
trackId: 'ref0',
|
|
43
|
+
type: 'ReferenceSequenceTrack',
|
|
44
|
+
adapter: {
|
|
45
|
+
type: 'FromConfigSequenceAdapter',
|
|
46
|
+
features: [{
|
|
47
|
+
refName: 'ctgA',
|
|
48
|
+
uniqueId: 'firstId',
|
|
49
|
+
start: 0,
|
|
50
|
+
end: 10,
|
|
51
|
+
seq: 'cattgttgcg'
|
|
52
|
+
}]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
var model = session.views[0];
|
|
57
|
+
|
|
58
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ScaleBar["default"], {
|
|
59
|
+
model: model
|
|
60
|
+
})),
|
|
61
|
+
getByTestId = _render.getByTestId;
|
|
62
|
+
|
|
63
|
+
var ret1 = getByTestId('refLabel-ctgA');
|
|
64
|
+
var ret2 = getByTestId('refLabel-ctgB');
|
|
65
|
+
expect(ret1.style.left).toBe('-1px');
|
|
66
|
+
expect(ret2.style.left).toBe('101px');
|
|
67
|
+
});
|
|
68
|
+
it('renders two regions when scrolled to the left, the label is ctgA to the actual blocks', function () {
|
|
69
|
+
var session = (0, _rootModel.createTestSession)({
|
|
70
|
+
views: [{
|
|
71
|
+
type: 'LinearGenomeView',
|
|
72
|
+
offsetPx: -100,
|
|
73
|
+
bpPerPx: 1,
|
|
74
|
+
displayedRegions: [{
|
|
75
|
+
assemblyName: 'volvox',
|
|
76
|
+
refName: 'ctgA',
|
|
77
|
+
start: 0,
|
|
78
|
+
end: 100
|
|
79
|
+
}, {
|
|
80
|
+
assemblyName: 'volvox',
|
|
81
|
+
refName: 'ctgB',
|
|
82
|
+
start: 0,
|
|
83
|
+
end: 100
|
|
84
|
+
}],
|
|
85
|
+
tracks: [],
|
|
86
|
+
configuration: {}
|
|
87
|
+
}]
|
|
88
|
+
});
|
|
89
|
+
session.addAssemblyConf({
|
|
90
|
+
name: 'volMyt1',
|
|
91
|
+
sequence: {
|
|
92
|
+
trackId: 'ref0',
|
|
93
|
+
type: 'ReferenceSequenceTrack',
|
|
94
|
+
adapter: {
|
|
95
|
+
type: 'FromConfigSequenceAdapter',
|
|
96
|
+
features: [{
|
|
97
|
+
refName: 'ctgA',
|
|
98
|
+
uniqueId: 'firstId',
|
|
99
|
+
start: 0,
|
|
100
|
+
end: 10,
|
|
101
|
+
seq: 'cattgttgcg'
|
|
102
|
+
}]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
var model = session.views[0];
|
|
107
|
+
|
|
108
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ScaleBar["default"], {
|
|
109
|
+
model: model
|
|
110
|
+
})),
|
|
111
|
+
getByTestId = _render2.getByTestId;
|
|
112
|
+
|
|
113
|
+
var ret1 = getByTestId('refLabel-ctgA');
|
|
114
|
+
var ret2 = getByTestId('refLabel-ctgB');
|
|
115
|
+
expect(ret1.style.left).toBe('99px');
|
|
116
|
+
expect(ret2.style.left).toBe('201px');
|
|
117
|
+
});
|
|
118
|
+
it('renders two regions when scrolled to the left, the label is ctgA to the actual blocks', function () {
|
|
119
|
+
var session = (0, _rootModel.createTestSession)({
|
|
120
|
+
views: [{
|
|
121
|
+
type: 'LinearGenomeView',
|
|
122
|
+
offsetPx: -100,
|
|
123
|
+
bpPerPx: 1,
|
|
124
|
+
displayedRegions: [{
|
|
125
|
+
assemblyName: 'volvox',
|
|
126
|
+
refName: 'ctgA',
|
|
127
|
+
start: 0,
|
|
128
|
+
end: 1000
|
|
129
|
+
}, {
|
|
130
|
+
assemblyName: 'volvox',
|
|
131
|
+
refName: 'ctgB',
|
|
132
|
+
start: 0,
|
|
133
|
+
end: 1
|
|
134
|
+
}, {
|
|
135
|
+
assemblyName: 'volvox',
|
|
136
|
+
refName: 'ctgC',
|
|
137
|
+
start: 0,
|
|
138
|
+
end: 1
|
|
139
|
+
}, {
|
|
140
|
+
assemblyName: 'volvox',
|
|
141
|
+
refName: 'ctgD',
|
|
142
|
+
start: 0,
|
|
143
|
+
end: 1
|
|
144
|
+
}],
|
|
145
|
+
tracks: [],
|
|
146
|
+
configuration: {}
|
|
147
|
+
}]
|
|
148
|
+
});
|
|
149
|
+
session.addAssemblyConf({
|
|
150
|
+
name: 'volMyt1',
|
|
151
|
+
sequence: {
|
|
152
|
+
trackId: 'ref0',
|
|
153
|
+
type: 'ReferenceSequenceTrack',
|
|
154
|
+
adapter: {
|
|
155
|
+
type: 'FromConfigSequenceAdapter',
|
|
156
|
+
features: [{
|
|
157
|
+
refName: 'ctgA',
|
|
158
|
+
uniqueId: 'firstId',
|
|
159
|
+
start: 0,
|
|
160
|
+
end: 10,
|
|
161
|
+
seq: 'cattgttgcg'
|
|
162
|
+
}]
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
var model = session.views[0];
|
|
167
|
+
|
|
168
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ScaleBar["default"], {
|
|
169
|
+
model: model
|
|
170
|
+
})),
|
|
171
|
+
queryByTestId = _render3.queryByTestId;
|
|
172
|
+
|
|
173
|
+
var ret2 = queryByTestId('refLabel-ctgB');
|
|
174
|
+
var ret3 = queryByTestId('refLabel-ctgC');
|
|
175
|
+
var ret4 = queryByTestId('refLabel-ctgD');
|
|
176
|
+
expect(ret2).toBe(null);
|
|
177
|
+
expect(ret3).toBe(null);
|
|
178
|
+
expect(ret4).toBe(null);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { LinearGenomeViewModel } from '..';
|
|
3
|
-
declare function SearchBox({ model, showHelp, }: {
|
|
4
|
-
showHelp?: boolean;
|
|
5
|
-
model: LinearGenomeViewModel;
|
|
6
|
-
}): JSX.Element;
|
|
7
|
-
declare const _default: typeof SearchBox;
|
|
8
|
-
export default _default;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LinearGenomeViewModel } from '..';
|
|
3
|
+
declare function SearchBox({ model, showHelp, }: {
|
|
4
|
+
showHelp?: boolean;
|
|
5
|
+
model: LinearGenomeViewModel;
|
|
6
|
+
}): JSX.Element;
|
|
7
|
+
declare const _default: typeof SearchBox;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
var _mobxReact = require("mobx-react");
|
|
19
|
+
|
|
20
|
+
var _core = require("@material-ui/core");
|
|
21
|
+
|
|
22
|
+
var _BaseResults = _interopRequireDefault(require("@jbrowse/core/TextSearch/BaseResults"));
|
|
23
|
+
|
|
24
|
+
var _util = require("@jbrowse/core/util");
|
|
25
|
+
|
|
26
|
+
var _RefNameAutocomplete = _interopRequireDefault(require("./RefNameAutocomplete"));
|
|
27
|
+
|
|
28
|
+
var _util2 = require("./util");
|
|
29
|
+
|
|
30
|
+
var _ = require("..");
|
|
31
|
+
|
|
32
|
+
// locals
|
|
33
|
+
var useStyles = (0, _core.makeStyles)(function () {
|
|
34
|
+
return {
|
|
35
|
+
headerRefName: {
|
|
36
|
+
minWidth: 100
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function SearchBox(_ref) {
|
|
42
|
+
var model = _ref.model,
|
|
43
|
+
showHelp = _ref.showHelp;
|
|
44
|
+
var classes = useStyles();
|
|
45
|
+
var theme = (0, _core.useTheme)();
|
|
46
|
+
var session = (0, _util.getSession)(model);
|
|
47
|
+
var textSearchManager = session.textSearchManager,
|
|
48
|
+
assemblyManager = session.assemblyManager;
|
|
49
|
+
var assemblyNames = model.assemblyNames,
|
|
50
|
+
rankSearchResults = model.rankSearchResults;
|
|
51
|
+
var assemblyName = assemblyNames[0];
|
|
52
|
+
var assembly = assemblyManager.get(assemblyName);
|
|
53
|
+
var searchScope = model.searchScope(assemblyName);
|
|
54
|
+
|
|
55
|
+
function fetchResults(_x, _x2) {
|
|
56
|
+
return _fetchResults.apply(this, arguments);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function _fetchResults() {
|
|
60
|
+
_fetchResults = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(query, searchType) {
|
|
61
|
+
var _assembly$allRefNames;
|
|
62
|
+
|
|
63
|
+
var textSearchResults, refNameResults;
|
|
64
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
65
|
+
while (1) {
|
|
66
|
+
switch (_context.prev = _context.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
if (!textSearchManager) {
|
|
69
|
+
console.warn('No text search manager');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_context.next = 3;
|
|
73
|
+
return textSearchManager === null || textSearchManager === void 0 ? void 0 : textSearchManager.search({
|
|
74
|
+
queryString: query,
|
|
75
|
+
searchType: searchType
|
|
76
|
+
}, searchScope, rankSearchResults);
|
|
77
|
+
|
|
78
|
+
case 3:
|
|
79
|
+
textSearchResults = _context.sent;
|
|
80
|
+
refNameResults = assembly === null || assembly === void 0 ? void 0 : (_assembly$allRefNames = assembly.allRefNames) === null || _assembly$allRefNames === void 0 ? void 0 : _assembly$allRefNames.filter(function (refName) {
|
|
81
|
+
return refName.startsWith(query);
|
|
82
|
+
}).map(function (r) {
|
|
83
|
+
return new _BaseResults["default"]({
|
|
84
|
+
label: r
|
|
85
|
+
});
|
|
86
|
+
}).slice(0, 10);
|
|
87
|
+
return _context.abrupt("return", (0, _util2.dedupe)([].concat((0, _toConsumableArray2["default"])(refNameResults || []), (0, _toConsumableArray2["default"])(textSearchResults || [])), function (elt) {
|
|
88
|
+
return elt.getId();
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
case 6:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context.stop();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}, _callee);
|
|
97
|
+
}));
|
|
98
|
+
return _fetchResults.apply(this, arguments);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function handleSelectedRegion(_x3) {
|
|
102
|
+
return _handleSelectedRegion.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function _handleSelectedRegion() {
|
|
106
|
+
_handleSelectedRegion = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(option) {
|
|
107
|
+
var trackId, location, label, _assembly$allRefNames2, results;
|
|
108
|
+
|
|
109
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
110
|
+
while (1) {
|
|
111
|
+
switch (_context2.prev = _context2.next) {
|
|
112
|
+
case 0:
|
|
113
|
+
trackId = option.getTrackId();
|
|
114
|
+
location = option.getLocation();
|
|
115
|
+
label = option.getLabel();
|
|
116
|
+
_context2.prev = 3;
|
|
117
|
+
|
|
118
|
+
if (!(assembly !== null && assembly !== void 0 && (_assembly$allRefNames2 = assembly.allRefNames) !== null && _assembly$allRefNames2 !== void 0 && _assembly$allRefNames2.includes(location))) {
|
|
119
|
+
_context2.next = 8;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
model.navToLocString(location);
|
|
124
|
+
_context2.next = 19;
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case 8:
|
|
128
|
+
_context2.next = 10;
|
|
129
|
+
return fetchResults(label, 'exact');
|
|
130
|
+
|
|
131
|
+
case 10:
|
|
132
|
+
results = _context2.sent;
|
|
133
|
+
|
|
134
|
+
if (!(results && results.length > 1)) {
|
|
135
|
+
_context2.next = 16;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
model.setSearchResults(results, label.toLowerCase());
|
|
140
|
+
return _context2.abrupt("return");
|
|
141
|
+
|
|
142
|
+
case 16:
|
|
143
|
+
if ((results === null || results === void 0 ? void 0 : results.length) === 1) {
|
|
144
|
+
location = results[0].getLocation();
|
|
145
|
+
trackId = results[0].getTrackId();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
case 17:
|
|
149
|
+
model.navToLocString(location, assemblyName);
|
|
150
|
+
|
|
151
|
+
if (trackId) {
|
|
152
|
+
model.showTrack(trackId);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
case 19:
|
|
156
|
+
_context2.next = 25;
|
|
157
|
+
break;
|
|
158
|
+
|
|
159
|
+
case 21:
|
|
160
|
+
_context2.prev = 21;
|
|
161
|
+
_context2.t0 = _context2["catch"](3);
|
|
162
|
+
console.error(_context2.t0);
|
|
163
|
+
session.notify("".concat(_context2.t0), 'warning');
|
|
164
|
+
|
|
165
|
+
case 25:
|
|
166
|
+
case "end":
|
|
167
|
+
return _context2.stop();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}, _callee2, null, [[3, 21]]);
|
|
171
|
+
}));
|
|
172
|
+
return _handleSelectedRegion.apply(this, arguments);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return /*#__PURE__*/_react["default"].createElement(_RefNameAutocomplete["default"], {
|
|
176
|
+
showHelp: showHelp,
|
|
177
|
+
onSelect: handleSelectedRegion,
|
|
178
|
+
assemblyName: assemblyName,
|
|
179
|
+
fetchResults: fetchResults,
|
|
180
|
+
model: model,
|
|
181
|
+
TextFieldProps: {
|
|
182
|
+
variant: 'outlined',
|
|
183
|
+
className: classes.headerRefName,
|
|
184
|
+
style: {
|
|
185
|
+
margin: _.SPACING,
|
|
186
|
+
minWidth: '175px'
|
|
187
|
+
},
|
|
188
|
+
InputProps: {
|
|
189
|
+
style: {
|
|
190
|
+
padding: 0,
|
|
191
|
+
height: _.WIDGET_HEIGHT,
|
|
192
|
+
background: (0, _core.alpha)(theme.palette.background.paper, 0.8)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var _default = (0, _mobxReact.observer)(SearchBox);
|
|
200
|
+
|
|
201
|
+
exports["default"] = _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { LinearGenomeViewModel } from '../..';
|
|
3
|
-
export declare const useStyles: (props?: any) =>
|
|
4
|
-
export default function SearchResultsDialog({ model, optAssemblyName, handleClose, }: {
|
|
5
|
-
model: LinearGenomeViewModel;
|
|
6
|
-
optAssemblyName?: string;
|
|
7
|
-
handleClose: () => void;
|
|
8
|
-
}): JSX.Element;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { LinearGenomeViewModel } from '../..';
|
|
3
|
+
export declare const useStyles: (props?: any) => import("@material-ui/styles").ClassNameMap<"closeButton" | "dialogContent">;
|
|
4
|
+
export default function SearchResultsDialog({ model, optAssemblyName, handleClose, }: {
|
|
5
|
+
model: LinearGenomeViewModel;
|
|
6
|
+
optAssemblyName?: string;
|
|
7
|
+
handleClose: () => void;
|
|
8
|
+
}): JSX.Element;
|