@jbrowse/plugin-variants 1.5.6 → 1.6.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.
@@ -9,7 +9,7 @@ import Plugin from '@jbrowse/core/Plugin';
9
9
  import { linearBasicDisplayConfigSchemaFactory, linearBasicDisplayModelFactory, BaseLinearDisplayComponent } from '@jbrowse/plugin-linear-genome-view';
10
10
  import { baseChordDisplayConfig, BaseChordDisplayModel, BaseChordDisplayComponentFactory } from '@jbrowse/plugin-circular-view';
11
11
  import { getRpcSessionId, getFileName, makeIndex, makeIndexType } from '@jbrowse/core/util/tracks';
12
- import { getContainingView, getSession, isSessionModelWithWidgets, getContainingTrack, polarToCartesian } from '@jbrowse/core/util';
12
+ import { getContainingView, getSession, isSessionModelWithWidgets, getContainingTrack, polarToCartesian, bytesForRegions } from '@jbrowse/core/util';
13
13
  import { types, getSnapshot, getEnv } from 'mobx-state-tree';
14
14
  import ChordRendererType from '@jbrowse/core/pluggableElementTypes/renderers/CircularChordRendererType';
15
15
  import { PropTypes as PropTypes$2, observer } from 'mobx-react';
@@ -136,14 +136,14 @@ function _inherits(subClass, superClass) {
136
136
  throw new TypeError("Super expression must either be null or a function");
137
137
  }
138
138
 
139
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
140
+ constructor: {
141
+ value: subClass,
142
+ writable: true,
143
+ configurable: true
144
+ }
145
+ });
139
146
  Object.defineProperty(subClass, "prototype", {
140
- value: Object.create(superClass && superClass.prototype, {
141
- constructor: {
142
- value: subClass,
143
- writable: true,
144
- configurable: true
145
- }
146
- }),
147
147
  writable: false
148
148
  });
149
149
  if (superClass) _setPrototypeOf(subClass, superClass);
