@jbrowse/plugin-variants 1.4.4 → 1.5.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.
@@ -8,7 +8,7 @@ import WidgetType from '@jbrowse/core/pluggableElementTypes/WidgetType';
8
8
  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
- import { getRpcSessionId } from '@jbrowse/core/util/tracks';
11
+ import { getRpcSessionId, getFileName, makeIndex, makeIndexType } from '@jbrowse/core/util/tracks';
12
12
  import { getContainingView, getSession, isSessionModelWithWidgets, getContainingTrack, polarToCartesian } from '@jbrowse/core/util';
13
13
  import { types, getSnapshot, getEnv } from 'mobx-state-tree';
14
14
  import ChordRendererType from '@jbrowse/core/pluggableElementTypes/renderers/CircularChordRendererType';
@@ -20,10 +20,11 @@ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'
20
20
  import { openLocation } from '@jbrowse/core/util/io';
21
21
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
22
22
  import { TabixIndexedFile } from '@gmod/tabix';
23
+ import IntervalTree from '@flatten-js/interval-tree';
23
24
  import { unzip } from '@gmod/bgzf-filehandle';
24
25
  import { Dialog, DialogTitle, IconButton, Divider, DialogContent, FormControlLabel, Checkbox, DialogActions, Button, Paper, Typography, TextField, Link } from '@material-ui/core';
25
26
  import SimpleFeature from '@jbrowse/core/util/simpleFeature';
26
- import { DataGrid } from '@material-ui/data-grid';
27
+ import { DataGrid } from '@mui/x-data-grid';
27
28
  import { FeatureDetails, BaseCard } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail';
28
29
  import { makeStyles } from '@material-ui/core/styles';
29
30
  import CloseIcon from '@material-ui/icons/Close';
@@ -230,6 +231,8 @@ function _assertThisInitialized(self) {
230
231
  function _possibleConstructorReturn(self, call) {
231
232
  if (call && (typeof call === "object" || typeof call === "function")) {
232
233
  return call;
234
+ } else if (call !== void 0) {
235
+ throw new TypeError("Derived constructors may only return object or undefined");
233
236
  }
234
237
 
235
238
  return _assertThisInitialized(self);
@@ -593,11 +596,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
593
596
 
594
597
 
595
598
  var IteratorPrototype = {};
596
-
597
- IteratorPrototype[iteratorSymbol] = function () {
599
+ define(IteratorPrototype, iteratorSymbol, function () {
598
600
  return this;
599
- };
600
-
601
+ });
601
602
  var getProto = Object.getPrototypeOf;
602
603
  var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
603
604
 
@@ -608,8 +609,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
608
609
  }
609
610
 
610
611
  var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
611
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
612
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
612
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
613
+ define(Gp, "constructor", GeneratorFunctionPrototype);
614
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
613
615
  GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
614
616
  // Iterator interface in terms of a single ._invoke method.
615
617
 
@@ -714,11 +716,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
714
716
  }
715
717
 
716
718
  defineIteratorMethods(AsyncIterator.prototype);
717
-
718
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
719
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
719
720
  return this;
720
- };
721
-
721
+ });
722
722
  exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
723
723
  // AsyncIterator objects; they just return a Promise for the value of
724
724
  // the final result produced by the iterator.
@@ -895,13 +895,12 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
895
895
  // object to not be returned from this call. This ensures that doesn't happen.
896
896
  // See https://github.com/facebook/regenerator/issues/274 for more details.
897
897
 
898
- Gp[iteratorSymbol] = function () {
898
+ define(Gp, iteratorSymbol, function () {
899
899
  return this;
900
- };
901
-
902
- Gp.toString = function () {
900
+ });
901
+ define(Gp, "toString", function () {
903
902
  return "[object Generator]";
904
- };
903
+ });
905
904
 
