@jbrowse/img 2.2.0 → 2.2.2

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