@jbrowse/plugin-variants 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/ChordVariantDisplay/index.js +0 -1
- package/dist/ChordVariantDisplay/models/configSchema.js +0 -1
- package/dist/ChordVariantDisplay/models/stateModelFactory.d.ts +11 -3
- package/dist/ChordVariantDisplay/models/stateModelFactory.js +0 -1
- package/dist/LinearVariantDisplay/configSchema.js +0 -1
- package/dist/LinearVariantDisplay/index.js +0 -1
- package/dist/LinearVariantDisplay/model.d.ts +52 -49
- package/dist/LinearVariantDisplay/model.js +0 -1
- package/dist/StructuralVariantChordRenderer/Chord.d.ts +2 -1
- package/dist/StructuralVariantChordRenderer/Chord.js +0 -1
- package/dist/StructuralVariantChordRenderer/ReactComponent.d.ts +2 -1
- package/dist/StructuralVariantChordRenderer/ReactComponent.js +0 -1
- package/dist/StructuralVariantChordRenderer/configSchema.js +0 -1
- package/dist/StructuralVariantChordRenderer/index.js +0 -1
- package/dist/VariantFeatureWidget/AnnotGrid.d.ts +2 -1
- package/dist/VariantFeatureWidget/AnnotGrid.js +8 -14
- package/dist/VariantFeatureWidget/BreakendOptionDialog.d.ts +2 -1
- package/dist/VariantFeatureWidget/BreakendOptionDialog.js +0 -1
- package/dist/VariantFeatureWidget/BreakendPanel.d.ts +2 -1
- package/dist/VariantFeatureWidget/BreakendPanel.js +0 -1
- package/dist/VariantFeatureWidget/VariantAnnotationTable.d.ts +6 -0
- package/dist/VariantFeatureWidget/VariantAnnotationTable.js +16 -0
- package/dist/VariantFeatureWidget/VariantFeatureWidget.d.ts +8 -1
- package/dist/VariantFeatureWidget/VariantFeatureWidget.js +26 -15
- package/dist/VariantFeatureWidget/VariantSampleGrid.d.ts +9 -2
- package/dist/VariantFeatureWidget/VariantSampleGrid.js +0 -1
- package/dist/VariantFeatureWidget/index.js +0 -1
- package/dist/VariantTrack/configSchema.js +0 -1
- package/dist/VariantTrack/index.js +0 -1
- package/dist/VcfAdapter/VcfAdapter.js +0 -1
- package/dist/VcfAdapter/configSchema.js +0 -1
- package/dist/VcfAdapter/index.js +0 -1
- package/dist/VcfFeature/index.js +2 -2
- package/dist/VcfFeature/util.js +0 -1
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js +0 -1
- package/dist/VcfTabixAdapter/configSchema.js +0 -1
- package/dist/VcfTabixAdapter/index.js +0 -1
- package/dist/extensionPoints.js +0 -1
- package/dist/index.js +0 -1
- package/esm/ChordVariantDisplay/index.js +0 -1
- package/esm/ChordVariantDisplay/models/configSchema.js +0 -1
- package/esm/ChordVariantDisplay/models/stateModelFactory.d.ts +11 -3
- package/esm/ChordVariantDisplay/models/stateModelFactory.js +0 -1
- package/esm/LinearVariantDisplay/configSchema.js +0 -1
- package/esm/LinearVariantDisplay/index.js +0 -1
- package/esm/LinearVariantDisplay/model.d.ts +52 -49
- package/esm/LinearVariantDisplay/model.js +0 -1
- package/esm/StructuralVariantChordRenderer/Chord.d.ts +2 -1
- package/esm/StructuralVariantChordRenderer/Chord.js +0 -1
- package/esm/StructuralVariantChordRenderer/ReactComponent.d.ts +2 -1
- package/esm/StructuralVariantChordRenderer/ReactComponent.js +0 -1
- package/esm/StructuralVariantChordRenderer/configSchema.js +0 -1
- package/esm/StructuralVariantChordRenderer/index.js +0 -1
- package/esm/VariantFeatureWidget/AnnotGrid.d.ts +2 -1
- package/esm/VariantFeatureWidget/AnnotGrid.js +8 -14
- package/esm/VariantFeatureWidget/BreakendOptionDialog.d.ts +2 -1
- package/esm/VariantFeatureWidget/BreakendOptionDialog.js +0 -1
- package/esm/VariantFeatureWidget/BreakendPanel.d.ts +2 -1
- package/esm/VariantFeatureWidget/BreakendPanel.js +0 -1
- package/esm/VariantFeatureWidget/VariantAnnotationTable.d.ts +6 -0
- package/esm/VariantFeatureWidget/VariantAnnotationTable.js +10 -0
- package/esm/VariantFeatureWidget/VariantFeatureWidget.d.ts +8 -1
- package/esm/VariantFeatureWidget/VariantFeatureWidget.js +26 -15
- package/esm/VariantFeatureWidget/VariantSampleGrid.d.ts +9 -2
- package/esm/VariantFeatureWidget/VariantSampleGrid.js +0 -1
- package/esm/VariantFeatureWidget/index.js +0 -1
- package/esm/VariantTrack/configSchema.js +0 -1
- package/esm/VariantTrack/index.js +0 -1
- package/esm/VcfAdapter/VcfAdapter.js +0 -1
- package/esm/VcfAdapter/configSchema.js +0 -1
- package/esm/VcfAdapter/index.js +0 -1
- package/esm/VcfFeature/index.js +2 -2
- package/esm/VcfFeature/util.js +0 -1
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js +0 -1
- package/esm/VcfTabixAdapter/configSchema.js +0 -1
- package/esm/VcfTabixAdapter/index.js +0 -1
- package/esm/extensionPoints.js +0 -1
- package/esm/index.js +0 -1
- package/package.json +3 -4
- package/dist/ChordVariantDisplay/index.js.map +0 -1
- package/dist/ChordVariantDisplay/models/configSchema.js.map +0 -1
- package/dist/ChordVariantDisplay/models/stateModelFactory.js.map +0 -1
- package/dist/LinearVariantDisplay/configSchema.js.map +0 -1
- package/dist/LinearVariantDisplay/index.js.map +0 -1
- package/dist/LinearVariantDisplay/model.js.map +0 -1
- package/dist/StructuralVariantChordRenderer/Chord.js.map +0 -1
- package/dist/StructuralVariantChordRenderer/ReactComponent.js.map +0 -1
- package/dist/StructuralVariantChordRenderer/configSchema.js.map +0 -1
- package/dist/StructuralVariantChordRenderer/index.js.map +0 -1
- package/dist/VariantFeatureWidget/AnnotGrid.js.map +0 -1
- package/dist/VariantFeatureWidget/BreakendOptionDialog.js.map +0 -1
- package/dist/VariantFeatureWidget/BreakendPanel.js.map +0 -1
- package/dist/VariantFeatureWidget/VariantAnnPanel.d.ts +0 -4
- package/dist/VariantFeatureWidget/VariantAnnPanel.js +0 -25
- package/dist/VariantFeatureWidget/VariantAnnPanel.js.map +0 -1
- package/dist/VariantFeatureWidget/VariantCsqPanel.d.ts +0 -4
- package/dist/VariantFeatureWidget/VariantCsqPanel.js +0 -25
- package/dist/VariantFeatureWidget/VariantCsqPanel.js.map +0 -1
- package/dist/VariantFeatureWidget/VariantFeatureWidget.js.map +0 -1
- package/dist/VariantFeatureWidget/VariantSampleGrid.js.map +0 -1
- package/dist/VariantFeatureWidget/index.js.map +0 -1
- package/dist/VariantTrack/configSchema.js.map +0 -1
- package/dist/VariantTrack/index.js.map +0 -1
- package/dist/VcfAdapter/VcfAdapter.js.map +0 -1
- package/dist/VcfAdapter/configSchema.js.map +0 -1
- package/dist/VcfAdapter/index.js.map +0 -1
- package/dist/VcfFeature/index.js.map +0 -1
- package/dist/VcfFeature/util.js.map +0 -1
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js.map +0 -1
- package/dist/VcfTabixAdapter/configSchema.js.map +0 -1
- package/dist/VcfTabixAdapter/index.js.map +0 -1
- package/dist/extensionPoints.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/esm/ChordVariantDisplay/index.js.map +0 -1
- package/esm/ChordVariantDisplay/models/configSchema.js.map +0 -1
- package/esm/ChordVariantDisplay/models/stateModelFactory.js.map +0 -1
- package/esm/LinearVariantDisplay/configSchema.js.map +0 -1
- package/esm/LinearVariantDisplay/index.js.map +0 -1
- package/esm/LinearVariantDisplay/model.js.map +0 -1
- package/esm/StructuralVariantChordRenderer/Chord.js.map +0 -1
- package/esm/StructuralVariantChordRenderer/ReactComponent.js.map +0 -1
- package/esm/StructuralVariantChordRenderer/configSchema.js.map +0 -1
- package/esm/StructuralVariantChordRenderer/index.js.map +0 -1
- package/esm/VariantFeatureWidget/AnnotGrid.js.map +0 -1
- package/esm/VariantFeatureWidget/BreakendOptionDialog.js.map +0 -1
- package/esm/VariantFeatureWidget/BreakendPanel.js.map +0 -1
- package/esm/VariantFeatureWidget/VariantAnnPanel.d.ts +0 -4
- package/esm/VariantFeatureWidget/VariantAnnPanel.js +0 -19
- package/esm/VariantFeatureWidget/VariantAnnPanel.js.map +0 -1
- package/esm/VariantFeatureWidget/VariantCsqPanel.d.ts +0 -4
- package/esm/VariantFeatureWidget/VariantCsqPanel.js +0 -19
- package/esm/VariantFeatureWidget/VariantCsqPanel.js.map +0 -1
- package/esm/VariantFeatureWidget/VariantFeatureWidget.js.map +0 -1
- package/esm/VariantFeatureWidget/VariantSampleGrid.js.map +0 -1
- package/esm/VariantFeatureWidget/index.js.map +0 -1
- package/esm/VariantTrack/configSchema.js.map +0 -1
- package/esm/VariantTrack/index.js.map +0 -1
- package/esm/VcfAdapter/VcfAdapter.js.map +0 -1
- package/esm/VcfAdapter/configSchema.js.map +0 -1
- package/esm/VcfAdapter/index.js.map +0 -1
- package/esm/VcfFeature/index.js.map +0 -1
- package/esm/VcfFeature/util.js.map +0 -1
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js.map +0 -1
- package/esm/VcfTabixAdapter/configSchema.js.map +0 -1
- package/esm/VcfTabixAdapter/index.js.map +0 -1
- package/esm/extensionPoints.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/src/ChordVariantDisplay/index.ts +0 -23
- package/src/ChordVariantDisplay/models/configSchema.ts +0 -33
- package/src/ChordVariantDisplay/models/stateModelFactory.ts +0 -63
- package/src/LinearVariantDisplay/configSchema.ts +0 -30
- package/src/LinearVariantDisplay/index.ts +0 -20
- package/src/LinearVariantDisplay/model.ts +0 -76
- package/src/StructuralVariantChordRenderer/Chord.tsx +0 -141
- package/src/StructuralVariantChordRenderer/ReactComponent.tsx +0 -78
- package/src/StructuralVariantChordRenderer/configSchema.ts +0 -42
- package/src/StructuralVariantChordRenderer/index.ts +0 -17
- package/src/VariantFeatureWidget/AnnotGrid.tsx +0 -52
- package/src/VariantFeatureWidget/BreakendOptionDialog.tsx +0 -117
- package/src/VariantFeatureWidget/BreakendPanel.tsx +0 -93
- package/src/VariantFeatureWidget/VariantAnnPanel.tsx +0 -31
- package/src/VariantFeatureWidget/VariantCsqPanel.tsx +0 -31
- package/src/VariantFeatureWidget/VariantFeatureWidget.test.tsx +0 -42
- package/src/VariantFeatureWidget/VariantFeatureWidget.tsx +0 -67
- package/src/VariantFeatureWidget/VariantSampleGrid.tsx +0 -152
- package/src/VariantFeatureWidget/__snapshots__/VariantFeatureWidget.test.tsx.snap +0 -244
- package/src/VariantFeatureWidget/index.ts +0 -32
- package/src/VariantTrack/configSchema.ts +0 -24
- package/src/VariantTrack/index.ts +0 -16
- package/src/VcfAdapter/VcfAdapter.test.ts +0 -28
- package/src/VcfAdapter/VcfAdapter.ts +0 -125
- package/src/VcfAdapter/__snapshots__/VcfAdapter.test.ts.snap +0 -325
- package/src/VcfAdapter/configSchema.ts +0 -22
- package/src/VcfAdapter/index.ts +0 -15
- package/src/VcfAdapter/test_data/volvox.filtered.vcf +0 -73
- package/src/VcfFeature/index.test.ts +0 -132
- package/src/VcfFeature/index.ts +0 -104
- package/src/VcfFeature/util.ts +0 -138
- package/src/VcfTabixAdapter/VcfTabixAdapter.test.ts +0 -69
- package/src/VcfTabixAdapter/VcfTabixAdapter.ts +0 -90
- package/src/VcfTabixAdapter/__snapshots__/VcfTabixAdapter.test.ts.snap +0 -325
- package/src/VcfTabixAdapter/configSchema.ts +0 -43
- package/src/VcfTabixAdapter/index.ts +0 -17
- package/src/VcfTabixAdapter/test_data/volvox.filtered.vcf.gz +0 -0
- package/src/VcfTabixAdapter/test_data/volvox.filtered.vcf.gz.csi +0 -0
- package/src/VcfTabixAdapter/test_data/volvox.filtered.vcf.gz.tbi +0 -0
- package/src/__snapshots__/index.test.ts.snap +0 -20
- package/src/extensionPoints.ts +0 -74
- package/src/index.test.ts +0 -32
- package/src/index.ts +0 -27
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import VcfParser from '@gmod/vcf'
|
|
2
|
-
import VcfFeature from './index'
|
|
3
|
-
|
|
4
|
-
test('test usage of the VcfFeature', () => {
|
|
5
|
-
const parser = new VcfParser({
|
|
6
|
-
header: `#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tBAMs/caudaus.sorted.sam`,
|
|
7
|
-
})
|
|
8
|
-
const line = `lcl|Scaffald_1\t80465\trs118266897\tR\tA\t29\tPASS\tNS=3;0,14;AF=0.5;DB;112;PG2.1`
|
|
9
|
-
|
|
10
|
-
const variant = parser.parseLine(line)
|
|
11
|
-
|
|
12
|
-
const f = new VcfFeature({
|
|
13
|
-
parser,
|
|
14
|
-
variant,
|
|
15
|
-
id: 'myuniqueid',
|
|
16
|
-
})
|
|
17
|
-
expect(f.id()).toEqual('myuniqueid')
|
|
18
|
-
expect(f.get('name')).toEqual('rs118266897')
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test('try INS feature with END less than start', () => {
|
|
22
|
-
const parser = new VcfParser({
|
|
23
|
-
header: `#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tBAMs/caudaus.sorted.sam`,
|
|
24
|
-
})
|
|
25
|
-
const line = `chr1\t100\trs123\tR\tA\t29\tPASS\tEND=1;SVTYPE=INS`
|
|
26
|
-
|
|
27
|
-
const variant = parser.parseLine(line)
|
|
28
|
-
|
|
29
|
-
const f = new VcfFeature({
|
|
30
|
-
parser,
|
|
31
|
-
variant,
|
|
32
|
-
id: 'myuniqueid',
|
|
33
|
-
})
|
|
34
|
-
expect(f.id()).toEqual('myuniqueid')
|
|
35
|
-
expect(f.get('start')).toEqual(99)
|
|
36
|
-
expect(f.get('end')).toEqual(100)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
test('try DEL feature with END info field valid', () => {
|
|
40
|
-
const parser = new VcfParser({
|
|
41
|
-
header: `#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tBAMs/caudaus.sorted.sam`,
|
|
42
|
-
})
|
|
43
|
-
const line = `chr1\t100\trs123\tR\t<DEL>\t29\tPASS\tEND=1000;SVTYPE=DEL`
|
|
44
|
-
|
|
45
|
-
const variant = parser.parseLine(line)
|
|
46
|
-
|
|
47
|
-
const f = new VcfFeature({
|
|
48
|
-
parser,
|
|
49
|
-
variant,
|
|
50
|
-
id: 'myuniqueid',
|
|
51
|
-
})
|
|
52
|
-
expect(f.id()).toEqual('myuniqueid')
|
|
53
|
-
expect(f.get('start')).toEqual(99)
|
|
54
|
-
expect(f.get('end')).toEqual(1000)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test('multiple SVs', () => {
|
|
58
|
-
const parser = new VcfParser({
|
|
59
|
-
header: `#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tBAMs/caudaus.sorted.sam`,
|
|
60
|
-
})
|
|
61
|
-
const line = `chr1\t100\trs123\tR\t<INVDUP>,<INV>\t29\tPASS\tEND=1000;SVTYPE=DEL`
|
|
62
|
-
|
|
63
|
-
const variant = parser.parseLine(line)
|
|
64
|
-
|
|
65
|
-
const f = new VcfFeature({
|
|
66
|
-
parser,
|
|
67
|
-
variant,
|
|
68
|
-
id: 'myuniqueid',
|
|
69
|
-
})
|
|
70
|
-
expect(f.get('description')).toEqual('<INVDUP>,<INV>')
|
|
71
|
-
})
|
|
72
|
-
test('BND', () => {
|
|
73
|
-
const parser = new VcfParser({
|
|
74
|
-
header: `#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tBAMs/caudaus.sorted.sam`,
|
|
75
|
-
})
|
|
76
|
-
const line = `chr1\t100\trs123\tR\tG[ctgA:34200[\t29\tPASS\tEND=1000;SVTYPE=BND`
|
|
77
|
-
|
|
78
|
-
const variant = parser.parseLine(line)
|
|
79
|
-
|
|
80
|
-
const f = new VcfFeature({
|
|
81
|
-
parser,
|
|
82
|
-
variant,
|
|
83
|
-
id: 'myuniqueid',
|
|
84
|
-
})
|
|
85
|
-
expect(f.get('description')).toEqual('G[ctgA:34200[')
|
|
86
|
-
})
|
|
87
|
-
test('multiple BND', () => {
|
|
88
|
-
const parser = new VcfParser({
|
|
89
|
-
header: `#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tBAMs/caudaus.sorted.sam`,
|
|
90
|
-
})
|
|
91
|
-
const line = `chr1\t100\trs123\tR\tG[ctgA:34200[,G[ctgA:44200[\t29\tPASS\tEND=1000;SVTYPE=BND`
|
|
92
|
-
|
|
93
|
-
const variant = parser.parseLine(line)
|
|
94
|
-
|
|
95
|
-
const f = new VcfFeature({
|
|
96
|
-
parser,
|
|
97
|
-
variant,
|
|
98
|
-
id: 'myuniqueid',
|
|
99
|
-
})
|
|
100
|
-
expect(f.get('description')).toEqual('G[ctgA:34200[,G[ctgA:44200[')
|
|
101
|
-
})
|
|
102
|
-
test('multiple SNV', () => {
|
|
103
|
-
const parser = new VcfParser({
|
|
104
|
-
header: `#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tBAMs/caudaus.sorted.sam`,
|
|
105
|
-
})
|
|
106
|
-
const line = `chr1\t100\trs123\tG\tA,C\t29\tPASS\tHELLO=world`
|
|
107
|
-
|
|
108
|
-
const variant = parser.parseLine(line)
|
|
109
|
-
|
|
110
|
-
const f = new VcfFeature({
|
|
111
|
-
parser,
|
|
112
|
-
variant,
|
|
113
|
-
id: 'myuniqueid',
|
|
114
|
-
})
|
|
115
|
-
expect(f.get('description')).toEqual('SNV G -> A,C')
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
test('multiple SNV2', () => {
|
|
119
|
-
const parser = new VcfParser({
|
|
120
|
-
header: `#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tBAMs/caudaus.sorted.sam`,
|
|
121
|
-
})
|
|
122
|
-
const line = `chr1\t100\trs123\tG\tAT,<*>\t29\tPASS\tHELLO=world`
|
|
123
|
-
|
|
124
|
-
const variant = parser.parseLine(line)
|
|
125
|
-
|
|
126
|
-
const f = new VcfFeature({
|
|
127
|
-
parser,
|
|
128
|
-
variant,
|
|
129
|
-
id: 'myuniqueid',
|
|
130
|
-
})
|
|
131
|
-
expect(f.get('description')).toEqual('insertion G -> AT,<*>')
|
|
132
|
-
})
|
package/src/VcfFeature/index.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { Feature } from '@jbrowse/core/util'
|
|
2
|
-
import VCF from '@gmod/vcf'
|
|
3
|
-
|
|
4
|
-
// locals
|
|
5
|
-
import { getSOTermAndDescription } from './util'
|
|
6
|
-
|
|
7
|
-
/* eslint-disable no-underscore-dangle */
|
|
8
|
-
|
|
9
|
-
interface Samples {
|
|
10
|
-
[key: string]: {
|
|
11
|
-
[key: string]: { values: string[] | number[] | null }
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface FeatureData {
|
|
16
|
-
[key: string]: unknown
|
|
17
|
-
refName: string
|
|
18
|
-
start: number
|
|
19
|
-
end: number
|
|
20
|
-
description?: string
|
|
21
|
-
type?: string
|
|
22
|
-
name?: string
|
|
23
|
-
aliases?: string[]
|
|
24
|
-
samples?: Samples
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default class VCFFeature implements Feature {
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
private variant: any
|
|
30
|
-
|
|
31
|
-
private parser: VCF
|
|
32
|
-
|
|
33
|
-
private data: FeatureData
|
|
34
|
-
|
|
35
|
-
private _id: string
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
-
constructor(args: { variant: any; parser: VCF; id: string }) {
|
|
39
|
-
this.variant = args.variant
|
|
40
|
-
this.parser = args.parser
|
|
41
|
-
this.data = this.dataFromVariant(this.variant)
|
|
42
|
-
this._id = args.id
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
-
get(field: string): any {
|
|
47
|
-
return field === 'samples'
|
|
48
|
-
? this.variant.SAMPLES
|
|
49
|
-
: this.data[field] || this.variant[field]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
set() {}
|
|
53
|
-
|
|
54
|
-
parent() {
|
|
55
|
-
return undefined
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
children() {
|
|
59
|
-
return undefined
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
tags() {
|
|
63
|
-
return [...Object.keys(this.data), ...Object.keys(this.variant), 'samples']
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
id() {
|
|
67
|
-
return this._id
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
dataFromVariant(variant: {
|
|
71
|
-
REF: string
|
|
72
|
-
POS: number
|
|
73
|
-
ALT: string[]
|
|
74
|
-
CHROM: string
|
|
75
|
-
INFO: any // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
76
|
-
ID: string[]
|
|
77
|
-
}): FeatureData {
|
|
78
|
-
const { REF, ALT, POS, CHROM, INFO, ID } = variant
|
|
79
|
-
const start = POS - 1
|
|
80
|
-
const [type, description] = getSOTermAndDescription(REF, ALT, this.parser)
|
|
81
|
-
const isTRA = ALT?.some(f => f === '<TRA>')
|
|
82
|
-
const isSymbolic = ALT?.some(f => f.includes('<'))
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
refName: CHROM,
|
|
86
|
-
start,
|
|
87
|
-
end: isSymbolic && INFO.END && !isTRA ? +INFO.END[0] : start + REF.length,
|
|
88
|
-
description,
|
|
89
|
-
type,
|
|
90
|
-
name: ID?.join(','),
|
|
91
|
-
aliases: ID && ID.length > 1 ? variant.ID.slice(1) : undefined,
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
-
toJSON(): any {
|
|
97
|
-
return {
|
|
98
|
-
uniqueId: this._id,
|
|
99
|
-
...this.variant,
|
|
100
|
-
...this.data,
|
|
101
|
-
samples: this.variant.SAMPLES,
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
package/src/VcfFeature/util.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import VCF, { parseBreakend } from '@gmod/vcf'
|
|
2
|
-
|
|
3
|
-
const altTypeToSO: { [key: string]: string | undefined } = {
|
|
4
|
-
DEL: 'deletion',
|
|
5
|
-
INS: 'insertion',
|
|
6
|
-
DUP: 'duplication',
|
|
7
|
-
INV: 'inversion',
|
|
8
|
-
INVDUP: 'inverted duplication',
|
|
9
|
-
CNV: 'copy_number_variation',
|
|
10
|
-
TRA: 'translocation',
|
|
11
|
-
'DUP:TANDEM': 'tandem_duplication',
|
|
12
|
-
NON_REF: 'sequence_variant',
|
|
13
|
-
'*': 'sequence_variant',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get a sequence ontology (SO) term that describes the variant type
|
|
18
|
-
*/
|
|
19
|
-
export function getSOTermAndDescription(
|
|
20
|
-
ref: string,
|
|
21
|
-
alt: string[],
|
|
22
|
-
parser: VCF,
|
|
23
|
-
): string[] {
|
|
24
|
-
// it's just a remark if there are no alternate alleles
|
|
25
|
-
if (!alt || alt.length === 0) {
|
|
26
|
-
return ['remark', 'no alternative alleles']
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const soTerms = new Set<string>()
|
|
30
|
-
let descriptions = new Set<string>()
|
|
31
|
-
alt.forEach(a => {
|
|
32
|
-
let [soTerm, description] = getSOAndDescFromAltDefs(ref, a, parser)
|
|
33
|
-
if (!soTerm) {
|
|
34
|
-
;[soTerm, description] = getSOAndDescByExamination(ref, a)
|
|
35
|
-
}
|
|
36
|
-
if (soTerm && description) {
|
|
37
|
-
soTerms.add(soTerm)
|
|
38
|
-
descriptions.add(description)
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
// Combine descriptions like ["SNV G -> A", "SNV G -> T"] to ["SNV G -> A,T"]
|
|
43
|
-
if (descriptions.size > 1) {
|
|
44
|
-
const descs = [...descriptions]
|
|
45
|
-
const prefixes = new Set(
|
|
46
|
-
descs.map(desc => {
|
|
47
|
-
const prefix = desc.split('->')
|
|
48
|
-
return prefix[1] ? prefix[0] : desc
|
|
49
|
-
}),
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
descriptions = new Set(
|
|
53
|
-
[...prefixes].map(prefix => {
|
|
54
|
-
const suffixes = descs
|
|
55
|
-
.map(desc => {
|
|
56
|
-
const pref = desc.split('-> ')
|
|
57
|
-
return pref[1] && pref[0] === prefix ? pref[1] : ''
|
|
58
|
-
})
|
|
59
|
-
.filter(f => !!f)
|
|
60
|
-
|
|
61
|
-
return suffixes.length ? prefix + '-> ' + suffixes.join(',') : prefix
|
|
62
|
-
}),
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
if (soTerms.size) {
|
|
66
|
-
return [[...soTerms].join(','), [...descriptions].join(',')]
|
|
67
|
-
}
|
|
68
|
-
return []
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function getSOAndDescFromAltDefs(
|
|
72
|
-
ref: string,
|
|
73
|
-
alt: string,
|
|
74
|
-
parser: VCF,
|
|
75
|
-
): string[] {
|
|
76
|
-
if (typeof alt === 'string' && !alt.startsWith('<')) {
|
|
77
|
-
return []
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// look for a definition with an SO type for this
|
|
81
|
-
let soTerm = altTypeToSO[alt]
|
|
82
|
-
// if no SO term but ALT is in metadata, assume sequence_variant
|
|
83
|
-
if (!soTerm && parser.getMetadata('ALT', alt)) {
|
|
84
|
-
soTerm = 'sequence_variant'
|
|
85
|
-
}
|
|
86
|
-
if (soTerm) {
|
|
87
|
-
return [soTerm, alt]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// try to look for a definition for a parent term if we can
|
|
91
|
-
const modAlt = alt.split(':')
|
|
92
|
-
if (modAlt.length > 1) {
|
|
93
|
-
return getSOAndDescFromAltDefs(
|
|
94
|
-
ref,
|
|
95
|
-
`<${modAlt.slice(0, -1).join(':')}>`,
|
|
96
|
-
parser,
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// no parent
|
|
101
|
-
return []
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// note: term SNV is used instead of SNP because SO definition of SNP says
|
|
105
|
-
// abundance must be at least 1% in population, and can't be sure we meet
|
|
106
|
-
// that
|
|
107
|
-
export function getSOAndDescByExamination(ref: string, alt: string) {
|
|
108
|
-
const bnd = parseBreakend(alt)
|
|
109
|
-
if (bnd) {
|
|
110
|
-
return ['breakend', alt]
|
|
111
|
-
} else if (ref.length === 1 && alt.length === 1) {
|
|
112
|
-
return ['SNV', makeDescriptionString('SNV', ref, alt)]
|
|
113
|
-
} else if (alt === '<INS>') {
|
|
114
|
-
return ['insertion', alt]
|
|
115
|
-
} else if (alt === '<DEL>') {
|
|
116
|
-
return ['deletion', alt]
|
|
117
|
-
} else if (alt === '<INV>') {
|
|
118
|
-
return ['deletion', alt]
|
|
119
|
-
} else if (alt === '<TRA>') {
|
|
120
|
-
return ['translocation', alt]
|
|
121
|
-
} else if (alt.includes('<')) {
|
|
122
|
-
return ['sv', alt]
|
|
123
|
-
} else if (ref.length === alt.length) {
|
|
124
|
-
return ref.split('').reverse().join('') === alt
|
|
125
|
-
? ['inversion', makeDescriptionString('inversion', ref, alt)]
|
|
126
|
-
: ['substitution', makeDescriptionString('substitution', ref, alt)]
|
|
127
|
-
} else if (ref.length <= alt.length) {
|
|
128
|
-
return ['insertion', makeDescriptionString('insertion', ref, alt)]
|
|
129
|
-
} else if (ref.length > alt.length) {
|
|
130
|
-
return ['deletion', makeDescriptionString('deletion', ref, alt)]
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return ['indel', makeDescriptionString('indel', ref, alt)]
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function makeDescriptionString(soTerm: string, ref: string, alt: string) {
|
|
137
|
-
return `${soTerm} ${ref} -> ${alt}`
|
|
138
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { toArray } from 'rxjs/operators'
|
|
2
|
-
import { firstValueFrom } from 'rxjs'
|
|
3
|
-
import Adapter from './VcfTabixAdapter'
|
|
4
|
-
import configSchema from './configSchema'
|
|
5
|
-
|
|
6
|
-
test('adapter can fetch variants from volvox.vcf.gz', async () => {
|
|
7
|
-
const adapter = new Adapter(
|
|
8
|
-
configSchema.create({
|
|
9
|
-
vcfGzLocation: {
|
|
10
|
-
localPath: require.resolve('./test_data/volvox.filtered.vcf.gz'),
|
|
11
|
-
locationType: 'LocalPathLocation',
|
|
12
|
-
},
|
|
13
|
-
index: {
|
|
14
|
-
indexType: 'TBI',
|
|
15
|
-
location: {
|
|
16
|
-
localPath: require.resolve('./test_data/volvox.filtered.vcf.gz.tbi'),
|
|
17
|
-
locationType: 'LocalPathLocation',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
}),
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
const csiAdapter = new Adapter(
|
|
24
|
-
configSchema.create({
|
|
25
|
-
vcfGzLocation: {
|
|
26
|
-
localPath: require.resolve('./test_data/volvox.filtered.vcf.gz'),
|
|
27
|
-
locationType: 'LocalPathLocation',
|
|
28
|
-
},
|
|
29
|
-
index: {
|
|
30
|
-
indexType: 'CSI',
|
|
31
|
-
location: {
|
|
32
|
-
localPath: require.resolve('./test_data/volvox.filtered.vcf.gz.csi'),
|
|
33
|
-
locationType: 'LocalPathLocation',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
}),
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
const csiFeatures = csiAdapter.getFeatures({
|
|
40
|
-
refName: 'ctgA',
|
|
41
|
-
start: 0,
|
|
42
|
-
end: 20000,
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
const names = await adapter.getRefNames()
|
|
46
|
-
const csiNames = await csiAdapter.getRefNames()
|
|
47
|
-
expect(names).toEqual(csiNames)
|
|
48
|
-
expect(names).toMatchSnapshot()
|
|
49
|
-
|
|
50
|
-
const feat = adapter.getFeatures({
|
|
51
|
-
refName: 'ctgA',
|
|
52
|
-
start: 0,
|
|
53
|
-
end: 20000,
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const featArray = await firstValueFrom(feat.pipe(toArray()))
|
|
57
|
-
const csiFeaturesArray = await firstValueFrom(csiFeatures.pipe(toArray()))
|
|
58
|
-
expect(featArray.slice(0, 5)).toMatchSnapshot()
|
|
59
|
-
expect(csiFeaturesArray.slice(0, 5)).toEqual(featArray.slice(0, 5))
|
|
60
|
-
|
|
61
|
-
const featNonExist = adapter.getFeatures({
|
|
62
|
-
refName: 'ctgC',
|
|
63
|
-
start: 0,
|
|
64
|
-
end: 20000,
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
const featArrayNonExist = await firstValueFrom(featNonExist.pipe(toArray()))
|
|
68
|
-
expect(featArrayNonExist).toEqual([])
|
|
69
|
-
})
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseFeatureDataAdapter,
|
|
3
|
-
BaseOptions,
|
|
4
|
-
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
5
|
-
import { NoAssemblyRegion } from '@jbrowse/core/util/types'
|
|
6
|
-
import { openLocation } from '@jbrowse/core/util/io'
|
|
7
|
-
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
8
|
-
import { Feature } from '@jbrowse/core/util'
|
|
9
|
-
import { TabixIndexedFile } from '@gmod/tabix'
|
|
10
|
-
import VcfParser from '@gmod/vcf'
|
|
11
|
-
|
|
12
|
-
// local
|
|
13
|
-
import VcfFeature from '../VcfFeature'
|
|
14
|
-
|
|
15
|
-
export default class extends BaseFeatureDataAdapter {
|
|
16
|
-
private configured?: Promise<{
|
|
17
|
-
vcf: TabixIndexedFile
|
|
18
|
-
parser: VcfParser
|
|
19
|
-
}>
|
|
20
|
-
|
|
21
|
-
private async configurePre() {
|
|
22
|
-
const pm = this.pluginManager
|
|
23
|
-
const vcfGzLocation = this.getConf('vcfGzLocation')
|
|
24
|
-
const location = this.getConf(['index', 'location'])
|
|
25
|
-
const indexType = this.getConf(['index', 'indexType'])
|
|
26
|
-
|
|
27
|
-
const filehandle = openLocation(vcfGzLocation, pm)
|
|
28
|
-
const isCSI = indexType === 'CSI'
|
|
29
|
-
const vcf = new TabixIndexedFile({
|
|
30
|
-
filehandle,
|
|
31
|
-
csiFilehandle: isCSI ? openLocation(location, pm) : undefined,
|
|
32
|
-
tbiFilehandle: !isCSI ? openLocation(location, pm) : undefined,
|
|
33
|
-
chunkCacheSize: 50 * 2 ** 20,
|
|
34
|
-
chunkSizeLimit: 1000000000,
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const header = await vcf.getHeader()
|
|
38
|
-
return {
|
|
39
|
-
vcf,
|
|
40
|
-
parser: new VcfParser({ header }),
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
protected async configure() {
|
|
45
|
-
if (!this.configured) {
|
|
46
|
-
this.configured = this.configurePre().catch(e => {
|
|
47
|
-
this.configured = undefined
|
|
48
|
-
throw e
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
return this.configured
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public async getRefNames(opts: BaseOptions = {}) {
|
|
55
|
-
const { vcf } = await this.configure()
|
|
56
|
-
return vcf.getReferenceSequenceNames(opts)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async getHeader() {
|
|
60
|
-
const { vcf } = await this.configure()
|
|
61
|
-
return vcf.getHeader()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async getMetadata() {
|
|
65
|
-
const { parser } = await this.configure()
|
|
66
|
-
return parser.getMetadata()
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public getFeatures(query: NoAssemblyRegion, opts: BaseOptions = {}) {
|
|
70
|
-
return ObservableCreate<Feature>(async observer => {
|
|
71
|
-
const { refName, start, end } = query
|
|
72
|
-
const { vcf, parser } = await this.configure()
|
|
73
|
-
await vcf.getLines(refName, start, end, {
|
|
74
|
-
lineCallback: (line, fileOffset) => {
|
|
75
|
-
observer.next(
|
|
76
|
-
new VcfFeature({
|
|
77
|
-
variant: parser.parseLine(line),
|
|
78
|
-
parser,
|
|
79
|
-
id: `${this.id}-vcf-${fileOffset}`,
|
|
80
|
-
}),
|
|
81
|
-
)
|
|
82
|
-
},
|
|
83
|
-
...opts,
|
|
84
|
-
})
|
|
85
|
-
observer.complete()
|
|
86
|
-
}, opts.signal)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public freeResources(/* { region } */): void {}
|
|
90
|
-
}
|