@jbrowse/plugin-bed 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 (64) hide show
  1. package/esm/BedAdapter/BedAdapter.d.ts +5 -22
  2. package/esm/BedAdapter/BedAdapter.js +29 -93
  3. package/esm/BedAdapter/configSchema.d.ts +59 -32
  4. package/esm/BedAdapter/configSchema.js +64 -14
  5. package/esm/BedAdapter/index.js +4 -2
  6. package/esm/BedGraphAdapter/BedGraphAdapter.d.ts +5 -12
  7. package/esm/BedGraphAdapter/BedGraphAdapter.js +33 -89
  8. package/esm/BedGraphAdapter/configSchema.d.ts +35 -11
  9. package/esm/BedGraphAdapter/configSchema.js +43 -13
  10. package/esm/BedGraphAdapter/index.js +3 -2
  11. package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.d.ts +5 -5
  12. package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.js +65 -57
  13. package/esm/BedGraphTabixAdapter/configSchema.d.ts +46 -22
  14. package/esm/BedGraphTabixAdapter/configSchema.js +50 -34
  15. package/esm/BedGraphTabixAdapter/index.js +3 -2
  16. package/esm/BedTabixAdapter/BedTabixAdapter.d.ts +34 -38
  17. package/esm/BedTabixAdapter/BedTabixAdapter.js +82 -72
  18. package/esm/BedTabixAdapter/configSchema.d.ts +55 -31
  19. package/esm/BedTabixAdapter/configSchema.js +58 -35
  20. package/esm/BedTabixAdapter/index.js +4 -2
  21. package/esm/BedpeAdapter/BedpeAdapter.d.ts +6 -13
  22. package/esm/BedpeAdapter/BedpeAdapter.js +26 -74
  23. package/esm/BedpeAdapter/configSchema.d.ts +31 -12
  24. package/esm/BedpeAdapter/configSchema.js +37 -13
  25. package/esm/BedpeAdapter/index.js +4 -2
  26. package/esm/BedpeAdapter/util.js +25 -25
  27. package/esm/BigBedAdapter/BigBedAdapter.d.ts +8 -7
  28. package/esm/BigBedAdapter/BigBedAdapter.js +99 -107
  29. package/esm/BigBedAdapter/configSchema.d.ts +38 -16
  30. package/esm/BigBedAdapter/configSchema.js +46 -13
  31. package/esm/BigBedAdapter/index.js +3 -2
  32. package/esm/BigBedTextSearchAdapter/BigBedTextSearchAdapter.d.ts +27 -0
  33. package/esm/BigBedTextSearchAdapter/BigBedTextSearchAdapter.js +128 -0
  34. package/esm/BigBedTextSearchAdapter/configSchema.d.ts +51 -0
  35. package/esm/BigBedTextSearchAdapter/configSchema.js +57 -0
  36. package/esm/BigBedTextSearchAdapter/index.d.ts +2 -0
  37. package/esm/BigBedTextSearchAdapter/index.js +11 -0
  38. package/esm/StarFusionAdapter/StarFusionAdapter.d.ts +14 -0
  39. package/esm/StarFusionAdapter/StarFusionAdapter.js +66 -0
  40. package/esm/StarFusionAdapter/configSchema.d.ts +30 -0
  41. package/esm/StarFusionAdapter/configSchema.js +43 -0
  42. package/esm/StarFusionAdapter/index.d.ts +2 -0
  43. package/esm/StarFusionAdapter/index.js +12 -0
  44. package/esm/adapterUtil.d.ts +5 -0
  45. package/esm/adapterUtil.js +43 -0
  46. package/esm/bedGraphUtil.d.ts +11 -0
  47. package/esm/bedGraphUtil.js +20 -0
  48. package/esm/copyExcept.d.ts +1 -0
  49. package/esm/copyExcept.js +11 -0
  50. package/esm/generateBedMethylFeature.d.ts +1 -1
  51. package/esm/generateBedMethylFeature.js +24 -6
  52. package/esm/generateRastairMethylFeature.d.ts +28 -0
  53. package/esm/generateRastairMethylFeature.js +38 -0
  54. package/esm/generateRepeatMaskerFeature.d.ts +17 -51
  55. package/esm/generateRepeatMaskerFeature.js +27 -37
  56. package/esm/generateUcscTranscript.d.ts +15 -7
  57. package/esm/generateUcscTranscript.js +106 -29
  58. package/esm/index.d.ts +2 -0
  59. package/esm/index.js +12 -8
  60. package/esm/util.d.ts +32 -27
  61. package/esm/util.js +139 -98
  62. package/package.json +10 -13
  63. package/esm/GuessAdapter/index.d.ts +0 -2
  64. package/esm/GuessAdapter/index.js +0 -71
