@jbrowse/img 3.7.0 → 4.0.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.
- package/package.json +31 -25
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +0 -11
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -146
- package/dist/parseArgv.d.ts +0 -8
- package/dist/parseArgv.js +0 -33
- package/dist/renderRegion.d.ts +0 -34
- package/dist/renderRegion.js +0 -385
- package/dist/setupEnv.d.ts +0 -1
- package/dist/setupEnv.js +0 -66
- package/dist/util.d.ts +0 -5
- package/dist/util.js +0 -30
- package/esm/bin.d.ts +0 -2
- package/esm/bin.js +0 -11
- package/esm/index.d.ts +0 -1
- package/esm/index.js +0 -141
- package/esm/parseArgv.d.ts +0 -8
- package/esm/parseArgv.js +0 -29
- package/esm/renderRegion.d.ts +0 -34
- package/esm/renderRegion.js +0 -378
- package/esm/setupEnv.d.ts +0 -1
- package/esm/setupEnv.js +0 -30
- package/esm/util.d.ts +0 -5
- package/esm/util.js +0 -23
package/dist/renderRegion.js
DELETED
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.readData = readData;
|
|
7
|
-
exports.renderRegion = renderRegion;
|
|
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_view2_1 = require("@jbrowse/react-linear-genome-view2");
|
|
12
|
-
const util_1 = require("./util");
|
|
13
|
-
function read(file) {
|
|
14
|
-
let res;
|
|
15
|
-
try {
|
|
16
|
-
res = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
throw new Error(`Failed to parse ${file} as JSON, use --fasta if you mean to pass a FASTA file`, { cause: e });
|
|
20
|
-
}
|
|
21
|
-
return res;
|
|
22
|
-
}
|
|
23
|
-
function makeLocation(file) {
|
|
24
|
-
return file.startsWith('http') ? { uri: file } : { localPath: file };
|
|
25
|
-
}
|
|
26
|
-
function addRelativePaths(config, configPath) {
|
|
27
|
-
if (typeof config === 'object') {
|
|
28
|
-
for (const key of Object.keys(config)) {
|
|
29
|
-
if (typeof config[key] === 'object') {
|
|
30
|
-
addRelativePaths(config[key], configPath);
|
|
31
|
-
}
|
|
32
|
-
else if (key === 'localPath') {
|
|
33
|
-
config.localPath = path_1.default.resolve(configPath, config.localPath);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function readData({ assembly: asm, config, session, fasta, aliases, cytobands, defaultSession, tracks, trackList = [], }) {
|
|
39
|
-
var _a, _b;
|
|
40
|
-
const assemblyData = asm && fs_1.default.existsSync(asm) ? read(asm) : undefined;
|
|
41
|
-
const tracksData = tracks ? read(tracks) : undefined;
|
|
42
|
-
const configData = config ? read(config) : {};
|
|
43
|
-
let sessionData = session
|
|
44
|
-
? read(session)
|
|
45
|
-
: undefined;
|
|
46
|
-
if (config) {
|
|
47
|
-
addRelativePaths(configData, path_1.default.dirname(path_1.default.resolve(config)));
|
|
48
|
-
}
|
|
49
|
-
if (sessionData === null || sessionData === void 0 ? void 0 : sessionData.session) {
|
|
50
|
-
sessionData = sessionData.session;
|
|
51
|
-
}
|
|
52
|
-
if (sessionData === null || sessionData === void 0 ? void 0 : sessionData.views) {
|
|
53
|
-
sessionData.view = sessionData.views[0];
|
|
54
|
-
}
|
|
55
|
-
if (assemblyData) {
|
|
56
|
-
configData.assembly = assemblyData;
|
|
57
|
-
}
|
|
58
|
-
else if ((_a = configData.assemblies) === null || _a === void 0 ? void 0 : _a.length) {
|
|
59
|
-
configData.assemblies.find(entry => entry.name === asm);
|
|
60
|
-
if (asm) {
|
|
61
|
-
const assembly = configData.assemblies.find(entry => entry.name === asm);
|
|
62
|
-
if (!assembly) {
|
|
63
|
-
throw new Error(`assembly ${asm} not found in config`);
|
|
64
|
-
}
|
|
65
|
-
configData.assembly = assembly;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
configData.assembly = configData.assemblies[0];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else if (fasta) {
|
|
72
|
-
const bgzip = fasta.endsWith('gz');
|
|
73
|
-
configData.assembly = {
|
|
74
|
-
name: path_1.default.basename(fasta),
|
|
75
|
-
sequence: {
|
|
76
|
-
type: 'ReferenceSequenceTrack',
|
|
77
|
-
trackId: 'refseq',
|
|
78
|
-
adapter: {
|
|
79
|
-
type: bgzip ? 'BgzipFastaAdapter' : 'IndexedFastaAdapter',
|
|
80
|
-
fastaLocation: makeLocation(fasta),
|
|
81
|
-
faiLocation: makeLocation(`${fasta}.fai`),
|
|
82
|
-
gziLocation: bgzip ? makeLocation(`${fasta}.gzi`) : undefined,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
if (aliases) {
|
|
87
|
-
configData.assembly.refNameAliases = {
|
|
88
|
-
adapter: {
|
|
89
|
-
type: 'RefNameAliasAdapter',
|
|
90
|
-
location: makeLocation(aliases),
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
if (cytobands) {
|
|
95
|
-
configData.assembly.cytobands = {
|
|
96
|
-
adapter: {
|
|
97
|
-
type: 'CytobandAdapter',
|
|
98
|
-
location: makeLocation(cytobands),
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (!configData.assembly) {
|
|
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');
|
|
105
|
-
}
|
|
106
|
-
if (tracksData) {
|
|
107
|
-
configData.tracks = tracksData;
|
|
108
|
-
}
|
|
109
|
-
else if (!configData.tracks) {
|
|
110
|
-
configData.tracks = [];
|
|
111
|
-
}
|
|
112
|
-
for (const track of trackList) {
|
|
113
|
-
const [type, opts] = track;
|
|
114
|
-
const [file, ...rest] = opts;
|
|
115
|
-
const index = (_b = rest.find(r => r.startsWith('index:'))) === null || _b === void 0 ? void 0 : _b.replace('index:', '');
|
|
116
|
-
if (!file) {
|
|
117
|
-
throw new Error('no file specified');
|
|
118
|
-
}
|
|
119
|
-
if (type === 'bam') {
|
|
120
|
-
configData.tracks = [
|
|
121
|
-
...configData.tracks,
|
|
122
|
-
{
|
|
123
|
-
type: 'AlignmentsTrack',
|
|
124
|
-
trackId: path_1.default.basename(file),
|
|
125
|
-
name: path_1.default.basename(file),
|
|
126
|
-
assemblyNames: [configData.assembly.name],
|
|
127
|
-
adapter: {
|
|
128
|
-
type: 'BamAdapter',
|
|
129
|
-
bamLocation: makeLocation(file),
|
|
130
|
-
index: {
|
|
131
|
-
location: makeLocation(index || `${file}.bai`),
|
|
132
|
-
indexType: (index === null || index === void 0 ? void 0 : index.endsWith('.csi')) ? 'CSI' : 'BAI',
|
|
133
|
-
},
|
|
134
|
-
sequenceAdapter: configData.assembly.sequence.adapter,
|
|
135
|
-
},
|
|
136
|
-
...(opts.includes('snpcov')
|
|
137
|
-
? {
|
|
138
|
-
displays: [
|
|
139
|
-
{
|
|
140
|
-
type: 'LinearSNPCoverageDisplay',
|
|
141
|
-
displayId: `${path_1.default.basename(file)}-${Math.random()}`,
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
}
|
|
145
|
-
: {}),
|
|
146
|
-
},
|
|
147
|
-
];
|
|
148
|
-
}
|
|
149
|
-
if (type === 'cram') {
|
|
150
|
-
configData.tracks = [
|
|
151
|
-
...configData.tracks,
|
|
152
|
-
{
|
|
153
|
-
type: 'AlignmentsTrack',
|
|
154
|
-
trackId: path_1.default.basename(file),
|
|
155
|
-
name: path_1.default.basename(file),
|
|
156
|
-
assemblyNames: [configData.assembly.name],
|
|
157
|
-
adapter: {
|
|
158
|
-
type: 'CramAdapter',
|
|
159
|
-
cramLocation: makeLocation(file),
|
|
160
|
-
craiLocation: makeLocation(index || `${file}.crai`),
|
|
161
|
-
sequenceAdapter: configData.assembly.sequence.adapter,
|
|
162
|
-
},
|
|
163
|
-
...(opts.includes('snpcov')
|
|
164
|
-
? {
|
|
165
|
-
displays: [
|
|
166
|
-
{
|
|
167
|
-
type: 'LinearSNPCoverageDisplay',
|
|
168
|
-
displayId: `${path_1.default.basename(file)}-${Math.random()}`,
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
}
|
|
172
|
-
: {}),
|
|
173
|
-
},
|
|
174
|
-
];
|
|
175
|
-
}
|
|
176
|
-
if (type === 'bigwig') {
|
|
177
|
-
configData.tracks = [
|
|
178
|
-
...configData.tracks,
|
|
179
|
-
{
|
|
180
|
-
type: 'QuantitativeTrack',
|
|
181
|
-
trackId: path_1.default.basename(file),
|
|
182
|
-
name: path_1.default.basename(file),
|
|
183
|
-
assemblyNames: [configData.assembly.name],
|
|
184
|
-
adapter: {
|
|
185
|
-
type: 'BigWigAdapter',
|
|
186
|
-
bigWigLocation: makeLocation(file),
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
];
|
|
190
|
-
}
|
|
191
|
-
if (type === 'vcfgz') {
|
|
192
|
-
configData.tracks = [
|
|
193
|
-
...configData.tracks,
|
|
194
|
-
{
|
|
195
|
-
type: 'VariantTrack',
|
|
196
|
-
trackId: path_1.default.basename(file),
|
|
197
|
-
name: path_1.default.basename(file),
|
|
198
|
-
assemblyNames: [configData.assembly.name],
|
|
199
|
-
adapter: {
|
|
200
|
-
type: 'VcfTabixAdapter',
|
|
201
|
-
vcfGzLocation: makeLocation(file),
|
|
202
|
-
index: {
|
|
203
|
-
location: makeLocation(index || `${file}.tbi`),
|
|
204
|
-
indexType: (index === null || index === void 0 ? void 0 : index.endsWith('.csi')) ? 'CSI' : 'TBI',
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
];
|
|
209
|
-
}
|
|
210
|
-
if (type === 'gffgz') {
|
|
211
|
-
configData.tracks = [
|
|
212
|
-
...configData.tracks,
|
|
213
|
-
{
|
|
214
|
-
type: 'FeatureTrack',
|
|
215
|
-
trackId: path_1.default.basename(file),
|
|
216
|
-
name: path_1.default.basename(file),
|
|
217
|
-
assemblyNames: [configData.assembly.name],
|
|
218
|
-
adapter: {
|
|
219
|
-
type: 'Gff3TabixAdapter',
|
|
220
|
-
gffGzLocation: makeLocation(file),
|
|
221
|
-
index: {
|
|
222
|
-
location: makeLocation(index || `${file}.tbi`),
|
|
223
|
-
indexType: (index === null || index === void 0 ? void 0 : index.endsWith('.csi')) ? 'CSI' : 'TBI',
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
];
|
|
228
|
-
}
|
|
229
|
-
if (type === 'hic') {
|
|
230
|
-
configData.tracks = [
|
|
231
|
-
...configData.tracks,
|
|
232
|
-
{
|
|
233
|
-
type: 'HicTrack',
|
|
234
|
-
trackId: path_1.default.basename(file),
|
|
235
|
-
name: path_1.default.basename(file),
|
|
236
|
-
assemblyNames: [configData.assembly.name],
|
|
237
|
-
adapter: {
|
|
238
|
-
type: 'HicAdapter',
|
|
239
|
-
hicLocation: makeLocation(file),
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
];
|
|
243
|
-
}
|
|
244
|
-
if (type === 'bigbed') {
|
|
245
|
-
configData.tracks = [
|
|
246
|
-
...configData.tracks,
|
|
247
|
-
{
|
|
248
|
-
type: 'FeatureTrack',
|
|
249
|
-
trackId: path_1.default.basename(file),
|
|
250
|
-
name: path_1.default.basename(file),
|
|
251
|
-
assemblyNames: [configData.assembly.name],
|
|
252
|
-
adapter: {
|
|
253
|
-
type: 'BigBedAdapter',
|
|
254
|
-
bigBedLocation: makeLocation(file),
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
];
|
|
258
|
-
}
|
|
259
|
-
if (type === 'bedgz') {
|
|
260
|
-
configData.tracks = [
|
|
261
|
-
...configData.tracks,
|
|
262
|
-
{
|
|
263
|
-
type: 'FeatureTrack',
|
|
264
|
-
trackId: path_1.default.basename(file),
|
|
265
|
-
name: path_1.default.basename(file),
|
|
266
|
-
assemblyNames: [configData.assembly.name],
|
|
267
|
-
adapter: {
|
|
268
|
-
type: 'BedTabixAdapter',
|
|
269
|
-
bedGzLocation: makeLocation(file),
|
|
270
|
-
index: {
|
|
271
|
-
location: makeLocation(index || `${file}.tbi`),
|
|
272
|
-
indexType: (index === null || index === void 0 ? void 0 : index.endsWith('.csi')) ? 'CSI' : 'TBI',
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
];
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (!defaultSession) {
|
|
280
|
-
configData.defaultSession = undefined;
|
|
281
|
-
}
|
|
282
|
-
if (sessionData) {
|
|
283
|
-
configData.defaultSession = sessionData;
|
|
284
|
-
}
|
|
285
|
-
return configData;
|
|
286
|
-
}
|
|
287
|
-
function process(trackEntry, view, extra = c => c) {
|
|
288
|
-
const [, [track, ...opts]] = trackEntry;
|
|
289
|
-
if (!track) {
|
|
290
|
-
throw new Error('invalid command line args');
|
|
291
|
-
}
|
|
292
|
-
const currentTrack = view.showTrack(extra(track));
|
|
293
|
-
const display = currentTrack.displays[0];
|
|
294
|
-
for (const opt of opts) {
|
|
295
|
-
if (opt.startsWith('height:')) {
|
|
296
|
-
const [, height] = opt.split(':');
|
|
297
|
-
if (height) {
|
|
298
|
-
display.setHeight(+height);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
else if (opt.startsWith('sort:')) {
|
|
302
|
-
const [, type, tag] = opt.split(':');
|
|
303
|
-
display.PileupDisplay.setSortedBy(type, tag);
|
|
304
|
-
}
|
|
305
|
-
else if (opt.startsWith('color:')) {
|
|
306
|
-
const [, type, tag] = opt.split(':');
|
|
307
|
-
if (display.PileupDisplay) {
|
|
308
|
-
display.PileupDisplay.setColorScheme({ type, tag });
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
display.setColor(type);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
else if (opt.startsWith('force:')) {
|
|
315
|
-
const [, force] = opt.split(':');
|
|
316
|
-
if (force) {
|
|
317
|
-
display.setFeatureDensityStatsLimit({ bytes: Number.MAX_VALUE });
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
else if (opt.startsWith('autoscale:')) {
|
|
321
|
-
const [, autoscale] = opt.split(':');
|
|
322
|
-
display.setAutoscale(autoscale);
|
|
323
|
-
}
|
|
324
|
-
else if (opt.startsWith('minmax:')) {
|
|
325
|
-
const [, min, max] = opt.split(':');
|
|
326
|
-
if (min) {
|
|
327
|
-
display.setMinScore(+min);
|
|
328
|
-
}
|
|
329
|
-
if (max) {
|
|
330
|
-
display.setMaxScore(+max);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
else if (opt.startsWith('scaletype:')) {
|
|
334
|
-
const [, scaletype] = opt.split(':');
|
|
335
|
-
display.setScaleType(scaletype);
|
|
336
|
-
}
|
|
337
|
-
else if (opt.startsWith('crosshatch:')) {
|
|
338
|
-
const [, val = 'false'] = opt.split(':');
|
|
339
|
-
display.setCrossHatches((0, util_1.booleanize)(val));
|
|
340
|
-
}
|
|
341
|
-
else if (opt.startsWith('fill:')) {
|
|
342
|
-
const [, val = 'true'] = opt.split(':');
|
|
343
|
-
display.setFill((0, util_1.booleanize)(val));
|
|
344
|
-
}
|
|
345
|
-
else if (opt.startsWith('resolution:')) {
|
|
346
|
-
let [, val = 1] = opt.split(':');
|
|
347
|
-
if (val === 'fine') {
|
|
348
|
-
val = '10';
|
|
349
|
-
}
|
|
350
|
-
else if (val === 'superfine') {
|
|
351
|
-
val = '100';
|
|
352
|
-
}
|
|
353
|
-
display.setResolution(+val);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
async function renderRegion(opts) {
|
|
358
|
-
const model = (0, react_linear_genome_view2_1.createViewState)({
|
|
359
|
-
...readData(opts),
|
|
360
|
-
});
|
|
361
|
-
const { loc, width = 1500, trackList = [], session: sessionParam, defaultSession, } = opts;
|
|
362
|
-
const { session } = model;
|
|
363
|
-
const { view } = session;
|
|
364
|
-
const { assemblyManager } = model;
|
|
365
|
-
view.setWidth(width);
|
|
366
|
-
if (loc) {
|
|
367
|
-
const { name } = assemblyManager.assemblies[0];
|
|
368
|
-
if (loc === 'all') {
|
|
369
|
-
view.showAllRegionsInAssembly(name);
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
await view.navToLocString(loc, name);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
else if (!sessionParam && !defaultSession) {
|
|
376
|
-
console.warn('No loc specified');
|
|
377
|
-
}
|
|
378
|
-
for (const track of trackList) {
|
|
379
|
-
process(track, view, extra => path_1.default.basename(extra));
|
|
380
|
-
}
|
|
381
|
-
return (0, plugin_linear_genome_view_1.renderToSvg)(view, {
|
|
382
|
-
rasterizeLayers: !opts.noRasterize,
|
|
383
|
-
...opts,
|
|
384
|
-
});
|
|
385
|
-
}
|
package/dist/setupEnv.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function setupEnv(): void;
|
package/dist/setupEnv.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
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
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.default = setupEnv;
|
|
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"));
|
|
41
|
-
function setupEnv() {
|
|
42
|
-
addGlobalCanvasUtils();
|
|
43
|
-
addGlobalTextUtils();
|
|
44
|
-
addGlobalDocument();
|
|
45
|
-
addFetchPolyfill();
|
|
46
|
-
}
|
|
47
|
-
function addGlobalCanvasUtils() {
|
|
48
|
-
global.nodeImage = canvas_1.Image;
|
|
49
|
-
global.nodeCreateCanvas = canvas_1.createCanvas;
|
|
50
|
-
}
|
|
51
|
-
function addGlobalTextUtils() {
|
|
52
|
-
global.TextEncoder = util_1.TextEncoder;
|
|
53
|
-
global.TextDecoder = util_1.TextDecoder;
|
|
54
|
-
}
|
|
55
|
-
function addGlobalDocument() {
|
|
56
|
-
const window = new jsdom_1.JSDOM('...').window;
|
|
57
|
-
global.document = window.document;
|
|
58
|
-
global.window = window;
|
|
59
|
-
addFetchPolyfill();
|
|
60
|
-
}
|
|
61
|
-
function addFetchPolyfill() {
|
|
62
|
-
global.fetch = node_fetch_1.default;
|
|
63
|
-
global.Headers = node_fetch_1.Headers;
|
|
64
|
-
global.Response = node_fetch_1.Response;
|
|
65
|
-
global.Request = node_fetch_1.Request;
|
|
66
|
-
}
|
package/dist/util.d.ts
DELETED
package/dist/util.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.booleanize = booleanize;
|
|
7
|
-
exports.convert = convert;
|
|
8
|
-
const child_process_1 = require("child_process");
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const tmp_1 = __importDefault(require("tmp"));
|
|
11
|
-
function booleanize(str) {
|
|
12
|
-
return str === 'false' ? false : !!str;
|
|
13
|
-
}
|
|
14
|
-
function createTmp() {
|
|
15
|
-
return tmp_1.default.fileSync({
|
|
16
|
-
mode: 0o644,
|
|
17
|
-
prefix: 'prefix-',
|
|
18
|
-
postfix: '.svg',
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function convert(result, args, spawnArgs = []) {
|
|
22
|
-
const { name } = createTmp();
|
|
23
|
-
const { pngwidth = '2048', out } = args;
|
|
24
|
-
fs_1.default.writeFileSync(name, result);
|
|
25
|
-
const a = ['-w', pngwidth, name, '-o', out, ...spawnArgs];
|
|
26
|
-
const ls = (0, child_process_1.spawnSync)('rsvg-convert', a);
|
|
27
|
-
console.error(`rsvg-convert stderr: ${ls.stderr.toString()}`);
|
|
28
|
-
console.log(`rsvg-convert stdout: ${ls.stdout.toString()}`);
|
|
29
|
-
fs_1.default.unlinkSync(name);
|
|
30
|
-
}
|
package/esm/bin.d.ts
DELETED
package/esm/bin.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
const Module = require('module');
|
|
4
|
-
const originalRequire = Module.prototype.require;
|
|
5
|
-
Module.prototype.require = function (path) {
|
|
6
|
-
if (path.endsWith('.css')) {
|
|
7
|
-
return {};
|
|
8
|
-
}
|
|
9
|
-
return Reflect.apply(originalRequire, this, arguments);
|
|
10
|
-
};
|
|
11
|
-
require('./index.js');
|
package/esm/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/esm/index.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import yargs from 'yargs';
|
|
3
|
-
import { parseArgv, standardizeArgv } from './parseArgv';
|
|
4
|
-
import { renderRegion } from './renderRegion';
|
|
5
|
-
import setupEnv from './setupEnv';
|
|
6
|
-
import { convert } from './util';
|
|
7
|
-
setupEnv();
|
|
8
|
-
const err = console.error;
|
|
9
|
-
console.error = (...p) => {
|
|
10
|
-
if (!/useLayoutEffect/.exec(`${p[0]}`)) {
|
|
11
|
-
err(p);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const warn = console.warn;
|
|
15
|
-
console.warn = (...p) => {
|
|
16
|
-
if (!/estimation reached timeout/.exec(`${p[0]}`)) {
|
|
17
|
-
warn(p);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
yargs
|
|
21
|
-
.command('jb2export', 'Creates a jbrowse 2 image snapshot')
|
|
22
|
-
.option('config', {
|
|
23
|
-
description: 'Path to config file',
|
|
24
|
-
type: 'string',
|
|
25
|
-
})
|
|
26
|
-
.option('session', {
|
|
27
|
-
description: 'Path to session file',
|
|
28
|
-
type: 'string',
|
|
29
|
-
})
|
|
30
|
-
.option('assembly', {
|
|
31
|
-
description: 'Path to an assembly configuration, or a name of an assembly in the configFile',
|
|
32
|
-
type: 'string',
|
|
33
|
-
})
|
|
34
|
-
.option('tracks', {
|
|
35
|
-
description: 'Path to tracks portion of a session',
|
|
36
|
-
type: 'string',
|
|
37
|
-
})
|
|
38
|
-
.option('loc', {
|
|
39
|
-
description: 'A locstring to navigate to, or --loc all to view the whole genome',
|
|
40
|
-
type: 'string',
|
|
41
|
-
})
|
|
42
|
-
.option('fasta', {
|
|
43
|
-
description: 'Supply a fasta for the assembly',
|
|
44
|
-
type: 'string',
|
|
45
|
-
})
|
|
46
|
-
.option('aliases', {
|
|
47
|
-
description: 'Supply aliases for the assembly, e.g. mapping of 1 to chr1. Tab separated file where column 1 matches the names from the FASTA',
|
|
48
|
-
type: 'string',
|
|
49
|
-
})
|
|
50
|
-
.option('width', {
|
|
51
|
-
description: 'Set the width of the window that jbrowse renders to, default: 1500px',
|
|
52
|
-
type: 'number',
|
|
53
|
-
})
|
|
54
|
-
.option('pngwidth', {
|
|
55
|
-
description: 'Set the width of the png canvas if using png output, default 2048px',
|
|
56
|
-
type: 'number',
|
|
57
|
-
default: 2048,
|
|
58
|
-
})
|
|
59
|
-
.option('configtracks', {
|
|
60
|
-
description: 'A list of track labels from a config file',
|
|
61
|
-
type: 'array',
|
|
62
|
-
})
|
|
63
|
-
.option('bam', {
|
|
64
|
-
description: 'A bam file, flag --bam can be used multiple times to specify multiple bam files',
|
|
65
|
-
type: 'array',
|
|
66
|
-
})
|
|
67
|
-
.option('bigwig', {
|
|
68
|
-
description: 'A bigwig file, the --bigwig flag can be used multiple times to specify multiple bigwig files',
|
|
69
|
-
type: 'array',
|
|
70
|
-
})
|
|
71
|
-
.option('cram', {
|
|
72
|
-
description: 'A cram file, the --cram flag can be used multiple times to specify multiple cram files',
|
|
73
|
-
type: 'array',
|
|
74
|
-
})
|
|
75
|
-
.option('vcfgz', {
|
|
76
|
-
description: 'A tabixed VCF, the --vcfgz flag can be used multiple times to specify multiple vcfgz files',
|
|
77
|
-
type: 'array',
|
|
78
|
-
})
|
|
79
|
-
.option('gffgz', {
|
|
80
|
-
description: 'A tabixed GFF, the --gffgz can be used multiple times to specify multiple gffgz files',
|
|
81
|
-
type: 'array',
|
|
82
|
-
})
|
|
83
|
-
.option('hic', {
|
|
84
|
-
description: 'A .hic file, the --hic can be used multiple times to specify multiple hic files',
|
|
85
|
-
type: 'array',
|
|
86
|
-
})
|
|
87
|
-
.option('bigbed', {
|
|
88
|
-
description: 'A .bigBed file, the --bigbed can be used multiple times to specify multiple bigbed files',
|
|
89
|
-
type: 'array',
|
|
90
|
-
})
|
|
91
|
-
.option('bedgz', {
|
|
92
|
-
description: 'A bed tabix file, the --bedgz can be used multiple times to specify multiple bedtabix files',
|
|
93
|
-
type: 'array',
|
|
94
|
-
})
|
|
95
|
-
.option('out', {
|
|
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',
|
|
97
|
-
type: 'string',
|
|
98
|
-
default: 'out.svg',
|
|
99
|
-
})
|
|
100
|
-
.option('noRasterize', {
|
|
101
|
-
description: 'Use full SVG rendering with no rasterized layers, this can substantially increase filesize',
|
|
102
|
-
type: 'boolean',
|
|
103
|
-
})
|
|
104
|
-
.option('defaultSession', {
|
|
105
|
-
description: 'Use the defaultSession from config.json',
|
|
106
|
-
type: 'boolean',
|
|
107
|
-
})
|
|
108
|
-
.help()
|
|
109
|
-
.alias('help', 'h')
|
|
110
|
-
.alias('width', 'w').argv;
|
|
111
|
-
const args = standardizeArgv(parseArgv(process.argv.slice(2)), [
|
|
112
|
-
'bam',
|
|
113
|
-
'cram',
|
|
114
|
-
'vcfgz',
|
|
115
|
-
'hic',
|
|
116
|
-
'bigwig',
|
|
117
|
-
'bigbed',
|
|
118
|
-
'bedgz',
|
|
119
|
-
'gffgz',
|
|
120
|
-
'configtracks',
|
|
121
|
-
]);
|
|
122
|
-
(async () => {
|
|
123
|
-
try {
|
|
124
|
-
const result = await renderRegion(args);
|
|
125
|
-
const { out = 'out.svg', pngwidth = '2048' } = args;
|
|
126
|
-
if (out.endsWith('.png')) {
|
|
127
|
-
convert(result, { out, pngwidth });
|
|
128
|
-
}
|
|
129
|
-
else if (out.endsWith('.pdf')) {
|
|
130
|
-
convert(result, { out, pngwidth }, ['-f', 'pdf']);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
fs.writeFileSync(out, result);
|
|
134
|
-
}
|
|
135
|
-
process.exit(0);
|
|
136
|
-
}
|
|
137
|
-
catch (e) {
|
|
138
|
-
console.error(e);
|
|
139
|
-
process.exit(1);
|
|
140
|
-
}
|
|
141
|
-
})();
|
package/esm/parseArgv.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type Entry = [string, string[]];
|
|
2
|
-
export declare function parseArgv(argv: string[]): Entry[];
|
|
3
|
-
export declare function standardizeArgv(args: Entry[], trackTypes: string[]): {
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
trackList: Entry[];
|
|
6
|
-
out?: string;
|
|
7
|
-
pngwidth?: string;
|
|
8
|
-
};
|
package/esm/parseArgv.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export function parseArgv(argv) {
|
|
2
|
-
const map = [];
|
|
3
|
-
while (argv.length) {
|
|
4
|
-
const val = argv[0].slice(2);
|
|
5
|
-
argv = argv.slice(1);
|
|
6
|
-
const next = argv.findIndex(arg => arg.startsWith('-'));
|
|
7
|
-
if (next !== -1) {
|
|
8
|
-
map.push([val, argv.slice(0, next)]);
|
|
9
|
-
argv = argv.slice(next);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
map.push([val, argv]);
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return map;
|
|
17
|
-
}
|
|
18
|
-
export function standardizeArgv(args, trackTypes) {
|
|
19
|
-
const result = { trackList: [] };
|
|
20
|
-
for (const arg of args) {
|
|
21
|
-
if (trackTypes.includes(arg[0])) {
|
|
22
|
-
result.trackList.push(arg);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
result[arg[0]] = arg[1][0] || true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return result;
|
|
29
|
-
}
|