906
905
  function pushTryEntry(locs) {
907
906
  var entry = {
@@ -1213,14 +1212,19 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
1213
1212
  } catch (accidentalStrictMode) {
1214
1213
  // This module should not be running in strict mode, so the above
1215
1214
  // assignment should always work unless something is misconfigured. Just
1216
- // in case runtime.js accidentally runs in strict mode, we can escape
1215
+ // in case runtime.js accidentally runs in strict mode, in modern engines
1216
+ // we can explicitly access globalThis. In older engines we can escape
1217
1217
  // strict mode using a global Function call. This could conceivably fail
1218
1218
  // if a Content Security Policy forbids using Function, but in that case
1219
1219
  // the proper solution is to fix the accidental strict mode problem. If
1220
1220
  // you've misconfigured your bundler to force strict mode and applied a
1221
1221
  // CSP to forbid Function, and you're not willing to fix either of those
1222
1222
  // problems, please detail your unique predicament in a GitHub issue.
1223
- Function("r", "regeneratorRuntime = r")(runtime);
1223
+ if (typeof globalThis === "object") {
1224
+ globalThis.regeneratorRuntime = runtime;
1225
+ } else {
1226
+ Function("r", "regeneratorRuntime = r")(runtime);
1227
+ }
1224
1228
  }
1225
1229
  });
1226
1230
 
@@ -1318,7 +1322,7 @@ var Chord = /*#__PURE__*/observer(function Chord(_ref) {
1318
1322
  var endPosition;
1319
1323
  var endBlock;
1320
1324
  var alt = (_feature$get = feature.get('ALT')) === null || _feature$get === void 0 ? void 0 : _feature$get[0];
1321
- var bnd = parseBreakend(alt);
1325
+ var bnd = alt && parseBreakend(alt);
1322
1326
 
1323
1327
  if (bnd) {
1324
1328
  // VCF BND
@@ -1374,6 +1378,7 @@ var Chord = /*#__PURE__*/observer(function Chord(_ref) {
1374
1378
  onMouseOut: function onMouseOut(evt) {
1375
1379
  if (!selected) {
1376
1380
  evt.target.style.stroke = strokeColor;
1381
+ evt.target.style.strokeWidth = 1;
1377
1382
  }
1378
1383
  }
1379
1384
  });
@@ -1517,7 +1522,8 @@ var vcfTabixAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('VcfTabixAdap
1517
1522
  vcfGzLocation: {
1518
1523
  type: 'fileLocation',
1519
1524
  defaultValue: {
1520
- uri: '/path/to/my.vcf.gz'
1525
+ uri: '/path/to/my.vcf.gz',
1526
+ locationType: 'UriLocation'
1521
1527
  }
1522
1528
  },
1523
1529
  index: /*#__PURE__*/ConfigurationSchema('VcfIndex', {
@@ -1529,7 +1535,8 @@ var vcfTabixAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('VcfTabixAdap
1529
1535
  location: {
1530
1536
  type: 'fileLocation',
1531
1537
  defaultValue: {
1532
- uri: '/path/to/my.vcf.gz.tbi'
1538
+ uri: '/path/to/my.vcf.gz.tbi',
1539
+ locationType: 'UriLocation'
1533
1540
  }
1534
1541
  }
1535
1542
  })
@@ -1541,7 +1548,8 @@ var vcfAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('VcfAdapter', {
1541
1548
  vcfLocation: {
1542
1549
  type: 'fileLocation',
1543
1550
  defaultValue: {
1544
- uri: '/path/to/my.vcf'
1551
+ uri: '/path/to/my.vcf',
1552
+ locationType: 'UriLocation'
1545
1553
  }
1546
1554
  }
1547
1555
  }, {
@@ -1810,6 +1818,36 @@ var VariantsPlugin = /*#__PURE__*/function (_Plugin) {
1810
1818
  }
1811
1819
  });
1812
1820
  });
1821
+ pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
1822
+ return function (file, index, adapterHint) {
1823
+ var regexGuess = /\.vcf\.b?gz$/i;
1824
+ var adapterName = 'VcfTabixAdapter';
1825
+ var fileName = getFileName(file);
1826
+ var indexName = index && getFileName(index);
1827
+
1828
+ if (regexGuess.test(fileName) || adapterHint === adapterName) {
1829
+ return {
1830
+ type: adapterName,
1831
+ vcfGzLocation: file,
1832
+ index: {
1833
+ location: index || makeIndex(file, '.tbi'),
1834
+ indexType: makeIndexType(indexName, 'CSI', 'TBI')
1835
+ }
1836
+ };
1837
+ }
1838
+
1839
+ return adapterGuesser(file, index, adapterHint);
1840
+ };
1841
+ });
1842
+ pluginManager.addToExtensionPoint('Core-guessTrackTypeForLocation', function (trackTypeGuesser) {
1843
+ return function (adapterName) {
1844
+ if (adapterName === 'VcfTabixAdapter') {
1845
+ return 'VariantTrack';
1846
+ }
1847
+
1848
+ return trackTypeGuesser(adapterName);
1849
+ };
1850
+ });
1813
1851
  pluginManager.addAdapterType(function () {
1814
1852
  return new AdapterType({
1815
1853
  name: 'VcfAdapter',
@@ -1821,6 +1859,22 @@ var VariantsPlugin = /*#__PURE__*/function (_Plugin) {
1821
1859
  }
1822
1860
  });
1823
1861
  });
1862
+ pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
1863
+ return function (file, index, adapterHint) {
1864
+ var regexGuess = /\.vcf$/i;
1865
+ var adapterName = 'VcfAdapter';
1866
+ var fileName = getFileName(file);
1867
+
1868
+ if (regexGuess.test(fileName) || adapterHint === adapterName) {
1869
+ return {
1870
+ type: adapterName,
1871
+ vcfLocation: file
1872
+ };
1873
+ }
1874
+
1875
+ return adapterGuesser(file, index, adapterHint);
1876
+ };
1877
+ });
1824
1878
  pluginManager.addRendererType(function () {
1825
1879
  return pluginManager.jbrequire(ChordRendererConfigF);
1826
1880
  });