@@ -1,6 +1,31 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
- function x() { }
1
+ import { ConfigurationSchema, expandUriShorthand, } from '@jbrowse/core/configuration';
2
+ export function normalizeSnapshot(snap) {
3
+ return expandUriShorthand(snap, 'bedGraphLocation');
4
+ }
5
+ /**
6
+ * #config BedGraphAdapter
7
+ * #trackType QuantitativeTrack
8
+ * #fileFormat quantitative | BedGraph (plain) | Loaded entirely into memory; for small files
9
+ * used to load plain-text bedGraph signal files. Loads the whole file into
10
+ * memory, so prefer the BedGraphTabixAdapter for large files.
11
+ * Several signals in one file are a `MultiQuantitativeTrack`'s subtracks:
12
+ * one value column each, named by the header, or a `source` column naming each
13
+ * row's, which is the form Save track data writes.
14
+ *
15
+ * #example
16
+ * ```js
17
+ * {
18
+ * type: 'BedGraphAdapter',
19
+ * uri: 'https://example.com/signal.bedGraph',
20
+ * }
21
+ * ```
22
+ */
3
23
  const BedGraphAdapter = ConfigurationSchema('BedGraphAdapter', {
24
+ /**
25
+ * #slot
26
+ * location of the plain-text bedGraph (`chrom start end value`, one line
27
+ * per interval). May be gzipped.
28
+ */
4
29
  bedGraphLocation: {
5
30
  type: 'fileLocation',
6
31
  defaultValue: {
@@ -8,6 +33,9 @@ const BedGraphAdapter = ConfigurationSchema('BedGraphAdapter', {
8
33
  locationType: 'UriLocation',
9
34
  },
10
35
  },
36
+ /**
37
+ * #slot
38
+ */
11
39
  columnNames: {
12
40
  type: 'stringArray',
13
41
  description: 'List of column names',
@@ -15,16 +43,18 @@ const BedGraphAdapter = ConfigurationSchema('BedGraphAdapter', {
15
43
  },
16
44
  }, {
17
45
  explicitlyTyped: true,
18
- preProcessSnapshot: snap => {
19
- return snap.uri
20
- ? {
21
- ...snap,
22
- bedGraphLocation: {
23
- uri: snap.uri,
24
- baseUri: snap.baseUri,
25
- },
26
- }
27
- : snap;
28
- },
46
+ /**
47
+ * #preProcessSnapshot
48
+ *
49
+ *
50
+ * preprocessor to allow minimal config:
51
+ * ```json
52
+ * {
53
+ * "type": "BedGraphAdapter",
54
+ * "uri": "yourfile.bed"
55
+ * }
56
+ * ```
57
+ */
58
+ preProcessSnapshot: normalizeSnapshot,
29
59
  });
30
60
  export default BedGraphAdapter;
@@ -1,10 +1,11 @@
1
1
  import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
2
- import configSchema from "./configSchema.js";
2
+ import configSchema, { normalizeSnapshot } from './configSchema.js';
3
3
  export default function BedGraphAdapterF(pluginManager) {
4
4
  pluginManager.addAdapterType(() => new AdapterType({
5
5
  name: 'BedGraphAdapter',
6
6
  displayName: 'BedGraph adapter',
7
+ normalizeSnapshot,
7
8
  configSchema,
8
- getAdapterClass: () => import("./BedGraphAdapter.js").then(r => r.default),
9
+ getAdapterClass: () => import('./BedGraphAdapter.js').then(r => r.default),
9
10
  }));
10
11
  }
@@ -1,15 +1,15 @@
1
1
  import { TabixIndexedFile } from '@gmod/tabix';
2
2
  import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import type { BedGraphTabixAdapterConfig } from './configSchema.ts';
3
4
  import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
4
5
  import type { Feature, Region } from '@jbrowse/core/util';
5
- export default class BedGraphAdapter extends BaseFeatureDataAdapter {
6
- private configured?;
7
- private configurePre;
8
- protected configure(): Promise<{
6
+ export default class BedGraphTabixAdapter extends BaseFeatureDataAdapter<BedGraphTabixAdapterConfig> {
7
+ protected configure: (opts?: BaseOptions) => Promise<{
8
+ columnNames: string[];
9
9
  bedGraph: TabixIndexedFile;
10
10
  header: string;
11
- columnNames: string[];
12
11
  }>;
12
+ private configurePre;
13
13
  getNames(): Promise<string[] | undefined>;
14
14
  getRefNames(opts?: BaseOptions): Promise<string[]>;
15
15
  getHeader(): Promise<string>;
@@ -1,74 +1,80 @@
1
1
  import { TabixIndexedFile } from '@gmod/tabix';
2
- import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
- import { SimpleFeature } from '@jbrowse/core/util';
4
- import { openLocation } from '@jbrowse/core/util/io';
2
+ import { BaseFeatureDataAdapter, cachedSetup, } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import { downloadStatus } from '@jbrowse/core/util';
4
+ import { sharedBgzfWorkerPool } from '@jbrowse/core/util/bgzfWorkerPool';
5
+ import { decompressedBytesBudget } from '@jbrowse/core/util/cacheBudgets';
6
+ import { openLocation, openTabixIndexFilehandle } from '@jbrowse/core/util/io';
5
7
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
6
- export default class BedGraphAdapter extends BaseFeatureDataAdapter {
7
- configured;
8
+ import { readTabixHeaderLines } from '@jbrowse/core/util/tabix';
9
+ import { makeBedGraphFeature } from '../bedGraphUtil.js';
10
+ import { parseNamesFromHeader } from '../util.js';
11
+ export default class BedGraphTabixAdapter extends BaseFeatureDataAdapter {
12
+ // `label` because the index setup narrates nothing itself; the helper shows
13
+ // it only while the first attempt is in flight, so pan/zoom re-entry (every
14
+ // getFeatures/byte-estimate awaits it) doesn't re-flash "Downloading index"
15
+ configure = cachedSetup({
16
+ label: 'Downloading index',
17
+ setup: () => this.configurePre(),
18
+ });
8
19
  async configurePre() {
9
20
  const pm = this.pluginManager;
10
21
  const bedGraphGzLocation = this.getConf('bedGraphGzLocation');
11
22
  const location = this.getConf(['index', 'location']);
12
23
  const indexType = this.getConf(['index', 'indexType']);
13
- const filehandle = openLocation(bedGraphGzLocation, pm);
14
- const isCSI = indexType === 'CSI';
15
24
  const bedGraph = new TabixIndexedFile({
16
- filehandle,
17
- csiFilehandle: isCSI ? openLocation(location, pm) : undefined,
18
- tbiFilehandle: !isCSI ? openLocation(location, pm) : undefined,
19
- chunkCacheSize: 50 * 2 ** 20,
25
+ filehandle: openLocation(bedGraphGzLocation, pm),
26
+ ...openTabixIndexFilehandle(location, indexType, pm),
27
+ chunkCacheBudget: decompressedBytesBudget,
28
+ bgzfWorkerPool: sharedBgzfWorkerPool(),
20
29
  });
21
30
  const columnNames = this.getConf('columnNames');
22
- const header = await bedGraph.getHeader();
31
+ // Not bedGraph.getHeader(): that returns only a `#`-commented header, so a
32
+ // file whose header is a plain row skipped via `tabix -S 1` reported none
33
+ // and quietly lost the names of its value columns.
34
+ const header = (await readTabixHeaderLines(bedGraph)).join('\n');
23
35
  return {
24
36
  columnNames,
25
37
  bedGraph,
26
38
  header,
27
39
  };
28
40
  }
29
- async configure() {
30
- if (!this.configured) {
31
- this.configured = this.configurePre().catch((e) => {
32
- this.configured = undefined;
33
- throw e;
34
- });
35
- }
36
- return this.configured;
37
- }
38
41
  async getNames() {
39
- const { bedGraph, columnNames } = await this.configure();
40
- if (columnNames.length) {
41
- return columnNames;
42
- }
43
- const header = await bedGraph.getHeader();
44
- const defs = header.split(/\n|\r\n|\r/).filter(f => !!f);
45
- const defline = defs.at(-1);
46
- return defline?.includes('\t')
47
- ? defline
48
- .slice(1)
49
- .split('\t')
50
- .map(f => f.trim())
51
- : undefined;
42
+ const { header, columnNames } = await this.configure();
43
+ return columnNames.length ? columnNames : parseNamesFromHeader(header);
52
44
  }
53
45
  async getRefNames(opts = {}) {
54
- const { bedGraph } = await this.configure();
55
- return bedGraph.getReferenceSequenceNames(opts);
46
+ const { bedGraph } = await this.configure(opts);
47
+ return downloadStatus('Downloading index', opts.statusCallback, onProgress => bedGraph.getReferenceSequenceNames({ ...opts, onProgress }));
56
48
  }
57
49
  async getHeader() {
58
- const { bedGraph } = await this.configure();
59
- return bedGraph.getHeader();
50
+ const { header } = await this.configure();
51
+ return header;
60
52
  }
61
53
  getFeatures(query, opts = {}) {
62
54
  return ObservableCreate(async (observer) => {
63
- const { bedGraph } = await this.configure();
55
+ const { bedGraph } = await this.configure(opts);
64
56
  const meta = await bedGraph.getMetadata();
65
57
  const { columnNumbers } = meta;
66
58
  const colRef = columnNumbers.ref - 1;
67
59
  const colStart = columnNumbers.start - 1;
68
60
  const colEnd = columnNumbers.end - 1;
69
61
  const same = colStart === colEnd;
70
- const names = (await this.getNames())?.slice(same ? 2 : 3) || [];
71
- await bedGraph.getLines(query.refName, query.start + (same ? -1 : 0), query.end, {
62
+ const names = (await this.getNames())?.slice(same ? 2 : 3) ?? [];
63
+ const sourceColumn = names.indexOf('source');
64
+ await downloadStatus('Downloading features', opts.statusCallback, onProgress =>
65
+ // `same` is a single-coordinate file — a GWAS-style txt with only a
66
+ // start column, indexed `-b N -e N`. The widening is not slop: the
67
+ // column value is used below as an interbase start (point p is
68
+ // drawn at [p, p+1)), while the index reads that same column as a
69
+ // 1-based position and places the record at [p-1, p). getLines
70
+ // filters on the index's view, so the point at exactly query.start
71
+ // — visible at the left edge of the view — is one the query would
72
+ // otherwise not ask for. Widening by a base is what asks for it.
73
+ //
74
+ // For a file indexed `-0`, the two views agree and this instead
75
+ // pulls in one extra point just left of the view, which is
76
+ // harmless.
77
+ bedGraph.getLines(query.refName, query.start + (same ? -1 : 0), query.end, {
72
78
  lineCallback: (line, fileOffset) => {
73
79
  const cols = line.split('\t');
74
80
  const refName = cols[colRef];
@@ -79,26 +85,28 @@ export default class BedGraphAdapter extends BaseFeatureDataAdapter {
79
85
  throw new Error(`start/end NaN on line "${line}", with colStart:${colStart} and colEnd:${colEnd}. run "tabix -p bed" to ensure bed preset`);
80
86
  }
81
87
  for (let j = 0; j < rest.length; j++) {
82
- const uniqueId = `${this.id}-${fileOffset}-${j}`;
83
- const score = Math.abs(+rest[j]);
84
- const source = names[j] || `col${j}`;
85
- if (score) {
86
- observer.next(new SimpleFeature({
87
- id: uniqueId,
88
- data: {
89
- refName,
90
- start,
91
- end,
92
- score,
93
- source,
94
- },
95
- }));
88
+ if (j === sourceColumn) {
89
+ continue;
90
+ }
91
+ const feat = makeBedGraphFeature({
92
+ uniqueId: `${this.id}-${fileOffset}-${j}`,
93
+ refName,
94
+ start,
95
+ end,
96
+ names,
97
+ j,
98
+ value: rest[j],
99
+ rowSource: rest[sourceColumn],
100
+ });
101
+ if (feat) {
102
+ observer.next(feat);
96
103
  }
97
104
  }
98
105
  },
99
106
  ...opts,
100
- });
107
+ onProgress,
108
+ }));
101
109
  observer.complete();
102
- });
110
+ }, opts.signal);
103
111
  }
104
112
  }
@@ -1,29 +1,53 @@
1
+ import type { Instance } from '@jbrowse/mobx-state-tree';
2
+ export declare function normalizeSnapshot(snap: Record<string, unknown>): Record<string, unknown>;
3
+ /**
4
+ * #config BedGraphTabixAdapter
5
+ * #trackType QuantitativeTrack
6
+ * #fileFormat quantitative | BedGraph (tabix)
7
+ * used to load bgzip-compressed, tabix-indexed bedGraph signal files.
8
+ * Several signals in one file are a `MultiQuantitativeTrack`'s subtracks:
9
+ * one value column each, named by the header, or a `source` column naming each
10
+ * row's, which is the form Save track data writes.
11
+ *
12
+ * #example
13
+ * The `uri` shorthand auto-resolves the `.tbi` index:
14
+ * ```js
15
+ * {
16
+ * type: 'BedGraphTabixAdapter',
17
+ * uri: 'https://example.com/signal.bedGraph.gz',
18
+ * }
19
+ * ```
20
+ */
1
21
  declare const BedGraphTabixAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
- bedGraphGzLocation: {
3
- type: string;
4
- defaultValue: {
5
- uri: string;
6
- locationType: string;
7
- };
22
+ type: {
23
+ type: "string";
24
+ } & {
25
+ defaultValue: string;
26
+ };
27
+ readonly bedGraphGzLocation: {
28
+ type: "fileLocation";
29
+ } & {
30
+ defaultValue: unknown;
8
31
  };
9
- index: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
10
- indexType: {
11
- model: import("@jbrowse/mobx-state-tree").ISimpleType<"TBI" | "CSI">;
12
- type: string;
32
+ readonly index: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
33
+ readonly indexType: {
34
+ type: "stringEnum";
35
+ } & {
36
+ model: import("@jbrowse/mobx-state-tree").ISimpleType<"CSI" | "TBI">;
37
+ } & {
13
38
  defaultValue: string;
14
39
  };
15
- location: {
16
- type: string;
17
- defaultValue: {
18
- uri: string;
19
- locationType: string;
20
- };
40
+ readonly location: {
41
+ type: "fileLocation";
42
+ } & {
43
+ defaultValue: unknown;
21
44
  };
22
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
23
- columnNames: {
24
- type: string;
25
- description: string;
26
- defaultValue: never[];
45
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined, undefined, import("@jbrowse/core/configuration").ConfigurationSchemaRequirement<Partial<Record<string, string[]>>, string>, any>>;
46
+ readonly columnNames: {
47
+ type: "stringArray";
48
+ } & {
49
+ defaultValue: unknown;
27
50
  };
28
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
51
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined, true, import("@jbrowse/core/configuration").ConfigurationSchemaRequirement<Partial<Record<string, string[]>>, string>, any>>;
52
+ export type BedGraphTabixAdapterConfig = Instance<typeof BedGraphTabixAdapter>;
29
53
  export default BedGraphTabixAdapter;
@@ -1,7 +1,32 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
- import { types } from '@jbrowse/mobx-state-tree';
3
- function x() { }
1
+ import { ConfigurationSchema, expandTabixShorthand, tabixIndexSchema, } from '@jbrowse/core/configuration';
2
+ export function normalizeSnapshot(snap) {
3
+ return expandTabixShorthand(snap, 'bedGraphGzLocation');
4
+ }
5
+ /**
6
+ * #config BedGraphTabixAdapter
7
+ * #trackType QuantitativeTrack
8
+ * #fileFormat quantitative | BedGraph (tabix)
9
+ * used to load bgzip-compressed, tabix-indexed bedGraph signal files.
10
+ * Several signals in one file are a `MultiQuantitativeTrack`'s subtracks:
11
+ * one value column each, named by the header, or a `source` column naming each
12
+ * row's, which is the form Save track data writes.
13
+ *
14
+ * #example
15
+ * The `uri` shorthand auto-resolves the `.tbi` index:
16
+ * ```js
17
+ * {
18
+ * type: 'BedGraphTabixAdapter',
19
+ * uri: 'https://example.com/signal.bedGraph.gz',
20
+ * }
21
+ * ```
22
+ */
4
23
  const BedGraphTabixAdapter = ConfigurationSchema('BedGraphTabixAdapter', {
24
+ /**
25
+ * #slot
26
+ * location of the bgzip-compressed bedGraph (`chrom start end value`,
27
+ * sorted by position). Must be bgzip rather than plain gzip, which tabix
28
+ * cannot index.
29
+ */
5
30
  bedGraphGzLocation: {
6
31
  type: 'fileLocation',
7
32
  defaultValue: {
@@ -9,20 +34,15 @@ const BedGraphTabixAdapter = ConfigurationSchema('BedGraphTabixAdapter', {
9
34
  locationType: 'UriLocation',
10
35
  },
11
36
  },
12
- index: ConfigurationSchema('VcfIndex', {
13
- indexType: {
14
- model: types.enumeration('IndexType', ['TBI', 'CSI']),
15
- type: 'stringEnum',
16
- defaultValue: 'TBI',
17
- },
18
- location: {
19
- type: 'fileLocation',
20
- defaultValue: {
21
- uri: '/path/to/my.vcf.gz.tbi',
22
- locationType: 'UriLocation',
23
- },
24
- },
25
- }),
37
+ /**
38
+ * #slot
39
+ * where the tabix index is and which kind it is. The `uri` shorthand derives
40
+ * both, so a config using it states neither.
41
+ */
42
+ index: tabixIndexSchema(),
43
+ /**
44
+ * #slot
45
+ */
26
46
  columnNames: {
27
47
  type: 'stringArray',
28
48
  description: 'List of column names',
@@ -30,22 +50,18 @@ const BedGraphTabixAdapter = ConfigurationSchema('BedGraphTabixAdapter', {
30
50
  },
31
51
  }, {
32
52
  explicitlyTyped: true,
33
- preProcessSnapshot: snap => {
34
- return snap.uri
35
- ? {
36
- ...snap,
37
- bedGraphGzLocation: {
38
- uri: snap.uri,
39
- baseUri: snap.baseUri,
40
- },
41
- index: {
42
- location: {
43
- uri: `${snap.uri}.tbi`,
44
- baseUri: snap.baseUri,
45
- },
46
- },
47
- }
48
- : snap;
49
- },
53
+ /**
54
+ * #preProcessSnapshot
55
+ *
56
+ *
57
+ * preprocessor to allow minimal config, assumes yourfile.bg.gz.tbi:
58
+ * ```json
59
+ * {
60
+ * "type": "BedGraphTabixAdapter",
61
+ * "uri": "yourfile.bg.gz"
62
+ * }
63
+ * ```
64
+ */
65
+ preProcessSnapshot: normalizeSnapshot,
50
66
  });
51
67
  export default BedGraphTabixAdapter;
@@ -1,10 +1,11 @@
1
1
  import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
2
- import configSchema from "./configSchema.js";
2
+ import configSchema, { normalizeSnapshot } from './configSchema.js';
3
3
  export default function BedGraphTabixAdapterF(pluginManager) {
4
4
  pluginManager.addAdapterType(() => new AdapterType({
5
5
  name: 'BedGraphTabixAdapter',
6
6
  displayName: 'BedGraphTabix adapter',
7
+ normalizeSnapshot,
7
8
  configSchema,
8
- getAdapterClass: () => import("./BedGraphTabixAdapter.js").then(r => r.default),
9
+ getAdapterClass: () => import('./BedGraphTabixAdapter.js').then(r => r.default),
9
10
  }));
10
11
  }
@@ -1,51 +1,47 @@
1
1
  import { TabixIndexedFile } from '@gmod/tabix';
2
2
  import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
3
+ import type { BedTabixAdapterConfig } from './configSchema.ts';
3
4
  import type PluginManager from '@jbrowse/core/PluginManager';
4
- import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
5
5
  import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
6
6
  import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
7
7
  import type { Feature, Region } from '@jbrowse/core/util';
8
- export default class BedTabixAdapter extends BaseFeatureDataAdapter {
9
- private parser;
8
+ export default class BedTabixAdapter extends BaseFeatureDataAdapter<BedTabixAdapterConfig> {
9
+ private getParser;
10
+ private readonly bedGzLoc;
10
11
  protected bed: TabixIndexedFile;
11
- protected columnNames: string[];
12
- protected scoreColumn: string;
13
12
  static capabilities: string[];
14
- setupP?: Promise<{
15
- meta: Awaited<ReturnType<TabixIndexedFile['getMetadata']>>;
13
+ getMetadata: (opts?: BaseOptions) => Promise<{
14
+ refNameToId: Record<string, number>;
15
+ refIdToName: string[];
16
+ metaChar: string | undefined;
17
+ columnNumbers: {
18
+ ref: number;
19
+ start: number;
20
+ end: number;
21
+ };
22
+ coordinateType: string;
23
+ format: string;
24
+ maxRefLength: number;
25
+ skipLines?: number;
26
+ maxBlockSize: number;
27
+ firstDataLine?: import("@gmod/tabix").default;
28
+ refCount?: number;
29
+ csi?: boolean;
30
+ csiVersion?: number;
31
+ minShift: number;
32
+ depth: number;
33
+ maxBinNumber: number;
16
34
  }>;
17
- constructor(config: AnyConfigurationModel, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
35
+ getNames: (opts?: BaseOptions) => Promise<string[] | undefined>;
36
+ constructor(config: BedTabixAdapterConfig, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
18
37
  getRefNames(opts?: BaseOptions): Promise<string[]>;
19
38
  getHeader(opts?: BaseOptions): Promise<string>;
20
- getMetadataPre2(_opts?: BaseOptions): Promise<{
21
- meta: Awaited<ReturnType<TabixIndexedFile["getMetadata"]>>;
22
- }>;
23
- getMetadataPre(): Promise<{
24
- meta: {
25
- refNameToId: Record<string, number>;
26
- refIdToName: string[];
27
- metaChar: string | undefined;
28
- columnNumbers: {
29
- ref: number;
30
- start: number;
31
- end: number;
32
- };
33
- coordinateType: string;
34
- format: string;
35
- maxRefLength: number;
36
- skipLines?: number;
37
- maxBinNumber?: number;
38
- maxBlockSize: number;
39
- firstDataLine?: import("@gmod/tabix").default;
40
- refCount?: number;
41
- csi?: boolean;
42
- csiVersion?: number;
43
- depth?: number;
44
- };
45
- }>;
46
- getMetadata(opts?: BaseOptions): Promise<{
47
- meta: Awaited<ReturnType<TabixIndexedFile["getMetadata"]>>;
48
- }>;
49
- getNames(): Promise<string[] | undefined>;
39
+ /**
40
+ * Estimate compressed bytes for regions straight from the tabix index — no
41
+ * feature download. Lets wrapping adapters (e.g. MafTabix) byte-budget a
42
+ * fetch before pulling the (potentially huge) per-line payload.
43
+ */
44
+ getRegionByteSize(regions: Region[], opts?: BaseOptions): Promise<number>;
45
+ private readNames;
50
46
  getFeatures(query: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
51
47
  }