@jbrowse/plugin-variants 1.6.9 → 1.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.
- package/dist/ChordVariantDisplay/index.js +33 -0
- package/dist/ChordVariantDisplay/models/ChordVariantDisplay.js +76 -0
- package/dist/LinearVariantDisplay/configSchema.js +18 -0
- package/dist/LinearVariantDisplay/configSchema.test.js +92 -0
- package/dist/LinearVariantDisplay/index.js +23 -0
- package/dist/LinearVariantDisplay/model.js +75 -0
- package/dist/StructuralVariantChordRenderer/ReactComponent.js +228 -0
- package/dist/StructuralVariantChordRenderer/index.js +48 -0
- package/dist/VariantFeatureWidget/BreakendOptionDialog.js +127 -0
- package/dist/VariantFeatureWidget/VariantFeatureWidget.js +251 -0
- package/dist/VariantFeatureWidget/VariantFeatureWidget.test.js +56 -0
- package/dist/VariantFeatureWidget/index.js +35 -0
- package/dist/VcfAdapter/VcfAdapter.js +383 -0
- package/dist/VcfAdapter/VcfAdapter.test.js +55 -0
- package/dist/VcfAdapter/configSchema.js +22 -0
- package/dist/VcfAdapter/index.js +15 -0
- package/dist/VcfTabixAdapter/VcfFeature.js +261 -0
- package/dist/VcfTabixAdapter/VcfFeature.test.js +106 -0
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js +392 -0
- package/dist/VcfTabixAdapter/VcfTabixAdapter.test.js +99 -0
- package/dist/VcfTabixAdapter/configSchema.js +38 -0
- package/dist/VcfTabixAdapter/index.js +15 -0
- package/dist/index.js +214 -6
- package/dist/index.test.js +37 -0
- package/package.json +3 -6
|
@@ -0,0 +1,33 @@
|
|
|
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 _pluginCircularView = require("@jbrowse/plugin-circular-view");
|
|
11
|
+
|
|
12
|
+
var _ChordVariantDisplay = _interopRequireDefault(require("./models/ChordVariantDisplay"));
|
|
13
|
+
|
|
14
|
+
var _default = function _default(pluginManager) {
|
|
15
|
+
var lib = pluginManager.lib,
|
|
16
|
+
load = pluginManager.load;
|
|
17
|
+
var DisplayType = lib['@jbrowse/core/pluggableElementTypes/DisplayType'];
|
|
18
|
+
|
|
19
|
+
var _load = load(_ChordVariantDisplay["default"]),
|
|
20
|
+
stateModel = _load.stateModel,
|
|
21
|
+
configSchema = _load.configSchema;
|
|
22
|
+
|
|
23
|
+
return new DisplayType({
|
|
24
|
+
name: 'ChordVariantDisplay',
|
|
25
|
+
configSchema: configSchema,
|
|
26
|
+
stateModel: stateModel,
|
|
27
|
+
trackType: 'VariantTrack',
|
|
28
|
+
viewType: 'CircularView',
|
|
29
|
+
ReactComponent: (0, _pluginCircularView.BaseChordDisplayComponentFactory)(pluginManager)
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,76 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _pluginCircularView = require("@jbrowse/plugin-circular-view");
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
var ChordVariantDisplayF = function ChordVariantDisplayF(pluginManager) {
|
|
19
|
+
var jbrequire = pluginManager.jbrequire;
|
|
20
|
+
|
|
21
|
+
var _jbrequire = jbrequire('mobx-state-tree'),
|
|
22
|
+
types = _jbrequire.types;
|
|
23
|
+
|
|
24
|
+
var _jbrequire2 = jbrequire('@jbrowse/core/configuration'),
|
|
25
|
+
ConfigurationSchema = _jbrequire2.ConfigurationSchema,
|
|
26
|
+
ConfigurationReference = _jbrequire2.ConfigurationReference;
|
|
27
|
+
|
|
28
|
+
var _jbrequire3 = jbrequire('@jbrowse/core/util'),
|
|
29
|
+
getContainingView = _jbrequire3.getContainingView;
|
|
30
|
+
|
|
31
|
+
var _jbrequire4 = jbrequire('@jbrowse/core/util/tracks'),
|
|
32
|
+
getParentRenderProps = _jbrequire4.getParentRenderProps;
|
|
33
|
+
|
|
34
|
+
var configSchema = ConfigurationSchema('ChordVariantDisplay', {
|
|
35
|
+
renderer: types.optional(pluginManager.pluggableConfigSchemaType('renderer'), {
|
|
36
|
+
type: 'StructuralVariantChordRenderer'
|
|
37
|
+
})
|
|
38
|
+
}, {
|
|
39
|
+
baseConfiguration: _pluginCircularView.baseChordDisplayConfig,
|
|
40
|
+
explicitlyTyped: true
|
|
41
|
+
});
|
|
42
|
+
var stateModel = types.compose('ChordVariantDisplay', _pluginCircularView.BaseChordDisplayModel, types.model({
|
|
43
|
+
type: types.literal('ChordVariantDisplay'),
|
|
44
|
+
configuration: ConfigurationReference(configSchema)
|
|
45
|
+
})).views(function (self) {
|
|
46
|
+
return {
|
|
47
|
+
get rendererTypeName() {
|
|
48
|
+
return self.configuration.renderer.type;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
renderProps: function renderProps() {
|
|
52
|
+
var view = getContainingView(self);
|
|
53
|
+
return _objectSpread(_objectSpread({}, getParentRenderProps(self)), {}, {
|
|
54
|
+
rpcDriverName: self.rpcDriverName,
|
|
55
|
+
displayModel: self,
|
|
56
|
+
bezierRadius: view.radiusPx * self.bezierRadiusRatio,
|
|
57
|
+
radius: view.radiusPx,
|
|
58
|
+
blockDefinitions: this.blockDefinitions,
|
|
59
|
+
config: self.configuration.renderer,
|
|
60
|
+
onChordClick: self.onChordClick
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
stateModel: stateModel,
|
|
67
|
+
configSchema: configSchema
|
|
68
|
+
};
|
|
69
|
+
}; // http://localhost:3000/test_data/hs37d5.HG002-SequelII-CCS.sv.vcf.gz.tbi
|
|
70
|
+
// render request is for 1.5x the current viewing window
|
|
71
|
+
// tracks all have a height
|
|
72
|
+
//
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
var _default = ChordVariantDisplayF;
|
|
76
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LinearVariantDisplayConfigFactory = LinearVariantDisplayConfigFactory;
|
|
7
|
+
|
|
8
|
+
var _configuration = require("@jbrowse/core/configuration");
|
|
9
|
+
|
|
10
|
+
var _pluginLinearGenomeView = require("@jbrowse/plugin-linear-genome-view");
|
|
11
|
+
|
|
12
|
+
function LinearVariantDisplayConfigFactory(pluginManager) {
|
|
13
|
+
var configSchema = (0, _pluginLinearGenomeView.linearBasicDisplayConfigSchemaFactory)(pluginManager);
|
|
14
|
+
return (0, _configuration.ConfigurationSchema)('LinearVariantDisplay', {}, {
|
|
15
|
+
baseConfiguration: configSchema,
|
|
16
|
+
explicitlyTyped: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
6
|
+
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
|
|
9
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
10
|
+
|
|
11
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
+
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
|
|
15
|
+
var _BoxRendererType = _interopRequireDefault(require("@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType"));
|
|
16
|
+
|
|
17
|
+
var _Plugin3 = _interopRequireDefault(require("@jbrowse/core/Plugin"));
|
|
18
|
+
|
|
19
|
+
var _PluginManager = _interopRequireDefault(require("@jbrowse/core/PluginManager"));
|
|
20
|
+
|
|
21
|
+
var _PileupRenderer = _interopRequireDefault(require("@jbrowse/plugin-alignments/src/PileupRenderer"));
|
|
22
|
+
|
|
23
|
+
var _SvgFeatureRenderer = require("@jbrowse/plugin-svg/src/SvgFeatureRenderer");
|
|
24
|
+
|
|
25
|
+
var _configSchema = require("./configSchema");
|
|
26
|
+
|
|
27
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
28
|
+
|
|
29
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
30
|
+
|
|
31
|
+
// mock warnings to avoid unnecessary outputs
|
|
32
|
+
beforeEach(function () {
|
|
33
|
+
jest.spyOn(console, 'warn').mockImplementation(function () {});
|
|
34
|
+
});
|
|
35
|
+
afterEach(function () {
|
|
36
|
+
console.warn.mockRestore();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
var PileupRendererPlugin = /*#__PURE__*/function (_Plugin) {
|
|
40
|
+
(0, _inherits2["default"])(PileupRendererPlugin, _Plugin);
|
|
41
|
+
|
|
42
|
+
var _super = _createSuper(PileupRendererPlugin);
|
|
43
|
+
|
|
44
|
+
function PileupRendererPlugin() {
|
|
45
|
+
(0, _classCallCheck2["default"])(this, PileupRendererPlugin);
|
|
46
|
+
return _super.apply(this, arguments);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
(0, _createClass2["default"])(PileupRendererPlugin, [{
|
|
50
|
+
key: "install",
|
|
51
|
+
value: function install(pluginManager) {
|
|
52
|
+
(0, _PileupRenderer["default"])(pluginManager);
|
|
53
|
+
}
|
|
54
|
+
}]);
|
|
55
|
+
return PileupRendererPlugin;
|
|
56
|
+
}(_Plugin3["default"]);
|
|
57
|
+
|
|
58
|
+
var SvgFeatureRendererPlugin = /*#__PURE__*/function (_Plugin2) {
|
|
59
|
+
(0, _inherits2["default"])(SvgFeatureRendererPlugin, _Plugin2);
|
|
60
|
+
|
|
61
|
+
var _super2 = _createSuper(SvgFeatureRendererPlugin);
|
|
62
|
+
|
|
63
|
+
function SvgFeatureRendererPlugin() {
|
|
64
|
+
(0, _classCallCheck2["default"])(this, SvgFeatureRendererPlugin);
|
|
65
|
+
return _super2.apply(this, arguments);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
(0, _createClass2["default"])(SvgFeatureRendererPlugin, [{
|
|
69
|
+
key: "install",
|
|
70
|
+
value: function install(pluginManager) {
|
|
71
|
+
pluginManager.addRendererType(function () {
|
|
72
|
+
return new _BoxRendererType["default"]({
|
|
73
|
+
name: 'SvgFeatureRenderer',
|
|
74
|
+
ReactComponent: _SvgFeatureRenderer.ReactComponent,
|
|
75
|
+
configSchema: _SvgFeatureRenderer.configSchema,
|
|
76
|
+
pluginManager: pluginManager
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}]);
|
|
81
|
+
return SvgFeatureRendererPlugin;
|
|
82
|
+
}(_Plugin3["default"]);
|
|
83
|
+
|
|
84
|
+
test('has a viewType attr', function () {
|
|
85
|
+
var configSchema = (0, _configSchema.LinearVariantDisplayConfigFactory)(new _PluginManager["default"]([new PileupRendererPlugin(), new SvgFeatureRendererPlugin()]).createPluggableElements().configure());
|
|
86
|
+
var config = configSchema.create({
|
|
87
|
+
type: 'LinearVariantDisplay',
|
|
88
|
+
displayId: 'diplayId0',
|
|
89
|
+
name: 'Zonker Display'
|
|
90
|
+
});
|
|
91
|
+
expect(config.type).toEqual('LinearVariantDisplay');
|
|
92
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "configSchemaFactory", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _configSchema.LinearVariantDisplayConfigFactory;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "modelFactory", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _model["default"];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
var _configSchema = require("./configSchema");
|
|
22
|
+
|
|
23
|
+
var _model = _interopRequireDefault(require("./model"));
|
|
@@ -0,0 +1,75 @@
|
|
|
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"] = _default;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _configuration = require("@jbrowse/core/configuration");
|
|
15
|
+
|
|
16
|
+
var _tracks = require("@jbrowse/core/util/tracks");
|
|
17
|
+
|
|
18
|
+
var _util = require("@jbrowse/core/util");
|
|
19
|
+
|
|
20
|
+
var _pluginLinearGenomeView = require("@jbrowse/plugin-linear-genome-view");
|
|
21
|
+
|
|
22
|
+
var _mobxStateTree = require("mobx-state-tree");
|
|
23
|
+
|
|
24
|
+
function _default(configSchema) {
|
|
25
|
+
return _mobxStateTree.types.compose('LinearVariantDisplay', (0, _pluginLinearGenomeView.linearBasicDisplayModelFactory)(configSchema), _mobxStateTree.types.model({
|
|
26
|
+
type: _mobxStateTree.types.literal('LinearVariantDisplay'),
|
|
27
|
+
configuration: (0, _configuration.ConfigurationReference)(configSchema)
|
|
28
|
+
})).actions(function (self) {
|
|
29
|
+
return {
|
|
30
|
+
selectFeature: function selectFeature(feature) {
|
|
31
|
+
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
32
|
+
var session, rpcManager, sessionId, track, adapterConfig, header, featureWidget;
|
|
33
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
34
|
+
while (1) {
|
|
35
|
+
switch (_context.prev = _context.next) {
|
|
36
|
+
case 0:
|
|
37
|
+
session = (0, _util.getSession)(self);
|
|
38
|
+
|
|
39
|
+
if (!(0, _util.isSessionModelWithWidgets)(session)) {
|
|
40
|
+
_context.next = 11;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
rpcManager = session.rpcManager;
|
|
45
|
+
sessionId = (0, _tracks.getRpcSessionId)(self);
|
|
46
|
+
track = (0, _util.getContainingTrack)(self);
|
|
47
|
+
adapterConfig = (0, _configuration.getConf)(track, 'adapter');
|
|
48
|
+
_context.next = 8;
|
|
49
|
+
return rpcManager.call(sessionId, 'CoreGetMetadata', {
|
|
50
|
+
adapterConfig: adapterConfig
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
case 8:
|
|
54
|
+
header = _context.sent;
|
|
55
|
+
featureWidget = session.addWidget('VariantFeatureWidget', 'variantFeature', {
|
|
56
|
+
featureData: feature.toJSON(),
|
|
57
|
+
view: (0, _util.getContainingView)(self),
|
|
58
|
+
descriptions: header
|
|
59
|
+
});
|
|
60
|
+
session.showWidget(featureWidget);
|
|
61
|
+
|
|
62
|
+
case 11:
|
|
63
|
+
session.setSelection(feature);
|
|
64
|
+
|
|
65
|
+
case 12:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, _callee);
|
|
71
|
+
}))();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _mobxReact = require("mobx-react");
|
|
19
|
+
|
|
20
|
+
var _util = require("@jbrowse/core/util");
|
|
21
|
+
|
|
22
|
+
var _configuration = require("@jbrowse/core/configuration");
|
|
23
|
+
|
|
24
|
+
var _mst = require("@jbrowse/core/util/types/mst");
|
|
25
|
+
|
|
26
|
+
var _vcf = require("@gmod/vcf");
|
|
27
|
+
|
|
28
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
|
+
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
34
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
35
|
+
|
|
36
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
+
|
|
38
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
39
|
+
|
|
40
|
+
function bpToRadians(block, pos) {
|
|
41
|
+
var blockStart = block.region.elided ? 0 : block.region.start;
|
|
42
|
+
var blockEnd = block.region.elided ? 0 : block.region.end;
|
|
43
|
+
var bpOffset = block.flipped ? blockEnd - pos : pos - blockStart;
|
|
44
|
+
var radians = bpOffset / block.bpPerRadian + block.startRadians;
|
|
45
|
+
return radians;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var Chord = (0, _mobxReact.observer)(function Chord(_ref) {
|
|
49
|
+
var _feature$get;
|
|
50
|
+
|
|
51
|
+
var feature = _ref.feature,
|
|
52
|
+
blocksForRefs = _ref.blocksForRefs,
|
|
53
|
+
radius = _ref.radius,
|
|
54
|
+
config = _ref.config,
|
|
55
|
+
bezierRadius = _ref.bezierRadius,
|
|
56
|
+
selected = _ref.selected,
|
|
57
|
+
_onClick = _ref.onClick;
|
|
58
|
+
// find the blocks that our start and end points belong to
|
|
59
|
+
var startBlock = blocksForRefs[feature.get('refName')];
|
|
60
|
+
|
|
61
|
+
if (!startBlock) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var svType;
|
|
66
|
+
|
|
67
|
+
if (feature.get('INFO')) {
|
|
68
|
+
;
|
|
69
|
+
|
|
70
|
+
var _ref2 = feature.get('INFO').SVTYPE || [];
|
|
71
|
+
|
|
72
|
+
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 1);
|
|
73
|
+
|
|
74
|
+
svType = _ref3[0];
|
|
75
|
+
} else if (feature.get('mate')) {
|
|
76
|
+
svType = 'mate';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var endPosition;
|
|
80
|
+
var endBlock;
|
|
81
|
+
var alt = (_feature$get = feature.get('ALT')) === null || _feature$get === void 0 ? void 0 : _feature$get[0];
|
|
82
|
+
var bnd = alt && (0, _vcf.parseBreakend)(alt);
|
|
83
|
+
|
|
84
|
+
if (bnd) {
|
|
85
|
+
// VCF BND
|
|
86
|
+
var matePosition = bnd.MatePosition.split(':');
|
|
87
|
+
endPosition = +matePosition[1];
|
|
88
|
+
endBlock = blocksForRefs[matePosition[0]];
|
|
89
|
+
} else if (alt === '<TRA>') {
|
|
90
|
+
var _feature$get2, _feature$get2$CHR, _feature$get3, _feature$get3$END;
|
|
91
|
+
|
|
92
|
+
// VCF TRA
|
|
93
|
+
var chr2 = (_feature$get2 = feature.get('INFO')) === null || _feature$get2 === void 0 ? void 0 : (_feature$get2$CHR = _feature$get2.CHR2) === null || _feature$get2$CHR === void 0 ? void 0 : _feature$get2$CHR[0];
|
|
94
|
+
var end = (_feature$get3 = feature.get('INFO')) === null || _feature$get3 === void 0 ? void 0 : (_feature$get3$END = _feature$get3.END) === null || _feature$get3$END === void 0 ? void 0 : _feature$get3$END[0];
|
|
95
|
+
endPosition = parseInt(end, 10);
|
|
96
|
+
endBlock = blocksForRefs[chr2];
|
|
97
|
+
} else if (svType === 'mate') {
|
|
98
|
+
// generic simplefeatures arcs
|
|
99
|
+
var mate = feature.get('mate');
|
|
100
|
+
var _chr = mate.refName;
|
|
101
|
+
endPosition = mate.start;
|
|
102
|
+
endBlock = blocksForRefs[_chr];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (endBlock) {
|
|
106
|
+
var startPos = feature.get('start');
|
|
107
|
+
var startRadians = bpToRadians(startBlock, startPos);
|
|
108
|
+
var endRadians = bpToRadians(endBlock, endPosition);
|
|
109
|
+
var startXY = (0, _util.polarToCartesian)(radius, startRadians);
|
|
110
|
+
var endXY = (0, _util.polarToCartesian)(radius, endRadians);
|
|
111
|
+
var controlXY = (0, _util.polarToCartesian)(bezierRadius, (endRadians + startRadians) / 2);
|
|
112
|
+
var strokeColor = selected ? (0, _configuration.readConfObject)(config, 'strokeColorSelected', {
|
|
113
|
+
feature: feature
|
|
114
|
+
}) : (0, _configuration.readConfObject)(config, 'strokeColor', {
|
|
115
|
+
feature: feature
|
|
116
|
+
});
|
|
117
|
+
var hoverStrokeColor = (0, _configuration.readConfObject)(config, 'strokeColorHover', {
|
|
118
|
+
feature: feature
|
|
119
|
+
});
|
|
120
|
+
return /*#__PURE__*/_react["default"].createElement("path", {
|
|
121
|
+
"data-testid": "chord-".concat(feature.id()),
|
|
122
|
+
d: ['M'].concat((0, _toConsumableArray2["default"])(startXY), ['Q'], (0, _toConsumableArray2["default"])(controlXY), (0, _toConsumableArray2["default"])(endXY)).join(' '),
|
|
123
|
+
style: {
|
|
124
|
+
stroke: strokeColor
|
|
125
|
+
},
|
|
126
|
+
onClick: function onClick(evt) {
|
|
127
|
+
return _onClick(feature, startBlock.region, endBlock.region, evt);
|
|
128
|
+
},
|
|
129
|
+
onMouseOver: function onMouseOver(evt) {
|
|
130
|
+
if (!selected) {
|
|
131
|
+
evt.target.style.stroke = hoverStrokeColor;
|
|
132
|
+
evt.target.style.strokeWidth = 3;
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
onMouseOut: function onMouseOut(evt) {
|
|
136
|
+
if (!selected) {
|
|
137
|
+
evt.target.style.stroke = strokeColor;
|
|
138
|
+
evt.target.style.strokeWidth = 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
function StructuralVariantChords(props) {
|
|
148
|
+
var features = props.features,
|
|
149
|
+
config = props.config,
|
|
150
|
+
displayModel = props.displayModel,
|
|
151
|
+
blockDefinitions = props.blockDefinitions,
|
|
152
|
+
radius = props.radius,
|
|
153
|
+
bezierRadius = props.bezierRadius,
|
|
154
|
+
selectedFeatureId = props.displayModel.selectedFeatureId,
|
|
155
|
+
onChordClick = props.onChordClick; // make a map of refName -> blockDefinition
|
|
156
|
+
|
|
157
|
+
var blocksForRefsMemo = (0, _react.useMemo)(function () {
|
|
158
|
+
var blocksForRefs = {};
|
|
159
|
+
blockDefinitions.forEach(function (block) {
|
|
160
|
+
var regions = block.region.elided ? block.region.regions : [block.region];
|
|
161
|
+
regions.forEach(function (region) {
|
|
162
|
+
blocksForRefs[region.refName] = block;
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
return blocksForRefs;
|
|
166
|
+
}, [blockDefinitions]); // console.log(blocksForRefs)
|
|
167
|
+
|
|
168
|
+
var chords = [];
|
|
169
|
+
|
|
170
|
+
var _iterator = _createForOfIteratorHelper(features),
|
|
171
|
+
_step;
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
175
|
+
var _step$value = (0, _slicedToArray2["default"])(_step.value, 2),
|
|
176
|
+
id = _step$value[0],
|
|
177
|
+
feature = _step$value[1];
|
|
178
|
+
|
|
179
|
+
var selected = String(selectedFeatureId) === String(feature.id());
|
|
180
|
+
chords.push( /*#__PURE__*/_react["default"].createElement(Chord, {
|
|
181
|
+
key: id,
|
|
182
|
+
feature: feature,
|
|
183
|
+
config: config,
|
|
184
|
+
displayModel: displayModel,
|
|
185
|
+
radius: radius,
|
|
186
|
+
bezierRadius: bezierRadius,
|
|
187
|
+
blocksForRefs: blocksForRefsMemo,
|
|
188
|
+
selected: selected,
|
|
189
|
+
onClick: onChordClick
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
} catch (err) {
|
|
193
|
+
_iterator.e(err);
|
|
194
|
+
} finally {
|
|
195
|
+
_iterator.f();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
var trackStyleId = "chords-".concat(displayModel.id);
|
|
199
|
+
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
200
|
+
id: trackStyleId,
|
|
201
|
+
"data-testid": "structuralVariantChordRenderer"
|
|
202
|
+
}, /*#__PURE__*/_react["default"].createElement("style", {
|
|
203
|
+
// eslint-disable-next-line react/no-danger
|
|
204
|
+
dangerouslySetInnerHTML: {
|
|
205
|
+
__html: "\n #".concat(trackStyleId, " > path {\n cursor: crosshair;\n fill: none;\n }\n")
|
|
206
|
+
}
|
|
207
|
+
}), chords);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
StructuralVariantChords.propTypes = {
|
|
211
|
+
features: _propTypes["default"].instanceOf(Map).isRequired,
|
|
212
|
+
config: _mst.PropTypes.ConfigSchema.isRequired,
|
|
213
|
+
displayModel: _mobxReact.PropTypes.objectOrObservableObject,
|
|
214
|
+
blockDefinitions: _propTypes["default"].arrayOf(_mobxReact.PropTypes.objectOrObservableObject).isRequired,
|
|
215
|
+
radius: _propTypes["default"].number.isRequired,
|
|
216
|
+
bezierRadius: _propTypes["default"].number.isRequired,
|
|
217
|
+
selectedFeatureId: _propTypes["default"].string,
|
|
218
|
+
onChordClick: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].string])
|
|
219
|
+
};
|
|
220
|
+
StructuralVariantChords.defaultProps = {
|
|
221
|
+
displayModel: undefined,
|
|
222
|
+
selectedFeatureId: '',
|
|
223
|
+
onChordClick: undefined
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
var _default = (0, _mobxReact.observer)(StructuralVariantChords);
|
|
227
|
+
|
|
228
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 _CircularChordRendererType = _interopRequireDefault(require("@jbrowse/core/pluggableElementTypes/renderers/CircularChordRendererType"));
|
|
11
|
+
|
|
12
|
+
var _configuration = require("@jbrowse/core/configuration");
|
|
13
|
+
|
|
14
|
+
var _ReactComponent = _interopRequireDefault(require("./ReactComponent"));
|
|
15
|
+
|
|
16
|
+
var ChordRendererConfigF = function ChordRendererConfigF(pluginManager) {
|
|
17
|
+
var configSchema = (0, _configuration.ConfigurationSchema)('StructuralVariantChordRenderer', {
|
|
18
|
+
strokeColor: {
|
|
19
|
+
type: 'color',
|
|
20
|
+
description: 'the line color of each arc',
|
|
21
|
+
defaultValue: 'rgba(255,133,0,0.32)',
|
|
22
|
+
contextVariable: ['feature']
|
|
23
|
+
},
|
|
24
|
+
strokeColorSelected: {
|
|
25
|
+
type: 'color',
|
|
26
|
+
description: 'the line color of an arc that has been selected',
|
|
27
|
+
defaultValue: 'black',
|
|
28
|
+
contextVariable: ['feature']
|
|
29
|
+
},
|
|
30
|
+
strokeColorHover: {
|
|
31
|
+
type: 'color',
|
|
32
|
+
description: 'the line color of an arc that is being hovered over with the mouse',
|
|
33
|
+
defaultValue: '#555',
|
|
34
|
+
contextVariable: ['feature']
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
explicitlyTyped: true
|
|
38
|
+
});
|
|
39
|
+
return new _CircularChordRendererType["default"]({
|
|
40
|
+
name: 'StructuralVariantChordRenderer',
|
|
41
|
+
ReactComponent: _ReactComponent["default"],
|
|
42
|
+
configSchema: configSchema,
|
|
43
|
+
pluginManager: pluginManager
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
var _default = ChordRendererConfigF;
|
|
48
|
+
exports["default"] = _default;
|