@jbrowse/img 2.1.7 → 2.2.1

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.
Files changed (51) hide show
  1. package/README.md +1 -4
  2. package/dist/bin.d.ts +2 -0
  3. package/dist/bin.js +2 -2
  4. package/dist/bin.js.map +1 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +207 -235
  7. package/dist/index.js.map +1 -0
  8. package/dist/index.testmod.d.ts +1 -0
  9. package/dist/index.testmod.js +166 -246
  10. package/dist/index.testmod.js.map +1 -0
  11. package/dist/parseArgv.d.ts +8 -0
  12. package/dist/parseArgv.js +42 -38
  13. package/dist/parseArgv.js.map +1 -0
  14. package/dist/parseArgv.testmod.d.ts +1 -0
  15. package/dist/parseArgv.testmod.js +25 -7
  16. package/dist/parseArgv.testmod.js.map +1 -0
  17. package/dist/renderRegion.d.ts +35 -0
  18. package/dist/renderRegion.js +350 -450
  19. package/dist/renderRegion.js.map +1 -0
  20. package/dist/util.d.ts +5 -0
  21. package/dist/util.js +31 -11
  22. package/dist/util.js.map +1 -0
  23. package/esm/bin.d.ts +2 -0
  24. package/esm/bin.js +4 -0
  25. package/esm/bin.js.map +1 -0
  26. package/esm/index.d.ts +1 -0
  27. package/esm/index.js +185 -0
  28. package/esm/index.js.map +1 -0
  29. package/esm/index.testmod.d.ts +1 -0
  30. package/esm/index.testmod.js +141 -0
  31. package/esm/index.testmod.js.map +1 -0
  32. package/esm/parseArgv.d.ts +8 -0
  33. package/esm/parseArgv.js +42 -0
  34. package/esm/parseArgv.js.map +1 -0
  35. package/esm/parseArgv.testmod.d.ts +1 -0
  36. package/esm/parseArgv.testmod.js +24 -0
  37. package/esm/parseArgv.testmod.js.map +1 -0
  38. package/esm/renderRegion.d.ts +35 -0
  39. package/esm/renderRegion.js +366 -0
  40. package/esm/renderRegion.js.map +1 -0
  41. package/esm/util.d.ts +5 -0
  42. package/esm/util.js +25 -0
  43. package/esm/util.js.map +1 -0
  44. package/package.json +18 -17
  45. package/src/bin.js +2 -0
  46. package/src/index.testmod.js +163 -0
  47. package/src/index.ts +209 -0
  48. package/src/parseArgv.testmod.js +29 -0
  49. package/src/parseArgv.ts +48 -0
  50. package/src/renderRegion.tsx +456 -0
  51. package/src/util.ts +32 -0
@@ -1,474 +1,374 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.readData = readData;
9
- exports.renderRegion = renderRegion;
10
-
11
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
-
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
- var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
16
-
17
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
18
-
19
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
20
-
21
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
22
-
23
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
24
-
25
- var _reactLinearGenomeView = require("@jbrowse/react-linear-genome-view");
26
-
27
- var _pluginLinearGenomeView = require("@jbrowse/plugin-linear-genome-view");
28
-
29
- var _mobx = require("mobx");
30
-
31
- var _path = _interopRequireDefault(require("path"));
32
-
33
- var _fs = _interopRequireDefault(require("fs"));
34
-
35
- var _util = require("./util");
36
-
37
- 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; }
38
-
39
- 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; }
40
-
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.renderRegion = exports.muiCache = exports.readData = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_linear_genome_view_1 = require("@jbrowse/react-linear-genome-view");
9
+ const plugin_linear_genome_view_1 = require("@jbrowse/plugin-linear-genome-view");
10
+ const cache_1 = __importDefault(require("@emotion/cache"));
11
+ const react_2 = require("@emotion/react");
12
+ const path_1 = __importDefault(require("path"));
13
+ const fs_1 = __importDefault(require("fs"));
14
+ const util_1 = require("./util");
41
15
  function read(file) {
42
- var res;
43
-
44
- try {
45
- res = JSON.parse(_fs.default.readFileSync(file));
46
- } catch (e) {
47
- throw new Error("Failed to parse ".concat(file, " as JSON, use --fasta if you mean to pass a FASTA file"));
48
- }
49
-
50
- return res;
16
+ let res;
17
+ try {
18
+ res = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
19
+ }
20
+ catch (e) {
21
+ throw new Error(`Failed to parse ${file} as JSON, use --fasta if you mean to pass a FASTA file`);
22
+ }
23
+ return res;
51
24
  }
