@jbrowse/img 2.17.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -11
- package/dist/parseArgv.js +0 -12
- package/dist/renderRegion.d.ts +1 -1
- package/dist/renderRegion.js +3 -29
- package/dist/setupEnv.js +20 -37
- package/dist/util.js +1 -2
- package/esm/index.js +2 -12
- package/esm/parseArgv.js +0 -12
- package/esm/renderRegion.d.ts +1 -1
- package/esm/renderRegion.js +3 -29
- package/esm/setupEnv.js +3 -30
- package/esm/util.js +1 -2
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -5,11 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
7
|
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
-
// locals
|
|
9
8
|
const parseArgv_1 = require("./parseArgv");
|
|
10
9
|
const renderRegion_1 = require("./renderRegion");
|
|
11
|
-
const util_1 = require("./util");
|
|
12
10
|
const setupEnv_1 = __importDefault(require("./setupEnv"));
|
|
11
|
+
const util_1 = require("./util");
|
|
13
12
|
(0, setupEnv_1.default)();
|
|
14
13
|
const err = console.error;
|
|
15
14
|
console.error = (...p) => {
|
|
@@ -23,10 +22,6 @@ console.warn = (...p) => {
|
|
|
23
22
|
warn(p);
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
|
-
// note: yargs is actually unused except for printing help we do custom command
|
|
27
|
-
// line parsing, see parseArgv.ts
|
|
28
|
-
//
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises,@typescript-eslint/no-unused-expressions
|
|
30
25
|
yargs_1.default
|
|
31
26
|
.command('jb2export', 'Creates a jbrowse 2 image snapshot')
|
|
32
27
|
.option('config', {
|
|
@@ -66,7 +61,6 @@ yargs_1.default
|
|
|
66
61
|
type: 'number',
|
|
67
62
|
default: 2048,
|
|
68
63
|
})
|
|
69
|
-
// track types
|
|
70
64
|
.option('configtracks', {
|
|
71
65
|
description: 'A list of track labels from a config file',
|
|
72
66
|
type: 'array',
|
|
@@ -103,7 +97,6 @@ yargs_1.default
|
|
|
103
97
|
description: 'A bed tabix file, the --bedgz can be used multiple times to specify multiple bedtabix files',
|
|
104
98
|
type: 'array',
|
|
105
99
|
})
|
|
106
|
-
// other
|
|
107
100
|
.option('out', {
|
|
108
101
|
description: 'File to output to. Default: out.svg. If a filename with extension .png is supplied the program will try to automatically execute rsvg-convert to convert it to png',
|
|
109
102
|
type: 'string',
|
|
@@ -144,9 +137,6 @@ const args = (0, parseArgv_1.standardizeArgv)((0, parseArgv_1.parseArgv)(process
|
|
|
144
137
|
else {
|
|
145
138
|
fs_1.default.writeFileSync(out, result);
|
|
146
139
|
}
|
|
147
|
-
// manually exit the process after done rendering because autoruns or
|
|
148
|
-
// something similar otherwise keeps the nodejs process alive xref
|
|
149
|
-
// https://github.com/GMOD/jb2export/issues/6
|
|
150
140
|
process.exit(0);
|
|
151
141
|
}
|
|
152
142
|
catch (e) {
|
package/dist/parseArgv.js
CHANGED
|
@@ -2,18 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseArgv = parseArgv;
|
|
4
4
|
exports.standardizeArgv = standardizeArgv;
|
|
5
|
-
// example (see parseArgv.test.js):
|
|
6
|
-
// const args =
|
|
7
|
-
// '--bam dad.bam color:red --vcf variants.vcf --bam mom.bam --defaultSession --out out.svg --noRasterize'
|
|
8
|
-
//
|
|
9
|
-
// expect(parseArgv(args.split(' '))).toEqual([
|
|
10
|
-
// ['bam', ['dad.bam', 'color:red']],
|
|
11
|
-
// ['vcf', ['variants.vcf']],
|
|
12
|
-
// ['bam', ['mom.bam']],
|
|
13
|
-
// ['defaultSession', []],
|
|
14
|
-
// ['out', ['out.svg']],
|
|
15
|
-
// ['noRasterize', []],
|
|
16
|
-
// ])
|
|
17
5
|
function parseArgv(argv) {
|
|
18
6
|
const map = [];
|
|
19
7
|
while (argv.length) {
|
package/dist/renderRegion.d.ts
CHANGED
package/dist/renderRegion.js
CHANGED
|
@@ -5,11 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.readData = readData;
|
|
7
7
|
exports.renderRegion = renderRegion;
|
|
8
|
-
const client_1 = require("react-dom/client");
|
|
9
|
-
const react_linear_genome_view_1 = require("@jbrowse/react-linear-genome-view");
|
|
10
|
-
const plugin_linear_genome_view_1 = require("@jbrowse/plugin-linear-genome-view");
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const plugin_linear_genome_view_1 = require("@jbrowse/plugin-linear-genome-view");
|
|
11
|
+
const react_linear_genome_view_1 = require("@jbrowse/react-linear-genome-view");
|
|
13
12
|
const util_1 = require("./util");
|
|
14
13
|
function read(file) {
|
|
15
14
|
let res;
|
|
@@ -47,22 +46,15 @@ function readData({ assembly: asm, config, session, fasta, aliases, cytobands, d
|
|
|
47
46
|
if (config) {
|
|
48
47
|
addRelativePaths(configData, path_1.default.dirname(path_1.default.resolve(config)));
|
|
49
48
|
}
|
|
50
|
-
// the session.json can be a raw session or a json file with a "session"
|
|
51
|
-
// attribute, which is what is exported via the "File->Export session" in
|
|
52
|
-
// jbrowse-web
|
|
53
49
|
if (sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) {
|
|
54
50
|
sessionData = sessionData.session;
|
|
55
51
|
}
|
|
56
|
-
// only export first view
|
|
57
52
|
if (sessionData === null || sessionData === void 0 ? void 0 : sessionData.views) {
|
|
58
53
|
sessionData.view = sessionData.views[0];
|
|
59
54
|
}
|
|
60
|
-
// use assembly from file if a file existed
|
|
61
55
|
if (assemblyData) {
|
|
62
56
|
configData.assembly = assemblyData;
|
|
63
57
|
}
|
|
64
|
-
// else check if it was an assembly name in a config file
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
66
58
|
else if ((_a = configData.assemblies) === null || _a === void 0 ? void 0 : _a.length) {
|
|
67
59
|
configData.assemblies.find(entry => entry.name === asm);
|
|
68
60
|
if (asm) {
|
|
@@ -76,7 +68,6 @@ function readData({ assembly: asm, config, session, fasta, aliases, cytobands, d
|
|
|
76
68
|
configData.assembly = configData.assemblies[0];
|
|
77
69
|
}
|
|
78
70
|
}
|
|
79
|
-
// else load fasta from command line
|
|
80
71
|
else if (fasta) {
|
|
81
72
|
const bgzip = fasta.endsWith('gz');
|
|
82
73
|
configData.assembly = {
|
|
@@ -109,15 +100,12 @@ function readData({ assembly: asm, config, session, fasta, aliases, cytobands, d
|
|
|
109
100
|
};
|
|
110
101
|
}
|
|
111
102
|
}
|
|
112
|
-
// throw if still no assembly
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
114
103
|
if (!configData.assembly) {
|
|
115
104
|
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');
|
|
116
105
|
}
|
|
117
106
|
if (tracksData) {
|
|
118
107
|
configData.tracks = tracksData;
|
|
119
108
|
}
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
121
109
|
else if (!configData.tracks) {
|
|
122
110
|
configData.tracks = [];
|
|
123
111
|
}
|
|
@@ -290,11 +278,8 @@ function readData({ assembly: asm, config, session, fasta, aliases, cytobands, d
|
|
|
290
278
|
}
|
|
291
279
|
});
|
|
292
280
|
if (!defaultSession) {
|
|
293
|
-
// don't use defaultSession from config.json file, can result in assembly
|
|
294
|
-
// name confusion
|
|
295
281
|
configData.defaultSession = undefined;
|
|
296
282
|
}
|
|
297
|
-
// only allow an external manually specified session
|
|
298
283
|
if (sessionData) {
|
|
299
284
|
configData.defaultSession = sessionData;
|
|
300
285
|
}
|
|
@@ -308,19 +293,16 @@ function process(trackEntry, view, extra = c => c) {
|
|
|
308
293
|
const currentTrack = view.showTrack(extra(track));
|
|
309
294
|
const display = currentTrack.displays[0];
|
|
310
295
|
opts.forEach(opt => {
|
|
311
|
-
// apply height to any track
|
|
312
296
|
if (opt.startsWith('height:')) {
|
|
313
297
|
const [, height] = opt.split(':');
|
|
314
298
|
if (height) {
|
|
315
299
|
display.setHeight(+height);
|
|
316
300
|
}
|
|
317
301
|
}
|
|
318
|
-
// apply sort to pileup
|
|
319
302
|
else if (opt.startsWith('sort:')) {
|
|
320
303
|
const [, type, tag] = opt.split(':');
|
|
321
304
|
display.PileupDisplay.setSortedBy(type, tag);
|
|
322
305
|
}
|
|
323
|
-
// apply color scheme to pileup
|
|
324
306
|
else if (opt.startsWith('color:')) {
|
|
325
307
|
const [, type, tag] = opt.split(':');
|
|
326
308
|
if (display.PileupDisplay) {
|
|
@@ -330,19 +312,16 @@ function process(trackEntry, view, extra = c => c) {
|
|
|
330
312
|
display.setColor(type);
|
|
331
313
|
}
|
|
332
314
|
}
|
|
333
|
-
// force track to render even if maxbpperpx limit hit...
|
|
334
315
|
else if (opt.startsWith('force:')) {
|
|
335
316
|
const [, force] = opt.split(':');
|
|
336
317
|
if (force) {
|
|
337
318
|
display.setFeatureDensityStatsLimit({ bytes: Number.MAX_VALUE });
|
|
338
319
|
}
|
|
339
320
|
}
|
|
340
|
-
// apply wiggle autoscale
|
|
341
321
|
else if (opt.startsWith('autoscale:')) {
|
|
342
322
|
const [, autoscale] = opt.split(':');
|
|
343
323
|
display.setAutoscale(autoscale);
|
|
344
324
|
}
|
|
345
|
-
// apply min and max score to wiggle
|
|
346
325
|
else if (opt.startsWith('minmax:')) {
|
|
347
326
|
const [, min, max] = opt.split(':');
|
|
348
327
|
if (min) {
|
|
@@ -352,22 +331,18 @@ function process(trackEntry, view, extra = c => c) {
|
|
|
352
331
|
display.setMaxScore(+max);
|
|
353
332
|
}
|
|
354
333
|
}
|
|
355
|
-
// apply linear or log scale to wiggle
|
|
356
334
|
else if (opt.startsWith('scaletype:')) {
|
|
357
335
|
const [, scaletype] = opt.split(':');
|
|
358
336
|
display.setScaleType(scaletype);
|
|
359
337
|
}
|
|
360
|
-
// draw crosshatches on wiggle
|
|
361
338
|
else if (opt.startsWith('crosshatch:')) {
|
|
362
339
|
const [, val = 'false'] = opt.split(':');
|
|
363
340
|
display.setCrossHatches((0, util_1.booleanize)(val));
|
|
364
341
|
}
|
|
365
|
-
// turn off fill on bigwig with fill:false
|
|
366
342
|
else if (opt.startsWith('fill:')) {
|
|
367
343
|
const [, val = 'true'] = opt.split(':');
|
|
368
344
|
display.setFill((0, util_1.booleanize)(val));
|
|
369
345
|
}
|
|
370
|
-
// set resolution:superfine to use finer bigwig bin size
|
|
371
346
|
else if (opt.startsWith('resolution:')) {
|
|
372
347
|
let [, val = 1] = opt.split(':');
|
|
373
348
|
if (val === 'fine') {
|
|
@@ -383,7 +358,6 @@ function process(trackEntry, view, extra = c => c) {
|
|
|
383
358
|
async function renderRegion(opts) {
|
|
384
359
|
const model = (0, react_linear_genome_view_1.createViewState)({
|
|
385
360
|
...readData(opts),
|
|
386
|
-
createRootFn: client_1.createRoot,
|
|
387
361
|
});
|
|
388
362
|
const { loc, width = 1500, trackList = [], session: sessionParam, defaultSession, } = opts;
|
|
389
363
|
const { session } = model;
|
package/dist/setupEnv.js
CHANGED
|
@@ -15,19 +15,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.default = setupEnv;
|
|
27
|
-
const node_fetch_1 = __importStar(require("node-fetch"));
|
|
28
|
-
const jsdom_1 = require("jsdom");
|
|
29
|
-
const canvas_1 = require("canvas");
|
|
30
37
|
const util_1 = require("util");
|
|
38
|
+
const canvas_1 = require("canvas");
|
|
39
|
+
const jsdom_1 = require("jsdom");
|
|
40
|
+
const node_fetch_1 = __importStar(require("node-fetch"));
|
|
31
41
|
function setupEnv() {
|
|
32
42
|
addGlobalCanvasUtils();
|
|
33
43
|
addGlobalTextUtils();
|
|
@@ -35,49 +45,22 @@ function setupEnv() {
|
|
|
35
45
|
addFetchPolyfill();
|
|
36
46
|
}
|
|
37
47
|
function addGlobalCanvasUtils() {
|
|
38
|
-
// @ts-expect-error
|
|
39
48
|
global.nodeImage = canvas_1.Image;
|
|
40
|
-
// @ts-expect-error
|
|
41
49
|
global.nodeCreateCanvas = canvas_1.createCanvas;
|
|
42
50
|
}
|
|
43
51
|
function addGlobalTextUtils() {
|
|
44
52
|
global.TextEncoder = util_1.TextEncoder;
|
|
45
|
-
// @ts-expect-error
|
|
46
53
|
global.TextDecoder = util_1.TextDecoder;
|
|
47
54
|
}
|
|
48
55
|
function addGlobalDocument() {
|
|
49
56
|
const window = new jsdom_1.JSDOM('...').window;
|
|
50
57
|
global.document = window.document;
|
|
51
|
-
// @ts-expect-error
|
|
52
58
|
global.window = window;
|
|
53
59
|
addFetchPolyfill();
|
|
54
60
|
}
|
|
55
61
|
function addFetchPolyfill() {
|
|
56
|
-
// force use of node-fetch polyfill, even if node 18+ fetch is available.
|
|
57
|
-
// native node 18+ fetch currently gives errors related to unidici and
|
|
58
|
-
// Uint8Array:
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
// % node --version
|
|
62
|
-
// v18.12.1
|
|
63
|
-
//
|
|
64
|
-
// % jb2export --fasta https://jbrowse.org/code/jb2/main/test_data/volvox/volvox.fa --bam https://jbrowse.org/code/jb2/main/test_data/volvox/volvox-sorted.bam --loc ctgA:1-1000 --out out4.svg
|
|
65
|
-
// [
|
|
66
|
-
// '(node:1387934) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time\n' +
|
|
67
|
-
// '(Use `node --trace-warnings ...` to show where the warning was created)'
|
|
68
|
-
// ]
|
|
69
|
-
// [
|
|
70
|
-
// RangeError: offset is out of bounds
|
|
71
|
-
// at Uint8Array.set (<anonymous>)
|
|
72
|
-
// at Response.arrayBuffer (node:internal/deps/undici/undici:6117:23)
|
|
73
|
-
// at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
|
|
74
|
-
// ]
|
|
75
|
-
// @ts-expect-error
|
|
76
62
|
global.fetch = node_fetch_1.default;
|
|
77
|
-
// @ts-expect-error
|
|
78
63
|
global.Headers = node_fetch_1.Headers;
|
|
79
|
-
// @ts-expect-error
|
|
80
64
|
global.Response = node_fetch_1.Response;
|
|
81
|
-
// @ts-expect-error
|
|
82
65
|
global.Request = node_fetch_1.Request;
|
|
83
66
|
}
|
package/dist/util.js
CHANGED
|
@@ -5,10 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.booleanize = booleanize;
|
|
7
7
|
exports.convert = convert;
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
8
9
|
const fs_1 = __importDefault(require("fs"));
|
|
9
10
|
const tmp_1 = __importDefault(require("tmp"));
|
|
10
|
-
const child_process_1 = require("child_process");
|
|
11
|
-
// nice helper function from https://stackoverflow.com/questions/263965/
|
|
12
11
|
function booleanize(str) {
|
|
13
12
|
return str === 'false' ? false : !!str;
|
|
14
13
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import yargs from 'yargs';
|
|
3
|
-
|
|
4
|
-
import { standardizeArgv, parseArgv } from './parseArgv';
|
|
3
|
+
import { parseArgv, standardizeArgv } from './parseArgv';
|
|
5
4
|
import { renderRegion } from './renderRegion';
|
|
6
|
-
import { convert } from './util';
|
|
7
5
|
import setupEnv from './setupEnv';
|
|
6
|
+
import { convert } from './util';
|
|
8
7
|
setupEnv();
|
|
9
8
|
const err = console.error;
|
|
10
9
|
console.error = (...p) => {
|
|
@@ -18,10 +17,6 @@ console.warn = (...p) => {
|
|
|
18
17
|
warn(p);
|
|
19
18
|
}
|
|
20
19
|
};
|
|
21
|
-
// note: yargs is actually unused except for printing help we do custom command
|
|
22
|
-
// line parsing, see parseArgv.ts
|
|
23
|
-
//
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises,@typescript-eslint/no-unused-expressions
|
|
25
20
|
yargs
|
|
26
21
|
.command('jb2export', 'Creates a jbrowse 2 image snapshot')
|
|
27
22
|
.option('config', {
|
|
@@ -61,7 +56,6 @@ yargs
|
|
|
61
56
|
type: 'number',
|
|
62
57
|
default: 2048,
|
|
63
58
|
})
|
|
64
|
-
// track types
|
|
65
59
|
.option('configtracks', {
|
|
66
60
|
description: 'A list of track labels from a config file',
|
|
67
61
|
type: 'array',
|
|
@@ -98,7 +92,6 @@ yargs
|
|
|
98
92
|
description: 'A bed tabix file, the --bedgz can be used multiple times to specify multiple bedtabix files',
|
|
99
93
|
type: 'array',
|
|
100
94
|
})
|
|
101
|
-
// other
|
|
102
95
|
.option('out', {
|
|
103
96
|
description: 'File to output to. Default: out.svg. If a filename with extension .png is supplied the program will try to automatically execute rsvg-convert to convert it to png',
|
|
104
97
|
type: 'string',
|
|
@@ -139,9 +132,6 @@ const args = standardizeArgv(parseArgv(process.argv.slice(2)), [
|
|
|
139
132
|
else {
|
|
140
133
|
fs.writeFileSync(out, result);
|
|
141
134
|
}
|
|
142
|
-
// manually exit the process after done rendering because autoruns or
|
|
143
|
-
// something similar otherwise keeps the nodejs process alive xref
|
|
144
|
-
// https://github.com/GMOD/jb2export/issues/6
|
|
145
135
|
process.exit(0);
|
|
146
136
|
}
|
|
147
137
|
catch (e) {
|
package/esm/parseArgv.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
// example (see parseArgv.test.js):
|
|
2
|
-
// const args =
|
|
3
|
-
// '--bam dad.bam color:red --vcf variants.vcf --bam mom.bam --defaultSession --out out.svg --noRasterize'
|
|
4
|
-
//
|
|
5
|
-
// expect(parseArgv(args.split(' '))).toEqual([
|
|
6
|
-
// ['bam', ['dad.bam', 'color:red']],
|
|
7
|
-
// ['vcf', ['variants.vcf']],
|
|
8
|
-
// ['bam', ['mom.bam']],
|
|
9
|
-
// ['defaultSession', []],
|
|
10
|
-
// ['out', ['out.svg']],
|
|
11
|
-
// ['noRasterize', []],
|
|
12
|
-
// ])
|
|
13
1
|
export function parseArgv(argv) {
|
|
14
2
|
const map = [];
|
|
15
3
|
while (argv.length) {
|
package/esm/renderRegion.d.ts
CHANGED
package/esm/renderRegion.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { createRoot } from 'react-dom/client';
|
|
2
|
-
import { createViewState } from '@jbrowse/react-linear-genome-view';
|
|
3
|
-
import { renderToSvg, } from '@jbrowse/plugin-linear-genome-view';
|
|
4
|
-
import path from 'path';
|
|
5
1
|
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { renderToSvg } from '@jbrowse/plugin-linear-genome-view';
|
|
4
|
+
import { createViewState } from '@jbrowse/react-linear-genome-view';
|
|
6
5
|
import { booleanize } from './util';
|
|
7
6
|
function read(file) {
|
|
8
7
|
let res;
|
|
@@ -40,22 +39,15 @@ export function readData({ assembly: asm, config, session, fasta, aliases, cytob
|
|
|
40
39
|
if (config) {
|
|
41
40
|
addRelativePaths(configData, path.dirname(path.resolve(config)));
|
|
42
41
|
}
|
|
43
|
-
// the session.json can be a raw session or a json file with a "session"
|
|
44
|
-
// attribute, which is what is exported via the "File->Export session" in
|
|
45
|
-
// jbrowse-web
|
|
46
42
|
if (sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) {
|
|
47
43
|
sessionData = sessionData.session;
|
|
48
44
|
}
|
|
49
|
-
// only export first view
|
|
50
45
|
if (sessionData === null || sessionData === void 0 ? void 0 : sessionData.views) {
|
|
51
46
|
sessionData.view = sessionData.views[0];
|
|
52
47
|
}
|
|
53
|
-
// use assembly from file if a file existed
|
|
54
48
|
if (assemblyData) {
|
|
55
49
|
configData.assembly = assemblyData;
|
|
56
50
|
}
|
|
57
|
-
// else check if it was an assembly name in a config file
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
59
51
|
else if ((_a = configData.assemblies) === null || _a === void 0 ? void 0 : _a.length) {
|
|
60
52
|
configData.assemblies.find(entry => entry.name === asm);
|
|
61
53
|
if (asm) {
|
|
@@ -69,7 +61,6 @@ export function readData({ assembly: asm, config, session, fasta, aliases, cytob
|
|
|
69
61
|
configData.assembly = configData.assemblies[0];
|
|
70
62
|
}
|
|
71
63
|
}
|
|
72
|
-
// else load fasta from command line
|
|
73
64
|
else if (fasta) {
|
|
74
65
|
const bgzip = fasta.endsWith('gz');
|
|
75
66
|
configData.assembly = {
|
|
@@ -102,15 +93,12 @@ export function readData({ assembly: asm, config, session, fasta, aliases, cytob
|
|
|
102
93
|
};
|
|
103
94
|
}
|
|
104
95
|
}
|
|
105
|
-
// throw if still no assembly
|
|
106
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
107
96
|
if (!configData.assembly) {
|
|
108
97
|
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');
|
|
109
98
|
}
|
|
110
99
|
if (tracksData) {
|
|
111
100
|
configData.tracks = tracksData;
|
|
112
101
|
}
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
114
102
|
else if (!configData.tracks) {
|
|
115
103
|
configData.tracks = [];
|
|
116
104
|
}
|
|
@@ -283,11 +271,8 @@ export function readData({ assembly: asm, config, session, fasta, aliases, cytob
|
|
|
283
271
|
}
|
|
284
272
|
});
|
|
285
273
|
if (!defaultSession) {
|
|
286
|
-
// don't use defaultSession from config.json file, can result in assembly
|
|
287
|
-
// name confusion
|
|
288
274
|
configData.defaultSession = undefined;
|
|
289
275
|
}
|
|
290
|
-
// only allow an external manually specified session
|
|
291
276
|
if (sessionData) {
|
|
292
277
|
configData.defaultSession = sessionData;
|
|
293
278
|
}
|
|
@@ -301,19 +286,16 @@ function process(trackEntry, view, extra = c => c) {
|
|
|
301
286
|
const currentTrack = view.showTrack(extra(track));
|
|
302
287
|
const display = currentTrack.displays[0];
|
|
303
288
|
opts.forEach(opt => {
|
|
304
|
-
// apply height to any track
|
|
305
289
|
if (opt.startsWith('height:')) {
|
|
306
290
|
const [, height] = opt.split(':');
|
|
307
291
|
if (height) {
|
|
308
292
|
display.setHeight(+height);
|
|
309
293
|
}
|
|
310
294
|
}
|
|
311
|
-
// apply sort to pileup
|
|
312
295
|
else if (opt.startsWith('sort:')) {
|
|
313
296
|
const [, type, tag] = opt.split(':');
|
|
314
297
|
display.PileupDisplay.setSortedBy(type, tag);
|
|
315
298
|
}
|
|
316
|
-
// apply color scheme to pileup
|
|
317
299
|
else if (opt.startsWith('color:')) {
|
|
318
300
|
const [, type, tag] = opt.split(':');
|
|
319
301
|
if (display.PileupDisplay) {
|
|
@@ -323,19 +305,16 @@ function process(trackEntry, view, extra = c => c) {
|
|
|
323
305
|
display.setColor(type);
|
|
324
306
|
}
|
|
325
307
|
}
|
|
326
|
-
// force track to render even if maxbpperpx limit hit...
|
|
327
308
|
else if (opt.startsWith('force:')) {
|
|
328
309
|
const [, force] = opt.split(':');
|
|
329
310
|
if (force) {
|
|
330
311
|
display.setFeatureDensityStatsLimit({ bytes: Number.MAX_VALUE });
|
|
331
312
|
}
|
|
332
313
|
}
|
|
333
|
-
// apply wiggle autoscale
|
|
334
314
|
else if (opt.startsWith('autoscale:')) {
|
|
335
315
|
const [, autoscale] = opt.split(':');
|
|
336
316
|
display.setAutoscale(autoscale);
|
|
337
317
|
}
|
|
338
|
-
// apply min and max score to wiggle
|
|
339
318
|
else if (opt.startsWith('minmax:')) {
|
|
340
319
|
const [, min, max] = opt.split(':');
|
|
341
320
|
if (min) {
|
|
@@ -345,22 +324,18 @@ function process(trackEntry, view, extra = c => c) {
|
|
|
345
324
|
display.setMaxScore(+max);
|
|
346
325
|
}
|
|
347
326
|
}
|
|
348
|
-
// apply linear or log scale to wiggle
|
|
349
327
|
else if (opt.startsWith('scaletype:')) {
|
|
350
328
|
const [, scaletype] = opt.split(':');
|
|
351
329
|
display.setScaleType(scaletype);
|
|
352
330
|
}
|
|
353
|
-
// draw crosshatches on wiggle
|
|
354
331
|
else if (opt.startsWith('crosshatch:')) {
|
|
355
332
|
const [, val = 'false'] = opt.split(':');
|
|
356
333
|
display.setCrossHatches(booleanize(val));
|
|
357
334
|
}
|
|
358
|
-
// turn off fill on bigwig with fill:false
|
|
359
335
|
else if (opt.startsWith('fill:')) {
|
|
360
336
|
const [, val = 'true'] = opt.split(':');
|
|
361
337
|
display.setFill(booleanize(val));
|
|
362
338
|
}
|
|
363
|
-
// set resolution:superfine to use finer bigwig bin size
|
|
364
339
|
else if (opt.startsWith('resolution:')) {
|
|
365
340
|
let [, val = 1] = opt.split(':');
|
|
366
341
|
if (val === 'fine') {
|
|
@@ -376,7 +351,6 @@ function process(trackEntry, view, extra = c => c) {
|
|
|
376
351
|
export async function renderRegion(opts) {
|
|
377
352
|
const model = createViewState({
|
|
378
353
|
...readData(opts),
|
|
379
|
-
createRootFn: createRoot,
|
|
380
354
|
});
|
|
381
355
|
const { loc, width = 1500, trackList = [], session: sessionParam, defaultSession, } = opts;
|
|
382
356
|
const { session } = model;
|
package/esm/setupEnv.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { JSDOM } from 'jsdom';
|
|
1
|
+
import { TextDecoder, TextEncoder } from 'util';
|
|
3
2
|
import { Image, createCanvas } from 'canvas';
|
|
4
|
-
import {
|
|
3
|
+
import { JSDOM } from 'jsdom';
|
|
4
|
+
import fetch, { Headers, Request, Response } from 'node-fetch';
|
|
5
5
|
export default function setupEnv() {
|
|
6
6
|
addGlobalCanvasUtils();
|
|
7
7
|
addGlobalTextUtils();
|
|
@@ -9,49 +9,22 @@ export default function setupEnv() {
|
|
|
9
9
|
addFetchPolyfill();
|
|
10
10
|
}
|
|
11
11
|
function addGlobalCanvasUtils() {
|
|
12
|
-
// @ts-expect-error
|
|
13
12
|
global.nodeImage = Image;
|
|
14
|
-
// @ts-expect-error
|
|
15
13
|
global.nodeCreateCanvas = createCanvas;
|
|
16
14
|
}
|
|
17
15
|
function addGlobalTextUtils() {
|
|
18
16
|
global.TextEncoder = TextEncoder;
|
|
19
|
-
// @ts-expect-error
|
|
20
17
|
global.TextDecoder = TextDecoder;
|
|
21
18
|
}
|
|
22
19
|
function addGlobalDocument() {
|
|
23
20
|
const window = new JSDOM('...').window;
|
|
24
21
|
global.document = window.document;
|
|
25
|
-
// @ts-expect-error
|
|
26
22
|
global.window = window;
|
|
27
23
|
addFetchPolyfill();
|
|
28
24
|
}
|
|
29
25
|
function addFetchPolyfill() {
|
|
30
|
-
// force use of node-fetch polyfill, even if node 18+ fetch is available.
|
|
31
|
-
// native node 18+ fetch currently gives errors related to unidici and
|
|
32
|
-
// Uint8Array:
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
// % node --version
|
|
36
|
-
// v18.12.1
|
|
37
|
-
//
|
|
38
|
-
// % jb2export --fasta https://jbrowse.org/code/jb2/main/test_data/volvox/volvox.fa --bam https://jbrowse.org/code/jb2/main/test_data/volvox/volvox-sorted.bam --loc ctgA:1-1000 --out out4.svg
|
|
39
|
-
// [
|
|
40
|
-
// '(node:1387934) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time\n' +
|
|
41
|
-
// '(Use `node --trace-warnings ...` to show where the warning was created)'
|
|
42
|
-
// ]
|
|
43
|
-
// [
|
|
44
|
-
// RangeError: offset is out of bounds
|
|
45
|
-
// at Uint8Array.set (<anonymous>)
|
|
46
|
-
// at Response.arrayBuffer (node:internal/deps/undici/undici:6117:23)
|
|
47
|
-
// at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
|
|
48
|
-
// ]
|
|
49
|
-
// @ts-expect-error
|
|
50
26
|
global.fetch = fetch;
|
|
51
|
-
// @ts-expect-error
|
|
52
27
|
global.Headers = Headers;
|
|
53
|
-
// @ts-expect-error
|
|
54
28
|
global.Response = Response;
|
|
55
|
-
// @ts-expect-error
|
|
56
29
|
global.Request = Request;
|
|
57
30
|
}
|
package/esm/util.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
1
2
|
import fs from 'fs';
|
|
2
3
|
import tmp from 'tmp';
|
|
3
|
-
import { spawnSync } from 'child_process';
|
|
4
|
-
// nice helper function from https://stackoverflow.com/questions/263965/
|
|
5
4
|
export function booleanize(str) {
|
|
6
5
|
return str === 'false' ? false : !!str;
|
|
7
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/img",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"author": "JBrowse Team",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"@babel/runtime": "^7.17.9",
|
|
28
28
|
"@emotion/cache": "^11.7.1",
|
|
29
29
|
"@emotion/react": "^11.9.0",
|
|
30
|
-
"@jbrowse/plugin-linear-genome-view": "^
|
|
31
|
-
"@jbrowse/react-linear-genome-view": "^
|
|
32
|
-
"canvas": "^
|
|
33
|
-
"jsdom": "^
|
|
30
|
+
"@jbrowse/plugin-linear-genome-view": "^3.0.0",
|
|
31
|
+
"@jbrowse/react-linear-genome-view": "^3.0.0",
|
|
32
|
+
"canvas": "^3.0.0",
|
|
33
|
+
"jsdom": "^26.0.0",
|
|
34
34
|
"mobx": "^6.6.0",
|
|
35
35
|
"node-fetch": "^2.6.7",
|
|
36
|
-
"react": "^
|
|
37
|
-
"react-dom": "^
|
|
36
|
+
"react": "^19.0.0",
|
|
37
|
+
"react-dom": "^19.0.0",
|
|
38
38
|
"tmp": "^0.2.1",
|
|
39
39
|
"yargs": "^17.3.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "2c6897f1fa732b1db5b094d1dca197e333e95319"
|
|
45
45
|
}
|