@jbrowse/plugin-legacy-jbrowse 4.3.0 → 5.0.0-beta.10

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 (36) hide show
  1. package/esm/JBrowse1Connection/configSchema.d.ts +58 -18
  2. package/esm/JBrowse1Connection/configSchema.js +29 -3
  3. package/esm/JBrowse1Connection/get-value.d.ts +1 -10
  4. package/esm/JBrowse1Connection/get-value.js +9 -82
  5. package/esm/JBrowse1Connection/index.js +2 -2
  6. package/esm/JBrowse1Connection/jb1ConfigLoad.d.ts +9 -36
  7. package/esm/JBrowse1Connection/jb1ConfigLoad.js +72 -241
  8. package/esm/JBrowse1Connection/jb1ConfigParse.d.ts +6 -3
  9. package/esm/JBrowse1Connection/jb1ConfigParse.js +25 -250
  10. package/esm/JBrowse1Connection/jb1ToJb2.d.ts +8 -3
  11. package/esm/JBrowse1Connection/jb1ToJb2.js +124 -368
  12. package/esm/JBrowse1Connection/model.d.ts +79 -49
  13. package/esm/JBrowse1Connection/model.js +23 -9
  14. package/esm/JBrowse1Connection/set-value.d.ts +1 -0
  15. package/esm/JBrowse1Connection/set-value.js +14 -0
  16. package/esm/JBrowse1Connection/types.d.ts +4 -57
  17. package/esm/JBrowse1Connection/util.d.ts +13 -8
  18. package/esm/JBrowse1Connection/util.js +15 -80
  19. package/esm/JBrowse1TextSearchAdapter/HttpMap.d.ts +36 -8
  20. package/esm/JBrowse1TextSearchAdapter/HttpMap.js +61 -27
  21. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +5 -6
  22. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +21 -23
  23. package/esm/JBrowse1TextSearchAdapter/configSchema.d.ts +36 -16
  24. package/esm/JBrowse1TextSearchAdapter/configSchema.js +28 -5
  25. package/esm/JBrowse1TextSearchAdapter/index.js +2 -2
  26. package/esm/NCListAdapter/NCListAdapter.d.ts +11 -1
  27. package/esm/NCListAdapter/NCListAdapter.js +16 -7
  28. package/esm/NCListAdapter/NCListFeature.d.ts +34 -3
  29. package/esm/NCListAdapter/NCListFeature.js +22 -8
  30. package/esm/NCListAdapter/configSchema.d.ts +31 -11
  31. package/esm/NCListAdapter/configSchema.js +26 -1
  32. package/esm/NCListAdapter/index.js +2 -2
  33. package/esm/index.js +3 -5
  34. package/package.json +9 -12
  35. package/esm/GuessNCList/index.d.ts +0 -2
  36. package/esm/GuessNCList/index.js +0 -15
@@ -1,22 +1,45 @@
1
1
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
- function x() { }
2
+ /**
3
+ * #config JBrowse1TextSearchAdapter
4
+ * #trackType TextSearchAdapter
5
+ * #fileFormat textsearch | JBrowse 1 names index | From JBrowse 1 `generate-names.pl`
6
+ * note: metadata about tracks and assemblies covered by text search adapter
7
+ *
8
+ * #example
9
+ * An entry in `aggregateTextSearchAdapters`, pointing at the `names/`
10
+ * directory JBrowse 1's `generate-names.pl` wrote — so an existing instance's
11
+ * search index is reused rather than rebuilt with `jbrowse text-index`:
12
+ * ```js
13
+ * {
14
+ * type: 'JBrowse1TextSearchAdapter',
15
+ * namesIndexLocation: { uri: 'https://example.com/jbrowse1/data/names/' },
16
+ * assemblyNames: ['hg19'],
17
+ * }
18
+ * ```
19
+ */
3
20
  export default ConfigurationSchema('JBrowse1TextSearchAdapter', {
21
+ /**
22
+ * #slot
23
+ */
4
24
  namesIndexLocation: {
5
25
  type: 'fileLocation',
6
26
  defaultValue: { uri: '/volvox/names', locationType: 'UriLocation' },
7
27
  description: 'the location of the JBrowse1 names index data directory',
8
28
  },
29
+ /**
30
+ * #slot
31
+ */
9
32
  tracks: {
10
33
  type: 'stringArray',
11
34
  defaultValue: [],
12
35
  description: 'List of tracks covered by text search adapter',
13
36
  },
37
+ /**
38
+ * #slot
39
+ */
14
40
  assemblyNames: {
15
41
  type: 'stringArray',
16
42
  defaultValue: [],
17
43
  description: 'List of assemblies covered by text search adapter',
18
44
  },
19
- }, {
20
- explicitlyTyped: true,
21
- explicitIdentifier: 'textSearchAdapterId',
22
- });
45
+ }, { explicitlyTyped: true });
@@ -1,10 +1,10 @@
1
1
  import TextSearchAdapterType from '@jbrowse/core/pluggableElementTypes/TextSearchAdapterType';
