@jbrowse/plugin-legacy-jbrowse 3.6.5 → 4.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.
Files changed (62) hide show
  1. package/esm/JBrowse1Connection/configSchema.d.ts +3 -3
  2. package/esm/JBrowse1Connection/get-value.d.ts +10 -0
  3. package/esm/JBrowse1Connection/get-value.js +84 -0
  4. package/esm/JBrowse1Connection/index.js +2 -2
  5. package/esm/JBrowse1Connection/jb1ConfigLoad.d.ts +1 -1
  6. package/esm/JBrowse1Connection/jb1ConfigLoad.js +2 -2
  7. package/esm/JBrowse1Connection/jb1ConfigParse.d.ts +1 -1
  8. package/esm/JBrowse1Connection/jb1ConfigParse.js +12 -10
  9. package/esm/JBrowse1Connection/jb1ToJb2.d.ts +2 -3
  10. package/esm/JBrowse1Connection/jb1ToJb2.js +43 -45
  11. package/esm/JBrowse1Connection/model.d.ts +16 -24
  12. package/esm/JBrowse1Connection/model.js +8 -14
  13. package/esm/JBrowse1Connection/util.d.ts +1 -1
  14. package/esm/JBrowse1Connection/util.js +13 -3
  15. package/esm/JBrowse1TextSearchAdapter/HttpMap.js +16 -1
  16. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +1 -1
  17. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +3 -1
  18. package/esm/JBrowse1TextSearchAdapter/configSchema.d.ts +2 -2
  19. package/esm/JBrowse1TextSearchAdapter/index.js +2 -2
  20. package/esm/NCListAdapter/NCListAdapter.d.ts +1 -1
  21. package/esm/NCListAdapter/NCListAdapter.js +6 -5
  22. package/esm/NCListAdapter/NCListFeature.js +3 -0
  23. package/esm/NCListAdapter/configSchema.d.ts +2 -2
  24. package/esm/NCListAdapter/index.js +2 -2
  25. package/esm/index.js +5 -8
  26. package/package.json +25 -33
  27. package/dist/GuessNCList/index.d.ts +0 -2
  28. package/dist/GuessNCList/index.js +0 -18
  29. package/dist/JBrowse1Connection/configSchema.d.ts +0 -27
  30. package/dist/JBrowse1Connection/configSchema.js +0 -23
  31. package/dist/JBrowse1Connection/index.d.ts +0 -2
  32. package/dist/JBrowse1Connection/index.js +0 -19
  33. package/dist/JBrowse1Connection/jb1ConfigLoad.d.ts +0 -36
  34. package/dist/JBrowse1Connection/jb1ConfigLoad.js +0 -253
  35. package/dist/JBrowse1Connection/jb1ConfigParse.d.ts +0 -4
  36. package/dist/JBrowse1Connection/jb1ConfigParse.js +0 -341
  37. package/dist/JBrowse1Connection/jb1ToJb2.d.ts +0 -49
  38. package/dist/JBrowse1Connection/jb1ToJb2.js +0 -408
  39. package/dist/JBrowse1Connection/model.d.ts +0 -75
  40. package/dist/JBrowse1Connection/model.js +0 -82
  41. package/dist/JBrowse1Connection/types.d.ts +0 -91
  42. package/dist/JBrowse1Connection/types.js +0 -2
  43. package/dist/JBrowse1Connection/util.d.ts +0 -8
  44. package/dist/JBrowse1Connection/util.js +0 -86
  45. package/dist/JBrowse1TextSearchAdapter/HttpMap.d.ts +0 -19
  46. package/dist/JBrowse1TextSearchAdapter/HttpMap.js +0 -65
  47. package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +0 -28
  48. package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +0 -58
  49. package/dist/JBrowse1TextSearchAdapter/configSchema.d.ts +0 -21
  50. package/dist/JBrowse1TextSearchAdapter/configSchema.js +0 -24
  51. package/dist/JBrowse1TextSearchAdapter/index.d.ts +0 -2
  52. package/dist/JBrowse1TextSearchAdapter/index.js +0 -49
  53. package/dist/NCListAdapter/NCListAdapter.d.ts +0 -17
  54. package/dist/NCListAdapter/NCListAdapter.js +0 -48
  55. package/dist/NCListAdapter/NCListFeature.d.ts +0 -16
  56. package/dist/NCListAdapter/NCListFeature.js +0 -58
  57. package/dist/NCListAdapter/configSchema.d.ts +0 -15
  58. package/dist/NCListAdapter/configSchema.js +0 -21
  59. package/dist/NCListAdapter/index.d.ts +0 -2
  60. package/dist/NCListAdapter/index.js +0 -52
  61. package/dist/index.d.ts +0 -6
  62. package/dist/index.js +0 -23
