@jbrowse/plugin-bed 2.5.0 → 2.6.2
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.js +1 -2
- package/dist/BedAdapter/configSchema.js +0 -1
- package/dist/BedAdapter/index.js +0 -1
- package/dist/BedTabixAdapter/BedTabixAdapter.js +1 -2
- package/dist/BedTabixAdapter/configSchema.js +0 -1
- package/dist/BedTabixAdapter/index.js +0 -1
- package/dist/BedpeAdapter/BedpeAdapter.d.ts +2 -2
- package/dist/BedpeAdapter/BedpeAdapter.js +11 -6
- package/dist/BedpeAdapter/configSchema.js +0 -1
- package/dist/BedpeAdapter/index.js +0 -1
- package/dist/BigBedAdapter/BigBedAdapter.js +2 -3
- package/dist/BigBedAdapter/configSchema.js +0 -1
- package/dist/BigBedAdapter/index.js +0 -1
- package/dist/index.js +8 -1
- package/dist/util.js +1 -3
- package/esm/BedAdapter/BedAdapter.js +1 -2
- package/esm/BedAdapter/configSchema.js +0 -1
- package/esm/BedAdapter/index.js +0 -1
- package/esm/BedTabixAdapter/BedTabixAdapter.js +1 -2
- package/esm/BedTabixAdapter/configSchema.js +0 -1
- package/esm/BedTabixAdapter/index.js +0 -1
- package/esm/BedpeAdapter/BedpeAdapter.d.ts +2 -2
- package/esm/BedpeAdapter/BedpeAdapter.js +11 -6
- package/esm/BedpeAdapter/configSchema.js +0 -1
- package/esm/BedpeAdapter/index.js +0 -1
- package/esm/BigBedAdapter/BigBedAdapter.js +2 -3
- package/esm/BigBedAdapter/configSchema.js +0 -1
- package/esm/BigBedAdapter/index.js +0 -1
- package/esm/index.js +8 -1
- package/esm/util.js +1 -3
- package/package.json +4 -5
- package/dist/BedAdapter/BedAdapter.js.map +0 -1
- package/dist/BedAdapter/configSchema.js.map +0 -1
- package/dist/BedAdapter/index.js.map +0 -1
- package/dist/BedTabixAdapter/BedTabixAdapter.js.map +0 -1
- package/dist/BedTabixAdapter/configSchema.js.map +0 -1
- package/dist/BedTabixAdapter/index.js.map +0 -1
- package/dist/BedpeAdapter/BedpeAdapter.js.map +0 -1
- package/dist/BedpeAdapter/configSchema.js.map +0 -1
- package/dist/BedpeAdapter/index.js.map +0 -1
- package/dist/BigBedAdapter/BigBedAdapter.js.map +0 -1
- package/dist/BigBedAdapter/configSchema.js.map +0 -1
- package/dist/BigBedAdapter/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/util.js.map +0 -1
- package/esm/BedAdapter/BedAdapter.js.map +0 -1
- package/esm/BedAdapter/configSchema.js.map +0 -1
- package/esm/BedAdapter/index.js.map +0 -1
- package/esm/BedTabixAdapter/BedTabixAdapter.js.map +0 -1
- package/esm/BedTabixAdapter/configSchema.js.map +0 -1
- package/esm/BedTabixAdapter/index.js.map +0 -1
- package/esm/BedpeAdapter/BedpeAdapter.js.map +0 -1
- package/esm/BedpeAdapter/configSchema.js.map +0 -1
- package/esm/BedpeAdapter/index.js.map +0 -1
- package/esm/BigBedAdapter/BigBedAdapter.js.map +0 -1
- package/esm/BigBedAdapter/configSchema.js.map +0 -1
- package/esm/BigBedAdapter/index.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/util.js.map +0 -1
- package/src/BedAdapter/BedAdapter.test.ts +0 -166
- package/src/BedAdapter/BedAdapter.ts +0 -171
- package/src/BedAdapter/__snapshots__/BedAdapter.test.ts.snap +0 -437
- package/src/BedAdapter/configSchema.ts +0 -69
- package/src/BedAdapter/index.ts +0 -16
- package/src/BedAdapter/test_data/gwas.bed +0 -20
- package/src/BedAdapter/test_data/volvox-autosql.bed +0 -1
- package/src/BedAdapter/test_data/volvox-bed12.bed +0 -4
- package/src/BedAdapter/test_data/volvox.sort.bed +0 -109
- package/src/BedAdapter/test_data/volvox.sort.with.header.bed +0 -121
- package/src/BedTabixAdapter/BedTabixAdapter.test.ts +0 -196
- package/src/BedTabixAdapter/BedTabixAdapter.ts +0 -105
- package/src/BedTabixAdapter/__snapshots__/BedTabixAdapter.test.ts.snap +0 -437
- package/src/BedTabixAdapter/configSchema.ts +0 -71
- package/src/BedTabixAdapter/index.ts +0 -16
- package/src/BedTabixAdapter/test_data/gwas.bed.gz +0 -0
- package/src/BedTabixAdapter/test_data/gwas.bed.gz.tbi +0 -0
- package/src/BedTabixAdapter/test_data/volvox-autosql.bed.gz +0 -0
- package/src/BedTabixAdapter/test_data/volvox-autosql.bed.gz.tbi +0 -0
- package/src/BedTabixAdapter/test_data/volvox-bed12.bed.gz +0 -0
- package/src/BedTabixAdapter/test_data/volvox-bed12.bed.gz.tbi +0 -0
- package/src/BedTabixAdapter/test_data/volvox.sort.bed.gz +0 -0
- package/src/BedTabixAdapter/test_data/volvox.sort.bed.gz.tbi +0 -0
- package/src/BedTabixAdapter/test_data/volvox.sort.with.header.bed.gz +0 -0
- package/src/BedTabixAdapter/test_data/volvox.sort.with.header.bed.gz.tbi +0 -0
- package/src/BedpeAdapter/BedpeAdapter.ts +0 -202
- package/src/BedpeAdapter/configSchema.ts +0 -34
- package/src/BedpeAdapter/index.ts +0 -16
- package/src/BigBedAdapter/BigBedAdapter.test.ts +0 -28
- package/src/BigBedAdapter/BigBedAdapter.ts +0 -130
- package/src/BigBedAdapter/__snapshots__/BigBedAdapter.test.ts.snap +0 -254
- package/src/BigBedAdapter/configSchema.ts +0 -22
- package/src/BigBedAdapter/index.ts +0 -16
- package/src/BigBedAdapter/test_data/volvox.bb +0 -0
- package/src/__snapshots__/index.test.ts.snap +0 -3
- package/src/index.test.ts +0 -16
- package/src/index.ts +0 -120
- package/src/util.ts +0 -181
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseFeatureDataAdapter,
|
|
3
|
-
BaseOptions,
|
|
4
|
-
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
5
|
-
import { openLocation } from '@jbrowse/core/util/io'
|
|
6
|
-
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
7
|
-
import { Region, Feature, SimpleFeature } from '@jbrowse/core/util'
|
|
8
|
-
import IntervalTree from '@flatten-js/interval-tree'
|
|
9
|
-
import { unzip } from '@gmod/bgzf-filehandle'
|
|
10
|
-
|
|
11
|
-
function isGzip(buf: Buffer) {
|
|
12
|
-
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function featureData(
|
|
16
|
-
line: string,
|
|
17
|
-
uniqueId: string,
|
|
18
|
-
flip: boolean,
|
|
19
|
-
names?: string[],
|
|
20
|
-
) {
|
|
21
|
-
const l = line.split('\t')
|
|
22
|
-
const ref1 = l[flip ? 3 : 0]
|
|
23
|
-
const start1 = +l[flip ? 4 : 1]
|
|
24
|
-
const end1 = +l[flip ? 5 : 2]
|
|
25
|
-
const ref2 = +l[!flip ? 3 : 0]
|
|
26
|
-
const start2 = +l[!flip ? 4 : 1]
|
|
27
|
-
const end2 = +l[!flip ? 5 : 2]
|
|
28
|
-
const name = l[6]
|
|
29
|
-
const score = +l[7]
|
|
30
|
-
const strand1 = parseStrand(l[8])
|
|
31
|
-
const strand2 = parseStrand(l[9])
|
|
32
|
-
const extra = l.slice(9)
|
|
33
|
-
const rest = names
|
|
34
|
-
? Object.fromEntries(names.slice(9).map((n, idx) => [n, extra[idx]]))
|
|
35
|
-
: extra
|
|
36
|
-
|
|
37
|
-
return new SimpleFeature({
|
|
38
|
-
start: start1,
|
|
39
|
-
end: end1,
|
|
40
|
-
refName: ref1,
|
|
41
|
-
strand: strand1,
|
|
42
|
-
name,
|
|
43
|
-
...rest,
|
|
44
|
-
score,
|
|
45
|
-
uniqueId,
|
|
46
|
-
mate: { refName: ref2, start: start2, end: end2, strand: strand2 },
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function parseStrand(strand: string) {
|
|
51
|
-
if (strand === '+') {
|
|
52
|
-
return 1
|
|
53
|
-
} else if (strand === '-') {
|
|
54
|
-
return -1
|
|
55
|
-
} else if (strand === '.') {
|
|
56
|
-
return 0
|
|
57
|
-
} else {
|
|
58
|
-
return undefined
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default class BedpeAdapter extends BaseFeatureDataAdapter {
|
|
63
|
-
protected bedpeFeatures?: Promise<{
|
|
64
|
-
header: string
|
|
65
|
-
feats1: Record<string, string[]>
|
|
66
|
-
feats2: Record<string, string[]>
|
|
67
|
-
columnNames: string[]
|
|
68
|
-
}>
|
|
69
|
-
|
|
70
|
-
protected intervalTrees: {
|
|
71
|
-
[key: string]: Promise<IntervalTree | undefined> | undefined
|
|
72
|
-
} = {}
|
|
73
|
-
|
|
74
|
-
public static capabilities = ['getFeatures', 'getRefNames']
|
|
75
|
-
|
|
76
|
-
private async loadDataP(opts: BaseOptions = {}) {
|
|
77
|
-
const pm = this.pluginManager
|
|
78
|
-
const bedLoc = this.getConf('bedpeLocation')
|
|
79
|
-
const buf = await openLocation(bedLoc, pm).readFile(opts)
|
|
80
|
-
const buffer = isGzip(buf) ? await unzip(buf) : buf
|
|
81
|
-
// 512MB max chrome string length is 512MB
|
|
82
|
-
if (buffer.length > 536_870_888) {
|
|
83
|
-
throw new Error('Data exceeds maximum string length (512MB)')
|
|
84
|
-
}
|
|
85
|
-
const data = new TextDecoder('utf8', { fatal: true }).decode(buffer)
|
|
86
|
-
const lines = data.split(/\n|\r\n|\r/).filter(f => !!f)
|
|
87
|
-
const headerLines = []
|
|
88
|
-
let i = 0
|
|
89
|
-
for (; i < lines.length && lines[i].startsWith('#'); i++) {
|
|
90
|
-
headerLines.push(lines[i])
|
|
91
|
-
}
|
|
92
|
-
const header = headerLines.join('\n')
|
|
93
|
-
const feats1 = {} as Record<string, string[]>
|
|
94
|
-
const feats2 = {} as Record<string, string[]>
|
|
95
|
-
for (; i < lines.length; i++) {
|
|
96
|
-
const line = lines[i]
|
|
97
|
-
const cols = line.split('\t')
|
|
98
|
-
const r1 = cols[0]
|
|
99
|
-
const r2 = cols[3]
|
|
100
|
-
if (!feats1[r1]) {
|
|
101
|
-
feats1[r1] = []
|
|
102
|
-
}
|
|
103
|
-
if (!feats2[r2]) {
|
|
104
|
-
feats2[r2] = []
|
|
105
|
-
}
|
|
106
|
-
feats1[r1].push(line)
|
|
107
|
-
feats2[r2].push(line)
|
|
108
|
-
}
|
|
109
|
-
const columnNames = this.getConf('columnNames')
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
header,
|
|
113
|
-
feats1,
|
|
114
|
-
feats2,
|
|
115
|
-
columnNames,
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
private async loadData(opts: BaseOptions = {}) {
|
|
120
|
-
if (!this.bedpeFeatures) {
|
|
121
|
-
this.bedpeFeatures = this.loadDataP(opts).catch(e => {
|
|
122
|
-
this.bedpeFeatures = undefined
|
|
123
|
-
throw e
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return this.bedpeFeatures
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
public async getRefNames(opts: BaseOptions = {}) {
|
|
131
|
-
const { feats1, feats2 } = await this.loadData(opts)
|
|
132
|
-
return [...new Set([...Object.keys(feats1), ...Object.keys(feats2)])]
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async getHeader(opts: BaseOptions = {}) {
|
|
136
|
-
const { header } = await this.loadData(opts)
|
|
137
|
-
return header
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async getNames() {
|
|
141
|
-
const { header, columnNames } = await this.loadData()
|
|
142
|
-
if (columnNames.length) {
|
|
143
|
-
return columnNames
|
|
144
|
-
}
|
|
145
|
-
const defs = header.split(/\n|\r\n|\r/).filter(f => !!f)
|
|
146
|
-
const defline = defs[defs.length - 1]
|
|
147
|
-
return defline?.includes('\t')
|
|
148
|
-
? defline
|
|
149
|
-
.slice(1)
|
|
150
|
-
.split('\t')
|
|
151
|
-
.map(field => field.trim())
|
|
152
|
-
: undefined
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private async loadFeatureTreeP(refName: string) {
|
|
156
|
-
const { feats1, feats2 } = await this.loadData()
|
|
157
|
-
const lines1 = feats1[refName]
|
|
158
|
-
const lines2 = feats2[refName]
|
|
159
|
-
const names = await this.getNames()
|
|
160
|
-
|
|
161
|
-
const intervalTree = new IntervalTree()
|
|
162
|
-
const ret1 = lines1?.map((f, i) => {
|
|
163
|
-
const uniqueId = `${this.id}-${refName}-${i}`
|
|
164
|
-
return featureData(f, uniqueId, false, names)
|
|
165
|
-
})
|
|
166
|
-
const ret2 = lines2?.map((f, i) => {
|
|
167
|
-
const uniqueId = `${this.id}-${refName}-${i}`
|
|
168
|
-
return featureData(f, uniqueId, true, names)
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
for (const obj of ret1) {
|
|
172
|
-
intervalTree.insert([obj.get('start'), obj.get('end')], obj)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
for (const obj of ret2) {
|
|
176
|
-
intervalTree.insert([obj.get('start'), obj.get('end')], obj)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return intervalTree
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
private async loadFeatureTree(refName: string) {
|
|
183
|
-
if (!this.intervalTrees[refName]) {
|
|
184
|
-
this.intervalTrees[refName] = this.loadFeatureTreeP(refName).catch(e => {
|
|
185
|
-
this.intervalTrees[refName] = undefined
|
|
186
|
-
throw e
|
|
187
|
-
})
|
|
188
|
-
}
|
|
189
|
-
return this.intervalTrees[refName]
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public getFeatures(query: Region, opts: BaseOptions = {}) {
|
|
193
|
-
return ObservableCreate<Feature>(async observer => {
|
|
194
|
-
const { start, end, refName } = query
|
|
195
|
-
const intervalTree = await this.loadFeatureTree(refName)
|
|
196
|
-
intervalTree?.search([start, end]).forEach(f => observer.next(f))
|
|
197
|
-
observer.complete()
|
|
198
|
-
}, opts.signal)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
public freeResources(): void {}
|
|
202
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* #config BedpeAdapter
|
|
5
|
-
* intended for SVs in a single assembly
|
|
6
|
-
*/
|
|
7
|
-
function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
8
|
-
|
|
9
|
-
const BedpeAdapter = ConfigurationSchema(
|
|
10
|
-
'BedpeAdapter',
|
|
11
|
-
{
|
|
12
|
-
/**
|
|
13
|
-
* #slot
|
|
14
|
-
* can be plaintext or gzipped, not indexed so loaded into memory on startup
|
|
15
|
-
*/
|
|
16
|
-
bedpeLocation: {
|
|
17
|
-
type: 'fileLocation',
|
|
18
|
-
defaultValue: {
|
|
19
|
-
uri: '/path/to/my.bedpe.gz',
|
|
20
|
-
locationType: 'UriLocation',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
/**
|
|
24
|
-
* #slot
|
|
25
|
-
*/
|
|
26
|
-
columnNames: {
|
|
27
|
-
type: 'stringArray',
|
|
28
|
-
description: 'List of column names',
|
|
29
|
-
defaultValue: [],
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
{ explicitlyTyped: true },
|
|
33
|
-
)
|
|
34
|
-
export default BedpeAdapter
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
-
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
|
|
3
|
-
|
|
4
|
-
import configSchema from './configSchema'
|
|
5
|
-
|
|
6
|
-
export default (pluginManager: PluginManager) => {
|
|
7
|
-
pluginManager.addAdapterType(
|
|
8
|
-
() =>
|
|
9
|
-
new AdapterType({
|
|
10
|
-
name: 'BedpeAdapter',
|
|
11
|
-
displayName: 'BEDPE adapter',
|
|
12
|
-
configSchema,
|
|
13
|
-
getAdapterClass: () => import('./BedpeAdapter').then(r => r.default),
|
|
14
|
-
}),
|
|
15
|
-
)
|
|
16
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { toArray } from 'rxjs/operators'
|
|
2
|
-
import { firstValueFrom } from 'rxjs'
|
|
3
|
-
import BigBedAdapter from './BigBedAdapter'
|
|
4
|
-
import configSchema from './configSchema'
|
|
5
|
-
|
|
6
|
-
test('adapter can fetch features from volvox.bb', async () => {
|
|
7
|
-
const adapter = new BigBedAdapter(
|
|
8
|
-
configSchema.create({
|
|
9
|
-
bigBedLocation: {
|
|
10
|
-
localPath: require.resolve('./test_data/volvox.bb'),
|
|
11
|
-
locationType: 'LocalPathLocation',
|
|
12
|
-
},
|
|
13
|
-
}),
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
const features = adapter.getFeatures({
|
|
17
|
-
assemblyName: 'volvox',
|
|
18
|
-
refName: 'ctgA',
|
|
19
|
-
start: 0,
|
|
20
|
-
end: 20000,
|
|
21
|
-
})
|
|
22
|
-
expect(await adapter.hasDataForRefName('ctgA')).toBe(true)
|
|
23
|
-
expect(await adapter.hasDataForRefName('ctgB')).toBe(false)
|
|
24
|
-
|
|
25
|
-
const featuresArray = await firstValueFrom(features.pipe(toArray()))
|
|
26
|
-
const featuresJsonArray = featuresArray.map(f => f.toJSON())
|
|
27
|
-
expect(featuresJsonArray).toMatchSnapshot()
|
|
28
|
-
})
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { BigBed } from '@gmod/bbi'
|
|
3
|
-
import BED from '@gmod/bed'
|
|
4
|
-
import {
|
|
5
|
-
BaseFeatureDataAdapter,
|
|
6
|
-
BaseOptions,
|
|
7
|
-
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
8
|
-
import { Region } from '@jbrowse/core/util/types'
|
|
9
|
-
import { openLocation } from '@jbrowse/core/util/io'
|
|
10
|
-
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
11
|
-
import SimpleFeature, { Feature } from '@jbrowse/core/util/simpleFeature'
|
|
12
|
-
import { map, mergeAll } from 'rxjs/operators'
|
|
13
|
-
import { readConfObject } from '@jbrowse/core/configuration'
|
|
14
|
-
import { ucscProcessedTranscript } from '../util'
|
|
15
|
-
|
|
16
|
-
function isUCSC(f: Feature) {
|
|
17
|
-
return f.get('thickStart') && f.get('blockCount') && f.get('strand') !== 0
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default class BigBedAdapter extends BaseFeatureDataAdapter {
|
|
21
|
-
private cached?: Promise<{ bigbed: BigBed; header: any; parser: BED }>
|
|
22
|
-
|
|
23
|
-
public async configurePre(opts?: BaseOptions) {
|
|
24
|
-
const bigbed = new BigBed({
|
|
25
|
-
filehandle: openLocation(
|
|
26
|
-
readConfObject(this.config, 'bigBedLocation'),
|
|
27
|
-
this.pluginManager,
|
|
28
|
-
),
|
|
29
|
-
})
|
|
30
|
-
const header = await bigbed.getHeader(opts)
|
|
31
|
-
const parser = new BED({ autoSql: header.autoSql })
|
|
32
|
-
return { bigbed, header, parser }
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public async configure(opts?: BaseOptions) {
|
|
36
|
-
if (!this.cached) {
|
|
37
|
-
this.cached = this.configurePre(opts).catch(e => {
|
|
38
|
-
this.cached = undefined
|
|
39
|
-
throw e
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
return this.cached
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public async getRefNames(opts?: BaseOptions) {
|
|
46
|
-
const { header } = await this.configure(opts)
|
|
47
|
-
return Object.keys(header.refsByName)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async getHeader(opts?: BaseOptions) {
|
|
51
|
-
const { parser, header } = await this.configure(opts)
|
|
52
|
-
const { version, fileType } = header
|
|
53
|
-
const { fields, ...rest } = parser.autoSql
|
|
54
|
-
return {
|
|
55
|
-
version,
|
|
56
|
-
fileType,
|
|
57
|
-
autoSql: { ...rest },
|
|
58
|
-
fields: Object.fromEntries(
|
|
59
|
-
fields.map(({ name, comment }) => [name, comment]),
|
|
60
|
-
),
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public getFeatures(region: Region, opts: BaseOptions = {}) {
|
|
65
|
-
const { refName, start, end } = region
|
|
66
|
-
const { signal } = opts
|
|
67
|
-
return ObservableCreate<Feature>(async observer => {
|
|
68
|
-
try {
|
|
69
|
-
const { parser, bigbed } = await this.configure(opts)
|
|
70
|
-
const ob = await bigbed.getFeatureStream(refName, start, end, {
|
|
71
|
-
signal,
|
|
72
|
-
basesPerSpan: end - start,
|
|
73
|
-
})
|
|
74
|
-
ob.pipe(
|
|
75
|
-
mergeAll(),
|
|
76
|
-
map(r => {
|
|
77
|
-
const data = parser.parseLine(
|
|
78
|
-
`${refName}\t${r.start}\t${r.end}\t${r.rest}`,
|
|
79
|
-
{
|
|
80
|
-
uniqueId: r.uniqueId as string,
|
|
81
|
-
},
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
const { blockCount, blockSizes, blockStarts, chromStarts } = data
|
|
85
|
-
if (blockCount) {
|
|
86
|
-
const starts = chromStarts || blockStarts || []
|
|
87
|
-
const sizes = blockSizes
|
|
88
|
-
const blocksOffset = r.start
|
|
89
|
-
data.subfeatures = []
|
|
90
|
-
|
|
91
|
-
for (let b = 0; b < blockCount; b += 1) {
|
|
92
|
-
const bmin = (starts[b] || 0) + blocksOffset
|
|
93
|
-
const bmax = bmin + (sizes[b] || 0)
|
|
94
|
-
data.subfeatures.push({
|
|
95
|
-
uniqueId: `${r.uniqueId}-${b}`,
|
|
96
|
-
start: bmin,
|
|
97
|
-
end: bmax,
|
|
98
|
-
type: 'block',
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (r.uniqueId === undefined) {
|
|
103
|
-
throw new Error('invalid bbi feature')
|
|
104
|
-
}
|
|
105
|
-
const { chromStart, chromEnd, chrom, ...rest } = data
|
|
106
|
-
|
|
107
|
-
const f = new SimpleFeature({
|
|
108
|
-
id: `${this.id}-${r.uniqueId}`,
|
|
109
|
-
data: {
|
|
110
|
-
...rest,
|
|
111
|
-
start: r.start,
|
|
112
|
-
end: r.end,
|
|
113
|
-
refName,
|
|
114
|
-
},
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
// collection of heuristics for suggesting that this feature
|
|
118
|
-
// should be converted to a gene, CNV bigbed has many gene like
|
|
119
|
-
// features including thickStart and blockCount but no strand
|
|
120
|
-
return isUCSC(f) ? ucscProcessedTranscript(f) : f
|
|
121
|
-
}),
|
|
122
|
-
).subscribe(observer)
|
|
123
|
-
} catch (e) {
|
|
124
|
-
observer.error(e)
|
|
125
|
-
}
|
|
126
|
-
}, opts.signal)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
public freeResources(): void {}
|
|
130
|
-
}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`adapter can fetch features from volvox.bb 1`] = `
|
|
4
|
-
[
|
|
5
|
-
{
|
|
6
|
-
"end": 9000,
|
|
7
|
-
"geneBioType": "-",
|
|
8
|
-
"geneId": "EDEN",
|
|
9
|
-
"geneName": "EDEN",
|
|
10
|
-
"method": "-",
|
|
11
|
-
"name": "EDEN.1",
|
|
12
|
-
"refName": "ctgA",
|
|
13
|
-
"reserved": "0,0,0",
|
|
14
|
-
"score": 1000,
|
|
15
|
-
"start": 1049,
|
|
16
|
-
"strand": 1,
|
|
17
|
-
"subfeatures": [
|
|
18
|
-
{
|
|
19
|
-
"end": 1200,
|
|
20
|
-
"parentId": "test-bb-358912",
|
|
21
|
-
"start": 1049,
|
|
22
|
-
"strand": 1,
|
|
23
|
-
"type": "five_prime_UTR",
|
|
24
|
-
"uniqueId": "test-bb-358912-0",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"end": 1500,
|
|
28
|
-
"parentId": "test-bb-358912",
|
|
29
|
-
"start": 1200,
|
|
30
|
-
"strand": 1,
|
|
31
|
-
"type": "CDS",
|
|
32
|
-
"uniqueId": "test-bb-358912-1",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"end": 3902,
|
|
36
|
-
"parentId": "test-bb-358912",
|
|
37
|
-
"start": 2999,
|
|
38
|
-
"strand": 1,
|
|
39
|
-
"type": "CDS",
|
|
40
|
-
"uniqueId": "test-bb-358912-2",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"end": 5500,
|
|
44
|
-
"parentId": "test-bb-358912",
|
|
45
|
-
"start": 4999,
|
|
46
|
-
"strand": 1,
|
|
47
|
-
"type": "CDS",
|
|
48
|
-
"uniqueId": "test-bb-358912-3",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"end": 7608,
|
|
52
|
-
"parentId": "test-bb-358912",
|
|
53
|
-
"start": 6999,
|
|
54
|
-
"strand": 1,
|
|
55
|
-
"type": "CDS",
|
|
56
|
-
"uniqueId": "test-bb-358912-4",
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"end": 9000,
|
|
60
|
-
"parentId": "test-bb-358912",
|
|
61
|
-
"start": 7608,
|
|
62
|
-
"strand": 1,
|
|
63
|
-
"type": "three_prime_UTR",
|
|
64
|
-
"uniqueId": "test-bb-358912-5",
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
"tags": "-",
|
|
68
|
-
"type": "mRNA",
|
|
69
|
-
"uniqueId": "test-bb-358912",
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"end": 9000,
|
|
73
|
-
"geneBioType": "-",
|
|
74
|
-
"geneId": "EDEN",
|
|
75
|
-
"geneName": "EDEN",
|
|
76
|
-
"method": "-",
|
|
77
|
-
"name": "EDEN.2",
|
|
78
|
-
"refName": "ctgA",
|
|
79
|
-
"reserved": "0,0,0",
|
|
80
|
-
"score": 1000,
|
|
81
|
-
"start": 1049,
|
|
82
|
-
"strand": 1,
|
|
83
|
-
"subfeatures": [
|
|
84
|
-
{
|
|
85
|
-
"end": 1200,
|
|
86
|
-
"parentId": "test-bb-359006",
|
|
87
|
-
"start": 1049,
|
|
88
|
-
"strand": 1,
|
|
89
|
-
"type": "five_prime_UTR",
|
|
90
|
-
"uniqueId": "test-bb-359006-0",
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
"end": 1500,
|
|
94
|
-
"parentId": "test-bb-359006",
|
|
95
|
-
"start": 1200,
|
|
96
|
-
"strand": 1,
|
|
97
|
-
"type": "CDS",
|
|
98
|
-
"uniqueId": "test-bb-359006-1",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"end": 5500,
|
|
102
|
-
"parentId": "test-bb-359006",
|
|
103
|
-
"start": 4999,
|
|
104
|
-
"strand": 1,
|
|
105
|
-
"type": "CDS",
|
|
106
|
-
"uniqueId": "test-bb-359006-2",
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"end": 7608,
|
|
110
|
-
"parentId": "test-bb-359006",
|
|
111
|
-
"start": 6999,
|
|
112
|
-
"strand": 1,
|
|
113
|
-
"type": "CDS",
|
|
114
|
-
"uniqueId": "test-bb-359006-3",
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
"end": 9000,
|
|
118
|
-
"parentId": "test-bb-359006",
|
|
119
|
-
"start": 7608,
|
|
120
|
-
"strand": 1,
|
|
121
|
-
"type": "three_prime_UTR",
|
|
122
|
-
"uniqueId": "test-bb-359006-4",
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
"tags": "-",
|
|
126
|
-
"type": "mRNA",
|
|
127
|
-
"uniqueId": "test-bb-359006",
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
"end": 9000,
|
|
131
|
-
"geneBioType": "-",
|
|
132
|
-
"geneId": "EDEN",
|
|
133
|
-
"geneName": "EDEN",
|
|
134
|
-
"method": "-",
|
|
135
|
-
"name": "EDEN.3",
|
|
136
|
-
"refName": "ctgA",
|
|
137
|
-
"reserved": "0,0,0",
|
|
138
|
-
"score": 1000,
|
|
139
|
-
"start": 1299,
|
|
140
|
-
"strand": 1,
|
|
141
|
-
"subfeatures": [
|
|
142
|
-
{
|
|
143
|
-
"end": 1500,
|
|
144
|
-
"parentId": "test-bb-359091",
|
|
145
|
-
"start": 1299,
|
|
146
|
-
"strand": 1,
|
|
147
|
-
"type": "five_prime_UTR",
|
|
148
|
-
"uniqueId": "test-bb-359091-0",
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
"end": 3300,
|
|
152
|
-
"parentId": "test-bb-359091",
|
|
153
|
-
"start": 2999,
|
|
154
|
-
"strand": 1,
|
|
155
|
-
"type": "five_prime_UTR",
|
|
156
|
-
"uniqueId": "test-bb-359091-1",
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
"end": 3902,
|
|
160
|
-
"parentId": "test-bb-359091",
|
|
161
|
-
"start": 3300,
|
|
162
|
-
"strand": 1,
|
|
163
|
-
"type": "CDS",
|
|
164
|
-
"uniqueId": "test-bb-359091-2",
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
"end": 5500,
|
|
168
|
-
"parentId": "test-bb-359091",
|
|
169
|
-
"start": 4999,
|
|
170
|
-
"strand": 1,
|
|
171
|
-
"type": "CDS",
|
|
172
|
-
"uniqueId": "test-bb-359091-3",
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
"end": 7600,
|
|
176
|
-
"parentId": "test-bb-359091",
|
|
177
|
-
"start": 6999,
|
|
178
|
-
"strand": 1,
|
|
179
|
-
"type": "CDS",
|
|
180
|
-
"uniqueId": "test-bb-359091-4",
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
"end": 9000,
|
|
184
|
-
"parentId": "test-bb-359091",
|
|
185
|
-
"start": 7600,
|
|
186
|
-
"strand": 1,
|
|
187
|
-
"type": "three_prime_UTR",
|
|
188
|
-
"uniqueId": "test-bb-359091-5",
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
"tags": "-",
|
|
192
|
-
"type": "mRNA",
|
|
193
|
-
"uniqueId": "test-bb-359091",
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
"end": 23000,
|
|
197
|
-
"geneBioType": "-",
|
|
198
|
-
"geneId": "rna-Apple3",
|
|
199
|
-
"geneName": "rna-Apple3",
|
|
200
|
-
"method": "-",
|
|
201
|
-
"name": "rna-Apple3",
|
|
202
|
-
"refName": "ctgA",
|
|
203
|
-
"reserved": "0,0,0",
|
|
204
|
-
"score": 1000,
|
|
205
|
-
"start": 17399,
|
|
206
|
-
"strand": 1,
|
|
207
|
-
"subfeatures": [
|
|
208
|
-
{
|
|
209
|
-
"end": 17999,
|
|
210
|
-
"parentId": "test-bb-359185",
|
|
211
|
-
"start": 17399,
|
|
212
|
-
"strand": 1,
|
|
213
|
-
"type": "five_prime_UTR",
|
|
214
|
-
"uniqueId": "test-bb-359185-0",
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
"end": 18800,
|
|
218
|
-
"parentId": "test-bb-359185",
|
|
219
|
-
"start": 17999,
|
|
220
|
-
"strand": 1,
|
|
221
|
-
"type": "CDS",
|
|
222
|
-
"uniqueId": "test-bb-359185-1",
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
"end": 19500,
|
|
226
|
-
"parentId": "test-bb-359185",
|
|
227
|
-
"start": 18999,
|
|
228
|
-
"strand": 1,
|
|
229
|
-
"type": "CDS",
|
|
230
|
-
"uniqueId": "test-bb-359185-2",
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
"end": 21200,
|
|
234
|
-
"parentId": "test-bb-359185",
|
|
235
|
-
"start": 20999,
|
|
236
|
-
"strand": 1,
|
|
237
|
-
"type": "CDS",
|
|
238
|
-
"uniqueId": "test-bb-359185-3",
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
"end": 23000,
|
|
242
|
-
"parentId": "test-bb-359185",
|
|
243
|
-
"start": 21200,
|
|
244
|
-
"strand": 1,
|
|
245
|
-
"type": "three_prime_UTR",
|
|
246
|
-
"uniqueId": "test-bb-359185-4",
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
"tags": "-",
|
|
250
|
-
"type": "mRNA",
|
|
251
|
-
"uniqueId": "test-bb-359185",
|
|
252
|
-
},
|
|
253
|
-
]
|
|
254
|
-
`;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* #config BigBedAdapter
|
|
5
|
-
*/
|
|
6
|
-
function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
7
|
-
|
|
8
|
-
const BigBedAdapter = ConfigurationSchema(
|
|
9
|
-
'BigBedAdapter',
|
|
10
|
-
{
|
|
11
|
-
/**
|
|
12
|
-
* #slot
|
|
13
|
-
*/
|
|
14
|
-
bigBedLocation: {
|
|
15
|
-
type: 'fileLocation',
|
|
16
|
-
defaultValue: { uri: '/path/to/my.bb', locationType: 'UriLocation' },
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
{ explicitlyTyped: true },
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
export default BigBedAdapter
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
-
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
|
|
3
|
-
|
|
4
|
-
import configSchema from './configSchema'
|
|
5
|
-
|
|
6
|
-
export default (pluginManager: PluginManager) => {
|
|
7
|
-
pluginManager.addAdapterType(
|
|
8
|
-
() =>
|
|
9
|
-
new AdapterType({
|
|
10
|
-
name: 'BigBedAdapter',
|
|
11
|
-
displayName: 'BigBed adapter',
|
|
12
|
-
configSchema,
|
|
13
|
-
getAdapterClass: () => import('./BigBedAdapter').then(r => r.default),
|
|
14
|
-
}),
|
|
15
|
-
)
|
|
16
|
-
}
|