2
- import configSchema from "./configSchema.js";
2
+ import configSchema from './configSchema.js';
3
3
  export default function JBrowse1TextSearchAdapterF(pluginManager) {
4
4
  pluginManager.addTextSearchAdapterType(() => new TextSearchAdapterType({
5
5
  name: 'JBrowse1TextSearchAdapter',
6
6
  configSchema,
7
7
  description: 'A JBrowse 1 text search adapter',
8
- getAdapterClass: () => import("./JBrowse1TextSearchAdapter.js").then(t => t.default),
8
+ getAdapterClass: () => import('./JBrowse1TextSearchAdapter.js').then(t => t.default),
9
9
  }));
10
10
  }
@@ -1,5 +1,6 @@
1
1
  import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
2
2
  import NCListFeature from './NCListFeature.ts';
3
+ import type { NCListRawFeature } from './NCListFeature.ts';
3
4
  import type PluginManager from '@jbrowse/core/PluginManager';
4
5
  import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
5
6
  import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
@@ -10,8 +11,17 @@ export default class NCListAdapter extends BaseFeatureDataAdapter {
10
11
  private nclist;
11
12
  private configRefNames?;
12
13
  constructor(config: AnyConfigurationModel, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
14
+ /**
15
+ * Fetch features for a certain region.
16
+ * @param region -
17
+ * @param opts - [signal] optional signalling object for aborting the fetch
18
+ * @returns Observable of Feature objects in the region
19
+ */
13
20
  getFeatures(region: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
14
- wrapFeature(ncFeature: any): NCListFeature;
21
+ wrapFeature(ncFeature: NCListRawFeature): NCListFeature;
15
22
  hasDataForRefName(refName: string): Promise<boolean>;
23
+ /**
24
+ * NCList is unable to get list of ref names so returns empty
25
+ */
16
26
  getRefNames(): Promise<string[]>;
17
27
  }
@@ -1,9 +1,9 @@
1
1
  import NCListStore from '@gmod/nclist';
2
2
  import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import { checkAbortSignal } from '@jbrowse/core/util/aborting';
3
4
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
4
- import { checkStopToken } from '@jbrowse/core/util/stopToken';
5
5
  import { RemoteFile } from 'generic-filehandle2';
6
- import NCListFeature from "./NCListFeature.js";
6
+ import NCListFeature from './NCListFeature.js';
7
7
  export default class NCListAdapter extends BaseFeatureDataAdapter {
8
8
  nclist;
9
9
  configRefNames;
@@ -20,15 +20,21 @@ export default class NCListAdapter extends BaseFeatureDataAdapter {
20
20
  : url).readFile(),
21
21
  });
22
22
  }
23
+ /**
24
+ * Fetch features for a certain region.
25
+ * @param region -
26
+ * @param opts - [signal] optional signalling object for aborting the fetch
27
+ * @returns Observable of Feature objects in the region
28
+ */
23
29
  getFeatures(region, opts = {}) {
24
30
  return ObservableCreate(async (observer) => {
25
- const { stopToken } = opts;
26
- for await (const feature of this.nclist.getFeatures(region, opts)) {
27
- checkStopToken(stopToken);
31
+ const { signal } = opts;
32
+ for await (const feature of this.nclist.getFeatures(region)) {
33
+ checkAbortSignal(signal);
28
34
  observer.next(this.wrapFeature(feature));
29
35
  }
30
36
  observer.complete();
31
- });
37
+ }, opts.signal);
32
38
  }
33
39
  wrapFeature(ncFeature) {
34
40
  return new NCListFeature(ncFeature, undefined, `${this.id}-${ncFeature.id()}`);
@@ -37,7 +43,10 @@ export default class NCListAdapter extends BaseFeatureDataAdapter {
37
43
  const root = await this.nclist.getDataRoot(refName);
38
44
  return !!root?.stats?.featureCount;
39
45
  }
46
+ /**
47
+ * NCList is unable to get list of ref names so returns empty
48
+ */
40
49
  async getRefNames() {
41
- return this.configRefNames || [];
50
+ return this.configRefNames ?? [];
42
51
  }
43
52
  }
