@jbrowse/plugin-bed 4.3.0 → 5.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/BedAdapter/BedAdapter.d.ts +4 -19
- package/esm/BedAdapter/BedAdapter.js +31 -88
- package/esm/BedAdapter/configSchema.d.ts +89 -40
- package/esm/BedAdapter/configSchema.js +65 -13
- package/esm/BedAdapter/index.js +4 -2
- package/esm/BedGraphAdapter/BedGraphAdapter.d.ts +4 -9
- package/esm/BedGraphAdapter/BedGraphAdapter.js +31 -85
- package/esm/BedGraphAdapter/configSchema.d.ts +35 -9
- package/esm/BedGraphAdapter/configSchema.js +47 -12
- package/esm/BedGraphAdapter/index.js +3 -2
- package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.d.ts +5 -5
- package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.js +62 -57
- package/esm/BedGraphTabixAdapter/configSchema.d.ts +48 -19
- package/esm/BedGraphTabixAdapter/configSchema.js +42 -34
- package/esm/BedGraphTabixAdapter/index.js +3 -2
- package/esm/BedTabixAdapter/BedTabixAdapter.d.ts +34 -38
- package/esm/BedTabixAdapter/BedTabixAdapter.js +82 -71
- package/esm/BedTabixAdapter/configSchema.d.ts +68 -31
- package/esm/BedTabixAdapter/configSchema.js +51 -35
- package/esm/BedTabixAdapter/index.js +4 -2
- package/esm/BedpeAdapter/BedpeAdapter.d.ts +4 -10
- package/esm/BedpeAdapter/BedpeAdapter.js +28 -69
- package/esm/BedpeAdapter/configSchema.d.ts +33 -10
- package/esm/BedpeAdapter/configSchema.js +45 -12
- package/esm/BedpeAdapter/index.js +4 -2
- package/esm/BedpeAdapter/util.js +22 -23
- package/esm/BigBedAdapter/BigBedAdapter.d.ts +8 -7
- package/esm/BigBedAdapter/BigBedAdapter.js +100 -107
- package/esm/BigBedAdapter/configSchema.d.ts +47 -17
- package/esm/BigBedAdapter/configSchema.js +51 -12
- package/esm/BigBedAdapter/index.js +3 -2
- package/esm/StarFusionAdapter/StarFusionAdapter.d.ts +15 -0
- package/esm/StarFusionAdapter/StarFusionAdapter.js +121 -0
- package/esm/StarFusionAdapter/configSchema.d.ts +31 -0
- package/esm/StarFusionAdapter/configSchema.js +52 -0
- package/esm/StarFusionAdapter/index.d.ts +2 -0
- package/esm/StarFusionAdapter/index.js +12 -0
- package/esm/adapterUtil.d.ts +5 -0
- package/esm/adapterUtil.js +28 -0
- package/esm/bedGraphUtil.d.ts +10 -0
- package/esm/bedGraphUtil.js +18 -0
- package/esm/generateBedMethylFeature.d.ts +1 -1
- package/esm/generateBedMethylFeature.js +19 -6
- package/esm/generateRastairMethylFeature.d.ts +28 -0
- package/esm/generateRastairMethylFeature.js +38 -0
- package/esm/generateRepeatMaskerFeature.d.ts +4 -51
- package/esm/generateRepeatMaskerFeature.js +28 -41
- package/esm/generateUcscTranscript.d.ts +15 -7
- package/esm/generateUcscTranscript.js +58 -28
- package/esm/index.d.ts +2 -0
- package/esm/index.js +10 -8
- package/esm/util.d.ts +32 -27
- package/esm/util.js +127 -97
- package/package.json +9 -13
- package/esm/GuessAdapter/index.d.ts +0 -2
- package/esm/GuessAdapter/index.js +0 -71
|
@@ -1,15 +1,41 @@
|
|
|
1
|
+
import type { Instance } from '@jbrowse/mobx-state-tree';
|
|
2
|
+
export declare function normalizeSnapshot(snap: Record<string, unknown>): Record<string, unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* #config BedGraphAdapter
|
|
5
|
+
* #trackType QuantitativeTrack
|
|
6
|
+
* #fileFormat quantitative | BedGraph (plain) | Loaded entirely into memory; for small files
|
|
7
|
+
* used to load plain-text bedGraph signal files. Loads the whole file into
|
|
8
|
+
* memory, so prefer the BedGraphTabixAdapter for large files.
|
|
9
|
+
*
|
|
10
|
+
* #example
|
|
11
|
+
* ```js
|
|
12
|
+
* {
|
|
13
|
+
* type: 'BedGraphAdapter',
|
|
14
|
+
* uri: 'https://example.com/signal.bedGraph',
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
1
18
|
declare const BedGraphAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
19
|
+
/**
|
|
20
|
+
* #slot
|
|
21
|
+
* location of the plain-text bedGraph (`chrom start end value`, one line
|
|
22
|
+
* per interval). May be gzipped.
|
|
23
|
+
*/
|
|
24
|
+
readonly bedGraphLocation: {
|
|
25
|
+
readonly type: "fileLocation";
|
|
26
|
+
readonly defaultValue: {
|
|
27
|
+
readonly uri: "/path/to/my.bedgraph";
|
|
28
|
+
readonly locationType: "UriLocation";
|
|
7
29
|
};
|
|
8
30
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
31
|
+
/**
|
|
32
|
+
* #slot
|
|
33
|
+
*/
|
|
34
|
+
readonly columnNames: {
|
|
35
|
+
readonly type: "stringArray";
|
|
36
|
+
readonly description: "List of column names";
|
|
37
|
+
readonly defaultValue: readonly [];
|
|
13
38
|
};
|
|
14
39
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
40
|
+
export type BedGraphAdapterConfig = Instance<typeof BedGraphAdapter>;
|
|
15
41
|
export default BedGraphAdapter;
|
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
function
|
|
2
|
+
export function normalizeSnapshot(snap) {
|
|
3
|
+
return snap.uri
|
|
4
|
+
? {
|
|
5
|
+
...snap,
|
|
6
|
+
bedGraphLocation: {
|
|
7
|
+
uri: snap.uri,
|
|
8
|
+
baseUri: snap.baseUri,
|
|
9
|
+
},
|
|
10
|
+
}
|
|
11
|
+
: snap;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* #config BedGraphAdapter
|
|
15
|
+
* #trackType QuantitativeTrack
|
|
16
|
+
* #fileFormat quantitative | BedGraph (plain) | Loaded entirely into memory; for small files
|
|
17
|
+
* used to load plain-text bedGraph signal files. Loads the whole file into
|
|
18
|
+
* memory, so prefer the BedGraphTabixAdapter for large files.
|
|
19
|
+
*
|
|
20
|
+
* #example
|
|
21
|
+
* ```js
|
|
22
|
+
* {
|
|
23
|
+
* type: 'BedGraphAdapter',
|
|
24
|
+
* uri: 'https://example.com/signal.bedGraph',
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
3
28
|
const BedGraphAdapter = ConfigurationSchema('BedGraphAdapter', {
|
|
29
|
+
/**
|
|
30
|
+
* #slot
|
|
31
|
+
* location of the plain-text bedGraph (`chrom start end value`, one line
|
|
32
|
+
* per interval). May be gzipped.
|
|
33
|
+
*/
|
|
4
34
|
bedGraphLocation: {
|
|
5
35
|
type: 'fileLocation',
|
|
6
36
|
defaultValue: {
|
|
@@ -8,6 +38,9 @@ const BedGraphAdapter = ConfigurationSchema('BedGraphAdapter', {
|
|
|
8
38
|
locationType: 'UriLocation',
|
|
9
39
|
},
|
|
10
40
|
},
|
|
41
|
+
/**
|
|
42
|
+
* #slot
|
|
43
|
+
*/
|
|
11
44
|
columnNames: {
|
|
12
45
|
type: 'stringArray',
|
|
13
46
|
description: 'List of column names',
|
|
@@ -15,16 +48,18 @@ const BedGraphAdapter = ConfigurationSchema('BedGraphAdapter', {
|
|
|
15
48
|
},
|
|
16
49
|
}, {
|
|
17
50
|
explicitlyTyped: true,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
51
|
+
/**
|
|
52
|
+
* #preProcessSnapshot
|
|
53
|
+
*
|
|
54
|
+
*
|
|
55
|
+
* preprocessor to allow minimal config:
|
|
56
|
+
* ```json
|
|
57
|
+
* {
|
|
58
|
+
* "type": "BedGraphAdapter",
|
|
59
|
+
* "uri": "yourfile.bed"
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
preProcessSnapshot: normalizeSnapshot,
|
|
29
64
|
});
|
|
30
65
|
export default BedGraphAdapter;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
|
|
2
|
-
import configSchema from
|
|
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(
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
4
|
-
import {
|
|
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
|
-
|
|
7
|
-
|
|
8
|
+
import { withStopTokenSignal } from '@jbrowse/core/util/stopToken';
|
|
9
|
+
import { readTabixHeaderLines } from '@jbrowse/core/util/tabix';
|
|
10
|
+
import { makeBedGraphFeature } from '../bedGraphUtil.js';
|
|
11
|
+
import { parseNamesFromHeader } from '../util.js';
|
|
12
|
+
export default class BedGraphTabixAdapter extends BaseFeatureDataAdapter {
|
|
13
|
+
// `label` because the index setup narrates nothing itself; the helper shows
|
|
14
|
+
// it only while the first attempt is in flight, so pan/zoom re-entry (every
|
|
15
|
+
// getFeatures/byte-estimate awaits it) doesn't re-flash "Downloading index"
|
|
16
|
+
configure = cachedSetup({
|
|
17
|
+
label: 'Downloading index',
|
|
18
|
+
setup: () => this.configurePre(),
|
|
19
|
+
});
|
|
8
20
|
async configurePre() {
|
|
9
21
|
const pm = this.pluginManager;
|
|
10
22
|
const bedGraphGzLocation = this.getConf('bedGraphGzLocation');
|
|
11
23
|
const location = this.getConf(['index', 'location']);
|
|
12
24
|
const indexType = this.getConf(['index', 'indexType']);
|
|
13
|
-
const filehandle = openLocation(bedGraphGzLocation, pm);
|
|
14
|
-
const isCSI = indexType === 'CSI';
|
|
15
25
|
const bedGraph = new TabixIndexedFile({
|
|
16
|
-
filehandle,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
filehandle: openLocation(bedGraphGzLocation, pm),
|
|
27
|
+
...openTabixIndexFilehandle(location, indexType, pm),
|
|
28
|
+
chunkCacheBudget: decompressedBytesBudget,
|
|
29
|
+
bgzfWorkerPool: sharedBgzfWorkerPool(),
|
|
20
30
|
});
|
|
21
31
|
const columnNames = this.getConf('columnNames');
|
|
22
|
-
|
|
32
|
+
// Not bedGraph.getHeader(): that returns only a `#`-commented header, so a
|
|
33
|
+
// file whose header is a plain row skipped via `tabix -S 1` reported none
|
|
34
|
+
// and quietly lost the names of its value columns.
|
|
35
|
+
const header = (await readTabixHeaderLines(bedGraph)).join('\n');
|
|
23
36
|
return {
|
|
24
37
|
columnNames,
|
|
25
38
|
bedGraph,
|
|
26
39
|
header,
|
|
27
40
|
};
|
|
28
41
|
}
|
|
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
42
|
async getNames() {
|
|
39
|
-
const {
|
|
40
|
-
|
|
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;
|
|
43
|
+
const { header, columnNames } = await this.configure();
|
|
44
|
+
return columnNames.length ? columnNames : parseNamesFromHeader(header);
|
|
52
45
|
}
|
|
53
46
|
async getRefNames(opts = {}) {
|
|
54
|
-
const { bedGraph } = await this.configure();
|
|
55
|
-
return bedGraph.getReferenceSequenceNames(opts);
|
|
47
|
+
const { bedGraph } = await this.configure(opts);
|
|
48
|
+
return downloadStatus('Downloading index', opts.statusCallback, onProgress => bedGraph.getReferenceSequenceNames({ ...opts, onProgress }));
|
|
56
49
|
}
|
|
57
50
|
async getHeader() {
|
|
58
|
-
const {
|
|
59
|
-
return
|
|
51
|
+
const { header } = await this.configure();
|
|
52
|
+
return header;
|
|
60
53
|
}
|
|
61
54
|
getFeatures(query, opts = {}) {
|
|
62
55
|
return ObservableCreate(async (observer) => {
|
|
63
|
-
const { bedGraph } = await this.configure();
|
|
56
|
+
const { bedGraph } = await this.configure(opts);
|
|
64
57
|
const meta = await bedGraph.getMetadata();
|
|
65
58
|
const { columnNumbers } = meta;
|
|
66
59
|
const colRef = columnNumbers.ref - 1;
|
|
67
60
|
const colStart = columnNumbers.start - 1;
|
|
68
61
|
const colEnd = columnNumbers.end - 1;
|
|
69
62
|
const same = colStart === colEnd;
|
|
70
|
-
const names = (await this.getNames())?.slice(same ? 2 : 3)
|
|
71
|
-
await
|
|
63
|
+
const names = (await this.getNames())?.slice(same ? 2 : 3) ?? [];
|
|
64
|
+
await withStopTokenSignal(opts.stopToken, signal => 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,25 @@ 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
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
source,
|
|
94
|
-
},
|
|
95
|
-
}));
|
|
88
|
+
const feat = makeBedGraphFeature({
|
|
89
|
+
uniqueId: `${this.id}-${fileOffset}-${j}`,
|
|
90
|
+
refName,
|
|
91
|
+
start,
|
|
92
|
+
end,
|
|
93
|
+
names,
|
|
94
|
+
j,
|
|
95
|
+
value: rest[j],
|
|
96
|
+
});
|
|
97
|
+
if (feat) {
|
|
98
|
+
observer.next(feat);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
},
|
|
99
102
|
...opts,
|
|
100
|
-
|
|
103
|
+
onProgress,
|
|
104
|
+
signal,
|
|
105
|
+
})));
|
|
101
106
|
observer.complete();
|
|
102
|
-
});
|
|
107
|
+
}, opts.stopToken);
|
|
103
108
|
}
|
|
104
109
|
}
|
|
@@ -1,29 +1,58 @@
|
|
|
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
|
+
*
|
|
9
|
+
* #example
|
|
10
|
+
* The `uri` shorthand auto-resolves the `.tbi` index:
|
|
11
|
+
* ```js
|
|
12
|
+
* {
|
|
13
|
+
* type: 'BedGraphTabixAdapter',
|
|
14
|
+
* uri: 'https://example.com/signal.bedGraph.gz',
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
1
18
|
declare const BedGraphTabixAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
19
|
+
/**
|
|
20
|
+
* #slot
|
|
21
|
+
* location of the bgzip-compressed bedGraph (`chrom start end value`,
|
|
22
|
+
* sorted by position). Must be bgzip rather than plain gzip, which tabix
|
|
23
|
+
* cannot index.
|
|
24
|
+
*/
|
|
25
|
+
readonly bedGraphGzLocation: {
|
|
26
|
+
readonly type: "fileLocation";
|
|
27
|
+
readonly defaultValue: {
|
|
28
|
+
readonly uri: "/path/to/my.bedgraph";
|
|
29
|
+
readonly locationType: "UriLocation";
|
|
7
30
|
};
|
|
8
31
|
};
|
|
9
|
-
index: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
10
|
-
indexType: {
|
|
11
|
-
model: import("@jbrowse/mobx-state-tree").ISimpleType<"
|
|
12
|
-
type:
|
|
13
|
-
defaultValue:
|
|
32
|
+
readonly index: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
33
|
+
readonly indexType: {
|
|
34
|
+
readonly model: import("@jbrowse/mobx-state-tree").ISimpleType<"CSI" | "TBI">;
|
|
35
|
+
readonly type: 'stringEnum';
|
|
36
|
+
readonly defaultValue: 'TBI';
|
|
37
|
+
readonly description: '`TBI` is the usual `tabix` output. `CSI` is required for a reference longer than 512 Mb, which TBI cannot address.';
|
|
14
38
|
};
|
|
15
|
-
location: {
|
|
16
|
-
type:
|
|
17
|
-
defaultValue: {
|
|
18
|
-
uri:
|
|
19
|
-
locationType:
|
|
39
|
+
readonly location: {
|
|
40
|
+
readonly type: 'fileLocation';
|
|
41
|
+
readonly defaultValue: {
|
|
42
|
+
readonly uri: '/path/to/my.gz.tbi';
|
|
43
|
+
readonly locationType: 'UriLocation';
|
|
20
44
|
};
|
|
45
|
+
readonly description: 'location of the tabix index. Only needed when it is not named `<file>.tbi` (or `.csi`), which is what the `uri` shorthand assumes.';
|
|
21
46
|
};
|
|
22
47
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
48
|
+
/**
|
|
49
|
+
* #slot
|
|
50
|
+
*/
|
|
51
|
+
readonly columnNames: {
|
|
52
|
+
readonly type: "stringArray";
|
|
53
|
+
readonly description: "List of column names";
|
|
54
|
+
readonly defaultValue: readonly [];
|
|
27
55
|
};
|
|
28
56
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
57
|
+
export type BedGraphTabixAdapterConfig = Instance<typeof BedGraphTabixAdapter>;
|
|
29
58
|
export default BedGraphTabixAdapter;
|
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ConfigurationSchema, expandTabixShorthand, tabixIndexFields, } 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
|
+
*
|
|
11
|
+
* #example
|
|
12
|
+
* The `uri` shorthand auto-resolves the `.tbi` index:
|
|
13
|
+
* ```js
|
|
14
|
+
* {
|
|
15
|
+
* type: 'BedGraphTabixAdapter',
|
|
16
|
+
* uri: 'https://example.com/signal.bedGraph.gz',
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
4
20
|
const BedGraphTabixAdapter = ConfigurationSchema('BedGraphTabixAdapter', {
|
|
21
|
+
/**
|
|
22
|
+
* #slot
|
|
23
|
+
* location of the bgzip-compressed bedGraph (`chrom start end value`,
|
|
24
|
+
* sorted by position). Must be bgzip rather than plain gzip, which tabix
|
|
25
|
+
* cannot index.
|
|
26
|
+
*/
|
|
5
27
|
bedGraphGzLocation: {
|
|
6
28
|
type: 'fileLocation',
|
|
7
29
|
defaultValue: {
|
|
@@ -9,20 +31,10 @@ const BedGraphTabixAdapter = ConfigurationSchema('BedGraphTabixAdapter', {
|
|
|
9
31
|
locationType: 'UriLocation',
|
|
10
32
|
},
|
|
11
33
|
},
|
|
12
|
-
index: ConfigurationSchema('
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
}),
|
|
34
|
+
index: ConfigurationSchema('TabixIndex', { ...tabixIndexFields }),
|
|
35
|
+
/**
|
|
36
|
+
* #slot
|
|
37
|
+
*/
|
|
26
38
|
columnNames: {
|
|
27
39
|
type: 'stringArray',
|
|
28
40
|
description: 'List of column names',
|
|
@@ -30,22 +42,18 @@ const BedGraphTabixAdapter = ConfigurationSchema('BedGraphTabixAdapter', {
|
|
|
30
42
|
},
|
|
31
43
|
}, {
|
|
32
44
|
explicitlyTyped: true,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
: snap;
|
|
49
|
-
},
|
|
45
|
+
/**
|
|
46
|
+
* #preProcessSnapshot
|
|
47
|
+
*
|
|
48
|
+
*
|
|
49
|
+
* preprocessor to allow minimal config, assumes yourfile.bg.gz.tbi:
|
|
50
|
+
* ```json
|
|
51
|
+
* {
|
|
52
|
+
* "type": "BedGraphTabixAdapter",
|
|
53
|
+
* "uri": "yourfile.bg.gz"
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
preProcessSnapshot: normalizeSnapshot,
|
|
50
58
|
});
|
|
51
59
|
export default BedGraphTabixAdapter;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
|
|
2
|
-
import configSchema from
|
|
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(
|
|
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
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
}
|