@@ -1891,12 +1945,12 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1891
1945
  vcfGzLocation = readConfObject(this.config, 'vcfGzLocation');
1892
1946
  location = readConfObject(this.config, ['index', 'location']);
1893
1947
  indexType = readConfObject(this.config, ['index', 'indexType']);
1894
- filehandle = openLocation(vcfGzLocation);
1948
+ filehandle = openLocation(vcfGzLocation, this.pluginManager);
1895
1949
  isCSI = indexType === 'CSI';
1896
1950
  vcf = new TabixIndexedFile({
1897
1951
  filehandle: filehandle,
1898
- csiFilehandle: isCSI ? openLocation(location) : undefined,
1899
- tbiFilehandle: !isCSI ? openLocation(location) : undefined,
1952
+ csiFilehandle: isCSI ? openLocation(location, this.pluginManager) : undefined,
1953
+ tbiFilehandle: !isCSI ? openLocation(location, this.pluginManager) : undefined,
1900
1954
  chunkCacheSize: 50 * Math.pow(2, 20),
1901
1955
  chunkSizeLimit: 1000000000
1902
1956
  });
@@ -2228,9 +2282,9 @@ var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2228
2282
  }()
2229
2283
  }, {
2230
2284
  key: "freeResources",
2231
- value: function freeResources()
2232
- /* { region } */
2233
- {}
2285
+ value: function
2286
+ /* { region } */
2287
+ freeResources() {}
2234
2288
  }]);
2235
2289
 
2236
2290
  return _default;