@@ -1,16 +1,47 @@
1
1
  import type { Feature, SimpleFeatureSerialized } from '@jbrowse/core/util/simpleFeature';
2
+ /**
3
+ * the duck-typed shape of a raw @gmod/nclist feature (which the library types
4
+ * only as `any`)
5
+ */
6
+ export interface NCListRawFeature {
7
+ id(): string;
8
+ get(attr: string): unknown;
9
+ tags(): string[];
10
+ }
11
+ /**
12
+ * wrapper to adapt nclist features to act like jbrowse 2 features
13
+ */
2
14
  export default class NCListFeature implements Feature {
3
- private ncFeature;
4
15
  private parentHandle?;
5
16
  private uniqueId;
6
- constructor(ncFeature: any, parent?: Feature, id?: string);
17
+ private ncFeature;
18
+ constructor(ncFeature: NCListRawFeature, parent?: Feature, id?: string);
7
19
  set(): void;
8
20
  jb2TagToJb1Tag(tag: string): string;
9
21
  jb1TagToJb2Tag(tag: string): string;
10
- get(attrName: string): any;
22
+ get(name: 'refName'): string;
23
+ get(name: 'name' | 'type' | 'id' | 'source'): string | undefined;
24
+ get(name: 'start' | 'end'): number;
25
+ get(name: 'phase'): 0 | 1 | 2 | undefined;
26
+ get(name: 'strand'): -1 | 0 | 1 | undefined;
27
+ get(name: 'score'): number | undefined;
28
+ get(name: 'subfeatures'): Feature[] | undefined;
29
+ get(name: string): unknown;
30
+ /**
31
+ * Get an array listing which data keys are present in this feature.
32
+ */
11
33
  tags(): string[];
34
+ /**
35
+ * Get the unique ID of this feature.
36
+ */
12
37
  id(): string;
38
+ /**
39
+ * Get this feature's parent feature, or undefined if none.
40
+ */
13
41
  parent(): Feature | undefined;
42
+ /**
43
+ * Get an array of child features, or undefined if none.
44
+ */
14
45
  children(): Feature[] | undefined;
15
46
  toJSON(): SimpleFeatureSerialized;
16
47
  }
@@ -1,9 +1,12 @@
1
1
  const jb2ToJb1 = { refName: 'seq_id' };
2
2
  const jb1ToJb2 = { seq_id: 'refName' };
