@jbrowse/plugin-alignments 1.5.0 → 1.5.4
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 +3696 -3526
- 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 +3690 -3520
- 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 +91 -163
- 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,52 +1,32 @@
|
|
|
1
|
-
import {
|
|
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
|
-
import TrackType from '@jbrowse/core/pluggableElementTypes/TrackType'
|
|
10
|
-
import WidgetType from '@jbrowse/core/pluggableElementTypes/WidgetType'
|
|
1
|
+
import { FileLocation } from '@jbrowse/core/util/types'
|
|
11
2
|
import Plugin from '@jbrowse/core/Plugin'
|
|
12
3
|
import PluginManager from '@jbrowse/core/PluginManager'
|
|
13
|
-
import { BaseLinearDisplayComponent } from '@jbrowse/plugin-linear-genome-view'
|
|
14
|
-
import { LinearWiggleDisplayReactComponent } from '@jbrowse/plugin-wiggle'
|
|
15
|
-
import {
|
|
16
|
-
configSchema as alignmentsFeatureDetailConfigSchema,
|
|
17
|
-
stateModelFactory as alignmentsFeatureDetailStateModelFactory,
|
|
18
|
-
} from './AlignmentsFeatureDetail'
|
|
19
|
-
import BamAdapterF from './BamAdapter'
|
|
20
4
|
import * as MismatchParser from './BamAdapter/MismatchParser'
|
|
21
|
-
import CramAdapterF from './CramAdapter'
|
|
22
|
-
import HtsgetBamAdapterF from './HtsgetBamAdapter'
|
|
23
|
-
import {
|
|
24
|
-
configSchemaFactory as linearAligmentsDisplayConfigSchemaFactory,
|
|
25
|
-
modelFactory as linearAlignmentsDisplayModelFactory,
|
|
26
|
-
ReactComponent as LinearAlignmentsDisplayReactComponent,
|
|
27
|
-
} from './LinearAlignmentsDisplay'
|
|
28
|
-
import {
|
|
29
|
-
configSchemaFactory as linearPileupDisplayConfigSchemaFactory,
|
|
30
|
-
modelFactory as linearPileupDisplayModelFactory,
|
|
31
|
-
} from './LinearPileupDisplay'
|
|
32
5
|
import { LinearPileupDisplayModel } from './LinearPileupDisplay/model'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import PileupRenderer, {
|
|
38
|
-
configSchema as pileupRendererConfigSchema,
|
|
39
|
-
ReactComponent as PileupRendererReactComponent,
|
|
40
|
-
} from './PileupRenderer'
|
|
6
|
+
|
|
7
|
+
import BamAdapterF from './CramAdapter'
|
|
8
|
+
import CramAdapterF from './BamAdapter'
|
|
9
|
+
import HtsgetBamAdapterF from './HtsgetBamAdapter'
|
|
41
10
|
import SNPCoverageAdapterF from './SNPCoverageAdapter'
|
|
42
|
-
import SNPCoverageRenderer
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
|
|
46
19
|
import {
|
|
47
20
|
PileupGetGlobalValueForTag,
|
|
48
21
|
PileupGetVisibleModifications,
|
|
49
22
|
} from './PileupRPC/rpcMethods'
|
|
23
|
+
import {
|
|
24
|
+
makeIndex,
|
|
25
|
+
makeIndexType,
|
|
26
|
+
getFileName,
|
|
27
|
+
AdapterGuesser,
|
|
28
|
+
TrackTypeGuesser,
|
|
29
|
+
} from '@jbrowse/core/util/tracks'
|
|
50
30
|
|
|
51
31
|
export { MismatchParser }
|
|
52
32
|
export type { LinearPileupDisplayModel }
|
|
@@ -55,131 +35,79 @@ export default class AlignmentsPlugin extends Plugin {
|
|
|
55
35
|
name = 'AlignmentsPlugin'
|
|
56
36
|
|
|
57
37
|
install(pluginManager: PluginManager) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
ReactComponent: BaseLinearDisplayComponent,
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
pluginManager.addDisplayType(() => {
|
|
97
|
-
const configSchema =
|
|
98
|
-
linearSNPCoverageDisplayConfigSchemaFactory(pluginManager)
|
|
99
|
-
return new DisplayType({
|
|
100
|
-
name: 'LinearSNPCoverageDisplay',
|
|
101
|
-
configSchema,
|
|
102
|
-
stateModel: linearSNPCoverageDisplayModelFactory(
|
|
103
|
-
pluginManager,
|
|
104
|
-
configSchema,
|
|
105
|
-
),
|
|
106
|
-
trackType: 'AlignmentsTrack',
|
|
107
|
-
viewType: 'LinearGenomeView',
|
|
108
|
-
ReactComponent: LinearWiggleDisplayReactComponent,
|
|
109
|
-
})
|
|
110
|
-
})
|
|
111
|
-
pluginManager.addDisplayType(() => {
|
|
112
|
-
const configSchema =
|
|
113
|
-
linearAligmentsDisplayConfigSchemaFactory(pluginManager)
|
|
114
|
-
return new DisplayType({
|
|
115
|
-
name: 'LinearAlignmentsDisplay',
|
|
116
|
-
configSchema,
|
|
117
|
-
stateModel: linearAlignmentsDisplayModelFactory(
|
|
118
|
-
pluginManager,
|
|
119
|
-
configSchema,
|
|
120
|
-
),
|
|
121
|
-
trackType: 'AlignmentsTrack',
|
|
122
|
-
viewType: 'LinearGenomeView',
|
|
123
|
-
ReactComponent: LinearAlignmentsDisplayReactComponent,
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
pluginManager.addWidgetType(
|
|
127
|
-
() =>
|
|
128
|
-
new WidgetType({
|
|
129
|
-
name: 'AlignmentsFeatureWidget',
|
|
130
|
-
heading: 'Feature details',
|
|
131
|
-
configSchema: alignmentsFeatureDetailConfigSchema,
|
|
132
|
-
stateModel: alignmentsFeatureDetailStateModelFactory(pluginManager),
|
|
133
|
-
ReactComponent: lazy(
|
|
134
|
-
() => import('./AlignmentsFeatureDetail/AlignmentsFeatureDetail'),
|
|
135
|
-
),
|
|
136
|
-
}),
|
|
137
|
-
)
|
|
138
|
-
pluginManager.addAdapterType(
|
|
139
|
-
() =>
|
|
140
|
-
new AdapterType({
|
|
141
|
-
name: 'BamAdapter',
|
|
142
|
-
...pluginManager.load(BamAdapterF),
|
|
143
|
-
}),
|
|
144
|
-
)
|
|
145
|
-
pluginManager.addAdapterType(
|
|
146
|
-
() =>
|
|
147
|
-
new AdapterType({
|
|
148
|
-
name: 'SNPCoverageAdapter',
|
|
149
|
-
...pluginManager.load(SNPCoverageAdapterF),
|
|
150
|
-
}),
|
|
151
|
-
)
|
|
152
|
-
pluginManager.addAdapterType(
|
|
153
|
-
() =>
|
|
154
|
-
new AdapterType({
|
|
155
|
-
name: 'CramAdapter',
|
|
156
|
-
...pluginManager.load(CramAdapterF),
|
|
157
|
-
}),
|
|
158
|
-
)
|
|
159
|
-
pluginManager.addAdapterType(
|
|
160
|
-
() =>
|
|
161
|
-
new AdapterType({
|
|
162
|
-
name: 'HtsgetBamAdapter',
|
|
163
|
-
...pluginManager.load(HtsgetBamAdapterF),
|
|
164
|
-
}),
|
|
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))
|
|
51
|
+
|
|
52
|
+
pluginManager.addToExtensionPoint(
|
|
53
|
+
'Core-guessAdapterForLocation',
|
|
54
|
+
(adapterGuesser: AdapterGuesser) => {
|
|
55
|
+
return (
|
|
56
|
+
file: FileLocation,
|
|
57
|
+
index?: FileLocation,
|
|
58
|
+
adapterHint?: string,
|
|
59
|
+
) => {
|
|
60
|
+
const regexGuess = /\.cram$/i
|
|
61
|
+
const adapterName = 'CramAdapter'
|
|
62
|
+
const fileName = getFileName(file)
|
|
63
|
+
if (regexGuess.test(fileName) || adapterHint === adapterName) {
|
|
64
|
+
return {
|
|
65
|
+
type: adapterName,
|
|
66
|
+
cramLocation: file,
|
|
67
|
+
craiLocation: index || makeIndex(file, '.crai'),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return adapterGuesser(file, index, adapterHint)
|
|
71
|
+
}
|
|
72
|
+
},
|
|
165
73
|
)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
74
|
+
|
|
75
|
+
pluginManager.addToExtensionPoint(
|
|
76
|
+
'Core-guessAdapterForLocation',
|
|
77
|
+
(adapterGuesser: AdapterGuesser) => {
|
|
78
|
+
return (
|
|
79
|
+
file: FileLocation,
|
|
80
|
+
index?: FileLocation,
|
|
81
|
+
adapterHint?: string,
|
|
82
|
+
) => {
|
|
83
|
+
const regexGuess = /\.bam$/i
|
|
84
|
+
const adapterName = 'BamAdapter'
|
|
85
|
+
const fileName = getFileName(file)
|
|
86
|
+
const indexName = index && getFileName(index)
|
|
87
|
+
if (regexGuess.test(fileName) || adapterHint === adapterName) {
|
|
88
|
+
return {
|
|
89
|
+
type: adapterName,
|
|
90
|
+
bamLocation: file,
|
|
91
|
+
index: {
|
|
92
|
+
location: index || makeIndex(file, '.bai'),
|
|
93
|
+
indexType: makeIndexType(indexName, 'CSI', 'BAI'),
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return adapterGuesser(file, index, adapterHint)
|
|
98
|
+
}
|
|
99
|
+
},
|
|
174
100
|
)
|
|
175
|
-
pluginManager.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
101
|
+
pluginManager.addToExtensionPoint(
|
|
102
|
+
'Core-guessTrackTypeForLocation',
|
|
103
|
+
(trackTypeGuesser: TrackTypeGuesser) => {
|
|
104
|
+
return (adapterName: string) => {
|
|
105
|
+
if (adapterName === 'BamAdapter' || adapterName === 'CramAdapter') {
|
|
106
|
+
return 'AlignmentsTrack'
|
|
107
|
+
}
|
|
108
|
+
return trackTypeGuesser(adapterName)
|
|
109
|
+
}
|
|
110
|
+
},
|
|
183
111
|
)
|
|
184
112
|
|
|
185
113
|
pluginManager.addRpcMethod(
|
|
@@ -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
|
-
})
|