@@ -1818,16 +1818,19 @@ var VariantsPlugin = /*#__PURE__*/function (_Plugin) {
1818
1818
  var adapterName = 'VcfTabixAdapter';
1819
1819
  var fileName = getFileName(file);
1820
1820
  var indexName = index && getFileName(index);
1821
+ var obj = {
1822
+ type: adapterName,
1823
+ vcfGzLocation: file,
1824
+ index: {
1825
+ location: index || makeIndex(file, '.tbi'),
1826
+ indexType: makeIndexType(indexName, 'CSI', 'TBI')
1827
+ }
1828
+ };
1821
1829
 
1822
- if (regexGuess.test(fileName) || adapterHint === adapterName) {
1823
- return {
1824
- type: adapterName,
1825
- vcfGzLocation: file,
1826
- index: {
1827
- location: index || makeIndex(file, '.tbi'),
1828
- indexType: makeIndexType(indexName, 'CSI', 'TBI')
1829
- }
1830
- };
1830
+ if (regexGuess.test(fileName) && !adapterHint) {
1831
+ return obj;
1832
+ } else if (adapterHint === adapterName) {
1833
+ return obj;
1831
1834
  }
1832
1835
 
1833
1836
  return adapterGuesser(file, index, adapterHint);
@@ -1925,51 +1928,78 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1925
1928
  }
1926
1929
 
1927
1930
  _createClass(_default, [{
1931
+ key: "configurePre",
1932
+ value: function () {
1933
+ var _configurePre = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1934
+ var vcfGzLocation, location, indexType, filehandle, isCSI, vcf, header;
1935
+ return runtime_1.wrap(function _callee$(_context) {
1936
+ while (1) {
1937
+ switch (_context.prev = _context.next) {
1938
+ case 0:
1939
+ vcfGzLocation = readConfObject(this.config, 'vcfGzLocation');
1940
+ location = readConfObject(this.config, ['index', 'location']);
1941
+ indexType = readConfObject(this.config, ['index', 'indexType']);
1942
+ filehandle = openLocation(vcfGzLocation, this.pluginManager);
1943
+ isCSI = indexType === 'CSI';
1944
+ vcf = new TabixIndexedFile({
1945
+ filehandle: filehandle,
1946
+ csiFilehandle: isCSI ? openLocation(location, this.pluginManager) : undefined,
1947
+ tbiFilehandle: !isCSI ? openLocation(location, this.pluginManager) : undefined,
1948
+ chunkCacheSize: 50 * Math.pow(2, 20),
1949
+ chunkSizeLimit: 1000000000
1950
+ });
1951
+ _context.next = 8;
1952
+ return vcf.getHeader();
1953
+
1954
+ case 8:
1955
+ header = _context.sent;
1956
+ return _context.abrupt("return", {
1957
+ filehandle: filehandle,
1958
+ vcf: vcf,
1959
+ parser: new VCF({
1960
+ header: header
1961
+ })
1962
+ });
1963
+
1964
+ case 10:
1965
+ case "end":
1966
+ return _context.stop();
1967
+ }
1968
+ }
1969
+ }, _callee, this);
1970
+ }));
1971
+
1972
+ function configurePre() {
1973
+ return _configurePre.apply(this, arguments);
1974
+ }
1975
+
1976
+ return configurePre;
1977
+ }()
1978
+ }, {
1928
1979
  key: "configure",
1929
1980
  value: function () {
1930
- var _configure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1981
+ var _configure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1931
1982
  var _this = this;
1932
1983
 
1933
- var vcfGzLocation, location, indexType, filehandle, isCSI, vcf;
1934
- return runtime_1.wrap(function _callee$(_context) {
1984
+ return runtime_1.wrap(function _callee2$(_context2) {
1935
1985
  while (1) {
1936
- switch (_context.prev = _context.next) {
1986
+ switch (_context2.prev = _context2.next) {
1937
1987
  case 0:
1938
1988
  if (!this.configured) {
1939
- vcfGzLocation = readConfObject(this.config, 'vcfGzLocation');
1940
- location = readConfObject(this.config, ['index', 'location']);
1941
- indexType = readConfObject(this.config, ['index', 'indexType']);
1942
- filehandle = openLocation(vcfGzLocation, this.pluginManager);
1943
- isCSI = indexType === 'CSI';
1944
- vcf = new TabixIndexedFile({
1945
- filehandle: filehandle,
1946
- csiFilehandle: isCSI ? openLocation(location, this.pluginManager) : undefined,
1947
- tbiFilehandle: !isCSI ? openLocation(location, this.pluginManager) : undefined,
1948
- chunkCacheSize: 50 * Math.pow(2, 20),
1949
- chunkSizeLimit: 1000000000
1950
- });
1951
- this.configured = vcf.getHeader().then(function (header) {
1952
- return {
1953
- filehandle: filehandle,
1954
- vcf: vcf,
1955
- parser: new VCF({
1956
- header: header
1957
- })
1958
- };
1959
- })["catch"](function (e) {
1989
+ this.configured = this.configurePre()["catch"](function (e) {
1960
1990
  _this.configured = undefined;
1961
1991
  throw e;
1962
1992
  });
1963
1993
  }
1964
1994
 
1965
- return _context.abrupt("return", this.configured);
1995
+ return _context2.abrupt("return", this.configured);
1966
1996
 
1967
1997
  case 2:
1968
1998
  case "end":
1969
- return _context.stop();
1999
+ return _context2.stop();
1970
2000
  }
1971
2001
  }
1972
- }, _callee, this);
2002
+ }, _callee2, this);
1973
2003
  }));
1974
2004
 
1975
2005
  function configure() {
@@ -1981,31 +2011,31 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1981
2011
  }, {
1982
2012
  key: "getRefNames",
1983
2013
  value: function () {
1984
- var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2014
+ var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
1985
2015
  var opts,
1986
2016
  _yield$this$configure,
1987
2017
  vcf,
1988
- _args2 = arguments;
2018
+ _args3 = arguments;
1989
2019
 
1990
- return runtime_1.wrap(function _callee2$(_context2) {
2020
+ return runtime_1.wrap(function _callee3$(_context3) {
1991
2021
  while (1) {
1992
- switch (_context2.prev = _context2.next) {
2022
+ switch (_context3.prev = _context3.next) {
1993
2023
  case 0:
1994
- opts = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
1995
- _context2.next = 3;
2024
+ opts = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
2025
+ _context3.next = 3;
1996
2026
  return this.configure();
1997
2027
 
1998
2028
  case 3:
1999
- _yield$this$configure = _context2.sent;
2029
+ _yield$this$configure = _context3.sent;
2000
2030
  vcf = _yield$this$configure.vcf;
2001
- return _context2.abrupt("return", vcf.getReferenceSequenceNames(opts));
2031
+ return _context3.abrupt("return", vcf.getReferenceSequenceNames(opts));
2002
2032
 
2003
2033
  case 6:
2004
2034
  case "end":
2005
- return _context2.stop();
2035
+ return _context3.stop();
2006
2036
  }
2007
2037
  }
2008
- }, _callee2, this);
2038
+ }, _callee3, this);
2009
2039
  }));
2010
2040
 
2011
2041
  function getRefNames() {
@@ -2017,27 +2047,27 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2017
2047
  }, {
2018
2048
  key: "getHeader",
2019
2049
  value: function () {
2020
- var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
2050
+ var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
2021
2051
  var _yield$this$configure2, vcf;
2022
2052
 
2023
- return runtime_1.wrap(function _callee3$(_context3) {
2053
+ return runtime_1.wrap(function _callee4$(_context4) {
2024
2054
  while (1) {
2025
- switch (_context3.prev = _context3.next) {
2055
+ switch (_context4.prev = _context4.next) {
2026
2056
  case 0:
2027
- _context3.next = 2;
2057
+ _context4.next = 2;
2028
2058
  return this.configure();
2029
2059
 
2030
2060
  case 2:
2031
- _yield$this$configure2 = _context3.sent;
2061
+ _yield$this$configure2 = _context4.sent;
2032
2062
  vcf = _yield$this$configure2.vcf;
2033
- return _context3.abrupt("return", vcf.getHeader());
2063
+ return _context4.abrupt("return", vcf.getHeader());
2034
2064
 
2035
2065
  case 5:
2036
2066
  case "end":
2037
- return _context3.stop();
2067
+ return _context4.stop();
2038
2068
  }
2039
2069
  }
2040
- }, _callee3, this);
2070
+ }, _callee4, this);
2041
2071
  }));
2042
2072
 
2043
2073
  function getHeader() {
@@ -2049,27 +2079,27 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2049
2079
  }, {
2050
2080
  key: "getMetadata",
2051
2081
  value: function () {
2052
- var _getMetadata = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
2082
+ var _getMetadata = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
2053
2083
  var _yield$this$configure3, parser;
2054
2084
 
2055
- return runtime_1.wrap(function _callee4$(_context4) {
2085
+ return runtime_1.wrap(function _callee5$(_context5) {
2056
2086
  while (1) {
2057
- switch (_context4.prev = _context4.next) {
2087
+ switch (_context5.prev = _context5.next) {
2058
2088
  case 0:
2059
- _context4.next = 2;
2089
+ _context5.next = 2;
2060
2090
  return this.configure();
2061
2091
 
2062
2092
  case 2:
2063
- _yield$this$configure3 = _context4.sent;
2093
+ _yield$this$configure3 = _context5.sent;
2064
2094
  parser = _yield$this$configure3.parser;
2065
- return _context4.abrupt("return", parser.getMetadata());
2095
+ return _context5.abrupt("return", parser.getMetadata());
2066
2096
 
2067
2097
  case 5:
2068
2098
  case "end":
2069
- return _context4.stop();
2099
+ return _context5.stop();
2070
2100
  }
2071
2101
  }
2072
- }, _callee4, this);
2102
+ }, _callee5, this);
2073
2103
  }));
2074
2104
 
2075
2105
  function getMetadata() {
@@ -2085,22 +2115,22 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2085
2115
 
2086
2116
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2087
2117
  return ObservableCreate( /*#__PURE__*/function () {
2088
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(observer) {
2118
+ var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(observer) {
2089
2119
  var refName, start, end, _yield$_this2$configu, vcf, parser;
2090
2120
 
2091
- return runtime_1.wrap(function _callee5$(_context5) {
2121
+ return runtime_1.wrap(function _callee6$(_context6) {
2092
2122
  while (1) {
2093
- switch (_context5.prev = _context5.next) {
2123
+ switch (_context6.prev = _context6.next) {
2094
2124
  case 0:
2095
2125
  refName = query.refName, start = query.start, end = query.end;
2096
- _context5.next = 3;
2126
+ _context6.next = 3;
2097
2127
  return _this2.configure();
2098
2128
 
2099
2129
  case 3:
2100
- _yield$_this2$configu = _context5.sent;
2130
+ _yield$_this2$configu = _context6.sent;
2101
2131
  vcf = _yield$_this2$configu.vcf;
2102
2132
  parser = _yield$_this2$configu.parser;
2103
- _context5.next = 8;
2133
+ _context6.next = 8;
2104
2134
  return vcf.getLines(refName, start, end, _objectSpread2({
2105
2135
  lineCallback: function lineCallback(line, fileOffset) {
2106
2136
  observer.next(new VCFFeature({
@@ -2116,10 +2146,10 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2116
2146
 
2117
2147
  case 9:
2118
2148
  case "end":
2119
- return _context5.stop();
2149
+ return _context6.stop();
2120
2150
  }
2121
2151
  }
2122
- }, _callee5);
2152
+ }, _callee6);
2123
2153
  }));
2124
2154
 
2125
2155
  return function (_x) {
@@ -2154,29 +2184,35 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2154
2184
  var superGetFeaturesInMultipleRegions = _get(_getPrototypeOf(_default.prototype), "getFeaturesInMultipleRegions", this);
2155
2185
 
2156
2186
  return ObservableCreate( /*#__PURE__*/function () {
2157
- var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(observer) {
2158
- var bytes, _yield$_this3$configu, filehandle, stat, pct;
2187
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(observer) {
2188
+ var _yield$_this3$configu, vcf, bytes, _yield$_this3$configu2, filehandle, stat, pct;
2159
2189
 
2160
- return runtime_1.wrap(function _callee6$(_context6) {
2190
+ return runtime_1.wrap(function _callee7$(_context7) {
2161
2191
  while (1) {
2162
- switch (_context6.prev = _context6.next) {
2192
+ switch (_context7.prev = _context7.next) {
2163
2193
  case 0:
2164
- _context6.next = 2;
2165
- return _this3.bytesForRegions(regions);
2194
+ _context7.next = 2;
2195
+ return _this3.configure();
2166
2196
 
2167
2197
  case 2:
2168
- bytes = _context6.sent;
2169
- _context6.next = 5;
2198
+ _yield$_this3$configu = _context7.sent;
2199
+ vcf = _yield$_this3$configu.vcf;
2200
+ _context7.next = 6;
2201
+ return bytesForRegions(regions, vcf.index);
2202
+
2203
+ case 6:
2204
+ bytes = _context7.sent;
2205
+ _context7.next = 9;
2170
2206
  return _this3.configure();
2171
2207
 
2172
- case 5:
2173
- _yield$_this3$configu = _context6.sent;
2174
- filehandle = _yield$_this3$configu.filehandle;
2175
- _context6.next = 9;
2208
+ case 9:
2209
+ _yield$_this3$configu2 = _context7.sent;
2210
+ filehandle = _yield$_this3$configu2.filehandle;
2211
+ _context7.next = 13;
2176
2212
  return filehandle.stat();
2177
2213
 
2178
- case 9:
2179
- stat = _context6.sent;
2214
+ case 13:
2215
+ stat = _context7.sent;
2180
2216
  pct = Math.round(bytes / stat.size * 100);
2181
2217
 
2182
2218
  if (pct > 100) {
@@ -2190,12 +2226,12 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2190
2226
 
2191
2227
  superGetFeaturesInMultipleRegions.call(_this3, regions, opts).subscribe(observer); // super.getFeaturesInMultipleRegions(regions, opts).subscribe(observer)
2192
2228
 
2193
- case 14:
2229
+ case 18:
2194
2230
  case "end":
2195
- return _context6.stop();
2231
+ return _context7.stop();
2196
2232
  }
2197
2233
  }
2198
- }, _callee6);
2234
+ }, _callee7);
2199
2235
  }));
2200
2236
 
2201
2237
  return function (_x2) {
@@ -2203,77 +2239,6 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2203
2239
  };
2204
2240
  }());
2205
2241
  }
2206
- /**
2207
- * get the approximate number of bytes queried from the file for the given
2208
- * query regions
2209
- * @param regions - list of query regions
2210
- */
2211
-
2212
- }, {
2213
- key: "bytesForRegions",
2214
- value: function () {
2215
- var _bytesForRegions = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(regions) {
2216
- var _yield$this$configure4, vcf, blockResults, byteRanges;
2217
-
2218
- return runtime_1.wrap(function _callee7$(_context7) {
2219
- while (1) {
2220
- switch (_context7.prev = _context7.next) {
2221
- case 0:
2222
- _context7.next = 2;
2223
- return this.configure();
2224
-
2225
- case 2:
2226
- _yield$this$configure4 = _context7.sent;
2227
- vcf = _yield$this$configure4.vcf;
2228
- _context7.next = 6;
2229
- return Promise.all(regions.map(function (region) {
2230
- return (// @ts-ignore
2231
- vcf.index.blocksForRange(region.refName, region.start, region.end)
2232
- );
2233
- }));
2234
-
2235
- case 6:
2236
- blockResults = _context7.sent;
2237
- byteRanges = [];
2238
- blockResults.forEach(function (blocks) {
2239
- blocks.forEach(function (block) {
2240
- var start = block.minv.blockPosition;
2241
- var end = block.maxv.blockPosition + 64000;
2242
-
2243
- if (!byteRanges.find(function (range) {
2244
- if (range.start <= end && range.end >= start) {
2245
- range.start = Math.min(range.start, start);
2246
- range.end = Math.max(range.end, end);
2247
- return true;
2248
- }
2249
-
2250
- return false;
2251
- })) {
2252
- byteRanges.push({
2253
- start: start,
2254
- end: end
2255
- });
2256
- }
2257
- });
2258
- });
2259
- return _context7.abrupt("return", byteRanges.reduce(function (a, b) {
2260
- return a + b.end - b.start + 1;
2261
- }, 0));
2262
-
2263
- case 10:
2264
- case "end":
2265
- return _context7.stop();
2266
- }
2267
- }
2268
- }, _callee7, this);
2269
- }));
2270
-
2271
- function bytesForRegions(_x3) {
2272
- return _bytesForRegions.apply(this, arguments);
2273
- }
2274
-
2275
- return bytesForRegions;
2276
- }()
2277
2242
  }, {
2278
2243
  key: "freeResources",
2279
2244
  value: function