@@ -1,341 +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.parseJB1Json = parseJB1Json;
7
- exports.parseJB1Conf = parseJB1Conf;
8
- exports.regularizeConf = regularizeConf;
9
- const util_1 = require("@jbrowse/core/util");
10
- const get_value_1 = __importDefault(require("get-value"));
11
- const set_value_1 = __importDefault(require("set-value"));
12
- const util_2 = require("./util");
13
- function parseJB1Json(config, url) {
14
- if (typeof config === 'string') {
15
- let parsedConf;
16
- try {
17
- parsedConf = JSON.parse(config);
18
- }
19
- catch (error) {
20
- throw new Error(`${error} when parsing configuration.`);
21
- }
22
- return regularizeConf(parsedConf, url);
23
- }
24
- return regularizeConf(config, url);
25
- }
26
- function parseJB1Conf(config, url) {
27
- let parsedConf;
28
- try {
29
- parsedConf = parse(config, url);
30
- }
31
- catch (error) {
32
- throw new Error(`${error} when parsing configuration.`);
33
- }
34
- return regularizeConf(parsedConf, url);
35
- }
36
- function isAlwaysArray(varName) {
37
- if (varName === 'include') {
38
- return true;
39
- }
40
- return false;
41
- }
42
- function parse(text, url) {
43
- let section = [];
44
- let keyPath;
45
- let operation;
46
- let value;
47
- const data = { tracks: {} };
48
- let lineNumber;
49
- function recordVal() {
50
- if (value !== undefined) {
51
- let parsedValue;
52
- try {
53
- const match = /^json:(.+)/i.exec(value);
54
- if (match) {
55
- parsedValue = JSON.parse(match[1]);
56
- }
57
- else if (/^[+-]?[\d.,]+([eE][-+]?\d+)?$/.test(value)) {
58
- parsedValue = Number.parseFloat(value.replaceAll(',', ''));
59
- }
60
- else {
61
- parsedValue = value;
62
- }
63
- if (!keyPath) {
64
- throw new Error(`Error parsing in section ${section.join(' - ')}`);
65
- }
66
- const path = [...section, ...keyPath].join('.');
67
- if (operation === '+=') {
68
- let existing = (0, get_value_1.default)(data, path);
69
- if (existing) {
70
- if (!Array.isArray(existing)) {
71
- existing = [existing];
72
- }
73
- }
74
- else {
75
- existing = [];
76
- }
77
- existing.push(parsedValue);
78
- parsedValue = existing;
79
- }
80
- if (parsedValue === 'true') {
81
- parsedValue = true;
82
- }
83
- if (parsedValue === 'false') {
84
- parsedValue = false;
85
- }
86
- (0, set_value_1.default)(data, path, parsedValue);
87
- }
88
- catch (e) {
89
- throw new Error(`syntax error${url ? ` in ${url}` : ''}${lineNumber ? ` at line ${lineNumber - 1}` : ''}`);
90
- }
91
- }
92
- }
93
- for (const [i, textLine] of text.split(/\n|\r\n|\r/).entries()) {
94
- lineNumber = i + 1;
95
- const line = textLine.replace(/^\s*#.+/, '');
96
- let match;
97
- if ((match = /^\s*\[([^\]]+)/.exec(line))) {
98
- recordVal();
99
- keyPath = undefined;
100
- value = undefined;
101
- section = match[1].trim().split(/\s*\.\s*/);
102
- if (section.length === 1 && section[0].toLowerCase() === 'general') {
103
- section = [];
104
- }
105
- }
106
- else if ((match = line.match(value === undefined ? /^([^+=]+)(\+?=)(.*)/ : /^(\S[^+=]+)(\+?=)(.*)/))) {
107
- recordVal();
108
- keyPath = match[1].trim().split(/\s*\.\s*/);
109
- [, , operation] = match;
110
- if (isAlwaysArray([...section, ...keyPath].join('.'))) {
111
- operation = '+=';
112
- }
113
- value = match[3].trim();
114
- }
115
- else if (keyPath !== undefined &&
116
- (match = /^\s{0,4}\+\s*(.+)/.exec(line))) {
117
- recordVal();
118
- operation = '+=';
119
- value = match[1].trim();
120
- }
121
- else if (value !== undefined && (match = /^\s+(\S.*)/.exec(line))) {
122
- const m = match[1];
123
- value += value.length ? ` ${m.trim()}` : m.trim();
124
- }
125
- else {
126
- recordVal();
127
- keyPath = undefined;
128
- value = undefined;
129
- }
130
- }
131
- recordVal();
132
- return data;
133
- }
134
- function regularizeConf(conf, url) {
135
- if (conf.tracks && !Array.isArray(conf.tracks)) {
136
- if ((0, util_2.isTrack)(conf.tracks)) {
137
- conf.tracks = [conf.tracks];
138
- }
139
- else {
140
- const tracks = [];
141
- for (const label of Object.keys(conf.tracks)) {
142
- const track = conf.tracks[label];
143
- if ((0, util_2.isTrack)(track)) {
144
- tracks.push(track);
145
- }
146
- else {
147
- tracks.push({ label, ...track });
148
- }
149
- }
150
- conf.tracks = tracks;
151
- }
152
- }
153
- const meta = conf.trackMetadata;
154
- if (meta === null || meta === void 0 ? void 0 : meta.sources) {
155
- if (typeof meta.sources === 'string') {
156
- meta.sources = [meta.sources];
157
- }
158
- if ((0, util_2.isSource)(meta.sources)) {
159
- meta.sources = [meta.sources];
160
- }
161
- if (!Array.isArray(meta.sources)) {
162
- const sources = [];
163
- for (const name of Object.keys(meta.sources)) {
164
- const source = meta.sources[name];
165
- if (!('name' in source)) {
166
- source.name = name;
167
- }
168
- sources.push(source);
169
- }
170
- meta.sources = sources;
171
- }
172
- meta.sources = meta.sources.map((sourceDef) => {
173
- if (typeof sourceDef === 'string') {
174
- const newSourceDef = { url: sourceDef };
175
- const typeMatch = /\.(\w+)$/.exec(sourceDef);
176
- if (typeMatch) {
177
- newSourceDef.type = typeMatch[1].toLowerCase();
178
- }
179
- return newSourceDef;
180
- }
181
- return sourceDef;
182
- });
183
- }
184
- conf.sourceUrl = conf.sourceUrl || url;
185
- if (conf.sourceUrl.startsWith('/')) {
186
- conf.sourceUrl = new URL(conf.sourceUrl, window.location.href).href;
187
- }
188
- conf.baseUrl = conf.baseUrl || new URL('.', conf.sourceUrl).href;
189
- if (conf.baseUrl.length && !conf.baseUrl.endsWith('/')) {
190
- conf.baseUrl += '/';
191
- }
192
- if (conf.sourceUrl) {
193
- const addBase = [];
194
- if (conf.tracks) {
195
- addBase.push(...conf.tracks);
196
- }
197
- if (conf.stores) {
198
- addBase.push(...Object.values(conf.stores));
199
- }
200
- if (conf.names) {
201
- addBase.push(conf.names);
202
- }
203
- for (const t of addBase) {
204
- if (!t.baseUrl) {
205
- t.baseUrl = conf.baseUrl || '/';
206
- }
207
- }
208
- if (conf.refSeqs && typeof conf.refSeqs === 'string') {
209
- conf.refSeqs = new URL(conf.refSeqs, conf.sourceUrl).href;
210
- }
211
- if (conf.nameUrl) {
212
- conf.nameUrl = new URL(conf.nameUrl, conf.sourceUrl).href;
213
- }
214
- }
215
- conf.stores = conf.stores || {};
216
- for (let trackConfig of conf.tracks || []) {
217
- if (trackConfig.config) {
218
- const c = trackConfig.config;
219
- trackConfig.config = undefined;
220
- trackConfig = { ...c, ...trackConfig };
221
- }
222
- if (trackConfig.store) {
223
- continue;
224
- }
225
- let trackClassName;
226
- if (trackConfig.type === 'FeatureTrack') {
227
- trackClassName = 'JBrowse/View/Track/HTMLFeatures';
228
- }
229
- else if (trackConfig.type === 'ImageTrack') {
230
- trackClassName = 'JBrowse/View/Track/FixedImage';
231
- }
232
- else if (trackConfig.type === 'ImageTrack.Wiggle') {
233
- trackClassName = 'JBrowse/View/Track/FixedImage/Wiggle';
234
- }
235
- else if (trackConfig.type === 'SequenceTrack') {
236
- trackClassName = 'JBrowse/View/Track/Sequence';
237
- }
238
- else {
239
- trackClassName = regularizeClass('JBrowse/View/Track', trackConfig.type);
240
- }
241
- trackConfig.type = trackClassName;
242
- synthesizeTrackStoreConfig(conf, trackConfig);
243
- if (trackConfig.histograms) {
244
- if (!trackConfig.histograms.baseUrl) {
245
- trackConfig.histograms.baseUrl = trackConfig.baseUrl;
246
- }
247
- synthesizeTrackStoreConfig(conf, trackConfig.histograms);
248
- }
249
- }
250
- return conf;
251
- }
252
- function regularizeClass(root, className) {
253
- if (!className) {
254
- return '';
255
- }
256
- if (!className.includes('/')) {
257
- className = `${root}/${className}`;
258
- }
259
- className = className.replace(/^\//, '');
260
- return className;
261
- }
262
- function guessStoreClass(trackConfig, urlTemplate) {
263
- var _a, _b;
264
- if (!trackConfig) {
265
- return '';
266
- }
267
- if ((_a = trackConfig.type) === null || _a === void 0 ? void 0 : _a.includes('/FixedImage')) {
268
- return `JBrowse/Store/TiledImage/Fixed${trackConfig.backendVersion === 0 ? '_v0' : ''}`;
269
- }
270
- if (/\.jsonz?$/i.test(urlTemplate)) {
271
- return `JBrowse/Store/SeqFeature/NCList${trackConfig.backendVersion === 0 ? '_v0' : ''}`;
272
- }
273
- if (/\.bam$/i.test(urlTemplate)) {
274
- return 'JBrowse/Store/SeqFeature/BAM';
275
- }
276
- if (/\.cram$/i.test(urlTemplate)) {
277
- return 'JBrowse/Store/SeqFeature/CRAM';
278
- }
279
- if (/\.gff3?$/i.test(urlTemplate)) {
280
- return 'JBrowse/Store/SeqFeature/GFF3';
281
- }
282
- if (/\.bed$/i.test(urlTemplate)) {
283
- return 'JBrowse/Store/SeqFeature/BED';
284
- }
285
- if (/\.vcf.b?gz$/i.test(urlTemplate)) {
286
- return 'JBrowse/Store/SeqFeature/VCFTabix';
287
- }
288
- if (/\.gff3?.b?gz$/i.test(urlTemplate)) {
289
- return 'JBrowse/Store/SeqFeature/GFF3Tabix';
290
- }
291
- if (/\.bed.b?gz$/i.test(urlTemplate)) {
292
- return 'JBrowse/Store/SeqFeature/BEDTabix';
293
- }
294
- if (/\.(bw|bigwig)$/i.test(urlTemplate)) {
295
- return 'JBrowse/Store/SeqFeature/BigWig';
296
- }
297
- if (/\.(bb|bigbed)$/i.test(urlTemplate)) {
298
- return 'JBrowse/Store/SeqFeature/BigBed';
299
- }
300
- if (/\.(fa|fasta)$/i.test(urlTemplate)) {
301
- return 'JBrowse/Store/SeqFeature/IndexedFasta';
302
- }
303
- if (/\.(fa|fasta)\.b?gz$/i.test(urlTemplate)) {
304
- return 'JBrowse/Store/SeqFeature/BgzipIndexedFasta';
305
- }
306
- if (/\.2bit$/i.test(urlTemplate)) {
307
- return 'JBrowse/Store/SeqFeature/TwoBit';
308
- }
309
- if ((_b = trackConfig.type) === null || _b === void 0 ? void 0 : _b.endsWith('/Sequence')) {
310
- return 'JBrowse/Store/Sequence/StaticChunked';
311
- }
312
- return '';
313
- }
314
- function synthesizeTrackStoreConfig(mainConf, trackConfig) {
315
- var _a;
316
- const { urlTemplate = '' } = trackConfig;
317
- const storeClass = trackConfig.storeClass
318
- ? regularizeClass('JBrowse/Store', trackConfig.storeClass)
319
- : guessStoreClass(trackConfig, urlTemplate);
320
- if (!storeClass) {
321
- console.warn(`Unable to determine an appropriate data store to use with track '${trackConfig.label}', please explicitly specify a storeClass in the configuration.`);
322
- return;
323
- }
324
- const storeConf = { ...trackConfig, type: storeClass };
325
- storeConf.name =
326
- (storeClass === 'JBrowse/Store/Sequence/StaticChunked' ||
327
- storeClass === 'JBrowse/Store/Sequence/IndexedFasta' ||
328
- storeClass === 'JBrowse/Store/SeqFeature/IndexedFasta' ||
329
- storeClass === 'JBrowse/Store/SeqFeature/BgzipIndexedFasta' ||
330
- storeClass === 'JBrowse/Store/SeqFeature/TwoBit' ||
331
- storeClass === 'JBrowse/Store/Sequence/TwoBit' ||
332
- trackConfig.useAsRefSeqStore) &&
333
- !((_a = mainConf.stores) === null || _a === void 0 ? void 0 : _a.refseqs)
334
- ? 'refseqs'
335
- : `store${(0, util_1.objectHash)(storeConf)}`;
336
- if (!mainConf.stores) {
337
- mainConf.stores = {};
338
- }
339
- mainConf.stores[storeConf.name] = storeConf;
340
- trackConfig.store = storeConf.name;
341
- }
@@ -1,49 +0,0 @@
1
- import type { RefSeqs, Track } from './types';
2
- interface Jb2Track {
3
- trackId: string;
4
- name: string;
5
- description?: string;
6
- category?: string[];
7
- adapter?: Jb2Adapter;
8
- type?: string;
9
- defaultRendering?: string;
10
- }
11
- interface Jb2Adapter {
12
- type: string;
13
- features?: Jb2Feature[];
14
- bamLocation?: Jb2Location;
15
- cramLocation?: Jb2Location;
16
- craiLocation?: Jb2Location;
17
- fastaLocation?: Jb2Location;
18
- faiLocation?: Jb2Location;
19
- gziLocation?: Jb2Location;
20
- twoBitLocation?: Jb2Location;
21
- bigWigLocation?: Jb2Location;
22
- bigBedLocation?: Jb2Location;
23
- vcfGzLocation?: Jb2Location;
24
- gffLocation?: Jb2Location;
25
- gffGzLocation?: Jb2Location;
26
- gtfLocation?: Jb2Location;
27
- bedGzLocation?: Jb2Location;
28
- index?: {
29
- location: Jb2Location;
30
- indexType?: string;
31
- };
32
- rootUrlTemplate?: Jb2Location;
33
- sequenceAdapter?: Jb2Adapter;
34
- }
35
- interface Jb2Feature {
36
- refName: string;
37
- uniqueId: string;
38
- start: number;
39
- end: number;
40
- }
41
- interface Jb2Location {
42
- uri?: string;
43
- localPath?: string;
44
- blobId?: string;
45
- locationType?: string;
46
- }
47
- export declare function convertTrackConfig(jb1TrackConfig: Track, dataRoot: string, sequenceAdapter: Jb2Adapter): Jb2Track;
48
- export declare function createRefSeqsAdapter(refSeqs: string | RefSeqs): Promise<Jb2Adapter>;
49
- export {};