52
-
53
25
  function makeLocation(file) {
54
- return file.startsWith('http') ? {
55
- uri: file
56
- } : {
57
- localPath: file
58
- };
26
+ return file.startsWith('http') ? { uri: file } : { localPath: file };
59
27
  }
60
-
61
28
  function addRelativePaths(config, configPath) {
62
- if ((0, _typeof2.default)(config) === 'object') {
63
- for (var _i = 0, _Object$keys = Object.keys(config); _i < _Object$keys.length; _i++) {
64
- var key = _Object$keys[_i];
65
-
66
- if ((0, _typeof2.default)(config[key]) === 'object') {
67
- addRelativePaths(config[key], configPath);
68
- } else if (key === 'localPath') {
69
- config.localPath = _path.default.resolve(configPath, config.localPath);
70
- }
29
+ if (typeof config === 'object') {
30
+ for (const key of Object.keys(config)) {
31
+ if (typeof config[key] === 'object') {
32
+ addRelativePaths(config[key], configPath);
33
+ }
34
+ else if (key === 'localPath') {
35
+ config.localPath = path_1.default.resolve(configPath, config.localPath);
36
+ }
37
+ }
71
38
  }
72
- }
73
39
  }
74
-
75
- function readData(opts) {
76
- var _sessionData, _sessionData2, _configData$assemblie;
77
-
78
- var asm = opts.assembly,
79
- config = opts.config,
80
- session = opts.session,
81
- fasta = opts.fasta,
82
- aliases = opts.aliases,
83
- defaultSession = opts.defaultSession,
84
- _opts$trackList = opts.trackList,
85
- trackList = _opts$trackList === void 0 ? [] : _opts$trackList,
86
- tracks = opts.tracks;
87
- var assemblyData = asm && _fs.default.existsSync(asm) ? read(asm) : undefined;
88
- var tracksData = tracks ? read(tracks) : undefined;
89
- var configData = config ? read(config) : {};
90
- var sessionData = session ? read(session) : undefined;
91
-
92
- if (config) {
93
- addRelativePaths(configData, _path.default.dirname(_path.default.resolve(config)));
94
- } // the session.json can be a raw session or a json file with a "session"
95
- // attribute, which is what is exported via the "File->Export session" in
96
- // jbrowse-web
97
-
98
-
99
- if ((_sessionData = sessionData) !== null && _sessionData !== void 0 && _sessionData.session) {
100
- sessionData = sessionData.session;
101
- } // only export first view
102
-
103
-
104
- if ((_sessionData2 = sessionData) !== null && _sessionData2 !== void 0 && _sessionData2.views) {
105
- sessionData.view = sessionData.views[0];
106
- } // use assembly from file if a file existed
107
-
108
-
109
- if (assemblyData) {
110
- configData.assembly = assemblyData;
111
- } // else check if it was an assembly name in a config file
112
- else if ((_configData$assemblie = configData.assemblies) !== null && _configData$assemblie !== void 0 && _configData$assemblie.length) {
113
- configData.assembly = asm ? configData.assemblies.find(function (entry) {
114
- return entry.name === asm;
115
- }) : configData.assemblies[0];
116
- } // else load fasta from command line
117
- else if (fasta) {
118
- var bgzip = fasta.endsWith('gz');
119
- configData.assembly = {
120
- name: _path.default.basename(fasta),
121
- sequence: {
122
- type: 'ReferenceSequenceTrack',
123
- trackId: 'refseq',
124
- adapter: {
125
- type: bgzip ? 'BgzipFastaAdapter' : 'IndexedFastaAdapter',
126
- fastaLocation: makeLocation(fasta),
127
- faiLocation: makeLocation(fasta + '.fai'),
128
- gziLocation: bgzip ? makeLocation(fasta + '.gzi') : undefined
40
+ function readData({ assembly: asm, config, session, fasta, aliases, cytobands, defaultSession, tracks, trackList = [], }) {
41
+ var _a;
42
+ const assemblyData = asm && fs_1.default.existsSync(asm) ? read(asm) : undefined;
43
+ const tracksData = tracks ? read(tracks) : undefined;
44
+ const configData = (config ? read(config) : {});
45
+ let sessionData = session ? read(session) : undefined;
46
+ if (config) {
47
+ addRelativePaths(configData, path_1.default.dirname(path_1.default.resolve(config)));
48
+ }
49
+ // the session.json can be a raw session or a json file with a "session"
50
+ // attribute, which is what is exported via the "File->Export session" in
51
+ // jbrowse-web
52
+ if (sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) {
53
+ sessionData = sessionData.session;
54
+ }
55
+ // only export first view
56
+ if (sessionData === null || sessionData === void 0 ? void 0 : sessionData.views) {
57
+ sessionData.view = sessionData.views[0];
58
+ }
59
+ // use assembly from file if a file existed
60
+ if (assemblyData) {
61
+ configData.assembly = assemblyData;
62
+ }
63
+ // else check if it was an assembly name in a config file
64
+ else if ((_a = configData.assemblies) === null || _a === void 0 ? void 0 : _a.length) {
65
+ configData.assemblies.find(entry => entry.name === asm);
66
+ if (asm) {
67
+ const assembly = configData.assemblies.find(entry => entry.name === asm);
68
+ if (!assembly) {
69
+ throw new Error(`assembly ${asm} not found in config`);
70
+ }
71
+ configData.assembly = assembly;
129
72
  }
130
- }
131
- };
132
-
133
- if (aliases) {
134
- configData.assembly.refNameAliases = {
135
- adapter: {
136
- type: 'RefNameAliasAdapter',
137
- location: makeLocation(aliases)
73
+ else {
74
+ configData.assembly = configData.assemblies[0];
138
75
  }
139
- };
140
76
  }
141
- } // throw if still no assembly
142
-
143
-
144
- if (!configData.assembly) {
145
- throw new Error('no assembly specified, use --fasta to supply an indexed FASTA file (generated with samtools faidx yourfile.fa). see README for alternatives with --assembly and --config');
146
- }
147
-
148
- if (tracksData) {
149
- configData.tracks = tracksData;
150
- } else if (!configData.tracks) {
151
- configData.tracks = [];
152
- }
153
-
154
- trackList.forEach(function (track) {
155
- var _track = (0, _slicedToArray2.default)(track, 2),
156
- type = _track[0],
157
- _track$ = (0, _slicedToArray2.default)(_track[1], 1),
158
- file = _track$[0];
159
-
160
- if (type === 'bam') {
161
- configData.tracks = [].concat((0, _toConsumableArray2.default)(configData.tracks), [{
162
- type: 'AlignmentsTrack',
163
- trackId: _path.default.basename(file),
164
- name: _path.default.basename(file),
165
- assemblyNames: [configData.assembly.name],
166
- adapter: {
167
- type: 'BamAdapter',
168
- bamLocation: makeLocation(file),
169
- index: {
170
- location: makeLocation(file + '.bai')
171
- },
172
- sequenceAdapter: configData.assembly.sequence.adapter
77
+ // else load fasta from command line
78
+ else if (fasta) {
79
+ const bgzip = fasta.endsWith('gz');
80
+ configData.assembly = {
81
+ name: path_1.default.basename(fasta),
82
+ sequence: {
83
+ type: 'ReferenceSequenceTrack',
84
+ trackId: 'refseq',
85
+ adapter: {
86
+ type: bgzip ? 'BgzipFastaAdapter' : 'IndexedFastaAdapter',
87
+ fastaLocation: makeLocation(fasta),
88
+ faiLocation: makeLocation(fasta + '.fai'),
89
+ gziLocation: bgzip ? makeLocation(fasta + '.gzi') : undefined,
90
+ },
91
+ },
92
+ };
93
+ if (aliases) {
94
+ configData.assembly.refNameAliases = {
95
+ adapter: {
96
+ type: 'RefNameAliasAdapter',
97
+ location: makeLocation(aliases),
98
+ },
99
+ };
173
100
  }
174
- }]);
175
- }
176
-
177
- if (type === 'cram') {
178
- configData.tracks = [].concat((0, _toConsumableArray2.default)(configData.tracks), [{
179
- type: 'AlignmentsTrack',
180
- trackId: _path.default.basename(file),
181
- name: _path.default.basename(file),
182
- assemblyNames: [configData.assembly.name],
183
- adapter: {
184
- type: 'CramAdapter',
185
- cramLocation: makeLocation(file),
186
- craiLocation: makeLocation(file + '.crai'),
187
- sequenceAdapter: configData.assembly.sequence.adapter
101
+ if (cytobands) {
102
+ configData.assembly.cytobands = {
103
+ adapter: {
104
+ type: 'CytobandAdapter',
105
+ location: makeLocation(cytobands),
106
+ },
107
+ };
188
108
  }
189
- }]);
190
109
  }
191
-
192
- if (type === 'bigwig') {
193
- configData.tracks = [].concat((0, _toConsumableArray2.default)(configData.tracks), [{
194
- type: 'QuantitativeTrack',
195
- trackId: _path.default.basename(file),
196
- name: _path.default.basename(file),
197
- assemblyNames: [configData.assembly.name],
198
- adapter: {
199
- type: 'BigWigAdapter',
200
- bigWigLocation: makeLocation(file)
201
- }
202
- }]);
110
+ // throw if still no assembly
111
+ if (!configData.assembly) {
112
+ throw new Error('no assembly specified, use --fasta to supply an indexed FASTA file (generated with samtools faidx yourfile.fa). see README for alternatives with --assembly and --config');
203
113
  }
204
-
205
- if (type === 'vcfgz') {
206
- configData.tracks = [].concat((0, _toConsumableArray2.default)(configData.tracks), [{
207
- type: 'VariantTrack',
208
- trackId: _path.default.basename(file),
209
- name: _path.default.basename(file),
210
- assemblyNames: [configData.assembly.name],
211
- adapter: {
212
- type: 'VcfTabixAdapter',
213
- vcfGzLocation: makeLocation(file),
214
- index: {
215
- location: makeLocation(file + '.tbi')
216
- }
217
- }
218
- }]);
114
+ if (tracksData) {
115
+ configData.tracks = tracksData;
219
116
  }
220
-
221
- if (type === 'gffgz') {
222
- configData.tracks = [].concat((0, _toConsumableArray2.default)(configData.tracks), [{
223
- type: 'FeatureTrack',
224
- trackId: _path.default.basename(file),
225
- name: _path.default.basename(file),
226
- assemblyNames: [configData.assembly.name],
227
- adapter: {
228
- type: 'Gff3TabixAdapter',
229
- gffGzLocation: makeLocation(file),
230
- index: {
231
- location: makeLocation(file + '.tbi')
232
- }
233
- }
234
- }]);
117
+ else if (!configData.tracks) {
118
+ configData.tracks = [];
235
119
  }
236
-
237
- if (type === 'hic') {
238
- configData.tracks = [].concat((0, _toConsumableArray2.default)(configData.tracks), [{
239
- type: 'HicTrack',
240
- trackId: _path.default.basename(file),
241
- name: _path.default.basename(file),
242
- assemblyNames: [configData.assembly.name],
243
- adapter: {
244
- type: 'HicAdapter',
245
- hicLocation: makeLocation(file)
120
+ trackList.forEach(track => {
121
+ const [type, [file]] = track;
122
+ if (type === 'bam') {
123
+ configData.tracks = [
124
+ ...configData.tracks,
125
+ {
126
+ type: 'AlignmentsTrack',
127
+ trackId: path_1.default.basename(file),
128
+ name: path_1.default.basename(file),
129
+ assemblyNames: [configData.assembly.name],
130
+ adapter: {
131
+ type: 'BamAdapter',
132
+ bamLocation: makeLocation(file),
133
+ index: { location: makeLocation(file + '.bai') },
134
+ sequenceAdapter: configData.assembly.sequence.adapter,
135
+ },
136
+ },
137
+ ];
246
138
  }
247
- }]);
248
- }
249
-
250
- if (type === 'bigbed') {
251
- configData.tracks = [].concat((0, _toConsumableArray2.default)(configData.tracks), [{
252
- type: 'FeatureTrack',
253
- trackId: _path.default.basename(file),
254
- name: _path.default.basename(file),
255
- assemblyNames: [configData.assembly.name],
256
- adapter: {
257
- type: 'BigBedAdapter',
258
- bigBedLocation: makeLocation(file)
139
+ if (type === 'cram') {
140
+ configData.tracks = [
141
+ ...configData.tracks,
142
+ {
143
+ type: 'AlignmentsTrack',
144
+ trackId: path_1.default.basename(file),
145
+ name: path_1.default.basename(file),
146
+ assemblyNames: [configData.assembly.name],
147
+ adapter: {
148
+ type: 'CramAdapter',
149
+ cramLocation: makeLocation(file),
150
+ craiLocation: makeLocation(file + '.crai'),
151
+ sequenceAdapter: configData.assembly.sequence.adapter,
152
+ },
153
+ },
154
+ ];
259
155
  }
260
- }]);
261
- }
262
-
263
- if (type === 'bedgz') {
264
- configData.tracks = [].concat((0, _toConsumableArray2.default)(configData.tracks), [{
265
- type: 'FeatureTrack',
266
- trackId: _path.default.basename(file),
267
- name: _path.default.basename(file),
268
- assemblyNames: [configData.assembly.name],
269
- adapter: {
270
- type: 'BedTabixAdapter',
271
- bedGzLocation: makeLocation(file),
272
- index: {
273
- location: makeLocation(file + '.tbi')
274
- }
156
+ if (type === 'bigwig') {
157
+ configData.tracks = [
158
+ ...configData.tracks,
159
+ {
160
+ type: 'QuantitativeTrack',
161
+ trackId: path_1.default.basename(file),
162
+ name: path_1.default.basename(file),
163
+ assemblyNames: [configData.assembly.name],
164
+ adapter: {
165
+ type: 'BigWigAdapter',
166
+ bigWigLocation: makeLocation(file),
167
+ },
168
+ },
169
+ ];
170
+ }
171
+ if (type === 'vcfgz') {
172
+ configData.tracks = [
173
+ ...configData.tracks,
174
+ {
175
+ type: 'VariantTrack',
176
+ trackId: path_1.default.basename(file),
177
+ name: path_1.default.basename(file),
178
+ assemblyNames: [configData.assembly.name],
179
+ adapter: {
180
+ type: 'VcfTabixAdapter',
181
+ vcfGzLocation: makeLocation(file),
182
+ index: {
183
+ location: makeLocation(file + '.tbi'),
184
+ },
185
+ },
186
+ },
187
+ ];
188
+ }
189
+ if (type === 'gffgz') {
190
+ configData.tracks = [
191
+ ...configData.tracks,
192
+ {
193
+ type: 'FeatureTrack',
194
+ trackId: path_1.default.basename(file),
195
+ name: path_1.default.basename(file),
196
+ assemblyNames: [configData.assembly.name],
197
+ adapter: {
198
+ type: 'Gff3TabixAdapter',
199
+ gffGzLocation: makeLocation(file),
200
+ index: {
201
+ location: makeLocation(file + '.tbi'),
202
+ },
203
+ },
204
+ },
205
+ ];
206
+ }
207
+ if (type === 'hic') {
208
+ configData.tracks = [
209
+ ...configData.tracks,
210
+ {
211
+ type: 'HicTrack',
212
+ trackId: path_1.default.basename(file),
213
+ name: path_1.default.basename(file),
214
+ assemblyNames: [configData.assembly.name],
215
+ adapter: {
216
+ type: 'HicAdapter',
217
+ hicLocation: makeLocation(file),
218
+ },
219
+ },
220
+ ];
221
+ }
222
+ if (type === 'bigbed') {
223
+ configData.tracks = [
224
+ ...configData.tracks,
225
+ {
226
+ type: 'FeatureTrack',
227
+ trackId: path_1.default.basename(file),
228
+ name: path_1.default.basename(file),
229
+ assemblyNames: [configData.assembly.name],
230
+ adapter: {
231
+ type: 'BigBedAdapter',
232
+ bigBedLocation: makeLocation(file),
233
+ },
234
+ },
235
+ ];
236
+ }
237
+ if (type === 'bedgz') {
238
+ configData.tracks = [
239
+ ...configData.tracks,
240
+ {
241
+ type: 'FeatureTrack',
242
+ trackId: path_1.default.basename(file),
243
+ name: path_1.default.basename(file),
244
+ assemblyNames: [configData.assembly.name],
245
+ adapter: {
246
+ type: 'BedTabixAdapter',
247
+ bedGzLocation: makeLocation(file),
248
+ index: {
249
+ location: makeLocation(file + '.tbi'),
250
+ },
251
+ },
252
+ },
253
+ ];
275
254
  }
276
- }]);
255
+ });
256
+ if (!defaultSession) {
257
+ // don't use defaultSession from config.json file, can result in assembly
258
+ // name confusion
259
+ delete configData.defaultSession;
277
260
  }
278
- });
279
-
280
- if (!defaultSession) {
281
- // don't use defaultSession from config.json file, can result in assembly
282
- // name confusion
283
- delete configData.defaultSession;
284
- } // only allow an external manually specified session
285
-
286
-
287
- if (sessionData) {
288
- configData.defaultSession = sessionData;
289
- }
290
-
291
- return configData;
292
- }
293
-
294
- function renderRegion() {
295
- return _renderRegion.apply(this, arguments);
261
+ // only allow an external manually specified session
262
+ if (sessionData) {
263
+ configData.defaultSession = sessionData;
264
+ }
265
+ return configData;
296
266
  }
297
-
298
- function _renderRegion() {
299
- _renderRegion = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
300
- var opts,
301
- model,
302
- loc,
303
- _opts$width,
304
- width,
305
- _opts$trackList2,
306
- trackList,
307
- sessionParam,
308
- defaultSession,
309
- session,
310
- view,
311
- assemblyManager,
312
- assembly,
313
- region,
314
- process,
315
- _args = arguments;
316
-
317
- return _regenerator.default.wrap(function _callee$(_context) {
318
- while (1) {
319
- switch (_context.prev = _context.next) {
320
- case 0:
321
- process = function _process(trackEntry) {
322
- var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
323
-
324
- var _trackEntry = (0, _slicedToArray2.default)(trackEntry, 2),
325
- _trackEntry$ = (0, _toArray2.default)(_trackEntry[1]),
326
- track = _trackEntry$[0],
327
- opts = _trackEntry$.slice(1);
328
-
329
- var currentTrack = view.showTrack(extra(track));
330
- var display = currentTrack.displays[0];
331
- opts.forEach(function (opt) {
332
- // apply height to any track
333
- if (opt.startsWith('height:')) {
334
- var _opt$split = opt.split(':'),
335
- _opt$split2 = (0, _slicedToArray2.default)(_opt$split, 2),
336
- height = _opt$split2[1];
337
-
338
- display.setHeight(+height);
339
- } // apply sort to pileup
340
- else if (opt.startsWith('sort:')) {
341
- var _opt$split3 = opt.split(':'),
342
- _opt$split4 = (0, _slicedToArray2.default)(_opt$split3, 3),
343
- type = _opt$split4[1],
344
- tag = _opt$split4[2];
345
-
346
- display.PileupDisplay.setSortedBy(type, tag);
347
- } // apply color scheme to pileup
348
- else if (opt.startsWith('color:')) {
349
- var _opt$split5 = opt.split(':'),
350
- _opt$split6 = (0, _slicedToArray2.default)(_opt$split5, 3),
351
- _type = _opt$split6[1],
352
- _tag = _opt$split6[2];
353
-
354
- if (display.PileupDisplay) {
355
- display.PileupDisplay.setColorScheme({
356
- type: _type,
357
- tag: _tag
358
- });
359
- } else {
360
- display.setColor(_type);
361
- }
362
- } // force track to render even if maxbpperpx limit hit...
363
- else if (opt.startsWith('force:')) {
364
- var _opt$split7 = opt.split(':'),
365
- _opt$split8 = (0, _slicedToArray2.default)(_opt$split7, 2),
366
- force = _opt$split8[1];
367
-
368
- if (force) {
369
- display.setUserFeatureScreenDensity(Number.MAX_VALUE);
370
- }
371
- } // apply wiggle autoscale
372
- else if (opt.startsWith('autoscale:')) {
373
- var _opt$split9 = opt.split(':'),
374
- _opt$split10 = (0, _slicedToArray2.default)(_opt$split9, 2),
375
- autoscale = _opt$split10[1];
376
-
377
- display.setAutoscale(autoscale);
378
- } // apply min and max score to wiggle
379
- else if (opt.startsWith('minmax:')) {
380
- var _opt$split11 = opt.split(':'),
381
- _opt$split12 = (0, _slicedToArray2.default)(_opt$split11, 3),
382
- min = _opt$split12[1],
383
- max = _opt$split12[2];
384
-
385
- display.setMinScore(+min);
386
- display.setMaxScore(+max);
387
- } // apply linear or log scale to wiggle
388
- else if (opt.startsWith('scaletype:')) {
389
- var _opt$split13 = opt.split(':'),
390
- _opt$split14 = (0, _slicedToArray2.default)(_opt$split13, 2),
391
- scaletype = _opt$split14[1];
392
-
393
- display.setScaleType(scaletype);
394
- } // draw crosshatches on wiggle
395
- else if (opt.startsWith('crosshatch:')) {
396
- var _opt$split15 = opt.split(':'),
397
- _opt$split16 = (0, _slicedToArray2.default)(_opt$split15, 2),
398
- val = _opt$split16[1];
399
-
400
- display.setCrossHatches((0, _util.booleanize)(val));
401
- } // turn off fill on bigwig with fill:false
402
- else if (opt.startsWith('fill:')) {
403
- var _opt$split17 = opt.split(':'),
404
- _opt$split18 = (0, _slicedToArray2.default)(_opt$split17, 2),
405
- _val = _opt$split18[1];
406
-
407
- display.setFill((0, _util.booleanize)(_val));
408
- } // set resolution:superfine to use finer bigwig bin size
409
- else if (opt.startsWith('resolution:')) {
410
- var _opt$split19 = opt.split(':'),
411
- _opt$split20 = (0, _slicedToArray2.default)(_opt$split19, 2),
412
- _val2 = _opt$split20[1];
413
-
414
- if (_val2 === 'fine') {
415
- _val2 = 10;
416
- } else if (_val2 === 'superfine') {
417
- _val2 = 100;
418
- }
419
-
420
- display.setResolution(_val2);
421
- }
422
- });
423
- };
424
-
425
- opts = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
426
- model = (0, _reactLinearGenomeView.createViewState)(readData(opts));
427
- loc = opts.loc, _opts$width = opts.width, width = _opts$width === void 0 ? 1500 : _opts$width, _opts$trackList2 = opts.trackList, trackList = _opts$trackList2 === void 0 ? [] : _opts$trackList2, sessionParam = opts.session, defaultSession = opts.defaultSession;
428
- session = model.session;
429
- view = session.view;
430
- assemblyManager = model.assemblyManager;
431
- view.setWidth(width);
432
- _context.next = 10;
433
- return (0, _mobx.when)(function () {
434
- var _assemblyManager$allP;
435
-
436
- return ((_assemblyManager$allP = assemblyManager.allPossibleRefNames) === null || _assemblyManager$allP === void 0 ? void 0 : _assemblyManager$allP.length) && model.session.view.initialized;
437
- });
438
-
439
- case 10:
440
- if (loc) {
441
- assembly = assemblyManager.assemblies[0];
442
- region = assembly.regions[0];
443
-
444
- if (region) {
445
- view.setDisplayedRegions([region]);
446
- }
447
-
448
- if (loc === 'all') {
449
- view.showAllRegionsInAssembly(assembly.name);
450
- } else {
451
- view.navToLocString(loc);
452
- }
453
- } else if (!sessionParam && !defaultSession) {
454
- console.warn('No loc specified');
267
+ exports.readData = readData;
268
+ // without this, the styles can become messed up especially in lgv header
269
+ // xref https://github.com/garronej/tss-react/issues/25
270
+ exports.muiCache = (0, cache_1.default)({
271
+ key: 'mui',
272
+ prepend: true,
273
+ });
274
+ function process(trackEntry, view, extra = c => c) {
275
+ const [, [track, ...opts]] = trackEntry;
276
+ const currentTrack = view.showTrack(extra(track));
277
+ const display = currentTrack.displays[0];
278
+ opts.forEach(opt => {
279
+ // apply height to any track
280
+ if (opt.startsWith('height:')) {
281
+ const [, height] = opt.split(':');
282
+ display.setHeight(+height);
283
+ }
284
+ // apply sort to pileup
285
+ else if (opt.startsWith('sort:')) {
286
+ const [, type, tag] = opt.split(':');
287
+ display.PileupDisplay.setSortedBy(type, tag);
288
+ }
289
+ // apply color scheme to pileup
290
+ else if (opt.startsWith('color:')) {
291
+ const [, type, tag] = opt.split(':');
292
+ if (display.PileupDisplay) {
293
+ display.PileupDisplay.setColorScheme({ type, tag });
455
294
  }
456
-
457
- trackList.forEach(function (track) {
458
- return process(track, function (extra) {
459
- return _path.default.basename(extra);
460
- });
461
- });
462
- return _context.abrupt("return", (0, _pluginLinearGenomeView.renderToSvg)(view, _objectSpread({
463
- rasterizeLayers: !opts.noRasterize
464
- }, opts)));
465
-
466
- case 13:
467
- case "end":
468
- return _context.stop();
295
+ else {
296
+ display.setColor(type);
297
+ }
298
+ }
299
+ // force track to render even if maxbpperpx limit hit...
300
+ else if (opt.startsWith('force:')) {
301
+ const [, force] = opt.split(':');
302
+ if (force) {
303
+ display.updateStatsLimit({ bytes: Number.MAX_VALUE });
304
+ }
305
+ }
306
+ // apply wiggle autoscale
307
+ else if (opt.startsWith('autoscale:')) {
308
+ const [, autoscale] = opt.split(':');
309
+ display.setAutoscale(autoscale);
310
+ }
311
+ // apply min and max score to wiggle
312
+ else if (opt.startsWith('minmax:')) {
313
+ const [, min, max] = opt.split(':');
314
+ display.setMinScore(+min);
315
+ display.setMaxScore(+max);
316
+ }
317
+ // apply linear or log scale to wiggle
318
+ else if (opt.startsWith('scaletype:')) {
319
+ const [, scaletype] = opt.split(':');
320
+ display.setScaleType(scaletype);
469
321
  }
470
- }
471
- }, _callee);
472
- }));
473
- return _renderRegion.apply(this, arguments);
474
- }
322
+ // draw crosshatches on wiggle
323
+ else if (opt.startsWith('crosshatch:')) {
324
+ const [, val] = opt.split(':');
325
+ display.setCrossHatches((0, util_1.booleanize)(val));
326
+ }
327
+ // turn off fill on bigwig with fill:false
328
+ else if (opt.startsWith('fill:')) {
329
+ const [, val] = opt.split(':');
330
+ display.setFill((0, util_1.booleanize)(val));
331
+ }
332
+ // set resolution:superfine to use finer bigwig bin size
333
+ else if (opt.startsWith('resolution:')) {
334
+ let [, val] = opt.split(':');
335
+ if (val === 'fine') {
336
+ val = '10';
337
+ }
338
+ else if (val === 'superfine') {
339
+ val = '100';
340
+ }
341
+ display.setResolution(+val);
342
+ }
343
+ });
344
+ }
345
+ async function renderRegion(opts) {
346
+ const model = (0, react_linear_genome_view_1.createViewState)(readData(opts));
347
+ const { loc, width = 1500, trackList = [], session: sessionParam, defaultSession, } = opts;
348
+ const { session } = model;
349
+ const { view } = session;
350
+ const { assemblyManager } = model;
351
+ view.setWidth(width);
352
+ if (loc) {
353
+ const [assembly] = assemblyManager.assemblies;
354
+ if (loc === 'all') {
355
+ view.showAllRegionsInAssembly(assembly.name);
356
+ }
357
+ else {
358
+ await view.navToLocString(loc, assembly.name);
359
+ }
360
+ }
361
+ else if (!sessionParam && !defaultSession) {
362
+ console.warn('No loc specified');
363
+ }
364
+ trackList.forEach(track => {
365
+ process(track, view, extra => path_1.default.basename(extra));
366
+ });
367
+ return (0, plugin_linear_genome_view_1.renderToSvg)(view, {
368
+ rasterizeLayers: !opts.noRasterize,
369
+ ...opts,
370
+ Wrapper: ({ children }) => (react_1.default.createElement(react_2.CacheProvider, { value: exports.muiCache }, children)),
371
+ });
372
+ }
373
+ exports.renderRegion = renderRegion;
374
+ //# sourceMappingURL=renderRegion.js.map