@@ -2244,12 +2298,9 @@ var VcfTabixAdapter = {
2244
2298
  var readVcf = function readVcf(f) {
2245
2299
  var lines = f.split('\n');
2246
2300
  var header = [];
2247
- var refNames = [];
2248
2301
  var rest = [];
2249
2302
  lines.forEach(function (line) {
2250
- if (line.startsWith('##contig')) {
2251
- refNames.push(line.split('##contig=<ID=')[1].split(',')[0]);
2252
- } else if (line.startsWith('#')) {
2303
+ if (line.startsWith('#')) {
2253
2304
  header.push(line);
2254
2305
  } else if (line) {
2255
2306
  rest.push(line);
@@ -2257,60 +2308,44 @@ var readVcf = function readVcf(f) {
2257
2308
  });
2258
2309
  return {
2259
2310
  header: header.join('\n'),
2260
- lines: rest,
2261
- refNames: refNames
2311
+ lines: rest
2262
2312
  };
2263
2313
  };
2264
2314
 
2315
+ function isGzip(buf) {
2316
+ return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
2317
+ }
2318
+
2265
2319
  var VcfAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2266
2320
  _inherits(VcfAdapter, _BaseFeatureDataAdapt);
2267
2321
 
2268
2322
  var _super = /*#__PURE__*/_createSuper(VcfAdapter);
2269
2323
 
2270
- function VcfAdapter(config) {
2324
+ function VcfAdapter() {
2271
2325
  _classCallCheck(this, VcfAdapter);
2272
2326
 
2273
- return _super.call(this, config);
2327
+ return _super.apply(this, arguments);
2274
2328
  }
2275
2329
 
2276
2330
  _createClass(VcfAdapter, [{
2277
- key: "decodeFileContents",
2331
+ key: "getHeader",
2278
2332
  value: function () {
2279
- var _decodeFileContents = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
2280
- var vcfLocation, fileContents;
2333
+ var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
2334
+ var _yield$this$setup, header;
2335
+
2281
2336
  return runtime_1.wrap(function _callee$(_context) {
2282
2337
  while (1) {
2283
2338
  switch (_context.prev = _context.next) {
2284
2339
  case 0:
2285
- vcfLocation = readConfObject(this.config, 'vcfLocation');
2286
- _context.next = 3;
2287
- return openLocation(vcfLocation).readFile();
2288
-
2289
- case 3:
2290
- fileContents = _context.sent;
2291
-
2292
- if (!(typeof fileContents[0] === 'number' && fileContents[0] === 31 && typeof fileContents[1] === 'number' && fileContents[1] === 139 && typeof fileContents[2] === 'number' && fileContents[2] === 8)) {
2293
- _context.next = 12;
2294
- break;
2295
- }
2296
-
2297
- _context.t0 = new TextDecoder();
2298
- _context.next = 8;
2299
- return unzip(fileContents);
2340
+ _context.next = 2;
2341
+ return this.setup();
2300
2342
 
2301
- case 8:
2302
- _context.t1 = _context.sent;
2303
- fileContents = _context.t0.decode.call(_context.t0, _context.t1);
2304
- _context.next = 13;
2305
- break;
2306
-
2307
- case 12:
2308
- fileContents = fileContents.toString();
2309
-
2310
- case 13:
2311
- return _context.abrupt("return", readVcf(fileContents));
2343
+ case 2:
2344
+ _yield$this$setup = _context.sent;
2345
+ header = _yield$this$setup.header;
2346
+ return _context.abrupt("return", header);
2312
2347
 
2313
- case 14:
2348
+ case 5:
2314
2349
  case "end":
2315
2350
  return _context.stop();
2316
2351
  }
@@ -2318,31 +2353,34 @@ var VcfAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2318
2353
  }, _callee, this);
2319
2354
  }));
2320
2355
 
2321
- function decodeFileContents() {
2322
- return _decodeFileContents.apply(this, arguments);
2356
+ function getHeader() {
2357
+ return _getHeader.apply(this, arguments);
2323
2358
  }
2324
2359
 
2325
- return decodeFileContents;
2360
+ return getHeader;
2326
2361
  }()
2327
2362
  }, {
2328
- key: "getHeader",
2363
+ key: "getMetadata",
2329
2364
  value: function () {
2330
- var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2331
- var _yield$this$decodeFil, header;
2365
+ var _getMetadata = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2366
+ var _yield$this$setup2, header, parser;
2332
2367
 
2333
2368
  return runtime_1.wrap(function _callee2$(_context2) {
2334
2369
  while (1) {
2335
2370
  switch (_context2.prev = _context2.next) {
2336
2371
  case 0:
2337
2372
  _context2.next = 2;
2338
- return this.decodeFileContents();
2373
+ return this.setup();
2339
2374
 
2340
2375
  case 2:
2341
- _yield$this$decodeFil = _context2.sent;
2342
- header = _yield$this$decodeFil.header;
2343
- return _context2.abrupt("return", header);
2376
+ _yield$this$setup2 = _context2.sent;
2377
+ header = _yield$this$setup2.header;
2378
+ parser = new VCF({
2379
+ header: header
2380
+ });
2381
+ return _context2.abrupt("return", parser.getMetadata());
2344
2382
 
2345
- case 5:
2383
+ case 6:
2346
2384
  case "end":
2347
2385
  return _context2.stop();
2348
2386
  }
@@ -2350,111 +2388,131 @@ var VcfAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2350
2388
  }, _callee2, this);
2351
2389
  }));
2352
2390
 
2353
- function getHeader() {
2354
- return _getHeader.apply(this, arguments);
2391
+ function getMetadata() {
2392
+ return _getMetadata.apply(this, arguments);
2355
2393
  }
2356
2394
 
2357
- return getHeader;
2358
- }()
2395
+ return getMetadata;
2396
+ }() // converts lines into an interval tree
2397
+
2359
2398
  }, {
2360
- key: "getMetadata",
2399
+ key: "setupP",
2361
2400
  value: function () {
2362
- var _getMetadata = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
2363
- var _yield$this$decodeFil2, header, parser;
2401
+ var _setupP = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
2402
+ var buffer, buf, str, _readVcf, header, lines, intervalTree;
2364
2403
 
2365
2404
  return runtime_1.wrap(function _callee3$(_context3) {
2366
2405
  while (1) {
2367
2406
  switch (_context3.prev = _context3.next) {
2368
2407
  case 0:
2369
2408
  _context3.next = 2;
2370
- return this.decodeFileContents();
2409
+ return openLocation(readConfObject(this.config, 'vcfLocation'), this.pluginManager).readFile();
2371
2410
 
2372
2411
  case 2:
2373
- _yield$this$decodeFil2 = _context3.sent;
2374
- header = _yield$this$decodeFil2.header;
2375
- parser = new VCF({
2376
- header: header
2377
- });
2378
- return _context3.abrupt("return", parser.getMetadata());
2412
+ buffer = _context3.sent;
2413
+
2414
+ if (!isGzip(buffer)) {
2415
+ _context3.next = 9;
2416
+ break;
2417
+ }
2418
+
2419
+ _context3.next = 6;
2420
+ return unzip(buffer);
2379
2421
 
2380
2422
  case 6:
2381
- case "end":
2382
- return _context3.stop();
2383
- }
2384
- }
2385
- }, _callee3, this);
2386
- }));
2423
+ _context3.t0 = _context3.sent;
2424
+ _context3.next = 10;
2425
+ break;
2387
2426
 
2388
- function getMetadata() {
2389
- return _getMetadata.apply(this, arguments);
2390
- }
2427
+ case 9:
2428
+ _context3.t0 = buffer;
2391
2429
 
2392
- return getMetadata;
2393
- }()
2394
- }, {
2395
- key: "getLines",
2396
- value: function () {
2397
- var _getLines = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
2398
- var _this = this;
2430
+ case 10:
2431
+ buf = _context3.t0;
2399
2432
 
2400
- var _yield$this$decodeFil3, header, lines, parser;
2433
+ if (!(buf.length > 536870888)) {
2434
+ _context3.next = 13;
2435
+ break;
2436
+ }
2401
2437
 
2402
- return runtime_1.wrap(function _callee4$(_context4) {
2403
- while (1) {
2404
- switch (_context4.prev = _context4.next) {
2405
- case 0:
2406
- _context4.next = 2;
2407
- return this.decodeFileContents();
2438
+ throw new Error('Data exceeds maximum string length (512MB)');
2408
2439
 
2409
- case 2:
2410
- _yield$this$decodeFil3 = _context4.sent;
2411
- header = _yield$this$decodeFil3.header;
2412
- lines = _yield$this$decodeFil3.lines;
2413
- parser = new VCF({
2414
- header: header
2440
+ case 13:
2441
+ str = new TextDecoder().decode(buf);
2442
+ _readVcf = readVcf(str), header = _readVcf.header, lines = _readVcf.lines;
2443
+ intervalTree = lines.map(function (line, id) {
2444
+ var _info$match;
2445
+
2446
+ var _line$split = line.split('\t'),
2447
+ _line$split2 = _slicedToArray(_line$split, 8),
2448
+ refName = _line$split2[0],
2449
+ startP = _line$split2[1],
2450
+ ref = _line$split2[3],
2451
+ info = _line$split2[7];
2452
+
2453
+ var start = +startP - 1;
2454
+ var end = +(((_info$match = info.match(/END=(\d+)/)) === null || _info$match === void 0 ? void 0 : _info$match[1].trim()) || start + ref.length);
2455
+ return {
2456
+ line: line,
2457
+ refName: refName,
2458
+ start: start,
2459
+ end: end,
2460
+ id: id
2461
+ };
2462
+ }).reduce(function (acc, obj) {
2463
+ var key = obj.refName;
2464
+
2465
+ if (!acc[key]) {
2466
+ acc[key] = new IntervalTree();
2467
+ }
2468
+
2469
+ acc[key].insert([obj.start, obj.end], obj);
2470
+ return acc;
2471
+ }, {});
2472
+ return _context3.abrupt("return", {
2473
+ header: header,
2474
+ intervalTree: intervalTree
2415
2475
  });
2416
- return _context4.abrupt("return", lines.map(function (line, index) {
2417
- return new VCFFeature({
2418
- variant: parser.parseLine(line),
2419
- parser: parser,
2420
- id: "".concat(_this.id, "-vcf-").concat(index)
2421
- });
2422
- }));
2423
2476
 
2424
- case 7:
2477
+ case 17:
2425
2478
  case "end":
2426
- return _context4.stop();
2479
+ return _context3.stop();
2427
2480
  }
2428
2481
  }
2429
- }, _callee4, this);
2482
+ }, _callee3, this);
2430
2483
  }));
