@jbrowse/plugin-legacy-jbrowse 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/GuessNCList/index.d.ts +1 -1
- package/dist/GuessNCList/index.js +6 -8
- package/dist/JBrowse1Connection/configSchema.d.ts +0 -6
- package/dist/JBrowse1Connection/configSchema.js +2 -14
- package/dist/JBrowse1Connection/index.d.ts +1 -1
- package/dist/JBrowse1Connection/index.js +1 -2
- package/dist/JBrowse1Connection/jb1ConfigLoad.d.ts +1 -1
- package/dist/JBrowse1Connection/jb1ConfigLoad.js +5 -44
- package/dist/JBrowse1Connection/jb1ConfigParse.d.ts +1 -8
- package/dist/JBrowse1Connection/jb1ConfigParse.js +1 -41
- package/dist/JBrowse1Connection/jb1ToJb2.d.ts +1 -1
- package/dist/JBrowse1Connection/jb1ToJb2.js +1 -5
- package/dist/JBrowse1Connection/model.d.ts +5 -5
- package/dist/JBrowse1Connection/model.js +18 -10
- package/dist/JBrowse1Connection/util.d.ts +2 -21
- package/dist/JBrowse1Connection/util.js +9 -58
- package/dist/JBrowse1TextSearchAdapter/HttpMap.d.ts +0 -20
- package/dist/JBrowse1TextSearchAdapter/HttpMap.js +1 -28
- package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +5 -9
- package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +1 -7
- package/dist/JBrowse1TextSearchAdapter/configSchema.d.ts +0 -9
- package/dist/JBrowse1TextSearchAdapter/configSchema.js +1 -17
- package/dist/JBrowse1TextSearchAdapter/index.d.ts +1 -1
- package/dist/JBrowse1TextSearchAdapter/index.js +17 -8
- package/dist/NCListAdapter/NCListAdapter.d.ts +7 -22
- package/dist/NCListAdapter/NCListAdapter.js +5 -21
- package/dist/NCListAdapter/NCListFeature.d.ts +1 -16
- package/dist/NCListAdapter/NCListFeature.js +0 -19
- package/dist/NCListAdapter/configSchema.d.ts +0 -6
- package/dist/NCListAdapter/configSchema.js +1 -10
- package/dist/NCListAdapter/index.d.ts +1 -1
- package/dist/NCListAdapter/index.js +20 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/esm/GuessNCList/index.d.ts +1 -1
- package/esm/GuessNCList/index.js +6 -8
- package/esm/JBrowse1Connection/configSchema.d.ts +0 -6
- package/esm/JBrowse1Connection/configSchema.js +2 -14
- package/esm/JBrowse1Connection/index.d.ts +1 -1
- package/esm/JBrowse1Connection/index.js +1 -2
- package/esm/JBrowse1Connection/jb1ConfigLoad.d.ts +1 -1
- package/esm/JBrowse1Connection/jb1ConfigLoad.js +7 -46
- package/esm/JBrowse1Connection/jb1ConfigParse.d.ts +1 -8
- package/esm/JBrowse1Connection/jb1ConfigParse.js +1 -41
- package/esm/JBrowse1Connection/jb1ToJb2.d.ts +1 -1
- package/esm/JBrowse1Connection/jb1ToJb2.js +2 -6
- package/esm/JBrowse1Connection/model.d.ts +5 -5
- package/esm/JBrowse1Connection/model.js +1 -3
- package/esm/JBrowse1Connection/util.d.ts +2 -21
- package/esm/JBrowse1Connection/util.js +8 -57
- package/esm/JBrowse1TextSearchAdapter/HttpMap.d.ts +0 -20
- package/esm/JBrowse1TextSearchAdapter/HttpMap.js +1 -28
- package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +5 -9
- package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +2 -8
- package/esm/JBrowse1TextSearchAdapter/configSchema.d.ts +0 -9
- package/esm/JBrowse1TextSearchAdapter/configSchema.js +1 -17
- package/esm/JBrowse1TextSearchAdapter/index.d.ts +1 -1
- package/esm/JBrowse1TextSearchAdapter/index.js +0 -1
- package/esm/NCListAdapter/NCListAdapter.d.ts +7 -22
- package/esm/NCListAdapter/NCListAdapter.js +5 -21
- package/esm/NCListAdapter/NCListFeature.d.ts +1 -16
- package/esm/NCListAdapter/NCListFeature.js +0 -19
- package/esm/NCListAdapter/configSchema.d.ts +0 -6
- package/esm/NCListAdapter/configSchema.js +1 -10
- package/esm/NCListAdapter/index.d.ts +1 -1
- package/esm/NCListAdapter/index.js +3 -0
- package/esm/index.d.ts +1 -1
- package/esm/index.js +3 -3
- package/package.json +5 -5
|
@@ -15,13 +15,23 @@ 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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -34,6 +44,9 @@ function NCListAdapterF(pluginManager) {
|
|
|
34
44
|
name: 'NCListAdapter',
|
|
35
45
|
displayName: 'NCList adapter',
|
|
36
46
|
configSchema: configSchema_1.default,
|
|
47
|
+
adapterMetadata: {
|
|
48
|
+
category: 'Uncommon',
|
|
49
|
+
},
|
|
37
50
|
getAdapterClass: () => Promise.resolve().then(() => __importStar(require('./NCListAdapter'))).then(r => r.default),
|
|
38
51
|
}));
|
|
39
52
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
2
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
2
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
3
3
|
export default class LegacyJBrowsePlugin extends Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
install(pluginManager: PluginManager): void;
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Plugin_1 = __importDefault(require("@jbrowse/core/Plugin"));
|
|
7
|
-
const NCListAdapter_1 = __importDefault(require("./NCListAdapter"));
|
|
8
|
-
const JBrowse1TextSearchAdapter_1 = __importDefault(require("./JBrowse1TextSearchAdapter"));
|
|
9
|
-
const JBrowse1Connection_1 = __importDefault(require("./JBrowse1Connection"));
|
|
10
7
|
const GuessNCList_1 = __importDefault(require("./GuessNCList"));
|
|
8
|
+
const JBrowse1Connection_1 = __importDefault(require("./JBrowse1Connection"));
|
|
9
|
+
const JBrowse1TextSearchAdapter_1 = __importDefault(require("./JBrowse1TextSearchAdapter"));
|
|
10
|
+
const NCListAdapter_1 = __importDefault(require("./NCListAdapter"));
|
|
11
11
|
class LegacyJBrowsePlugin extends Plugin_1.default {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
2
|
export default function GuessNCListF(pluginManager: PluginManager): void;
|
package/esm/GuessNCList/index.js
CHANGED
|
@@ -2,16 +2,14 @@ import { getFileName } from '@jbrowse/core/util/tracks';
|
|
|
2
2
|
export default function GuessNCListF(pluginManager) {
|
|
3
3
|
pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', (adapterGuesser) => {
|
|
4
4
|
return (file, index, adapterHint) => {
|
|
5
|
-
const regexGuess = /trackData.jsonz?$/i;
|
|
6
|
-
const adapterName = 'NCListAdapter';
|
|
7
5
|
const fileName = getFileName(file);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
return (/trackData.jsonz?$/i.test(fileName) && !adapterHint) ||
|
|
7
|
+
adapterHint === 'NCListAdapter'
|
|
8
|
+
? {
|
|
9
|
+
type: 'NCListAdapter',
|
|
11
10
|
rootUrlTemplate: file,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return adapterGuesser(file, index, adapterHint);
|
|
11
|
+
}
|
|
12
|
+
: adapterGuesser(file, index, adapterHint);
|
|
15
13
|
};
|
|
16
14
|
});
|
|
17
15
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
declare const JBrowse1Connection: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
/**
|
|
3
|
-
* #slot
|
|
4
|
-
*/
|
|
5
2
|
dataDirLocation: {
|
|
6
3
|
type: string;
|
|
7
4
|
defaultValue: {
|
|
@@ -10,9 +7,6 @@ declare const JBrowse1Connection: import("@jbrowse/core/configuration/configurat
|
|
|
10
7
|
};
|
|
11
8
|
description: string;
|
|
12
9
|
};
|
|
13
|
-
/**
|
|
14
|
-
* #slot
|
|
15
|
-
*/
|
|
16
10
|
assemblyNames: {
|
|
17
11
|
description: string;
|
|
18
12
|
type: string;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { baseConnectionConfig } from '@jbrowse/core/pluggableElementTypes/models';
|
|
2
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { baseConnectionConfig } from '@jbrowse/core/pluggableElementTypes/models';
|
|
3
|
+
function x() { }
|
|
7
4
|
const JBrowse1Connection = ConfigurationSchema('JBrowse1Connection', {
|
|
8
|
-
/**
|
|
9
|
-
* #slot
|
|
10
|
-
*/
|
|
11
5
|
dataDirLocation: {
|
|
12
6
|
type: 'fileLocation',
|
|
13
7
|
defaultValue: {
|
|
@@ -16,18 +10,12 @@ const JBrowse1Connection = ConfigurationSchema('JBrowse1Connection', {
|
|
|
16
10
|
},
|
|
17
11
|
description: 'the location of the JBrowse 1 data directory, often something like http://mysite.com/jbrowse/data/',
|
|
18
12
|
},
|
|
19
|
-
/**
|
|
20
|
-
* #slot
|
|
21
|
-
*/
|
|
22
13
|
assemblyNames: {
|
|
23
14
|
description: 'name of the assembly the connection belongs to, should be a single entry',
|
|
24
15
|
type: 'stringArray',
|
|
25
16
|
defaultValue: [],
|
|
26
17
|
},
|
|
27
18
|
}, {
|
|
28
|
-
/**
|
|
29
|
-
* #baseConfiguration
|
|
30
|
-
*/
|
|
31
19
|
baseConfiguration: baseConnectionConfig,
|
|
32
20
|
});
|
|
33
21
|
export default JBrowse1Connection;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
2
|
export default function JBrowse1ConnectionF(pluginManager: PluginManager): void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import ConnectionType from '@jbrowse/core/pluggableElementTypes/ConnectionType';
|
|
2
|
-
// locals
|
|
3
|
-
import modelFactory from './model';
|
|
4
2
|
import configSchema from './configSchema';
|
|
3
|
+
import modelFactory from './model';
|
|
5
4
|
export default function JBrowse1ConnectionF(pluginManager) {
|
|
6
5
|
pluginManager.addConnectionType(() => new ConnectionType({
|
|
7
6
|
name: 'JBrowse1Connection',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Config, JBLocation } from './types';
|
|
2
2
|
export declare function fetchJb1(dataRoot?: JBLocation, baseConfig?: Config, baseConfigRoot?: JBLocation): Promise<Config>;
|
|
3
3
|
export declare function createFinalConfig(baseConfig: Config, defaults?: {
|
|
4
4
|
tracks: never[];
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { parseJB1Conf, parseJB1Json, regularizeConf } from './jb1ConfigParse';
|
|
3
|
+
import { deepUpdate, fillTemplate } from './util';
|
|
4
4
|
function isUriLocation(location) {
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
6
5
|
return location.uri !== undefined;
|
|
7
6
|
}
|
|
8
7
|
function isLocalPathLocation(location) {
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
10
8
|
return location.localPath !== undefined;
|
|
11
9
|
}
|
|
12
|
-
export async function fetchJb1(
|
|
13
|
-
// eslint-disable-next-line unicorn/no-object-as-default-parameter
|
|
14
|
-
dataRoot = { uri: '', locationType: 'UriLocation' },
|
|
15
|
-
// eslint-disable-next-line unicorn/no-object-as-default-parameter
|
|
16
|
-
baseConfig = {
|
|
10
|
+
export async function fetchJb1(dataRoot = { uri: '', locationType: 'UriLocation' }, baseConfig = {
|
|
17
11
|
include: ['{dataRoot}/trackList.json', '{dataRoot}/tracks.conf'],
|
|
18
|
-
},
|
|
19
|
-
// eslint-disable-next-line unicorn/no-object-as-default-parameter
|
|
20
|
-
baseConfigRoot = { uri: '', locationType: 'UriLocation' }) {
|
|
12
|
+
}, baseConfigRoot = { uri: '', locationType: 'UriLocation' }) {
|
|
21
13
|
const protocol = 'uri' in dataRoot ? 'uri' : 'localPath';
|
|
22
14
|
const dataRootReg = JSON.parse(JSON.stringify(dataRoot));
|
|
23
15
|
let dataRootLocation = '';
|
|
@@ -47,7 +39,6 @@ baseConfigRoot = { uri: '', locationType: 'UriLocation' }) {
|
|
|
47
39
|
for (const conf of ['jbrowse.conf', 'jbrowse_conf.json']) {
|
|
48
40
|
let fetchedConfig = null;
|
|
49
41
|
try {
|
|
50
|
-
// @ts-expect-error
|
|
51
42
|
fetchedConfig = await fetchConfigFile({
|
|
52
43
|
[baseProtocol]: `${baseConfigLocation}/${conf}`,
|
|
53
44
|
});
|
|
@@ -69,7 +60,7 @@ baseConfigRoot = { uri: '', locationType: 'UriLocation' }) {
|
|
|
69
60
|
return createFinalConfig(newConfig);
|
|
70
61
|
}
|
|
71
62
|
export async function createFinalConfig(baseConfig, defaults = configDefaults) {
|
|
72
|
-
const configWithDefaults = deepUpdate(
|
|
63
|
+
const configWithDefaults = deepUpdate(structuredClone(defaults), baseConfig);
|
|
73
64
|
let finalConfig = await loadIncludes(configWithDefaults);
|
|
74
65
|
finalConfig = mergeConfigs(finalConfig, baseConfig) || finalConfig;
|
|
75
66
|
fillTemplates(finalConfig, finalConfig);
|
|
@@ -92,9 +83,6 @@ export function parseJb1(config, url = '') {
|
|
|
92
83
|
}
|
|
93
84
|
return parseJB1Conf(config, url);
|
|
94
85
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Merges config object b into a. Properties in b override those in a.
|
|
97
|
-
*/
|
|
98
86
|
function mergeConfigs(a, b) {
|
|
99
87
|
if (b === null) {
|
|
100
88
|
return null;
|
|
@@ -115,11 +103,8 @@ function mergeConfigs(a, b) {
|
|
|
115
103
|
}
|
|
116
104
|
else if (!noRecursiveMerge(prop) &&
|
|
117
105
|
prop in a &&
|
|
118
|
-
// @ts-expect-error
|
|
119
106
|
typeof b[prop] === 'object' &&
|
|
120
|
-
// @ts-expect-error
|
|
121
107
|
typeof a[prop] === 'object') {
|
|
122
|
-
// @ts-expect-error
|
|
123
108
|
a[prop] = deepUpdate(a[prop], b[prop]);
|
|
124
109
|
}
|
|
125
110
|
else if (prop === 'dataRoot') {
|
|
@@ -127,23 +112,17 @@ function mergeConfigs(a, b) {
|
|
|
127
112
|
(a[prop] === 'data' && b[prop] !== undefined)) {
|
|
128
113
|
a[prop] = b[prop];
|
|
129
114
|
}
|
|
130
|
-
// @ts-expect-error
|
|
131
115
|
}
|
|
132
116
|
else if (a[prop] === undefined || b[prop] !== undefined) {
|
|
133
|
-
// @ts-expect-error
|
|
134
117
|
a[prop] = b[prop];
|
|
135
118
|
}
|
|
136
119
|
}
|
|
137
120
|
return a;
|
|
138
121
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Special-case merging of two `tracks` configuration arrays.
|
|
141
|
-
*/
|
|
142
122
|
function mergeTrackConfigs(a, b) {
|
|
143
123
|
if (!b.length) {
|
|
144
124
|
return a;
|
|
145
125
|
}
|
|
146
|
-
// index the tracks in `a` by track label
|
|
147
126
|
const aTracks = {};
|
|
148
127
|
a.forEach((t, i) => {
|
|
149
128
|
t.index = i;
|
|
@@ -160,19 +139,14 @@ function mergeTrackConfigs(a, b) {
|
|
|
160
139
|
});
|
|
161
140
|
return a;
|
|
162
141
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Recursively fetch, parse, and merge all the includes in the given config
|
|
165
|
-
* object. Calls the callback with the resulting configuration when finished.
|
|
166
|
-
* @param inputConfig - Config to load includes into
|
|
167
|
-
*/
|
|
168
142
|
async function loadIncludes(inputConfig) {
|
|
169
|
-
inputConfig =
|
|
143
|
+
inputConfig = structuredClone(inputConfig);
|
|
170
144
|
async function loadRecur(config, upstreamConf) {
|
|
171
145
|
const sourceUrl = config.sourceUrl || config.baseUrl;
|
|
172
146
|
if (!sourceUrl) {
|
|
173
147
|
throw new Error(`Could not determine source URL: ${JSON.stringify(config)}`);
|
|
174
148
|
}
|
|
175
|
-
const newUpstreamConf = mergeConfigs(
|
|
149
|
+
const newUpstreamConf = mergeConfigs(structuredClone(upstreamConf), config);
|
|
176
150
|
if (!newUpstreamConf) {
|
|
177
151
|
throw new Error('Problem merging configs');
|
|
178
152
|
}
|
|
@@ -198,16 +172,13 @@ function regularizeIncludes(includes) {
|
|
|
198
172
|
if (!includes) {
|
|
199
173
|
return [];
|
|
200
174
|
}
|
|
201
|
-
// coerce include to an array
|
|
202
175
|
if (!Array.isArray(includes)) {
|
|
203
176
|
includes = [includes];
|
|
204
177
|
}
|
|
205
178
|
return includes.map((include) => {
|
|
206
|
-
// coerce bare strings in the includes to URLs
|
|
207
179
|
if (typeof include === 'string') {
|
|
208
180
|
include = { url: include };
|
|
209
181
|
}
|
|
210
|
-
// set defaults for format and version
|
|
211
182
|
if (!('format' in include)) {
|
|
212
183
|
include.format = include.url.endsWith('.conf') ? 'conf' : 'JB_json';
|
|
213
184
|
}
|
|
@@ -233,15 +204,10 @@ function fillTemplates(subconfig, config) {
|
|
|
233
204
|
}
|
|
234
205
|
}
|
|
235
206
|
else if (typeof subconfig === 'string') {
|
|
236
|
-
// @ts-expect-error
|
|
237
207
|
return fillTemplate(subconfig, config);
|
|
238
208
|
}
|
|
239
209
|
return subconfig;
|
|
240
210
|
}
|
|
241
|
-
/**
|
|
242
|
-
* list of config properties that should not be recursively merged
|
|
243
|
-
* @param propName - name of config property
|
|
244
|
-
*/
|
|
245
211
|
function noRecursiveMerge(propName) {
|
|
246
212
|
return propName === 'datasets';
|
|
247
213
|
}
|
|
@@ -271,11 +237,6 @@ const configDefaults = {
|
|
|
271
237
|
highlightSearchedRegions: false,
|
|
272
238
|
highResolutionMode: 'auto',
|
|
273
239
|
};
|
|
274
|
-
/**
|
|
275
|
-
* Examine the loaded and merged configuration for errors. Throws
|
|
276
|
-
* exceptions if it finds anything amiss.
|
|
277
|
-
* @returns nothing meaningful
|
|
278
|
-
*/
|
|
279
240
|
function validateConfig(config) {
|
|
280
241
|
if (!config.tracks) {
|
|
281
242
|
config.tracks = [];
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import { Config } from './types';
|
|
1
|
+
import type { Config } from './types';
|
|
2
2
|
export declare function parseJB1Json(config: Config | string, url: string): Config;
|
|
3
3
|
export declare function parseJB1Conf(config: string, url: string): Config;
|
|
4
|
-
/**
|
|
5
|
-
* Applies defaults and any other necessary tweaks to the loaded configuration.
|
|
6
|
-
* @param conf - the object containing the configuration, which it modifies
|
|
7
|
-
* in-place
|
|
8
|
-
* @param url - URL of the config file
|
|
9
|
-
* @returns the same object it was passed
|
|
10
|
-
*/
|
|
11
4
|
export declare function regularizeConf(conf: Config, url: string): Config;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { objectHash } from '@jbrowse/core/util';
|
|
2
2
|
import getValue from 'get-value';
|
|
3
3
|
import setValue from 'set-value';
|
|
4
|
-
import { objectHash } from '@jbrowse/core/util';
|
|
5
4
|
import { isSource, isTrack } from './util';
|
|
6
5
|
export function parseJB1Json(config, url) {
|
|
7
6
|
if (typeof config === 'string') {
|
|
@@ -43,12 +42,10 @@ function parse(text, url) {
|
|
|
43
42
|
if (value !== undefined) {
|
|
44
43
|
let parsedValue;
|
|
45
44
|
try {
|
|
46
|
-
// parse json
|
|
47
45
|
const match = /^json:(.+)/i.exec(value);
|
|
48
46
|
if (match) {
|
|
49
47
|
parsedValue = JSON.parse(match[1]);
|
|
50
48
|
}
|
|
51
|
-
// parse numbers if it looks numeric
|
|
52
49
|
else if (/^[+-]?[\d.,]+([eE][-+]?\d+)?$/.test(value)) {
|
|
53
50
|
parsedValue = Number.parseFloat(value.replaceAll(',', ''));
|
|
54
51
|
}
|
|
@@ -88,10 +85,8 @@ function parse(text, url) {
|
|
|
88
85
|
text.split(/\n|\r\n|\r/).forEach((textLine, i) => {
|
|
89
86
|
lineNumber = i + 1;
|
|
90
87
|
const line = textLine.replace(/^\s*#.+/, '');
|
|
91
|
-
// new section
|
|
92
88
|
let match;
|
|
93
89
|
if ((match = /^\s*\[([^\]]+)/.exec(line))) {
|
|
94
|
-
// new section
|
|
95
90
|
recordVal();
|
|
96
91
|
keyPath = undefined;
|
|
97
92
|
value = undefined;
|
|
@@ -100,7 +95,6 @@ function parse(text, url) {
|
|
|
100
95
|
section = [];
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
|
-
// new value
|
|
104
98
|
else if ((match = line.match(value === undefined ? /^([^+=]+)(\+?=)(.*)/ : /^(\S[^+=]+)(\+?=)(.*)/))) {
|
|
105
99
|
recordVal();
|
|
106
100
|
keyPath = match[1].trim().split(/\s*\.\s*/);
|
|
@@ -110,19 +104,16 @@ function parse(text, url) {
|
|
|
110
104
|
}
|
|
111
105
|
value = match[3].trim();
|
|
112
106
|
}
|
|
113
|
-
// add to existing array value
|
|
114
107
|
else if (keyPath !== undefined &&
|
|
115
108
|
(match = /^\s{0,4}\+\s*(.+)/.exec(line))) {
|
|
116
109
|
recordVal();
|
|
117
110
|
operation = '+=';
|
|
118
111
|
value = match[1].trim();
|
|
119
112
|
}
|
|
120
|
-
// add to existing value
|
|
121
113
|
else if (value !== undefined && (match = /^\s+(\S.*)/.exec(line))) {
|
|
122
114
|
const m = match[1];
|
|
123
115
|
value += value.length ? ` ${m.trim()}` : m.trim();
|
|
124
116
|
}
|
|
125
|
-
// done with last value
|
|
126
117
|
else {
|
|
127
118
|
recordVal();
|
|
128
119
|
keyPath = undefined;
|
|
@@ -132,21 +123,11 @@ function parse(text, url) {
|
|
|
132
123
|
recordVal();
|
|
133
124
|
return data;
|
|
134
125
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Applies defaults and any other necessary tweaks to the loaded configuration.
|
|
137
|
-
* @param conf - the object containing the configuration, which it modifies
|
|
138
|
-
* in-place
|
|
139
|
-
* @param url - URL of the config file
|
|
140
|
-
* @returns the same object it was passed
|
|
141
|
-
*/
|
|
142
126
|
export function regularizeConf(conf, url) {
|
|
143
|
-
// if tracks is not an array, convert it to one
|
|
144
127
|
if (conf.tracks && !Array.isArray(conf.tracks)) {
|
|
145
|
-
// if it's a single track config, wrap it in an arrayref
|
|
146
128
|
if (isTrack(conf.tracks)) {
|
|
147
129
|
conf.tracks = [conf.tracks];
|
|
148
130
|
}
|
|
149
|
-
// otherwise, coerce it to an array
|
|
150
131
|
else {
|
|
151
132
|
const tracks = [];
|
|
152
133
|
for (const label of Object.keys(conf.tracks)) {
|
|
@@ -161,10 +142,8 @@ export function regularizeConf(conf, url) {
|
|
|
161
142
|
conf.tracks = tracks;
|
|
162
143
|
}
|
|
163
144
|
}
|
|
164
|
-
// regularize trackMetadata.sources
|
|
165
145
|
const meta = conf.trackMetadata;
|
|
166
146
|
if (meta === null || meta === void 0 ? void 0 : meta.sources) {
|
|
167
|
-
// if it's a single source config, wrap it in an arrayref
|
|
168
147
|
if (typeof meta.sources === 'string') {
|
|
169
148
|
meta.sources = [meta.sources];
|
|
170
149
|
}
|
|
@@ -182,7 +161,6 @@ export function regularizeConf(conf, url) {
|
|
|
182
161
|
}
|
|
183
162
|
meta.sources = sources;
|
|
184
163
|
}
|
|
185
|
-
// coerce any string source defs to be URLs, and try to detect their types
|
|
186
164
|
meta.sources = meta.sources.map((sourceDef) => {
|
|
187
165
|
if (typeof sourceDef === 'string') {
|
|
188
166
|
const newSourceDef = { url: sourceDef };
|
|
@@ -204,8 +182,6 @@ export function regularizeConf(conf, url) {
|
|
|
204
182
|
conf.baseUrl += '/';
|
|
205
183
|
}
|
|
206
184
|
if (conf.sourceUrl) {
|
|
207
|
-
// set a default baseUrl in each of the track and store confs, and the names
|
|
208
|
-
// conf, if needed
|
|
209
185
|
const addBase = [];
|
|
210
186
|
if (conf.tracks) {
|
|
211
187
|
addBase.push(...conf.tracks);
|
|
@@ -221,7 +197,6 @@ export function regularizeConf(conf, url) {
|
|
|
221
197
|
t.baseUrl = conf.baseUrl || '/';
|
|
222
198
|
}
|
|
223
199
|
});
|
|
224
|
-
// resolve the refSeqs and nameUrl if present
|
|
225
200
|
if (conf.refSeqs && typeof conf.refSeqs === 'string') {
|
|
226
201
|
conf.refSeqs = new URL(conf.refSeqs, conf.sourceUrl).href;
|
|
227
202
|
}
|
|
@@ -231,14 +206,11 @@ export function regularizeConf(conf, url) {
|
|
|
231
206
|
}
|
|
232
207
|
conf.stores = conf.stores || {};
|
|
233
208
|
(conf.tracks || []).forEach((trackConfig) => {
|
|
234
|
-
// if there is a `config` subpart, just copy its keys in to the top-level
|
|
235
|
-
// config
|
|
236
209
|
if (trackConfig.config) {
|
|
237
210
|
const c = trackConfig.config;
|
|
238
211
|
trackConfig.config = undefined;
|
|
239
212
|
trackConfig = { ...c, ...trackConfig };
|
|
240
213
|
}
|
|
241
|
-
// skip if it's a new-style track def
|
|
242
214
|
if (trackConfig.store) {
|
|
243
215
|
return;
|
|
244
216
|
}
|
|
@@ -269,11 +241,6 @@ export function regularizeConf(conf, url) {
|
|
|
269
241
|
});
|
|
270
242
|
return conf;
|
|
271
243
|
}
|
|
272
|
-
/**
|
|
273
|
-
* prefix class name with `root` if it contains no slashes
|
|
274
|
-
* @param root - Prefix root
|
|
275
|
-
* @param className - class name
|
|
276
|
-
*/
|
|
277
244
|
function regularizeClass(root, className) {
|
|
278
245
|
if (!className) {
|
|
279
246
|
return '';
|
|
@@ -338,8 +305,6 @@ function guessStoreClass(trackConfig, urlTemplate) {
|
|
|
338
305
|
}
|
|
339
306
|
function synthesizeTrackStoreConfig(mainConf, trackConfig) {
|
|
340
307
|
var _a;
|
|
341
|
-
// figure out what data store class to use with the track, applying some
|
|
342
|
-
// defaults if it is not explicit in the configuration
|
|
343
308
|
const { urlTemplate = '' } = trackConfig;
|
|
344
309
|
const storeClass = trackConfig.storeClass
|
|
345
310
|
? regularizeClass('JBrowse/Store', trackConfig.storeClass)
|
|
@@ -348,10 +313,7 @@ function synthesizeTrackStoreConfig(mainConf, trackConfig) {
|
|
|
348
313
|
console.warn(`Unable to determine an appropriate data store to use with track '${trackConfig.label}', please explicitly specify a storeClass in the configuration.`);
|
|
349
314
|
return;
|
|
350
315
|
}
|
|
351
|
-
// synthesize a separate store conf
|
|
352
316
|
const storeConf = { ...trackConfig, type: storeClass };
|
|
353
|
-
// if this is the first sequence store we see, and we have no refseqs store
|
|
354
|
-
// defined explicitly, make this the refseqs store.
|
|
355
317
|
storeConf.name =
|
|
356
318
|
(storeClass === 'JBrowse/Store/Sequence/StaticChunked' ||
|
|
357
319
|
storeClass === 'JBrowse/Store/Sequence/IndexedFasta' ||
|
|
@@ -363,11 +325,9 @@ function synthesizeTrackStoreConfig(mainConf, trackConfig) {
|
|
|
363
325
|
!((_a = mainConf.stores) === null || _a === void 0 ? void 0 : _a.refseqs)
|
|
364
326
|
? 'refseqs'
|
|
365
327
|
: `store${objectHash(storeConf)}`;
|
|
366
|
-
// record it
|
|
367
328
|
if (!mainConf.stores) {
|
|
368
329
|
mainConf.stores = {};
|
|
369
330
|
}
|
|
370
331
|
mainConf.stores[storeConf.name] = storeConf;
|
|
371
|
-
// connect it to the track conf
|
|
372
332
|
trackConfig.store = storeConf.name;
|
|
373
333
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { openLocation } from '@jbrowse/core/util/io';
|
|
2
1
|
import { objectHash } from '@jbrowse/core/util';
|
|
3
|
-
import {
|
|
2
|
+
import { openLocation } from '@jbrowse/core/util/io';
|
|
3
|
+
import { UNKNOWN, UNSUPPORTED, generateUnknownTrackConf, generateUnsupportedTrackConf, guessAdapter, guessTrackType, } from '@jbrowse/core/util/tracks';
|
|
4
4
|
export function convertTrackConfig(jb1TrackConfig, dataRoot, sequenceAdapter) {
|
|
5
5
|
var _a, _b, _c, _d, _e;
|
|
6
6
|
const jb2TrackConfig = {
|
|
@@ -313,8 +313,6 @@ export function convertTrackConfig(jb1TrackConfig, dataRoot, sequenceAdapter) {
|
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
// If we don't recognize the store class, make a best effort to guess by file
|
|
317
|
-
// type
|
|
318
316
|
jb2TrackConfig.adapter = guessAdapter({ uri: urlTemplate, locationType: 'UriLocation' }, undefined, urlTemplate);
|
|
319
317
|
if (jb2TrackConfig.adapter.type === UNSUPPORTED) {
|
|
320
318
|
return generateUnsupportedTrackConf(jb2TrackConfig.name, urlTemplate, jb2TrackConfig.category);
|
|
@@ -350,12 +348,10 @@ function generateFromConfigTrackConfig(jb1TrackConfig, jb2TrackConfig) {
|
|
|
350
348
|
}
|
|
351
349
|
export async function createRefSeqsAdapter(refSeqs) {
|
|
352
350
|
if (typeof refSeqs === 'string') {
|
|
353
|
-
// assume refSeqs is a url if it is string
|
|
354
351
|
refSeqs = {
|
|
355
352
|
url: refSeqs,
|
|
356
353
|
};
|
|
357
354
|
}
|
|
358
|
-
// check refseq urls
|
|
359
355
|
if (refSeqs.url) {
|
|
360
356
|
if (/.fai$/.exec(refSeqs.url)) {
|
|
361
357
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
2
|
export default function stateModelFactory(pluginManager: PluginManager): import("mobx-state-tree").IModelType<{
|
|
3
3
|
name: import("mobx-state-tree").ISimpleType<string>;
|
|
4
4
|
tracks: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyModelType>;
|
|
@@ -46,7 +46,7 @@ export default function stateModelFactory(pluginManager: PluginManager): import(
|
|
|
46
46
|
connect(_arg: import("@jbrowse/core/configuration").AnyConfigurationModel): void;
|
|
47
47
|
} & {
|
|
48
48
|
afterAttach(): void;
|
|
49
|
-
addTrackConf(trackConf: ({
|
|
49
|
+
addTrackConf(trackConf: Record<string, unknown> | ({
|
|
50
50
|
[x: string]: any;
|
|
51
51
|
} & import("mobx-state-tree/dist/internal").NonEmptyObject & {
|
|
52
52
|
setSubschema(slotName: string, data: Record<string, unknown>): Record<string, unknown> | ({
|
|
@@ -56,8 +56,8 @@ export default function stateModelFactory(pluginManager: PluginManager): import(
|
|
|
56
56
|
[x: string]: any;
|
|
57
57
|
} & import("mobx-state-tree/dist/internal").NonEmptyObject & any & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>);
|
|
58
58
|
} & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>);
|
|
59
|
-
} & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>)
|
|
60
|
-
addTrackConfs(trackConfs: (({
|
|
59
|
+
} & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>)): any;
|
|
60
|
+
addTrackConfs(trackConfs: (Record<string, unknown> | ({
|
|
61
61
|
[x: string]: any;
|
|
62
62
|
} & import("mobx-state-tree/dist/internal").NonEmptyObject & {
|
|
63
63
|
setSubschema(slotName: string, data: Record<string, unknown>): Record<string, unknown> | ({
|
|
@@ -67,7 +67,7 @@ export default function stateModelFactory(pluginManager: PluginManager): import(
|
|
|
67
67
|
[x: string]: any;
|
|
68
68
|
} & import("mobx-state-tree/dist/internal").NonEmptyObject & any & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>);
|
|
69
69
|
} & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>);
|
|
70
|
-
} & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>)
|
|
70
|
+
} & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>))[]): void;
|
|
71
71
|
setTrackConfs(trackConfs: import("@jbrowse/core/configuration").AnyConfigurationModel[]): void;
|
|
72
72
|
clear(): void;
|
|
73
73
|
} & {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ConfigurationReference, getConf, readConfObject, } from '@jbrowse/core/configuration';
|
|
2
|
-
import { getSession } from '@jbrowse/core/util';
|
|
3
2
|
import { BaseConnectionModelFactory } from '@jbrowse/core/pluggableElementTypes/models';
|
|
3
|
+
import { getSession } from '@jbrowse/core/util';
|
|
4
4
|
import { types } from 'mobx-state-tree';
|
|
5
|
-
// locals
|
|
6
5
|
import configSchema from './configSchema';
|
|
7
6
|
export default function stateModelFactory(pluginManager) {
|
|
8
7
|
return types
|
|
@@ -28,7 +27,6 @@ export default function stateModelFactory(pluginManager) {
|
|
|
28
27
|
throw new Error(`Assembly "${assemblyName}" not found`);
|
|
29
28
|
}
|
|
30
29
|
const sequenceAdapter = readConfObject(conf, ['sequence', 'adapter']);
|
|
31
|
-
// @ts-expect-error
|
|
32
30
|
const jb2Tracks = (_a = config.tracks) === null || _a === void 0 ? void 0 : _a.map(jb1Track => ({
|
|
33
31
|
...convertTrackConfig(jb1Track, config.dataRoot || '', sequenceAdapter),
|
|
34
32
|
assemblyNames: [assemblyName],
|
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Source, Track } from './types';
|
|
2
2
|
export declare function isTrack(arg: any): arg is Track;
|
|
3
3
|
export declare function isSource(arg: any): arg is Source;
|
|
4
|
-
/**
|
|
5
|
-
* updates a with values from b, recursively
|
|
6
|
-
*/
|
|
7
4
|
type Obj = Record<string, any>;
|
|
8
5
|
export declare function deepUpdate(a: Obj, b: Obj): Obj;
|
|
9
|
-
/**
|
|
10
|
-
* replace variables in a template string with values
|
|
11
|
-
*
|
|
12
|
-
* @param template - String with variable names in curly brackets
|
|
13
|
-
* e.g., `http://foo/{bar}?arg={baz.foo}`
|
|
14
|
-
* @param fillWith - object with attribute-value mappings
|
|
15
|
-
* e.g., `{ 'bar': 'someurl', 'baz': { 'foo': 42 } }`
|
|
16
|
-
* @returns the template string with variables in fillWith replaced
|
|
17
|
-
* e.g., 'htp://foo/someurl?arg=valueforbaz'
|
|
18
|
-
*/
|
|
19
6
|
export declare function fillTemplate(template: string, fillWith: Obj): string;
|
|
20
|
-
|
|
21
|
-
* Clones objects (including DOM nodes) and all children.
|
|
22
|
-
* Warning: do not clone cyclic structures
|
|
23
|
-
* (Lifted from dojo https://github.com/dojo/dojo/blob/master/_base/lang.js)
|
|
24
|
-
* @param src - The object to clone
|
|
25
|
-
*/
|
|
26
|
-
export declare function clone(src: any): any;
|
|
7
|
+
export declare function structuredClone(src: any): any;
|
|
27
8
|
export {};
|