@jbrowse/plugin-bed 2.17.0 → 2.18.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/BedAdapter/BedAdapter.d.ts +15 -5
- package/dist/BedAdapter/BedAdapter.js +7 -10
- package/dist/BedAdapter/configSchema.d.ts +0 -21
- package/dist/BedAdapter/configSchema.js +1 -25
- package/dist/BedAdapter/index.d.ts +1 -1
- package/dist/BedGraphAdapter/BedGraphAdapter.d.ts +24 -0
- package/dist/BedGraphAdapter/BedGraphAdapter.js +130 -0
- package/dist/BedGraphAdapter/configSchema.d.ts +15 -0
- package/dist/BedGraphAdapter/configSchema.js +19 -0
- package/dist/BedGraphAdapter/index.d.ts +2 -0
- package/dist/BedGraphAdapter/index.js +39 -0
- package/dist/BedGraphTabixAdapter/BedGraphTabixAdapter.d.ts +18 -0
- package/dist/BedGraphTabixAdapter/BedGraphTabixAdapter.js +105 -0
- package/dist/BedGraphTabixAdapter/configSchema.d.ts +29 -0
- package/dist/BedGraphTabixAdapter/configSchema.js +34 -0
- package/dist/BedGraphTabixAdapter/index.d.ts +2 -0
- package/dist/BedGraphTabixAdapter/index.js +39 -0
- package/dist/BedTabixAdapter/BedTabixAdapter.d.ts +6 -5
- package/dist/BedTabixAdapter/BedTabixAdapter.js +12 -5
- package/dist/BedTabixAdapter/configSchema.d.ts +0 -18
- package/dist/BedTabixAdapter/configSchema.js +1 -22
- package/dist/BedTabixAdapter/index.d.ts +1 -1
- package/dist/BedpeAdapter/BedpeAdapter.d.ts +4 -2
- package/dist/BedpeAdapter/BedpeAdapter.js +4 -5
- package/dist/BedpeAdapter/configSchema.d.ts +0 -7
- package/dist/BedpeAdapter/configSchema.js +1 -12
- package/dist/BedpeAdapter/index.d.ts +1 -1
- package/dist/BigBedAdapter/BigBedAdapter.d.ts +5 -4
- package/dist/BigBedAdapter/BigBedAdapter.js +13 -8
- package/dist/BigBedAdapter/configSchema.d.ts +0 -9
- package/dist/BigBedAdapter/configSchema.js +1 -13
- package/dist/BigBedAdapter/index.d.ts +1 -1
- package/dist/generateBedMethylFeature.d.ts +3 -3
- package/dist/generateBedMethylFeature.js +3 -5
- package/dist/generateUcscTranscript.d.ts +1 -1
- package/dist/generateUcscTranscript.js +0 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -4
- package/dist/util.d.ts +171 -6
- package/dist/util.js +65 -61
- package/esm/BedAdapter/BedAdapter.d.ts +15 -5
- package/esm/BedAdapter/BedAdapter.js +8 -11
- package/esm/BedAdapter/configSchema.d.ts +0 -21
- package/esm/BedAdapter/configSchema.js +1 -25
- package/esm/BedAdapter/index.d.ts +1 -1
- package/esm/BedGraphAdapter/BedGraphAdapter.d.ts +24 -0
- package/esm/BedGraphAdapter/BedGraphAdapter.js +124 -0
- package/esm/BedGraphAdapter/configSchema.d.ts +15 -0
- package/esm/BedGraphAdapter/configSchema.js +17 -0
- package/esm/BedGraphAdapter/index.d.ts +2 -0
- package/esm/BedGraphAdapter/index.js +10 -0
- package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.d.ts +18 -0
- package/esm/BedGraphTabixAdapter/BedGraphTabixAdapter.js +102 -0
- package/esm/BedGraphTabixAdapter/configSchema.d.ts +29 -0
- package/esm/BedGraphTabixAdapter/configSchema.js +32 -0
- package/esm/BedGraphTabixAdapter/index.d.ts +2 -0
- package/esm/BedGraphTabixAdapter/index.js +10 -0
- package/esm/BedTabixAdapter/BedTabixAdapter.d.ts +6 -5
- package/esm/BedTabixAdapter/BedTabixAdapter.js +13 -6
- package/esm/BedTabixAdapter/configSchema.d.ts +0 -18
- package/esm/BedTabixAdapter/configSchema.js +1 -22
- package/esm/BedTabixAdapter/index.d.ts +1 -1
- package/esm/BedpeAdapter/BedpeAdapter.d.ts +4 -2
- package/esm/BedpeAdapter/BedpeAdapter.js +5 -6
- package/esm/BedpeAdapter/configSchema.d.ts +0 -7
- package/esm/BedpeAdapter/configSchema.js +1 -12
- package/esm/BedpeAdapter/index.d.ts +1 -1
- package/esm/BigBedAdapter/BigBedAdapter.d.ts +5 -4
- package/esm/BigBedAdapter/BigBedAdapter.js +14 -9
- package/esm/BigBedAdapter/configSchema.d.ts +0 -9
- package/esm/BigBedAdapter/configSchema.js +1 -13
- package/esm/BigBedAdapter/index.d.ts +1 -1
- package/esm/generateBedMethylFeature.d.ts +3 -3
- package/esm/generateBedMethylFeature.js +3 -5
- package/esm/generateUcscTranscript.d.ts +1 -1
- package/esm/generateUcscTranscript.js +0 -6
- package/esm/index.d.ts +1 -1
- package/esm/index.js +8 -4
- package/esm/util.d.ts +171 -6
- package/esm/util.js +65 -61
- package/package.json +2 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import IntervalTree from '@flatten-js/interval-tree';
|
|
2
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import { SimpleFeature, fetchAndMaybeUnzip } from '@jbrowse/core/util';
|
|
4
|
+
import { openLocation } from '@jbrowse/core/util/io';
|
|
5
|
+
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
6
|
+
export default class BedGraphAdapter extends BaseFeatureDataAdapter {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.intervalTrees = {};
|
|
10
|
+
}
|
|
11
|
+
async getNames() {
|
|
12
|
+
const { header, columnNames } = await this.loadData();
|
|
13
|
+
if (columnNames.length) {
|
|
14
|
+
return columnNames;
|
|
15
|
+
}
|
|
16
|
+
const defs = header.split(/\n|\r\n|\r/).filter(f => !!f);
|
|
17
|
+
const defline = defs.at(-1);
|
|
18
|
+
return (defline === null || defline === void 0 ? void 0 : defline.includes('\t'))
|
|
19
|
+
? defline
|
|
20
|
+
.slice(1)
|
|
21
|
+
.split('\t')
|
|
22
|
+
.map(field => field.trim())
|
|
23
|
+
: undefined;
|
|
24
|
+
}
|
|
25
|
+
async loadFeatureIntervalTreeHelper(refName) {
|
|
26
|
+
var _a;
|
|
27
|
+
const { features } = await this.loadData();
|
|
28
|
+
const lines = features[refName];
|
|
29
|
+
if (!lines) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const names = ((_a = (await this.getNames())) === null || _a === void 0 ? void 0 : _a.slice(3)) || [];
|
|
33
|
+
const intervalTree = new IntervalTree();
|
|
34
|
+
for (let i = 0; i < lines.length; i++) {
|
|
35
|
+
const line = lines[i];
|
|
36
|
+
const [refName, s, e, ...rest] = line.split('\t');
|
|
37
|
+
for (let j = 0; j < rest.length; j++) {
|
|
38
|
+
const uniqueId = `${this.id}-${refName}-${i}-${j}`;
|
|
39
|
+
const start = +s;
|
|
40
|
+
const end = +e;
|
|
41
|
+
const score = +rest[j];
|
|
42
|
+
const source = names[j] || `col${j}`;
|
|
43
|
+
if (score) {
|
|
44
|
+
intervalTree.insert([start, end], new SimpleFeature({
|
|
45
|
+
id: uniqueId,
|
|
46
|
+
data: {
|
|
47
|
+
refName,
|
|
48
|
+
start,
|
|
49
|
+
end,
|
|
50
|
+
score,
|
|
51
|
+
source,
|
|
52
|
+
},
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return intervalTree;
|
|
58
|
+
}
|
|
59
|
+
async getRefNames(opts = {}) {
|
|
60
|
+
const { features } = await this.loadData(opts);
|
|
61
|
+
return Object.keys(features);
|
|
62
|
+
}
|
|
63
|
+
async loadDataP(opts = {}) {
|
|
64
|
+
const pm = this.pluginManager;
|
|
65
|
+
const bedLoc = this.getConf('bedGraphLocation');
|
|
66
|
+
const buffer = await fetchAndMaybeUnzip(openLocation(bedLoc, pm), opts);
|
|
67
|
+
if (buffer.length > 536870888) {
|
|
68
|
+
throw new Error('Data exceeds maximum string length (512MB)');
|
|
69
|
+
}
|
|
70
|
+
const data = new TextDecoder('utf8', { fatal: true }).decode(buffer);
|
|
71
|
+
const lines = data.split(/\n|\r\n|\r/).filter(f => !!f);
|
|
72
|
+
const headerLines = [];
|
|
73
|
+
let i = 0;
|
|
74
|
+
for (; i < lines.length && lines[i].startsWith('#'); i++) {
|
|
75
|
+
headerLines.push(lines[i]);
|
|
76
|
+
}
|
|
77
|
+
const header = headerLines.join('\n');
|
|
78
|
+
const features = {};
|
|
79
|
+
for (; i < lines.length; i++) {
|
|
80
|
+
const line = lines[i];
|
|
81
|
+
const tab = line.indexOf('\t');
|
|
82
|
+
const refName = line.slice(0, tab);
|
|
83
|
+
if (!features[refName]) {
|
|
84
|
+
features[refName] = [];
|
|
85
|
+
}
|
|
86
|
+
features[refName].push(line);
|
|
87
|
+
}
|
|
88
|
+
const columnNames = this.getConf('columnNames');
|
|
89
|
+
return {
|
|
90
|
+
header,
|
|
91
|
+
features,
|
|
92
|
+
columnNames,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async loadFeatureIntervalTree(refName) {
|
|
96
|
+
if (!this.intervalTrees[refName]) {
|
|
97
|
+
this.intervalTrees[refName] = this.loadFeatureIntervalTreeHelper(refName).catch((e) => {
|
|
98
|
+
this.intervalTrees[refName] = undefined;
|
|
99
|
+
throw e;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return this.intervalTrees[refName];
|
|
103
|
+
}
|
|
104
|
+
async loadData(opts = {}) {
|
|
105
|
+
if (!this.bedFeatures) {
|
|
106
|
+
this.bedFeatures = this.loadDataP(opts).catch((e) => {
|
|
107
|
+
this.bedFeatures = undefined;
|
|
108
|
+
throw e;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return this.bedFeatures;
|
|
112
|
+
}
|
|
113
|
+
getFeatures(query, _opts = {}) {
|
|
114
|
+
return ObservableCreate(async (observer) => {
|
|
115
|
+
const { start, end, refName } = query;
|
|
116
|
+
const intervalTree = await this.loadFeatureIntervalTree(refName);
|
|
117
|
+
intervalTree === null || intervalTree === void 0 ? void 0 : intervalTree.search([start, end]).forEach(f => {
|
|
118
|
+
observer.next(f);
|
|
119
|
+
});
|
|
120
|
+
observer.complete();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
freeResources() { }
|
|
124
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const BedGraphAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
+
bedGraphLocation: {
|
|
3
|
+
type: string;
|
|
4
|
+
defaultValue: {
|
|
5
|
+
uri: string;
|
|
6
|
+
locationType: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
columnNames: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
defaultValue: never[];
|
|
13
|
+
};
|
|
14
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
15
|
+
export default BedGraphAdapter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
+
function x() { }
|
|
3
|
+
const BedGraphAdapter = ConfigurationSchema('BedGraphAdapter', {
|
|
4
|
+
bedGraphLocation: {
|
|
5
|
+
type: 'fileLocation',
|
|
6
|
+
defaultValue: {
|
|
7
|
+
uri: '/path/to/my.bedgraph',
|
|
8
|
+
locationType: 'UriLocation',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
columnNames: {
|
|
12
|
+
type: 'stringArray',
|
|
13
|
+
description: 'List of column names',
|
|
14
|
+
defaultValue: [],
|
|
15
|
+
},
|
|
16
|
+
}, { explicitlyTyped: true });
|
|
17
|
+
export default BedGraphAdapter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
|
|
2
|
+
import configSchema from './configSchema';
|
|
3
|
+
export default function BedGraphAdapterF(pluginManager) {
|
|
4
|
+
pluginManager.addAdapterType(() => new AdapterType({
|
|
5
|
+
name: 'BedGraphAdapter',
|
|
6
|
+
displayName: 'BedGraph adapter',
|
|
7
|
+
configSchema,
|
|
8
|
+
getAdapterClass: () => import('./BedGraphAdapter').then(r => r.default),
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TabixIndexedFile } from '@gmod/tabix';
|
|
2
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
+
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<{
|
|
9
|
+
bedGraph: TabixIndexedFile;
|
|
10
|
+
header: string;
|
|
11
|
+
columnNames: string[];
|
|
12
|
+
}>;
|
|
13
|
+
getNames(): Promise<string[] | undefined>;
|
|
14
|
+
getRefNames(opts?: BaseOptions): Promise<string[]>;
|
|
15
|
+
getHeader(): Promise<string>;
|
|
16
|
+
getFeatures(query: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
17
|
+
freeResources(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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';
|
|
5
|
+
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
6
|
+
export default class BedGraphAdapter extends BaseFeatureDataAdapter {
|
|
7
|
+
async configurePre() {
|
|
8
|
+
const pm = this.pluginManager;
|
|
9
|
+
const bedGraphGzLocation = this.getConf('bedGraphGzLocation');
|
|
10
|
+
const location = this.getConf(['index', 'location']);
|
|
11
|
+
const indexType = this.getConf(['index', 'indexType']);
|
|
12
|
+
const filehandle = openLocation(bedGraphGzLocation, pm);
|
|
13
|
+
const isCSI = indexType === 'CSI';
|
|
14
|
+
const bedGraph = new TabixIndexedFile({
|
|
15
|
+
filehandle,
|
|
16
|
+
csiFilehandle: isCSI ? openLocation(location, pm) : undefined,
|
|
17
|
+
tbiFilehandle: !isCSI ? openLocation(location, pm) : undefined,
|
|
18
|
+
chunkCacheSize: 50 * 2 ** 20,
|
|
19
|
+
});
|
|
20
|
+
const columnNames = this.getConf('columnNames');
|
|
21
|
+
const header = await bedGraph.getHeader();
|
|
22
|
+
return {
|
|
23
|
+
columnNames,
|
|
24
|
+
bedGraph,
|
|
25
|
+
header,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async configure() {
|
|
29
|
+
if (!this.configured) {
|
|
30
|
+
this.configured = this.configurePre().catch((e) => {
|
|
31
|
+
this.configured = undefined;
|
|
32
|
+
throw e;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return this.configured;
|
|
36
|
+
}
|
|
37
|
+
async getNames() {
|
|
38
|
+
const { bedGraph, columnNames } = await this.configure();
|
|
39
|
+
if (columnNames.length) {
|
|
40
|
+
return columnNames;
|
|
41
|
+
}
|
|
42
|
+
const header = await bedGraph.getHeader();
|
|
43
|
+
const defs = header.split(/\n|\r\n|\r/).filter(f => !!f);
|
|
44
|
+
const defline = defs.at(-1);
|
|
45
|
+
return (defline === null || defline === void 0 ? void 0 : defline.includes('\t'))
|
|
46
|
+
? defline
|
|
47
|
+
.slice(1)
|
|
48
|
+
.split('\t')
|
|
49
|
+
.map(f => f.trim())
|
|
50
|
+
: undefined;
|
|
51
|
+
}
|
|
52
|
+
async getRefNames(opts = {}) {
|
|
53
|
+
const { bedGraph } = await this.configure();
|
|
54
|
+
return bedGraph.getReferenceSequenceNames(opts);
|
|
55
|
+
}
|
|
56
|
+
async getHeader() {
|
|
57
|
+
const { bedGraph } = await this.configure();
|
|
58
|
+
return bedGraph.getHeader();
|
|
59
|
+
}
|
|
60
|
+
getFeatures(query, opts = {}) {
|
|
61
|
+
return ObservableCreate(async (observer) => {
|
|
62
|
+
var _a;
|
|
63
|
+
const { bedGraph } = await this.configure();
|
|
64
|
+
const meta = await bedGraph.getMetadata();
|
|
65
|
+
const { columnNumbers } = meta;
|
|
66
|
+
const colRef = columnNumbers.ref - 1;
|
|
67
|
+
const colStart = columnNumbers.start - 1;
|
|
68
|
+
const colEnd = columnNumbers.end - 1;
|
|
69
|
+
const same = colStart === colEnd;
|
|
70
|
+
const names = ((_a = (await this.getNames())) === null || _a === void 0 ? void 0 : _a.slice(same ? 2 : 3)) || [];
|
|
71
|
+
await bedGraph.getLines(query.refName, query.start + (same ? -1 : 0), query.end, {
|
|
72
|
+
lineCallback: (line, fileOffset) => {
|
|
73
|
+
const cols = line.split('\t');
|
|
74
|
+
const refName = cols[colRef];
|
|
75
|
+
const start = +cols[colStart];
|
|
76
|
+
const end = +(same ? start + 1 : cols[colEnd]);
|
|
77
|
+
const rest = cols.slice(colEnd + 1);
|
|
78
|
+
for (let j = 0; j < rest.length; j++) {
|
|
79
|
+
const uniqueId = `${this.id}-${fileOffset}-${j}`;
|
|
80
|
+
const score = Math.abs(+rest[j]);
|
|
81
|
+
const source = names[j] || `col${j}`;
|
|
82
|
+
if (score) {
|
|
83
|
+
observer.next(new SimpleFeature({
|
|
84
|
+
id: uniqueId,
|
|
85
|
+
data: {
|
|
86
|
+
refName,
|
|
87
|
+
start,
|
|
88
|
+
end,
|
|
89
|
+
score,
|
|
90
|
+
source,
|
|
91
|
+
},
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
...opts,
|
|
97
|
+
});
|
|
98
|
+
observer.complete();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
freeResources() { }
|
|
102
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare const BedGraphTabixAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
+
bedGraphGzLocation: {
|
|
3
|
+
type: string;
|
|
4
|
+
defaultValue: {
|
|
5
|
+
uri: string;
|
|
6
|
+
locationType: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
index: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
10
|
+
indexType: {
|
|
11
|
+
model: import("mobx-state-tree").ISimpleType<string>;
|
|
12
|
+
type: string;
|
|
13
|
+
defaultValue: string;
|
|
14
|
+
};
|
|
15
|
+
location: {
|
|
16
|
+
type: string;
|
|
17
|
+
defaultValue: {
|
|
18
|
+
uri: string;
|
|
19
|
+
locationType: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
23
|
+
columnNames: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
defaultValue: never[];
|
|
27
|
+
};
|
|
28
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
29
|
+
export default BedGraphTabixAdapter;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
+
import { types } from 'mobx-state-tree';
|
|
3
|
+
function x() { }
|
|
4
|
+
const BedGraphTabixAdapter = ConfigurationSchema('BedGraphTabixAdapter', {
|
|
5
|
+
bedGraphGzLocation: {
|
|
6
|
+
type: 'fileLocation',
|
|
7
|
+
defaultValue: {
|
|
8
|
+
uri: '/path/to/my.bedgraph',
|
|
9
|
+
locationType: 'UriLocation',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
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
|
+
}),
|
|
26
|
+
columnNames: {
|
|
27
|
+
type: 'stringArray',
|
|
28
|
+
description: 'List of column names',
|
|
29
|
+
defaultValue: [],
|
|
30
|
+
},
|
|
31
|
+
}, { explicitlyTyped: true });
|
|
32
|
+
export default BedGraphTabixAdapter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
|
|
2
|
+
import configSchema from './configSchema';
|
|
3
|
+
export default function BedGraphTabixAdapterF(pluginManager) {
|
|
4
|
+
pluginManager.addAdapterType(() => new AdapterType({
|
|
5
|
+
name: 'BedGraphTabixAdapter',
|
|
6
|
+
displayName: 'BedGraphTabix adapter',
|
|
7
|
+
configSchema,
|
|
8
|
+
getAdapterClass: () => import('./BedGraphTabixAdapter').then(r => r.default),
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import { Region, Feature } from '@jbrowse/core/util';
|
|
3
1
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
2
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
4
|
+
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
5
|
+
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
6
|
+
import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
7
|
+
import type { Feature, Region } from '@jbrowse/core/util';
|
|
7
8
|
export default class BedTabixAdapter extends BaseFeatureDataAdapter {
|
|
8
9
|
private parser;
|
|
9
10
|
protected bed: TabixIndexedFile;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import BED from '@gmod/bed';
|
|
2
|
-
import {
|
|
2
|
+
import { TabixIndexedFile } from '@gmod/tabix';
|
|
3
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
+
import { SimpleFeature } from '@jbrowse/core/util';
|
|
3
5
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
4
6
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
5
|
-
import {
|
|
6
|
-
import { TabixIndexedFile } from '@gmod/tabix';
|
|
7
|
-
// locals
|
|
7
|
+
import { checkStopToken } from '@jbrowse/core/util/stopToken';
|
|
8
8
|
import { featureData } from '../util';
|
|
9
9
|
class BedTabixAdapter extends BaseFeatureDataAdapter {
|
|
10
10
|
constructor(config, getSubAdapter, pluginManager) {
|
|
@@ -45,6 +45,7 @@ class BedTabixAdapter extends BaseFeatureDataAdapter {
|
|
|
45
45
|
: undefined;
|
|
46
46
|
}
|
|
47
47
|
getFeatures(query, opts = {}) {
|
|
48
|
+
const { stopToken } = opts;
|
|
48
49
|
return ObservableCreate(async (observer) => {
|
|
49
50
|
const meta = await this.bed.getMetadata();
|
|
50
51
|
const { columnNumbers } = meta;
|
|
@@ -52,8 +53,14 @@ class BedTabixAdapter extends BaseFeatureDataAdapter {
|
|
|
52
53
|
const colStart = columnNumbers.start - 1;
|
|
53
54
|
const colEnd = columnNumbers.end - 1;
|
|
54
55
|
const names = await this.getNames();
|
|
56
|
+
let start = performance.now();
|
|
57
|
+
checkStopToken(stopToken);
|
|
55
58
|
await this.bed.getLines(query.refName, query.start, query.end, {
|
|
56
59
|
lineCallback: (line, fileOffset) => {
|
|
60
|
+
if (performance.now() - start > 200) {
|
|
61
|
+
checkStopToken(stopToken);
|
|
62
|
+
start = performance.now();
|
|
63
|
+
}
|
|
57
64
|
observer.next(new SimpleFeature(featureData({
|
|
58
65
|
line,
|
|
59
66
|
colRef,
|
|
@@ -65,10 +72,10 @@ class BedTabixAdapter extends BaseFeatureDataAdapter {
|
|
|
65
72
|
names,
|
|
66
73
|
})));
|
|
67
74
|
},
|
|
68
|
-
|
|
75
|
+
stopToken: opts.stopToken,
|
|
69
76
|
});
|
|
70
77
|
observer.complete();
|
|
71
|
-
}, opts.
|
|
78
|
+
}, opts.stopToken);
|
|
72
79
|
}
|
|
73
80
|
freeResources() { }
|
|
74
81
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
declare const BedTabixAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
/**
|
|
3
|
-
* #slot
|
|
4
|
-
*/
|
|
5
2
|
bedGzLocation: {
|
|
6
3
|
type: string;
|
|
7
4
|
defaultValue: {
|
|
@@ -10,17 +7,11 @@ declare const BedTabixAdapter: import("@jbrowse/core/configuration/configuration
|
|
|
10
7
|
};
|
|
11
8
|
};
|
|
12
9
|
index: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
13
|
-
/**
|
|
14
|
-
* #slot index.indexType
|
|
15
|
-
*/
|
|
16
10
|
indexType: {
|
|
17
11
|
model: import("mobx-state-tree").ISimpleType<string>;
|
|
18
12
|
type: string;
|
|
19
13
|
defaultValue: string;
|
|
20
14
|
};
|
|
21
|
-
/**
|
|
22
|
-
* #slot index.location
|
|
23
|
-
*/
|
|
24
15
|
location: {
|
|
25
16
|
type: string;
|
|
26
17
|
defaultValue: {
|
|
@@ -29,25 +20,16 @@ declare const BedTabixAdapter: import("@jbrowse/core/configuration/configuration
|
|
|
29
20
|
};
|
|
30
21
|
};
|
|
31
22
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
32
|
-
/**
|
|
33
|
-
* #slot
|
|
34
|
-
*/
|
|
35
23
|
columnNames: {
|
|
36
24
|
type: string;
|
|
37
25
|
description: string;
|
|
38
26
|
defaultValue: never[];
|
|
39
27
|
};
|
|
40
|
-
/**
|
|
41
|
-
* #slot
|
|
42
|
-
*/
|
|
43
28
|
scoreColumn: {
|
|
44
29
|
type: string;
|
|
45
30
|
description: string;
|
|
46
31
|
defaultValue: string;
|
|
47
32
|
};
|
|
48
|
-
/**
|
|
49
|
-
* #slot
|
|
50
|
-
*/
|
|
51
33
|
autoSql: {
|
|
52
34
|
type: string;
|
|
53
35
|
description: string;
|
|
@@ -1,29 +1,17 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
2
|
import { types } from 'mobx-state-tree';
|
|
3
|
-
|
|
4
|
-
* #config BedTabixAdapter
|
|
5
|
-
*/
|
|
6
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
function x() { }
|
|
7
4
|
const BedTabixAdapter = ConfigurationSchema('BedTabixAdapter', {
|
|
8
|
-
/**
|
|
9
|
-
* #slot
|
|
10
|
-
*/
|
|
11
5
|
bedGzLocation: {
|
|
12
6
|
type: 'fileLocation',
|
|
13
7
|
defaultValue: { uri: '/path/to/my.bed.gz', locationType: 'UriLocation' },
|
|
14
8
|
},
|
|
15
9
|
index: ConfigurationSchema('TabixIndex', {
|
|
16
|
-
/**
|
|
17
|
-
* #slot index.indexType
|
|
18
|
-
*/
|
|
19
10
|
indexType: {
|
|
20
11
|
model: types.enumeration('IndexType', ['TBI', 'CSI']),
|
|
21
12
|
type: 'stringEnum',
|
|
22
13
|
defaultValue: 'TBI',
|
|
23
14
|
},
|
|
24
|
-
/**
|
|
25
|
-
* #slot index.location
|
|
26
|
-
*/
|
|
27
15
|
location: {
|
|
28
16
|
type: 'fileLocation',
|
|
29
17
|
defaultValue: {
|
|
@@ -32,25 +20,16 @@ const BedTabixAdapter = ConfigurationSchema('BedTabixAdapter', {
|
|
|
32
20
|
},
|
|
33
21
|
},
|
|
34
22
|
}),
|
|
35
|
-
/**
|
|
36
|
-
* #slot
|
|
37
|
-
*/
|
|
38
23
|
columnNames: {
|
|
39
24
|
type: 'stringArray',
|
|
40
25
|
description: 'List of column names',
|
|
41
26
|
defaultValue: [],
|
|
42
27
|
},
|
|
43
|
-
/**
|
|
44
|
-
* #slot
|
|
45
|
-
*/
|
|
46
28
|
scoreColumn: {
|
|
47
29
|
type: 'string',
|
|
48
30
|
description: 'The column to use as a "score" attribute',
|
|
49
31
|
defaultValue: '',
|
|
50
32
|
},
|
|
51
|
-
/**
|
|
52
|
-
* #slot
|
|
53
|
-
*/
|
|
54
33
|
autoSql: {
|
|
55
34
|
type: 'string',
|
|
56
35
|
description: 'The autoSql definition for the data fields in the file',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
2
|
export default function BedTabixAdapterF(pluginManager: PluginManager): void;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import { Region, Feature, SimpleFeature } from '@jbrowse/core/util';
|
|
3
1
|
import IntervalTree from '@flatten-js/interval-tree';
|
|
2
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import { SimpleFeature } from '@jbrowse/core/util';
|
|
4
|
+
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
5
|
+
import type { Feature, Region } from '@jbrowse/core/util';
|
|
4
6
|
export declare function featureData(line: string, uniqueId: string, flip: boolean, names?: string[]): SimpleFeature;
|
|
5
7
|
export default class BedpeAdapter extends BaseFeatureDataAdapter {
|
|
6
8
|
protected bedpeFeatures?: Promise<{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import IntervalTree from '@flatten-js/interval-tree';
|
|
2
|
+
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import { SimpleFeature, fetchAndMaybeUnzip } from '@jbrowse/core/util';
|
|
2
4
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
3
5
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
4
|
-
import { SimpleFeature, fetchAndMaybeUnzip, } from '@jbrowse/core/util';
|
|
5
|
-
import IntervalTree from '@flatten-js/interval-tree';
|
|
6
6
|
const svTypes = new Set(['DUP', 'TRA', 'INV', 'CNV', 'DEL']);
|
|
7
7
|
export function featureData(line, uniqueId, flip, names) {
|
|
8
8
|
const l = line.split('\t');
|
|
@@ -37,7 +37,7 @@ export function featureData(line, uniqueId, flip, names) {
|
|
|
37
37
|
end: end2,
|
|
38
38
|
strand: strand2,
|
|
39
39
|
},
|
|
40
|
-
...(ALT ? { ALT: [ALT] } : {}),
|
|
40
|
+
...(ALT ? { ALT: [ALT] } : {}),
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
function parseStrand(strand) {
|
|
@@ -62,7 +62,6 @@ class BedpeAdapter extends BaseFeatureDataAdapter {
|
|
|
62
62
|
const bedLoc = this.getConf('bedpeLocation');
|
|
63
63
|
const loc = openLocation(bedLoc, pm);
|
|
64
64
|
const buffer = await fetchAndMaybeUnzip(loc, opts);
|
|
65
|
-
// 512MB max chrome string length is 512MB
|
|
66
65
|
if (buffer.length > 536870888) {
|
|
67
66
|
throw new Error('Data exceeds maximum string length (512MB)');
|
|
68
67
|
}
|
|
@@ -158,7 +157,7 @@ class BedpeAdapter extends BaseFeatureDataAdapter {
|
|
|
158
157
|
observer.next(f);
|
|
159
158
|
});
|
|
160
159
|
observer.complete();
|
|
161
|
-
}, opts.
|
|
160
|
+
}, opts.stopToken);
|
|
162
161
|
}
|
|
163
162
|
freeResources() { }
|
|
164
163
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
declare const BedpeAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
/**
|
|
3
|
-
* #slot
|
|
4
|
-
* can be plaintext or gzipped, not indexed so loaded into memory on startup
|
|
5
|
-
*/
|
|
6
2
|
bedpeLocation: {
|
|
7
3
|
type: string;
|
|
8
4
|
defaultValue: {
|
|
@@ -10,9 +6,6 @@ declare const BedpeAdapter: import("@jbrowse/core/configuration/configurationSch
|
|
|
10
6
|
locationType: string;
|
|
11
7
|
};
|
|
12
8
|
};
|
|
13
|
-
/**
|
|
14
|
-
* #slot
|
|
15
|
-
*/
|
|
16
9
|
columnNames: {
|
|
17
10
|
type: string;
|
|
18
11
|
description: string;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
-
|
|
3
|
-
* #config BedpeAdapter
|
|
4
|
-
* intended for SVs in a single assembly
|
|
5
|
-
*/
|
|
6
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
function x() { }
|
|
7
3
|
const BedpeAdapter = ConfigurationSchema('BedpeAdapter', {
|
|
8
|
-
/**
|
|
9
|
-
* #slot
|
|
10
|
-
* can be plaintext or gzipped, not indexed so loaded into memory on startup
|
|
11
|
-
*/
|
|
12
4
|
bedpeLocation: {
|
|
13
5
|
type: 'fileLocation',
|
|
14
6
|
defaultValue: {
|
|
@@ -16,9 +8,6 @@ const BedpeAdapter = ConfigurationSchema('BedpeAdapter', {
|
|
|
16
8
|
locationType: 'UriLocation',
|
|
17
9
|
},
|
|
18
10
|
},
|
|
19
|
-
/**
|
|
20
|
-
* #slot
|
|
21
|
-
*/
|
|
22
11
|
columnNames: {
|
|
23
12
|
type: 'stringArray',
|
|
24
13
|
description: 'List of column names',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
2
|
export default function BedpeAdapterF(pluginManager: PluginManager): void;
|