3
+ /**
4
+ * wrapper to adapt nclist features to act like jbrowse 2 features
5
+ */
3
6
  export default class NCListFeature {
4
- ncFeature;
5
7
  parentHandle;
6
8
  uniqueId;
9
+ ncFeature;
7
10
  constructor(ncFeature, parent, id) {
8
11
  this.ncFeature = ncFeature;
9
12
  this.uniqueId = id || ncFeature.id();
@@ -13,29 +16,40 @@ export default class NCListFeature {
13
16
  throw new Error('not implemented');
14
17
  }
15
18
  jb2TagToJb1Tag(tag) {
16
- const mapped = jb2ToJb1[tag] || tag;
17
- return mapped.toLowerCase();
19
+ return (jb2ToJb1[tag] ?? tag).toLowerCase();
18
20
  }
19
21
  jb1TagToJb2Tag(tag) {
20
22
  const t = tag.toLowerCase();
21
- return jb1ToJb2[t] || t;
23
+ return jb1ToJb2[t] ?? t;
22
24
  }
23
25
  get(attrName) {
24
26
  const attr = this.ncFeature.get(this.jb2TagToJb1Tag(attrName));
25
27
  if (attr && attrName === 'subfeatures') {
26
- return attr.map((subfeature) => new NCListFeature(subfeature, this));
28
+ return attr.map(subfeature => new NCListFeature(subfeature, this));
27
29
  }
28
30
  return attr;
29
31
  }
32
+ /**
33
+ * Get an array listing which data keys are present in this feature.
34
+ */
30
35
  tags() {
31
36
  return this.ncFeature.tags().map((t) => this.jb1TagToJb2Tag(t));
32
37
  }
38
+ /**
39
+ * Get the unique ID of this feature.
40
+ */
33
41
  id() {
34
42
  return this.uniqueId;
35
43
  }
44
+ /**
45
+ * Get this feature's parent feature, or undefined if none.
46
+ */
36
47
  parent() {
37
48
  return this.parentHandle;
38
49
  }
50
+ /**
51
+ * Get an array of child features, or undefined if none.
52
+ */
39
53
  children() {
40
54
  return this.get('subfeatures');
41
55
  }
@@ -45,9 +59,9 @@ export default class NCListFeature {
45
59
  const mappedTag = this.jb1TagToJb2Tag(tag);
46
60
  const value = this.ncFeature.get(tag);
47
61
  if (mappedTag === 'subfeatures') {
48
- data.subfeatures = (value || []).map((f) => {
49
- return new NCListFeature(f, this).toJSON();
50
- });
62
+ data.subfeatures = (value ?? []).map(
63
+ // note: was new NCListFeature(f, `${this.id()}-${i}`, this).toJSON()
64
+ f => new NCListFeature(f, this).toJSON());
51
65
  }
52
66
  else {
53
67
  data[mappedTag] = value;
@@ -1,15 +1,35 @@
1
+ /**
2
+ * #config NCListAdapter
3
+ * #trackType FeatureTrack
4
+ *
5
+ * #example
6
+ * Reads a JBrowse 1 NCList store in place, so an existing JBrowse 1 instance's
7
+ * data serves JBrowse 2 without re-processing. `{refseq}` in the URL template
8
+ * is substituted per sequence, which is how the store is laid out on disk:
9
+ * ```js
10
+ * {
11
+ * type: 'NCListAdapter',
12
+ * rootUrlTemplate: {
13
+ * uri: 'https://example.com/jbrowse1/data/tracks/genes/{refseq}/trackData.json',
14
+ * },
15
+ * }
16
+ * ```
17
+ */
1
18
  declare const NCListAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- rootUrlTemplate: {
3
- type: string;
4
- defaultValue: {
5
- uri: string;
6
- locationType: string;
7
- };
19
+ type: {
20
+ type: "string";
21
+ } & {
22
+ defaultValue: string;
8
23
  };
9
- refNames: {
10
- type: string;
11
- defaultValue: never[];
12
- description: string;
24
+ readonly rootUrlTemplate: {
25
+ type: "fileLocation";
26
+ } & {
27
+ defaultValue: unknown;
13
28
  };
14
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
29
+ readonly refNames: {
30
+ type: "stringArray";
31
+ } & {
32
+ defaultValue: unknown;
33
+ };
34
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined, true, import("@jbrowse/core/configuration").ConfigurationSchemaRequirement<Partial<Record<string, string[]>>, string>, any>>;
15
35
  export default NCListAdapter;
@@ -1,6 +1,28 @@
1
1
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
- function x() { }
2
+ /**
3
+ * #config NCListAdapter
4
+ * #trackType FeatureTrack
5
+ *
6
+ * #example
7
+ * Reads a JBrowse 1 NCList store in place, so an existing JBrowse 1 instance's
8
+ * data serves JBrowse 2 without re-processing. `{refseq}` in the URL template
9
+ * is substituted per sequence, which is how the store is laid out on disk:
10
+ * ```js
11
+ * {
12
+ * type: 'NCListAdapter',
13
+ * rootUrlTemplate: {
14
+ * uri: 'https://example.com/jbrowse1/data/tracks/genes/{refseq}/trackData.json',
15
+ * },
16
+ * }
17
+ * ```
18
+ */
3
19
  const NCListAdapter = ConfigurationSchema('NCListAdapter', {
20
+ /**
21
+ * #slot
22
+ * URL of a JBrowse 1 NCList `trackData.json`, with `{refseq}` standing in
23
+ * for the reference sequence name — the per-reference directory layout
24
+ * `flatfile-to-json.pl` and `biodb-to-json.pl` write.
25
+ */
4
26
  rootUrlTemplate: {
5
27
  type: 'fileLocation',
6
28
  defaultValue: {
@@ -8,6 +30,9 @@ const NCListAdapter = ConfigurationSchema('NCListAdapter', {
8
30
  locationType: 'UriLocation',
9
31
  },
10
32
  },
33
+ /**
34
+ * #slot
35
+ */
11
36
  refNames: {
12
37
  type: 'stringArray',
13
38
  defaultValue: [],
@@ -1,5 +1,5 @@
1
1
  import { AdapterType } from '@jbrowse/core/pluggableElementTypes';
2
- import configSchema from "./configSchema.js";
2
+ import configSchema from './configSchema.js';
3
3
  export default function NCListAdapterF(pluginManager) {
4
4
  pluginManager.addAdapterType(() => new AdapterType({
5
5
  name: 'NCListAdapter',
@@ -8,6 +8,6 @@ export default function NCListAdapterF(pluginManager) {
8
8
  adapterMetadata: {
9
9
  category: 'Uncommon',
10
10
  },
11
- getAdapterClass: () => import("./NCListAdapter.js").then(r => r.default),
11
+ getAdapterClass: () => import('./NCListAdapter.js').then(r => r.default),
12
12
  }));
13
13
  }
package/esm/index.js CHANGED
@@ -1,13 +1,11 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import GuessNCListF from "./GuessNCList/index.js";
3
- import JBrowse1ConnectionF from "./JBrowse1Connection/index.js";
4
- import JBrowse1TextSearchAdapterF from "./JBrowse1TextSearchAdapter/index.js";
5
- import NCListAdapterF from "./NCListAdapter/index.js";
2
+ import JBrowse1ConnectionF from './JBrowse1Connection/index.js';
3
+ import JBrowse1TextSearchAdapterF from './JBrowse1TextSearchAdapter/index.js';
4
+ import NCListAdapterF from './NCListAdapter/index.js';
6
5
  export default class LegacyJBrowsePlugin extends Plugin {
7
6
  name = 'LegacyJBrowsePlugin';
8
7
  install(pluginManager) {
9
8
  NCListAdapterF(pluginManager);
10
- GuessNCListF(pluginManager);
11
9
  JBrowse1TextSearchAdapterF(pluginManager);
12
10
  JBrowse1ConnectionF(pluginManager);
13
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-legacy-jbrowse",
3
- "version": "4.3.0",
3
+ "version": "5.0.0-beta.10",
4
4
  "type": "module",
5
5
  "description": "JBrowse 2 plugin for connecting to and reading JBrowse 1 data",
6
6
  "keywords": [
@@ -21,13 +21,13 @@
21
21
  "esm"
22
22
  ],
23
23
  "dependencies": {
24
- "@gmod/nclist": "^3.0.7",
25
- "@jbrowse/mobx-state-tree": "^5.6.0",
26
- "generic-filehandle2": "^2.1.7",
27
- "mobx": "^6.15.3",
24
+ "@gmod/nclist": "^3.0.14",
25
+ "@jbrowse/mobx-state-tree": "^6.6.1",
26
+ "generic-filehandle2": "^2.4.0",
27
+ "mobx": "^7.0.5",
28
28
  "rxjs": "^7.8.2",
29
- "set-value": "^4.1.0",
30
- "@jbrowse/core": "^4.3.0"
29
+ "@jbrowse/add-track-core": "^5.0.0-beta.10",
30
+ "@jbrowse/core": "^5.0.0-beta.10"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
@@ -37,14 +37,11 @@
37
37
  "build": "pnpm run /^build:/",
38
38
  "test": "cd ../..; jest --passWithNoTests plugins/legacy-jbrowse",
39
39
  "prebuild": "pnpm clean",
40
- "build:esm": "tsc -p tsconfig.build.esm.json",
40
+ "build:esm": "node ../../node_modules/typescript7/bin/tsc --build tsconfig.build.esm.json",
41
41
  "clean": "rimraf esm *.tsbuildinfo"
42
42
  },
43
43
  "types": "esm/index.d.ts",
44
44
  "exports": {
45
- ".": {
46
- "types": "./esm/index.d.ts",
47
- "import": "./esm/index.js"
48
- }
45
+ ".": "./esm/index.js"
49
46
  }
50
47
  }
@@ -1,2 +0,0 @@
1
- import type PluginManager from '@jbrowse/core/PluginManager';
2
- export default function GuessNCListF(pluginManager: PluginManager): void;
@@ -1,15 +0,0 @@
1
- import { getFileName } from '@jbrowse/core/util/tracks';
2
- export default function GuessNCListF(pluginManager) {
3
- pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', (adapterGuesser) => {
4
- return (file, index, adapterHint) => {
5
- const fileName = getFileName(file);
6
- return (/trackData.jsonz?$/i.test(fileName) && !adapterHint) ||
7
- adapterHint === 'NCListAdapter'
8
- ? {
9
- type: 'NCListAdapter',
10
- rootUrlTemplate: file,
11
- }
12
- : adapterGuesser(file, index, adapterHint);
13
- };
14
- });
15
- }