2431
2484
 
2432
- function getLines() {
2433
- return _getLines.apply(this, arguments);
2485
+ function setupP() {
2486
+ return _setupP.apply(this, arguments);
2434
2487
  }
2435
2488
 
2436
- return getLines;
2489
+ return setupP;
2437
2490
  }()
2438
2491
  }, {
2439
2492
  key: "setup",
2440
2493
  value: function () {
2441
- var _setup = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
2442
- return runtime_1.wrap(function _callee5$(_context5) {
2494
+ var _setup = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
2495
+ var _this = this;
2496
+
2497
+ return runtime_1.wrap(function _callee4$(_context4) {
2443
2498
  while (1) {
2444
- switch (_context5.prev = _context5.next) {
2499
+ switch (_context4.prev = _context4.next) {
2445
2500
  case 0:
2446
- if (!this.setupP) {
2447
- this.setupP = this.getLines();
2501
+ if (!this.vcfFeatures) {
2502
+ this.vcfFeatures = this.setupP()["catch"](function (e) {
2503
+ _this.vcfFeatures = undefined;
2504
+ throw e;
2505
+ });
2448
2506
  }
2449
2507
 
2450
- return _context5.abrupt("return", this.setupP);
2508
+ return _context4.abrupt("return", this.vcfFeatures);
2451
2509
 
2452
2510
  case 2:
2453
2511
  case "end":
2454
- return _context5.stop();
2512
+ return _context4.stop();
2455
2513
  }
2456
2514
  }
2457
- }, _callee5, this);
2515
+ }, _callee4, this);
2458
2516
  }));
2459
2517
 
2460
2518
  function setup() {
@@ -2466,28 +2524,28 @@ var VcfAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2466
2524
  }, {
2467
2525
  key: "getRefNames",
2468
2526
  value: function () {
2469
- var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
2470
- var _yield$this$decodeFil4,
2471
- refNames;
2527
+ var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
2528
+ var _yield$this$setup3,
2529
+ intervalTree;
2472
2530
 
2473
- return runtime_1.wrap(function _callee6$(_context6) {
2531
+ return runtime_1.wrap(function _callee5$(_context5) {
2474
2532
  while (1) {
2475
- switch (_context6.prev = _context6.next) {
2533
+ switch (_context5.prev = _context5.next) {
2476
2534
  case 0:
2477
- _context6.next = 3;
2478
- return this.decodeFileContents();
2535
+ _context5.next = 3;
2536
+ return this.setup();
2479
2537
 
2480
2538
  case 3:
2481
- _yield$this$decodeFil4 = _context6.sent;
2482
- refNames = _yield$this$decodeFil4.refNames;
2483
- return _context6.abrupt("return", refNames);
2539
+ _yield$this$setup3 = _context5.sent;
2540
+ intervalTree = _yield$this$setup3.intervalTree;
2541
+ return _context5.abrupt("return", Object.keys(intervalTree));
2484
2542
 
2485
2543
  case 6:
2486
2544
  case "end":
2487
- return _context6.stop();
2545
+ return _context5.stop();
2488
2546
  }
2489
2547
  }
2490
- }, _callee6, this);
2548
+ }, _callee5, this);
2491
2549
  }));
2492
2550
 
2493
2551
  function getRefNames() {
@@ -2503,30 +2561,47 @@ var VcfAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2503
2561
 
2504
2562
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2505
2563
  return ObservableCreate( /*#__PURE__*/function () {
2506
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(observer) {
2507
- var feats;
2508
- return runtime_1.wrap(function _callee7$(_context7) {
2564
+ var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(observer) {
2565
+ var _intervalTree$refName, start, end, refName, _yield$_this2$setup, header, intervalTree, parser;
2566
+
2567
+ return runtime_1.wrap(function _callee6$(_context6) {
2509
2568
  while (1) {
2510
- switch (_context7.prev = _context7.next) {
2569
+ switch (_context6.prev = _context6.next) {
2511
2570
  case 0:
2512
- _context7.next = 2;
2571
+ _context6.prev = 0;
2572
+ start = region.start, end = region.end, refName = region.refName;
2573
+ _context6.next = 4;
2513
2574
  return _this2.setup();
2514
2575
 
2515
- case 2:
2516
- feats = _context7.sent;
2517
- feats.forEach(function (f) {
2518
- if (f.get('refName') === region.refName && f.get('end') > region.start && f.get('start') < region.end) {
2519
- observer.next(f);
2520
- }
2576
+ case 4:
2577
+ _yield$_this2$setup = _context6.sent;
2578
+ header = _yield$_this2$setup.header;
2579
+ intervalTree = _yield$_this2$setup.intervalTree;
2580
+ parser = new VCF({
2581
+ header: header
2582
+ });
2583
+ (_intervalTree$refName = intervalTree[refName]) === null || _intervalTree$refName === void 0 ? void 0 : _intervalTree$refName.search([start, end]).forEach(function (f) {
2584
+ return observer.next(new VCFFeature({
2585
+ variant: parser.parseLine(f.line),
2586
+ parser: parser,
2587
+ id: "".concat(_this2.id, "-").concat(f.id)
2588
+ }));
2521
2589
  });
2522
2590
  observer.complete();
2591
+ _context6.next = 15;
2592
+ break;
2523
2593
 
2524
- case 5:
2594
+ case 12:
2595
+ _context6.prev = 12;
2596
+ _context6.t0 = _context6["catch"](0);
2597
+ observer.error(_context6.t0);
2598
+
2599
+ case 15:
2525
2600
  case "end":
2526
- return _context7.stop();
2601
+ return _context6.stop();
2527
2602
  }
2528
2603
  }
2529
- }, _callee7);
2604
+ }, _callee6, null, [[0, 12]]);
2530
2605
  }));
2531
2606
 
2532
2607
  return function (_x) {