@jbrowse/plugin-sequence 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.
@@ -4,6 +4,7 @@ import FeatureRendererType from '@jbrowse/core/pluggableElementTypes/renderers/F
4
4
  import TrackType from '@jbrowse/core/pluggableElementTypes/TrackType';
5
5
  import Plugin from '@jbrowse/core/Plugin';
6
6
  import { BaseLinearDisplay, BaseLinearDisplayComponent } from '@jbrowse/plugin-linear-genome-view';
7
+ import { getFileName, makeIndex } from '@jbrowse/core/util/tracks';
7
8
  import { ConfigurationSchema, ConfigurationReference, readConfObject } from '@jbrowse/core/configuration';
8
9
  import { contrastingTextColor } from '@jbrowse/core/util/color';
9
10
  import { createJBrowseTheme } from '@jbrowse/core/ui';
@@ -187,6 +188,8 @@ function _assertThisInitialized(self) {
187
188
  function _possibleConstructorReturn(self, call) {
188
189
  if (call && (typeof call === "object" || typeof call === "function")) {
189
190
  return call;
191
+ } else if (call !== void 0) {
192
+ throw new TypeError("Derived constructors may only return object or undefined");
190
193
  }
191
194
 
192
195
  return _assertThisInitialized(self);
@@ -290,19 +293,22 @@ var bgzipFastaAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('BgzipFasta
290
293
  fastaLocation: {
291
294
  type: 'fileLocation',
292
295
  defaultValue: {
293
- uri: '/path/to/seq.fa.gz'
296
+ uri: '/path/to/seq.fa.gz',
297
+ locationType: 'UriLocation'
294
298
  }
295
299
  },
296
300
  faiLocation: {
297
301
  type: 'fileLocation',
298
302
  defaultValue: {
299
- uri: '/path/to/seq.fa.gz.fai'
303
+ uri: '/path/to/seq.fa.gz.fai',
304
+ locationType: 'UriLocation'
300
305
  }
301
306
  },
302
307
  gziLocation: {
303
308
  type: 'fileLocation',
304
309
  defaultValue: {
305
- uri: '/path/to/seq.fa.gz.gzi'
310
+ uri: '/path/to/seq.fa.gz.gzi',
311
+ locationType: 'UriLocation'
306
312
  }
307
313
  }
308
314
  }, {
@@ -313,7 +319,8 @@ var chromSizesAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('ChromSizes
313
319
  chromSizesLocation: {
314
320
  type: 'fileLocation',
315
321
  defaultValue: {
316
- uri: '/path/to/species.chrom.sizes'
322
+ uri: '/path/to/species.chrom.sizes',
323
+ locationType: 'UriLocation'
317
324
  }
318
325
  }
319
326
  }, {
@@ -545,13 +552,15 @@ var indexedFastaAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('IndexedF
545
552
  fastaLocation: {
546
553
  type: 'fileLocation',
547
554
  defaultValue: {
548
- uri: '/path/to/seq.fa'
555
+ uri: '/path/to/seq.fa',
556
+ locationType: 'UriLocation'
549
557
  }
550
558
  },
551
559
  faiLocation: {
552
560
  type: 'fileLocation',
553
561
  defaultValue: {
554
- uri: '/path/to/seq.fa.fai'
562
+ uri: '/path/to/seq.fa.fai',
563
+ locationType: 'UriLocation'
555
564
  }
556
565
  }
557
566
  }, {
@@ -588,9 +597,7 @@ function modelFactory(configSchema) {
588
597
  showTranslation: showTranslation
589
598
  });
590
599
  },
591
- regionCannotBeRendered: function regionCannotBeRendered()
592
- /* region */
593
- {
600
+ regionCannotBeRendered: function regionCannotBeRendered() {
594
601
  var view = getContainingView(self);
595
602
 
596
603
  if (view && view.bpPerPx >= 1) {
@@ -651,13 +658,15 @@ var twoBitAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('TwoBitAdapter'
651
658
  twoBitLocation: {
652
659
  type: 'fileLocation',
653
660
  defaultValue: {
654
- uri: '/path/to/my.2bit'
661
+ uri: '/path/to/my.2bit',
662
+ locationType: 'UriLocation'
655
663
  }
656
664
  },
657
665
  chromSizesLocation: {
658
666
  type: 'fileLocation',
659
667
  defaultValue: {
660
- uri: '/path/to/default.chrom.sizes'
668
+ uri: '/path/to/default.chrom.sizes',
669
+ locationType: 'UriLocation'
661
670
  },
662
671
  description: 'An optional chrom.sizes file can be supplied to speed up loading since parsing the twobit file can take time'
663
672
  }
@@ -807,6 +816,12 @@ var SequencePlugin = /*#__PURE__*/function (_Plugin) {
807
816
  return new AdapterType({
808
817
  name: 'TwoBitAdapter',
809
818
  configSchema: twoBitAdapterConfigSchema,
819
+ adapterMetadata: {
820
+ category: null,
821
+ hiddenFromGUI: true,
822
+ displayName: null,
823
+ description: null
824
+ },
810
825
  getAdapterClass: function getAdapterClass() {
811
826
  return Promise.resolve().then(function () { return TwoBitAdapter$1; }).then(function (r) {
812
827
  return r["default"];
@@ -814,10 +829,41 @@ var SequencePlugin = /*#__PURE__*/function (_Plugin) {
814
829
  }
815
830
  });
816
831
  });
832
+ pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
833
+ return function (file, index, adapterHint) {
834
+ var regexGuess = /\.2bit$/i;
835
+ var adapterName = 'TwoBitAdapter';
836
+ var fileName = getFileName(file);
837
+
838
+ if (regexGuess.test(fileName) || adapterHint === adapterName) {
839
+ return {
840
+ type: adapterName,
841
+ twoBitLocation: file
842
+ };
843
+ }
844
+
845
+ return adapterGuesser(file, index, adapterHint);
846
+ };
847
+ });
848
+ pluginManager.addToExtensionPoint('Core-guessTrackTypeForLocation', function (trackTypeGuesser) {
849
+ return function (adapterName) {
850
+ if (adapterName === 'TwoBitAdapter') {
851
+ return 'ReferenceSequenceTrack';
852
+ }
853
+
854
+ return trackTypeGuesser(adapterName);
855
+ };
856
+ });
817
857
  pluginManager.addAdapterType(function () {
818
858
  return new AdapterType({
819
859
  name: 'ChromSizesAdapter',
820
860
  configSchema: chromSizesAdapterConfigSchema,
861
+ adapterMetadata: {
862
+ category: null,
863
+ hiddenFromGUI: true,
864
+ displayName: null,
865
+ description: null
866
+ },
821
867
  getAdapterClass: function getAdapterClass() {
822
868
  return Promise.resolve().then(function () { return ChromSizesAdapter; }).then(function (r) {
823
869
  return r["default"];
@@ -829,6 +875,12 @@ var SequencePlugin = /*#__PURE__*/function (_Plugin) {
829
875
  return new AdapterType({
830
876
  name: 'IndexedFastaAdapter',
831
877
  configSchema: indexedFastaAdapterConfigSchema,
878
+ adapterMetadata: {
879
+ category: null,
880
+ hiddenFromGUI: true,
881
+ displayName: null,
882
+ description: null
883
+ },
832
884
  getAdapterClass: function getAdapterClass() {
833
885
  return Promise.resolve().then(function () { return IndexedFastaAdapter; }).then(function (r) {
834
886
  return r["default"];
@@ -836,10 +888,42 @@ var SequencePlugin = /*#__PURE__*/function (_Plugin) {
836
888
  }
837
889
  });
838
890
  });
891
+ pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
892
+ return function (file, index, adapterHint) {
893
+ var regexGuess = /\.(fa|fasta|fas|fna|mfa)$/i;
894
+ var adapterName = 'IndexedFastaAdapter';
895
+ var fileName = getFileName(file);
896
+
897
+ if (regexGuess.test(fileName) || adapterHint === adapterName) {
898
+ return {
899
+ type: adapterName,
900
+ fastaLocation: file,
901
+ faiLocation: index || makeIndex(file, '.fai')
902
+ };
903
+ }
904
+
905
+ return adapterGuesser(file, index, adapterHint);
906
+ };
907
+ });
908
+ pluginManager.addToExtensionPoint('Core-guessTrackTypeForLocation', function (trackTypeGuesser) {
909
+ return function (adapterName) {
910
+ if (adapterName === 'IndexedFastaAdapter') {
911
+ return 'ReferenceSequenceTrack';
912
+ }
913
+
914
+ return trackTypeGuesser(adapterName);
915
+ };
916
+ });
839
917
  pluginManager.addAdapterType(function () {
840
918
  return new AdapterType({
841
919
  name: 'BgzipFastaAdapter',
842
920
  configSchema: bgzipFastaAdapterConfigSchema,
921
+ adapterMetadata: {
922
+ category: null,
923
+ hiddenFromGUI: true,
924
+ displayName: null,
925
+ description: null
926
+ },
843
927
  getAdapterClass: function getAdapterClass() {
844
928
  return Promise.resolve().then(function () { return BgzipFastaAdapter; }).then(function (r) {
845
929
  return r["default"];
@@ -847,9 +931,41 @@ var SequencePlugin = /*#__PURE__*/function (_Plugin) {
847
931
  }
848
932
  });
849
933
  });
934
+ pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
935
+ return function (file, index, adapterHint) {
936
+ var regexGuess = /\.(fa|fasta|fas|fna|mfa)\.b?gz$/i;
937
+ var adapterName = 'BgzipFastaAdapter';
938
+ var fileName = getFileName(file);
939
+
940
+ if (regexGuess.test(fileName) || adapterHint === adapterName) {
941
+ return {
942
+ type: adapterName,
943
+ faiLocation: makeIndex(file, '.fai'),
944
+ gziLocation: makeIndex(file, '.gzi')
945
+ };
946
+ }
947
+
948
+ return adapterGuesser(file, index, adapterHint);
949
+ };
950
+ });
951
+ pluginManager.addToExtensionPoint('Core-guessTrackTypeForLocation', function (trackTypeGuesser) {
952
+ return function (adapterName) {
953
+ if (adapterName === 'BgzipFastaAdapter') {
954
+ return 'ReferenceSequenceTrack';
955
+ }
956
+
957
+ return trackTypeGuesser(adapterName);
958
+ };
959
+ });
850
960
  pluginManager.addAdapterType(function () {
851
961
  return new AdapterType(_objectSpread2({
852
- name: 'GCContentAdapter'
962
+ name: 'GCContentAdapter',
963
+ adapterMetadata: {
964
+ category: null,
965
+ hiddenFromGUI: true,
966
+ displayName: null,
967
+ description: null
968
+ }
853
969
  }, pluginManager.load(GCContentAdapterF)));
854
970
  });
855
971
  pluginManager.addTrackType(function () {
@@ -982,11 +1098,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
982
1098
 
983
1099
 
984
1100
  var IteratorPrototype = {};
985
-
986
- IteratorPrototype[iteratorSymbol] = function () {
1101
+ define(IteratorPrototype, iteratorSymbol, function () {
987
1102
  return this;
988
- };
989
-
1103
+ });
990
1104
  var getProto = Object.getPrototypeOf;
991
1105
  var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
992
1106
 
@@ -997,8 +1111,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
997
1111
  }
998
1112
 
999
1113
  var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
1000
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
1001
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
1114
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
1115
+ define(Gp, "constructor", GeneratorFunctionPrototype);
1116
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
1002
1117
  GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
1003
1118
  // Iterator interface in terms of a single ._invoke method.
1004
1119
 
@@ -1103,11 +1218,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
1103
1218
  }
1104
1219
 
1105
1220
  defineIteratorMethods(AsyncIterator.prototype);
1106
-
1107
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
1221
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1108
1222
  return this;
1109
- };
1110
-
1223
+ });
1111
1224
  exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
1112
1225
  // AsyncIterator objects; they just return a Promise for the value of
1113
1226
  // the final result produced by the iterator.
@@ -1284,13 +1397,12 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
1284
1397
  // object to not be returned from this call. This ensures that doesn't happen.
1285
1398
  // See https://github.com/facebook/regenerator/issues/274 for more details.
1286
1399
 
1287
- Gp[iteratorSymbol] = function () {
1400
+ define(Gp, iteratorSymbol, function () {
1288
1401
  return this;
1289
- };
1290
-
1291
- Gp.toString = function () {
1402
+ });
1403
+ define(Gp, "toString", function () {
1292
1404
  return "[object Generator]";
1293
- };
1405
+ });
1294
1406
 
1295
1407
  function pushTryEntry(locs) {
1296
1408
  var entry = {
@@ -1602,14 +1714,19 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
1602
1714
  } catch (accidentalStrictMode) {
1603
1715
  // This module should not be running in strict mode, so the above
1604
1716
  // assignment should always work unless something is misconfigured. Just
1605
- // in case runtime.js accidentally runs in strict mode, we can escape
1717
+ // in case runtime.js accidentally runs in strict mode, in modern engines
1718
+ // we can explicitly access globalThis. In older engines we can escape
1606
1719
  // strict mode using a global Function call. This could conceivably fail
1607
1720
  // if a Content Security Policy forbids using Function, but in that case
1608
1721
  // the proper solution is to fix the accidental strict mode problem. If
1609
1722
  // you've misconfigured your bundler to force strict mode and applied a
1610
1723
  // CSP to forbid Function, and you're not willing to fix either of those
1611
1724
  // problems, please detail your unique predicament in a GitHub issue.
1612
- Function("r", "regeneratorRuntime = r")(runtime);
1725
+ if (typeof globalThis === "object") {
1726
+ globalThis.regeneratorRuntime = runtime;
1727
+ } else {
1728
+ Function("r", "regeneratorRuntime = r")(runtime);
1729
+ }
1613
1730
  }
1614
1731
  });
1615
1732
 
@@ -1818,9 +1935,9 @@ var default_1 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1818
1935
 
1819
1936
  }, {
1820
1937
  key: "freeResources",
1821
- value: function freeResources()
1822
- /* { region } */
1823
- {}
1938
+ value: function
1939
+ /* { region } */
1940
+ freeResources() {}
1824
1941
  }]);
1825
1942
 
1826
1943
  return default_1;
@@ -1837,15 +1954,15 @@ var TwoBitAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1837
1954
 
1838
1955
  var _super = /*#__PURE__*/_createSuper(TwoBitAdapter);
1839
1956
 
1840
- function TwoBitAdapter(config) {
1957
+ function TwoBitAdapter(config, getSubAdapter, pluginManager) {
1841
1958
  var _this;
1842
1959
 
1843
1960
  _classCallCheck(this, TwoBitAdapter);
1844
1961
 
1845
- _this = _super.call(this, config);
1962
+ _this = _super.call(this, config, getSubAdapter, pluginManager);
1846
1963
  _this.chromSizesData = _this.initChromSizes();
1847
1964
  _this.twobit = new TwoBitFile({
1848
- filehandle: openLocation(readConfObject(config, 'twoBitLocation'))
1965
+ filehandle: openLocation(readConfObject(config, 'twoBitLocation'), _this.pluginManager)
1849
1966
  });
1850
1967
  return _this;
1851
1968
  }
@@ -1868,7 +1985,7 @@ var TwoBitAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1868
1985
  break;
1869
1986
  }
1870
1987
 
1871
- file = openLocation(conf);
1988
+ file = openLocation(conf, this.pluginManager);
1872
1989
  _context.next = 5;
1873
1990
  return file.readFile('utf8');
1874
1991
 
@@ -2065,9 +2182,9 @@ var TwoBitAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2065
2182
 
2066
2183
  }, {
2067
2184
  key: "freeResources",
2068
- value: function freeResources()
2069
- /* { region } */
2070
- {}
2185
+ value: function
2186
+ /* { region } */
2187
+ freeResources() {}
2071
2188
  }]);
2072
2189
 
2073
2190
  return TwoBitAdapter;
@@ -2083,19 +2200,19 @@ var _default = /*#__PURE__*/function (_BaseAdapter) {
2083
2200
 
2084
2201
  var _super = /*#__PURE__*/_createSuper(_default);
2085
2202
 
2086
- function _default(config) {
2203
+ function _default(config, getSubAdapter, pluginManager) {
2087
2204
  var _this;
2088
2205
 
2089
2206
  _classCallCheck(this, _default);
2090
2207
 
2091
- _this = _super.call(this, config);
2208
+ _this = _super.call(this, config, getSubAdapter, pluginManager);
2092
2209
  var chromSizesLocation = readConfObject(config, 'chromSizesLocation');
2093
2210
 
2094
2211
  if (!chromSizesLocation) {
2095
2212
  throw new Error('must provide chromSizesLocation');
2096
2213
  }
2097
2214
 
2098
- var file = openLocation(chromSizesLocation);
2215
+ var file = openLocation(chromSizesLocation, _this.pluginManager);
2099
2216
  _this.source = file.toString();
2100
2217
  _this.refSeqs = _this.init(file);
2101
2218
  return _this;
@@ -2194,9 +2311,9 @@ var _default = /*#__PURE__*/function (_BaseAdapter) {
2194
2311
  }
2195
2312
  }, {
2196
2313
  key: "freeResources",
2197
- value: function freeResources()
2198
- /* { region } */
2199
- {}
2314
+ value: function
2315
+ /* { region } */
2316
+ freeResources() {}
2200
2317
  }]);
2201
2318
 
2202
2319
  return _default;
@@ -2212,12 +2329,12 @@ var _default$1 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2212
2329
 
2213
2330
  var _super = /*#__PURE__*/_createSuper(_default);
2214
2331
 
2215
- function _default(config) {
2332
+ function _default(config, getSubAdapter, pluginManager) {
2216
2333
  var _this;
2217
2334
 
2218
2335
  _classCallCheck(this, _default);
2219
2336
 
2220
- _this = _super.call(this, config);
2337
+ _this = _super.call(this, config, getSubAdapter, pluginManager);
2221
2338
  _this.seqCache = new AbortablePromiseCache({
2222
2339
  cache: new LRU({
2223
2340
  maxSize: 200
@@ -2252,8 +2369,8 @@ var _default$1 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2252
2369
  var fastaLocation = readConfObject(config, 'fastaLocation');
2253
2370
  var faiLocation = readConfObject(config, 'faiLocation');
2254
2371
  var fastaOpts = {
2255
- fasta: openLocation(fastaLocation),
2256
- fai: openLocation(faiLocation)
2372
+ fasta: openLocation(fastaLocation, _this.pluginManager),
2373
+ fai: openLocation(faiLocation, _this.pluginManager)
2257
2374
  };
2258
2375
  _this.fasta = new IndexedFasta(fastaOpts);
2259
2376
  return _this;
@@ -2382,9 +2499,9 @@ var _default$1 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2382
2499
 
2383
2500
  }, {
2384
2501
  key: "freeResources",
2385
- value: function freeResources()
2386
- /* { region } */
2387
- {}
2502
+ value: function
2503
+ /* { region } */
2504
+ freeResources() {}
2388
2505
  }]);
2389
2506
 
2390
2507
  return _default;
@@ -2400,12 +2517,12 @@ var _default$2 = /*#__PURE__*/function (_IndexedFasta) {
2400
2517
 
2401
2518
  var _super = /*#__PURE__*/_createSuper(_default);
2402
2519
 
2403
- function _default(config) {
2520
+ function _default(config, getSubAdapter, pluginManager) {
2404
2521
  var _this;
2405
2522
 
2406
2523
  _classCallCheck(this, _default);
2407
2524
 
2408
- _this = _super.call(this, config);
2525
+ _this = _super.call(this, config, getSubAdapter, pluginManager);
2409
2526
  var fastaLocation = readConfObject(config, 'fastaLocation');
2410
2527
  var faiLocation = readConfObject(config, 'faiLocation');
2411
2528
  var gziLocation = readConfObject(config, 'gziLocation');
@@ -2423,9 +2540,9 @@ var _default$2 = /*#__PURE__*/function (_IndexedFasta) {
2423
2540
  }
2424
2541
 
2425
2542
  var fastaOpts = {
2426
- fasta: openLocation(fastaLocation),
2427
- fai: openLocation(faiLocation),
2428
- gzi: openLocation(gziLocation)
2543
+ fasta: openLocation(fastaLocation, _this.pluginManager),
2544
+ fai: openLocation(faiLocation, _this.pluginManager),
2545
+ gzi: openLocation(gziLocation, _this.pluginManager)
2429
2546
  };
2430
2547
  _this.fasta = new BgzipIndexedFasta(fastaOpts);
2431
2548
  return _this;