@jbrowse/plugin-alignments 1.5.1 → 1.5.5
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/AlignmentsFeatureDetail/index.d.ts +7 -4
- package/dist/AlignmentsTrack/index.d.ts +2 -0
- package/dist/BamAdapter/BamSlightlyLazyFeature.d.ts +1 -1
- package/dist/BamAdapter/index.d.ts +2 -4
- package/dist/CramAdapter/index.d.ts +1 -4
- package/dist/HtsgetBamAdapter/HtsgetBamAdapter.d.ts +2 -1
- package/dist/HtsgetBamAdapter/index.d.ts +2 -4
- package/dist/LinearAlignmentsDisplay/index.d.ts +2 -3
- package/dist/LinearPileupDisplay/index.d.ts +2 -2
- package/dist/LinearPileupDisplay/model.d.ts +1 -2
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.d.ts +1 -1
- package/dist/LinearSNPCoverageDisplay/index.d.ts +2 -2
- package/dist/LinearSNPCoverageDisplay/models/model.d.ts +1 -0
- package/dist/PileupRenderer/PileupRenderer.d.ts +20 -7
- package/dist/PileupRenderer/index.d.ts +2 -3
- package/dist/SNPCoverageAdapter/SNPCoverageAdapter.d.ts +38 -26
- package/dist/SNPCoverageAdapter/index.d.ts +1 -5
- package/dist/SNPCoverageRenderer/index.d.ts +3 -3
- package/dist/plugin-alignments.cjs.development.js +3779 -3677
- package/dist/plugin-alignments.cjs.development.js.map +1 -1
- package/dist/plugin-alignments.cjs.production.min.js +1 -1
- package/dist/plugin-alignments.cjs.production.min.js.map +1 -1
- package/dist/plugin-alignments.esm.js +3775 -3673
- package/dist/plugin-alignments.esm.js.map +1 -1
- package/package.json +4 -4
- package/src/AlignmentsFeatureDetail/__snapshots__/index.test.js.snap +8 -0
- package/src/AlignmentsFeatureDetail/{index.js → index.ts} +19 -3
- package/src/AlignmentsTrack/index.ts +36 -0
- package/src/BamAdapter/BamSlightlyLazyFeature.ts +14 -30
- package/src/BamAdapter/MismatchParser.test.ts +20 -0
- package/src/BamAdapter/MismatchParser.ts +6 -5
- package/src/BamAdapter/index.ts +11 -5
- package/src/CramAdapter/CramSlightlyLazyFeature.ts +1 -5
- package/src/CramAdapter/index.ts +11 -4
- package/src/HtsgetBamAdapter/HtsgetBamAdapter.ts +2 -2
- package/src/HtsgetBamAdapter/index.ts +18 -5
- package/src/LinearAlignmentsDisplay/index.ts +20 -3
- package/src/LinearAlignmentsDisplay/models/configSchema.test.js +8 -68
- package/src/LinearPileupDisplay/configSchema.test.js +2 -13
- package/src/LinearPileupDisplay/index.ts +19 -2
- package/src/LinearPileupDisplay/model.ts +15 -20
- package/src/LinearSNPCoverageDisplay/components/Tooltip.tsx +17 -12
- package/src/LinearSNPCoverageDisplay/index.ts +19 -2
- package/src/LinearSNPCoverageDisplay/models/configSchema.test.js +2 -13
- package/src/LinearSNPCoverageDisplay/models/model.ts +21 -0
- package/src/PileupRenderer/PileupRenderer.tsx +154 -128
- package/src/PileupRenderer/components/PileupRendering.tsx +2 -0
- package/src/PileupRenderer/configSchema.ts +2 -2
- package/src/PileupRenderer/index.ts +16 -3
- package/src/SNPCoverageAdapter/SNPCoverageAdapter.ts +95 -25
- package/src/SNPCoverageAdapter/index.ts +17 -5
- package/src/SNPCoverageRenderer/SNPCoverageRenderer.ts +60 -13
- package/src/SNPCoverageRenderer/configSchema.js +5 -0
- package/src/SNPCoverageRenderer/index.ts +24 -0
- package/src/index.ts +39 -204
- package/src/SNPCoverageAdapter/SNPCoverageAdapter.test.ts +0 -275
- package/src/SNPCoverageAdapter/__snapshots__/SNPCoverageAdapter.test.ts.snap +0 -579
- package/src/SNPCoverageRenderer/index.js +0 -11
package/src/index.ts
CHANGED
|
@@ -1,49 +1,21 @@
|
|
|
1
|
-
import { lazy } from 'react'
|
|
2
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
3
|
-
import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType'
|
|
4
|
-
import DisplayType from '@jbrowse/core/pluggableElementTypes/DisplayType'
|
|
5
|
-
import {
|
|
6
|
-
createBaseTrackConfig,
|
|
7
|
-
createBaseTrackModel,
|
|
8
|
-
} from '@jbrowse/core/pluggableElementTypes/models'
|
|
9
1
|
import { FileLocation } from '@jbrowse/core/util/types'
|
|
10
|
-
import TrackType from '@jbrowse/core/pluggableElementTypes/TrackType'
|
|
11
|
-
import WidgetType from '@jbrowse/core/pluggableElementTypes/WidgetType'
|
|
12
2
|
import Plugin from '@jbrowse/core/Plugin'
|
|
13
3
|
import PluginManager from '@jbrowse/core/PluginManager'
|
|
14
|
-
import { BaseLinearDisplayComponent } from '@jbrowse/plugin-linear-genome-view'
|
|
15
|
-
import { LinearWiggleDisplayReactComponent } from '@jbrowse/plugin-wiggle'
|
|
16
|
-
import {
|
|
17
|
-
configSchema as alignmentsFeatureDetailConfigSchema,
|
|
18
|
-
stateModelFactory as alignmentsFeatureDetailStateModelFactory,
|
|
19
|
-
} from './AlignmentsFeatureDetail'
|
|
20
|
-
import BamAdapterF from './BamAdapter'
|
|
21
4
|
import * as MismatchParser from './BamAdapter/MismatchParser'
|
|
22
|
-
import CramAdapterF from './CramAdapter'
|
|
23
|
-
import HtsgetBamAdapterF from './HtsgetBamAdapter'
|
|
24
|
-
import {
|
|
25
|
-
configSchemaFactory as linearAligmentsDisplayConfigSchemaFactory,
|
|
26
|
-
modelFactory as linearAlignmentsDisplayModelFactory,
|
|
27
|
-
ReactComponent as LinearAlignmentsDisplayReactComponent,
|
|
28
|
-
} from './LinearAlignmentsDisplay'
|
|
29
|
-
import {
|
|
30
|
-
configSchemaFactory as linearPileupDisplayConfigSchemaFactory,
|
|
31
|
-
modelFactory as linearPileupDisplayModelFactory,
|
|
32
|
-
} from './LinearPileupDisplay'
|
|
33
5
|
import { LinearPileupDisplayModel } from './LinearPileupDisplay/model'
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
import PileupRenderer, {
|
|
39
|
-
configSchema as pileupRendererConfigSchema,
|
|
40
|
-
ReactComponent as PileupRendererReactComponent,
|
|
41
|
-
} from './PileupRenderer'
|
|
6
|
+
|
|
7
|
+
import BamAdapterF from './CramAdapter'
|
|
8
|
+
import CramAdapterF from './BamAdapter'
|
|
9
|
+
import HtsgetBamAdapterF from './HtsgetBamAdapter'
|
|
42
10
|
import SNPCoverageAdapterF from './SNPCoverageAdapter'
|
|
43
|
-
import SNPCoverageRenderer
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
11
|
+
import SNPCoverageRendererF from './SNPCoverageRenderer'
|
|
12
|
+
import PileupRendererF from './PileupRenderer'
|
|
13
|
+
import LinearAlignmentsDisplayF from './LinearAlignmentsDisplay'
|
|
14
|
+
import LinearSNPCoverageDisplayF from './LinearSNPCoverageDisplay'
|
|
15
|
+
import LinearPileupDisplayF from './LinearPileupDisplay'
|
|
16
|
+
import AlignmentsTrackF from './AlignmentsTrack'
|
|
17
|
+
import AlignmentsFeatureWidgetF from './AlignmentsFeatureDetail'
|
|
18
|
+
|
|
47
19
|
import {
|
|
48
20
|
PileupGetGlobalValueForTag,
|
|
49
21
|
PileupGetVisibleModifications,
|
|
@@ -51,8 +23,8 @@ import {
|
|
|
51
23
|
import {
|
|
52
24
|
makeIndex,
|
|
53
25
|
makeIndexType,
|
|
54
|
-
AdapterGuesser,
|
|
55
26
|
getFileName,
|
|
27
|
+
AdapterGuesser,
|
|
56
28
|
TrackTypeGuesser,
|
|
57
29
|
} from '@jbrowse/core/util/tracks'
|
|
58
30
|
|
|
@@ -63,93 +35,19 @@ export default class AlignmentsPlugin extends Plugin {
|
|
|
63
35
|
name = 'AlignmentsPlugin'
|
|
64
36
|
|
|
65
37
|
install(pluginManager: PluginManager) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
),
|
|
80
|
-
})
|
|
81
|
-
const linearAlignmentsDisplay = pluginManager.getDisplayType(
|
|
82
|
-
'LinearAlignmentsDisplay',
|
|
83
|
-
)
|
|
84
|
-
// Add LinearAlignmentsDisplay here so that it has priority over the other
|
|
85
|
-
// linear displays (defaults to order the displays are added, but we have
|
|
86
|
-
// to add the Pileup and SNPCoverage displays first).
|
|
87
|
-
track.addDisplayType(linearAlignmentsDisplay)
|
|
88
|
-
return track
|
|
89
|
-
})
|
|
90
|
-
pluginManager.addDisplayType(() => {
|
|
91
|
-
const configSchema = linearPileupDisplayConfigSchemaFactory(pluginManager)
|
|
92
|
-
return new DisplayType({
|
|
93
|
-
name: 'LinearPileupDisplay',
|
|
94
|
-
configSchema,
|
|
95
|
-
stateModel: linearPileupDisplayModelFactory(
|
|
96
|
-
pluginManager,
|
|
97
|
-
configSchema,
|
|
98
|
-
),
|
|
99
|
-
trackType: 'AlignmentsTrack',
|
|
100
|
-
viewType: 'LinearGenomeView',
|
|
101
|
-
ReactComponent: BaseLinearDisplayComponent,
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
pluginManager.addDisplayType(() => {
|
|
105
|
-
const configSchema =
|
|
106
|
-
linearSNPCoverageDisplayConfigSchemaFactory(pluginManager)
|
|
107
|
-
return new DisplayType({
|
|
108
|
-
name: 'LinearSNPCoverageDisplay',
|
|
109
|
-
configSchema,
|
|
110
|
-
stateModel: linearSNPCoverageDisplayModelFactory(
|
|
111
|
-
pluginManager,
|
|
112
|
-
configSchema,
|
|
113
|
-
),
|
|
114
|
-
trackType: 'AlignmentsTrack',
|
|
115
|
-
viewType: 'LinearGenomeView',
|
|
116
|
-
ReactComponent: LinearWiggleDisplayReactComponent,
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
pluginManager.addDisplayType(() => {
|
|
120
|
-
const configSchema =
|
|
121
|
-
linearAligmentsDisplayConfigSchemaFactory(pluginManager)
|
|
122
|
-
return new DisplayType({
|
|
123
|
-
name: 'LinearAlignmentsDisplay',
|
|
124
|
-
configSchema,
|
|
125
|
-
stateModel: linearAlignmentsDisplayModelFactory(
|
|
126
|
-
pluginManager,
|
|
127
|
-
configSchema,
|
|
128
|
-
),
|
|
129
|
-
trackType: 'AlignmentsTrack',
|
|
130
|
-
viewType: 'LinearGenomeView',
|
|
131
|
-
ReactComponent: LinearAlignmentsDisplayReactComponent,
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
pluginManager.addWidgetType(
|
|
135
|
-
() =>
|
|
136
|
-
new WidgetType({
|
|
137
|
-
name: 'AlignmentsFeatureWidget',
|
|
138
|
-
heading: 'Feature details',
|
|
139
|
-
configSchema: alignmentsFeatureDetailConfigSchema,
|
|
140
|
-
stateModel: alignmentsFeatureDetailStateModelFactory(pluginManager),
|
|
141
|
-
ReactComponent: lazy(
|
|
142
|
-
() => import('./AlignmentsFeatureDetail/AlignmentsFeatureDetail'),
|
|
143
|
-
),
|
|
144
|
-
}),
|
|
145
|
-
)
|
|
146
|
-
pluginManager.addAdapterType(
|
|
147
|
-
() =>
|
|
148
|
-
new AdapterType({
|
|
149
|
-
name: 'BamAdapter',
|
|
150
|
-
...pluginManager.load(BamAdapterF),
|
|
151
|
-
}),
|
|
152
|
-
)
|
|
38
|
+
;[
|
|
39
|
+
CramAdapterF,
|
|
40
|
+
BamAdapterF,
|
|
41
|
+
LinearPileupDisplayF,
|
|
42
|
+
LinearSNPCoverageDisplayF,
|
|
43
|
+
AlignmentsTrackF,
|
|
44
|
+
SNPCoverageAdapterF,
|
|
45
|
+
HtsgetBamAdapterF,
|
|
46
|
+
PileupRendererF,
|
|
47
|
+
SNPCoverageRendererF,
|
|
48
|
+
LinearAlignmentsDisplayF,
|
|
49
|
+
AlignmentsFeatureWidgetF,
|
|
50
|
+
].map(f => f(pluginManager))
|
|
153
51
|
|
|
154
52
|
pluginManager.addToExtensionPoint(
|
|
155
53
|
'Core-guessAdapterForLocation',
|
|
@@ -159,56 +57,21 @@ export default class AlignmentsPlugin extends Plugin {
|
|
|
159
57
|
index?: FileLocation,
|
|
160
58
|
adapterHint?: string,
|
|
161
59
|
) => {
|
|
162
|
-
const regexGuess = /\.
|
|
163
|
-
const adapterName = '
|
|
60
|
+
const regexGuess = /\.cram$/i
|
|
61
|
+
const adapterName = 'CramAdapter'
|
|
164
62
|
const fileName = getFileName(file)
|
|
165
|
-
const indexName = index && getFileName(index)
|
|
166
63
|
if (regexGuess.test(fileName) || adapterHint === adapterName) {
|
|
167
64
|
return {
|
|
168
65
|
type: adapterName,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
location: index || makeIndex(file, '.bai'),
|
|
172
|
-
indexType: makeIndexType(indexName, 'CSI', 'BAI'),
|
|
173
|
-
},
|
|
66
|
+
cramLocation: file,
|
|
67
|
+
craiLocation: index || makeIndex(file, '.crai'),
|
|
174
68
|
}
|
|
175
69
|
}
|
|
176
70
|
return adapterGuesser(file, index, adapterHint)
|
|
177
71
|
}
|
|
178
72
|
},
|
|
179
73
|
)
|
|
180
|
-
pluginManager.addToExtensionPoint(
|
|
181
|
-
'Core-guessTrackTypeForLocation',
|
|
182
|
-
(trackTypeGuesser: TrackTypeGuesser) => {
|
|
183
|
-
return (adapterName: string) => {
|
|
184
|
-
if (adapterName === 'BamAdapter') {
|
|
185
|
-
return 'AlignmentsTrack'
|
|
186
|
-
}
|
|
187
|
-
return trackTypeGuesser(adapterName)
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
)
|
|
191
74
|
|
|
192
|
-
pluginManager.addAdapterType(
|
|
193
|
-
() =>
|
|
194
|
-
new AdapterType({
|
|
195
|
-
name: 'SNPCoverageAdapter',
|
|
196
|
-
adapterMetadata: {
|
|
197
|
-
category: null,
|
|
198
|
-
displayName: null,
|
|
199
|
-
hiddenFromGUI: true,
|
|
200
|
-
description: null,
|
|
201
|
-
},
|
|
202
|
-
...pluginManager.load(SNPCoverageAdapterF),
|
|
203
|
-
}),
|
|
204
|
-
)
|
|
205
|
-
pluginManager.addAdapterType(
|
|
206
|
-
() =>
|
|
207
|
-
new AdapterType({
|
|
208
|
-
name: 'CramAdapter',
|
|
209
|
-
...pluginManager.load(CramAdapterF),
|
|
210
|
-
}),
|
|
211
|
-
)
|
|
212
75
|
pluginManager.addToExtensionPoint(
|
|
213
76
|
'Core-guessAdapterForLocation',
|
|
214
77
|
(adapterGuesser: AdapterGuesser) => {
|
|
@@ -217,14 +80,18 @@ export default class AlignmentsPlugin extends Plugin {
|
|
|
217
80
|
index?: FileLocation,
|
|
218
81
|
adapterHint?: string,
|
|
219
82
|
) => {
|
|
220
|
-
const regexGuess = /\.
|
|
221
|
-
const adapterName = '
|
|
83
|
+
const regexGuess = /\.bam$/i
|
|
84
|
+
const adapterName = 'BamAdapter'
|
|
222
85
|
const fileName = getFileName(file)
|
|
86
|
+
const indexName = index && getFileName(index)
|
|
223
87
|
if (regexGuess.test(fileName) || adapterHint === adapterName) {
|
|
224
88
|
return {
|
|
225
89
|
type: adapterName,
|
|
226
|
-
|
|
227
|
-
|
|
90
|
+
bamLocation: file,
|
|
91
|
+
index: {
|
|
92
|
+
location: index || makeIndex(file, '.bai'),
|
|
93
|
+
indexType: makeIndexType(indexName, 'CSI', 'BAI'),
|
|
94
|
+
},
|
|
228
95
|
}
|
|
229
96
|
}
|
|
230
97
|
return adapterGuesser(file, index, adapterHint)
|
|
@@ -235,7 +102,7 @@ export default class AlignmentsPlugin extends Plugin {
|
|
|
235
102
|
'Core-guessTrackTypeForLocation',
|
|
236
103
|
(trackTypeGuesser: TrackTypeGuesser) => {
|
|
237
104
|
return (adapterName: string) => {
|
|
238
|
-
if (adapterName === 'CramAdapter') {
|
|
105
|
+
if (adapterName === 'BamAdapter' || adapterName === 'CramAdapter') {
|
|
239
106
|
return 'AlignmentsTrack'
|
|
240
107
|
}
|
|
241
108
|
return trackTypeGuesser(adapterName)
|
|
@@ -243,38 +110,6 @@ export default class AlignmentsPlugin extends Plugin {
|
|
|
243
110
|
},
|
|
244
111
|
)
|
|
245
112
|
|
|
246
|
-
pluginManager.addAdapterType(
|
|
247
|
-
() =>
|
|
248
|
-
new AdapterType({
|
|
249
|
-
name: 'HtsgetBamAdapter',
|
|
250
|
-
adapterMetadata: {
|
|
251
|
-
category: null,
|
|
252
|
-
hiddenFromGUI: true,
|
|
253
|
-
displayName: null,
|
|
254
|
-
description: null,
|
|
255
|
-
},
|
|
256
|
-
...pluginManager.load(HtsgetBamAdapterF),
|
|
257
|
-
}),
|
|
258
|
-
)
|
|
259
|
-
pluginManager.addRendererType(
|
|
260
|
-
() =>
|
|
261
|
-
new PileupRenderer({
|
|
262
|
-
name: 'PileupRenderer',
|
|
263
|
-
ReactComponent: PileupRendererReactComponent,
|
|
264
|
-
configSchema: pileupRendererConfigSchema,
|
|
265
|
-
pluginManager,
|
|
266
|
-
}),
|
|
267
|
-
)
|
|
268
|
-
pluginManager.addRendererType(
|
|
269
|
-
() =>
|
|
270
|
-
new SNPCoverageRenderer({
|
|
271
|
-
name: 'SNPCoverageRenderer',
|
|
272
|
-
ReactComponent: SNPCoverageRendererReactComponent,
|
|
273
|
-
configSchema: SNPCoverageRendererConfigSchema,
|
|
274
|
-
pluginManager,
|
|
275
|
-
}),
|
|
276
|
-
)
|
|
277
|
-
|
|
278
113
|
pluginManager.addRpcMethod(
|
|
279
114
|
() => new PileupGetGlobalValueForTag(pluginManager),
|
|
280
115
|
)
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import { toArray } from 'rxjs/operators'
|
|
2
|
-
import { LocalFile } from 'generic-filehandle'
|
|
3
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
4
|
-
import { SnapshotIn } from 'mobx-state-tree'
|
|
5
|
-
import AdapterF from './index'
|
|
6
|
-
import CramAdapterF from '../CramAdapter'
|
|
7
|
-
import BamAdapterF from '../BamAdapter'
|
|
8
|
-
|
|
9
|
-
import { SequenceAdapter } from '../CramAdapter/CramTestAdapters'
|
|
10
|
-
|
|
11
|
-
const pluginManager = new PluginManager()
|
|
12
|
-
const { getAdapterClass: getSNPCoverageAdapter, configSchema } =
|
|
13
|
-
pluginManager.load(AdapterF)
|
|
14
|
-
const { getAdapterClass: getCramAdapter, configSchema: CramConfigSchema } =
|
|
15
|
-
pluginManager.load(CramAdapterF)
|
|
16
|
-
const { getAdapterClass: getBamAdapter, configSchema: BamConfigSchema } =
|
|
17
|
-
pluginManager.load(BamAdapterF)
|
|
18
|
-
|
|
19
|
-
pluginManager.configure()
|
|
20
|
-
|
|
21
|
-
async function newSNPCoverageWithBam(
|
|
22
|
-
bamConf: SnapshotIn<typeof BamConfigSchema>,
|
|
23
|
-
) {
|
|
24
|
-
const BamAdapter = await getBamAdapter()
|
|
25
|
-
const SNPCoverageAdapter = await getSNPCoverageAdapter()
|
|
26
|
-
return new SNPCoverageAdapter(configSchema.create({}), async () => {
|
|
27
|
-
return {
|
|
28
|
-
dataAdapter: new BamAdapter(BamConfigSchema.create(bamConf)),
|
|
29
|
-
sessionIds: new Set(),
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
test('SNP adapter can fetch features from volvox.bam using bam subadapter', async () => {
|
|
35
|
-
const adapter = await newSNPCoverageWithBam({
|
|
36
|
-
type: 'BamAdapter',
|
|
37
|
-
bamLocation: {
|
|
38
|
-
localPath: require.resolve('../../test_data/volvox-sorted.bam'),
|
|
39
|
-
locationType: 'LocalPathLocation',
|
|
40
|
-
},
|
|
41
|
-
index: {
|
|
42
|
-
location: {
|
|
43
|
-
localPath: require.resolve('../../test_data/volvox-sorted.bam.bai'),
|
|
44
|
-
locationType: 'LocalPathLocation',
|
|
45
|
-
},
|
|
46
|
-
indexType: 'BAI',
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
const features = adapter.getFeatures(
|
|
51
|
-
{
|
|
52
|
-
assemblyName: 'volvox',
|
|
53
|
-
refName: 'ctgA',
|
|
54
|
-
start: 0,
|
|
55
|
-
end: 20000,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
bpPerPx: 0.2,
|
|
59
|
-
},
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
const featuresArray = await features.pipe(toArray()).toPromise()
|
|
63
|
-
expect(featuresArray[0].get('refName')).toBe('ctgA')
|
|
64
|
-
expect(featuresArray[0].get('snpinfo')).toBeTruthy()
|
|
65
|
-
|
|
66
|
-
const featuresJsonArray = featuresArray.map(f => f.toJSON())
|
|
67
|
-
expect(featuresJsonArray.length).toEqual(19998)
|
|
68
|
-
expect(featuresJsonArray.slice(1000, 1010)).toMatchSnapshot()
|
|
69
|
-
|
|
70
|
-
expect(await adapter.hasDataForRefName('ctgA')).toBe(true)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test('test usage of BamSlightlyLazyFeature toJSON in a SNP adapter', async () => {
|
|
74
|
-
const adapter = await newSNPCoverageWithBam({
|
|
75
|
-
type: 'BamAdapter',
|
|
76
|
-
bamLocation: {
|
|
77
|
-
localPath: require.resolve('../../test_data/volvox-sorted.bam'),
|
|
78
|
-
locationType: 'LocalPathLocation',
|
|
79
|
-
},
|
|
80
|
-
index: {
|
|
81
|
-
location: {
|
|
82
|
-
localPath: require.resolve('../../test_data/volvox-sorted.bam.bai'),
|
|
83
|
-
locationType: 'LocalPathLocation',
|
|
84
|
-
},
|
|
85
|
-
indexType: 'BAI',
|
|
86
|
-
},
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
const features = adapter.getFeatures({
|
|
90
|
-
assemblyName: 'volvox',
|
|
91
|
-
refName: 'ctgA',
|
|
92
|
-
start: 0,
|
|
93
|
-
end: 100,
|
|
94
|
-
})
|
|
95
|
-
const featuresArray = await features.pipe(toArray()).toPromise()
|
|
96
|
-
const f = featuresArray[0].toJSON()
|
|
97
|
-
|
|
98
|
-
expect(f.refName).toBe('ctgA')
|
|
99
|
-
expect(f.start).toBe(2)
|
|
100
|
-
expect(f.end).toBe(3)
|
|
101
|
-
expect(f.snpinfo).toBeTruthy()
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
test('test usage of getMultiRegion stats, SNP adapter can generate a domain from BamFile', async () => {
|
|
105
|
-
const adapter = await newSNPCoverageWithBam({
|
|
106
|
-
type: 'BamAdapter',
|
|
107
|
-
bamLocation: {
|
|
108
|
-
localPath: require.resolve('../../test_data/volvox-sorted.bam'),
|
|
109
|
-
locationType: 'LocalPathLocation',
|
|
110
|
-
},
|
|
111
|
-
index: {
|
|
112
|
-
location: {
|
|
113
|
-
localPath: require.resolve('../../test_data/volvox-sorted.bam.bai'),
|
|
114
|
-
locationType: 'LocalPathLocation',
|
|
115
|
-
},
|
|
116
|
-
indexType: 'BAI',
|
|
117
|
-
},
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
const stats = await adapter.getMultiRegionStats(
|
|
121
|
-
[
|
|
122
|
-
{
|
|
123
|
-
assemblyName: 'volvox',
|
|
124
|
-
refName: 'ctgA',
|
|
125
|
-
start: 0,
|
|
126
|
-
end: 100,
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
{
|
|
130
|
-
opts: {
|
|
131
|
-
signal: {
|
|
132
|
-
aborted: false,
|
|
133
|
-
onabort: null,
|
|
134
|
-
},
|
|
135
|
-
bpPerPx: 0.2,
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
expect(Object.keys(stats).length).toEqual(9)
|
|
141
|
-
expect(stats.scoreMin).toEqual(1)
|
|
142
|
-
expect(stats.scoreMax).toEqual(13)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
async function newSNPCoverageWithCram(
|
|
146
|
-
cramConf: SnapshotIn<typeof CramConfigSchema>,
|
|
147
|
-
sequenceFileName: string,
|
|
148
|
-
) {
|
|
149
|
-
const CramAdapter = await getCramAdapter()
|
|
150
|
-
const SNPCoverageAdapter = await getSNPCoverageAdapter()
|
|
151
|
-
return new SNPCoverageAdapter(configSchema.create({}), async () => {
|
|
152
|
-
return {
|
|
153
|
-
dataAdapter: new CramAdapter(
|
|
154
|
-
CramConfigSchema.create(cramConf),
|
|
155
|
-
async () => {
|
|
156
|
-
return {
|
|
157
|
-
dataAdapter: new SequenceAdapter(new LocalFile(sequenceFileName)),
|
|
158
|
-
sessionIds: new Set(),
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
),
|
|
162
|
-
sessionIds: new Set(),
|
|
163
|
-
}
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
test('SNP adapter can fetch features from volvox.cram using cram subadapter', async () => {
|
|
168
|
-
const adapter = await newSNPCoverageWithCram(
|
|
169
|
-
{
|
|
170
|
-
type: 'CramAdapter',
|
|
171
|
-
cramLocation: {
|
|
172
|
-
localPath: require.resolve('../../test_data/volvox-sorted.cram'),
|
|
173
|
-
locationType: 'LocalPathLocation',
|
|
174
|
-
},
|
|
175
|
-
craiLocation: {
|
|
176
|
-
localPath: require.resolve('../../test_data/volvox-sorted.cram.crai'),
|
|
177
|
-
locationType: 'LocalPathLocation',
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
require.resolve('../../test_data/volvox.fa'),
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
const features = adapter.getFeatures(
|
|
184
|
-
{
|
|
185
|
-
assemblyName: 'volvox',
|
|
186
|
-
refName: 'ctgA',
|
|
187
|
-
start: 0,
|
|
188
|
-
end: 20000,
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
bpPerPx: 0.2,
|
|
192
|
-
},
|
|
193
|
-
)
|
|
194
|
-
|
|
195
|
-
const featuresArray = await features.pipe(toArray()).toPromise()
|
|
196
|
-
expect(featuresArray[0].get('refName')).toBe('ctgA')
|
|
197
|
-
expect(featuresArray[0].get('snpinfo')).toBeTruthy()
|
|
198
|
-
|
|
199
|
-
const featuresJsonArray = featuresArray.map(f => f.toJSON())
|
|
200
|
-
expect(featuresJsonArray.length).toEqual(19998)
|
|
201
|
-
expect(featuresJsonArray.slice(1000, 1010)).toMatchSnapshot()
|
|
202
|
-
expect(await adapter.hasDataForRefName('ctgA')).toBe(true)
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
test('test usage of CramSlightlyLazyFeature toJSON in a SNP adapter', async () => {
|
|
206
|
-
const adapter = await newSNPCoverageWithCram(
|
|
207
|
-
{
|
|
208
|
-
type: 'CramAdapter',
|
|
209
|
-
cramLocation: {
|
|
210
|
-
localPath: require.resolve('../../test_data/volvox-sorted.cram'),
|
|
211
|
-
locationType: 'LocalPathLocation',
|
|
212
|
-
},
|
|
213
|
-
craiLocation: {
|
|
214
|
-
localPath: require.resolve('../../test_data/volvox-sorted.cram.crai'),
|
|
215
|
-
locationType: 'LocalPathLocation',
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
require.resolve('../../test_data/volvox.fa'),
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
const features = adapter.getFeatures({
|
|
222
|
-
assemblyName: 'volvox',
|
|
223
|
-
refName: 'ctgA',
|
|
224
|
-
start: 0,
|
|
225
|
-
end: 100,
|
|
226
|
-
})
|
|
227
|
-
const featuresArray = await features.pipe(toArray()).toPromise()
|
|
228
|
-
const f = featuresArray[0].toJSON()
|
|
229
|
-
|
|
230
|
-
expect(f.refName).toBe('ctgA')
|
|
231
|
-
expect(f.start).toBe(2)
|
|
232
|
-
expect(f.end).toBe(3)
|
|
233
|
-
expect(f.snpinfo).toBeTruthy()
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
test('test usage of getMultiRegion stats, SNP adapter can generate a domain from CramFile', async () => {
|
|
237
|
-
const adapter = await newSNPCoverageWithCram(
|
|
238
|
-
{
|
|
239
|
-
type: 'CramAdapter',
|
|
240
|
-
cramLocation: {
|
|
241
|
-
localPath: require.resolve('../../test_data/volvox-sorted.cram'),
|
|
242
|
-
locationType: 'LocalPathLocation',
|
|
243
|
-
},
|
|
244
|
-
craiLocation: {
|
|
245
|
-
localPath: require.resolve('../../test_data/volvox-sorted.cram.crai'),
|
|
246
|
-
locationType: 'LocalPathLocation',
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
require.resolve('../../test_data/volvox.fa'),
|
|
250
|
-
)
|
|
251
|
-
|
|
252
|
-
const stats = await adapter.getMultiRegionStats(
|
|
253
|
-
[
|
|
254
|
-
{
|
|
255
|
-
assemblyName: 'volvox',
|
|
256
|
-
refName: 'ctgA',
|
|
257
|
-
start: 0,
|
|
258
|
-
end: 100,
|
|
259
|
-
},
|
|
260
|
-
],
|
|
261
|
-
{
|
|
262
|
-
opts: {
|
|
263
|
-
signal: {
|
|
264
|
-
aborted: false,
|
|
265
|
-
onabort: null,
|
|
266
|
-
},
|
|
267
|
-
bpPerPx: 0.2,
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
)
|
|
271
|
-
|
|
272
|
-
expect(Object.keys(stats).length).toEqual(9)
|
|
273
|
-
expect(stats.scoreMin).toEqual(1)
|
|
274
|
-
expect(stats.scoreMax).toEqual(13)
|
|
275
|
-
})
|