@jbrowse/plugin-variants 2.3.1 → 2.3.3
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/VcfAdapter/VcfAdapter.d.ts +1 -2
- package/dist/VcfAdapter/VcfAdapter.js +2 -2
- package/dist/VcfAdapter/VcfAdapter.js.map +1 -1
- package/dist/{VcfTabixAdapter/VcfFeature.d.ts → VcfFeature/index.d.ts} +3 -15
- package/dist/VcfFeature/index.js +59 -0
- package/dist/VcfFeature/index.js.map +1 -0
- package/dist/VcfFeature/util.d.ts +7 -0
- package/dist/VcfFeature/util.js +129 -0
- package/dist/VcfFeature/util.js.map +1 -0
- package/dist/VcfTabixAdapter/VcfTabixAdapter.d.ts +2 -19
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js +1 -35
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/esm/VcfAdapter/VcfAdapter.d.ts +1 -2
- package/esm/VcfAdapter/VcfAdapter.js +2 -2
- package/esm/VcfAdapter/VcfAdapter.js.map +1 -1
- package/esm/{VcfTabixAdapter/VcfFeature.d.ts → VcfFeature/index.d.ts} +3 -15
- package/esm/VcfFeature/index.js +56 -0
- package/esm/VcfFeature/index.js.map +1 -0
- package/esm/VcfFeature/util.d.ts +7 -0
- package/esm/VcfFeature/util.js +123 -0
- package/esm/VcfFeature/util.js.map +1 -0
- package/esm/VcfTabixAdapter/VcfTabixAdapter.d.ts +2 -19
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js +1 -35
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/package.json +3 -3
- package/src/VariantFeatureWidget/VariantFeatureWidget.test.tsx +42 -0
- package/src/VariantFeatureWidget/__snapshots__/{VariantFeatureWidget.test.js.snap → VariantFeatureWidget.test.tsx.snap} +1 -1
- package/src/VcfAdapter/VcfAdapter.test.ts +4 -5
- package/src/VcfAdapter/VcfAdapter.ts +3 -4
- package/src/VcfFeature/index.test.ts +132 -0
- package/src/VcfFeature/index.ts +104 -0
- package/src/VcfFeature/util.ts +140 -0
- package/src/VcfTabixAdapter/VcfTabixAdapter.test.ts +9 -10
- package/src/VcfTabixAdapter/VcfTabixAdapter.ts +3 -51
- package/src/__snapshots__/{index.test.js.snap → index.test.ts.snap} +0 -0
- package/src/{index.test.js → index.test.ts} +0 -1
- package/src/index.ts +1 -1
- package/dist/VcfTabixAdapter/VcfFeature.js +0 -187
- package/dist/VcfTabixAdapter/VcfFeature.js.map +0 -1
- package/esm/VcfTabixAdapter/VcfFeature.js +0 -184
- package/esm/VcfTabixAdapter/VcfFeature.js.map +0 -1
- package/src/LinearVariantDisplay/configSchema.test.js +0 -55
- package/src/VariantFeatureWidget/VariantFeatureWidget.test.js +0 -41
- package/src/VcfTabixAdapter/VcfFeature.test.ts +0 -118
- package/src/VcfTabixAdapter/VcfFeature.ts +0 -250
|
@@ -0,0 +1,140 @@
|
|
|
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, modAlt.length - 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
|
+
if (ref.split('').reverse().join('') === alt) {
|
|
125
|
+
return ['inversion', makeDescriptionString('inversion', ref, alt)]
|
|
126
|
+
} else {
|
|
127
|
+
return ['substitution', makeDescriptionString('substitution', ref, alt)]
|
|
128
|
+
}
|
|
129
|
+
} else if (ref.length <= alt.length) {
|
|
130
|
+
return ['insertion', makeDescriptionString('insertion', ref, alt)]
|
|
131
|
+
} else if (ref.length > alt.length) {
|
|
132
|
+
return ['deletion', makeDescriptionString('deletion', ref, alt)]
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return ['indel', makeDescriptionString('indel', ref, alt)]
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function makeDescriptionString(soTerm: string, ref: string, alt: string) {
|
|
139
|
+
return `${soTerm} ${ref} -> ${alt}`
|
|
140
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toArray } from 'rxjs/operators'
|
|
2
|
+
import { firstValueFrom } from 'rxjs'
|
|
2
3
|
import Adapter from './VcfTabixAdapter'
|
|
3
4
|
import configSchema from './configSchema'
|
|
4
5
|
|
|
@@ -46,25 +47,23 @@ test('adapter can fetch variants from volvox.vcf.gz', async () => {
|
|
|
46
47
|
expect(names).toEqual(csiNames)
|
|
47
48
|
expect(names).toMatchSnapshot()
|
|
48
49
|
|
|
49
|
-
const
|
|
50
|
+
const feat = adapter.getFeatures({
|
|
50
51
|
refName: 'ctgA',
|
|
51
52
|
start: 0,
|
|
52
53
|
end: 20000,
|
|
53
54
|
})
|
|
54
55
|
|
|
55
|
-
const
|
|
56
|
-
const csiFeaturesArray = await csiFeatures.pipe(toArray())
|
|
57
|
-
expect(
|
|
58
|
-
expect(csiFeaturesArray.slice(0, 5)).toEqual(
|
|
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))
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
+
const featNonExist = adapter.getFeatures({
|
|
61
62
|
refName: 'ctgC',
|
|
62
63
|
start: 0,
|
|
63
64
|
end: 20000,
|
|
64
65
|
})
|
|
65
66
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
.toPromise()
|
|
69
|
-
expect(featuresArrayNonExist).toEqual([])
|
|
67
|
+
const featArrayNonExist = await firstValueFrom(featNonExist.pipe(toArray()))
|
|
68
|
+
expect(featArrayNonExist).toEqual([])
|
|
70
69
|
})
|
|
@@ -2,26 +2,18 @@ import {
|
|
|
2
2
|
BaseFeatureDataAdapter,
|
|
3
3
|
BaseOptions,
|
|
4
4
|
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
5
|
-
import {
|
|
6
|
-
FileLocation,
|
|
7
|
-
NoAssemblyRegion,
|
|
8
|
-
Region,
|
|
9
|
-
} from '@jbrowse/core/util/types'
|
|
5
|
+
import { FileLocation, NoAssemblyRegion } from '@jbrowse/core/util/types'
|
|
10
6
|
import { openLocation } from '@jbrowse/core/util/io'
|
|
11
|
-
import { bytesForRegions } from '@jbrowse/core/util'
|
|
12
7
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
13
|
-
import { Feature } from '@jbrowse/core/util
|
|
8
|
+
import { Feature } from '@jbrowse/core/util'
|
|
14
9
|
import { TabixIndexedFile } from '@gmod/tabix'
|
|
15
10
|
import VcfParser from '@gmod/vcf'
|
|
16
|
-
import { Observer } from 'rxjs'
|
|
17
|
-
import { GenericFilehandle } from 'generic-filehandle'
|
|
18
11
|
|
|
19
12
|
// local
|
|
20
|
-
import VcfFeature from '
|
|
13
|
+
import VcfFeature from '../VcfFeature'
|
|
21
14
|
|
|
22
15
|
export default class extends BaseFeatureDataAdapter {
|
|
23
16
|
private configured?: Promise<{
|
|
24
|
-
filehandle: GenericFilehandle
|
|
25
17
|
vcf: TabixIndexedFile
|
|
26
18
|
parser: VcfParser
|
|
27
19
|
}>
|
|
@@ -44,7 +36,6 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
44
36
|
|
|
45
37
|
const header = await vcf.getHeader()
|
|
46
38
|
return {
|
|
47
|
-
filehandle,
|
|
48
39
|
vcf,
|
|
49
40
|
parser: new VcfParser({ header }),
|
|
50
41
|
}
|
|
@@ -95,44 +86,5 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
95
86
|
}, opts.signal)
|
|
96
87
|
}
|
|
97
88
|
|
|
98
|
-
/**
|
|
99
|
-
* Checks if the data source has data for the given reference sequence,
|
|
100
|
-
* and then gets the features in the region if it does
|
|
101
|
-
*
|
|
102
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
103
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
104
|
-
* implement a more efficient custom version of this method.
|
|
105
|
-
*
|
|
106
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
107
|
-
* of a VCF
|
|
108
|
-
* @param regions - Regions
|
|
109
|
-
* @param opts - Feature adapter options
|
|
110
|
-
* @returns Observable of Feature objects in the regions
|
|
111
|
-
*/
|
|
112
|
-
public getFeaturesInMultipleRegions(
|
|
113
|
-
regions: Region[],
|
|
114
|
-
opts: BaseOptions = {},
|
|
115
|
-
) {
|
|
116
|
-
return ObservableCreate<Feature>(async (observer: Observer<Feature>) => {
|
|
117
|
-
const { vcf } = await this.configure()
|
|
118
|
-
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
const bytes = await bytesForRegions(regions, vcf.index)
|
|
121
|
-
const { filehandle } = await this.configure()
|
|
122
|
-
const stat = await filehandle.stat()
|
|
123
|
-
let pct = Math.round((bytes / stat.size) * 100)
|
|
124
|
-
if (pct > 100) {
|
|
125
|
-
// this is just a bad estimate, make 100% if it goes over
|
|
126
|
-
pct = 100
|
|
127
|
-
}
|
|
128
|
-
if (pct > 60) {
|
|
129
|
-
console.warn(
|
|
130
|
-
`getFeaturesInMultipleRegions fetching ${pct}% of VCF file, but whole-file streaming not yet implemented`,
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
super.getFeaturesInMultipleRegions(regions, opts).subscribe(observer)
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
89
|
public freeResources(/* { region } */): void {}
|
|
138
90
|
}
|
|
File without changes
|
package/src/index.ts
CHANGED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vcf_1 = require("@gmod/vcf");
|
|
4
|
-
class VCFFeature {
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
constructor(args) {
|
|
7
|
-
this.variant = args.variant;
|
|
8
|
-
this.parser = args.parser;
|
|
9
|
-
this.data = this.dataFromVariant(this.variant);
|
|
10
|
-
this._id = args.id;
|
|
11
|
-
}
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
get(field) {
|
|
14
|
-
return field === 'samples'
|
|
15
|
-
? this.variant.SAMPLES
|
|
16
|
-
: this.data[field] || this.variant[field];
|
|
17
|
-
}
|
|
18
|
-
set() { }
|
|
19
|
-
parent() {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
children() {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
tags() {
|
|
26
|
-
const t = [
|
|
27
|
-
...Object.keys(this.data),
|
|
28
|
-
...Object.keys(this.variant),
|
|
29
|
-
'samples',
|
|
30
|
-
];
|
|
31
|
-
return t;
|
|
32
|
-
}
|
|
33
|
-
id() {
|
|
34
|
-
return this._id;
|
|
35
|
-
}
|
|
36
|
-
dataFromVariant(variant) {
|
|
37
|
-
const { REF, ALT, POS, CHROM, INFO, ID } = variant;
|
|
38
|
-
const start = POS - 1;
|
|
39
|
-
const [SO_term, description] = this._getSOTermAndDescription(REF, ALT);
|
|
40
|
-
const isTRA = ALT === null || ALT === void 0 ? void 0 : ALT.some(f => f === '<TRA>');
|
|
41
|
-
const isSymbolic = ALT === null || ALT === void 0 ? void 0 : ALT.some(f => f.indexOf('<') !== -1);
|
|
42
|
-
return {
|
|
43
|
-
refName: CHROM,
|
|
44
|
-
start,
|
|
45
|
-
end: isSymbolic && INFO.END && !isTRA ? +INFO.END[0] : start + REF.length,
|
|
46
|
-
description,
|
|
47
|
-
type: SO_term,
|
|
48
|
-
name: ID === null || ID === void 0 ? void 0 : ID.join(','),
|
|
49
|
-
aliases: ID && ID.length > 1 ? variant.ID.slice(1) : undefined,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Get a sequence ontology (SO) term that describes the variant type
|
|
54
|
-
*/
|
|
55
|
-
_getSOTermAndDescription(ref, alt) {
|
|
56
|
-
// it's just a remark if there are no alternate alleles
|
|
57
|
-
if (!alt || alt.length === 0) {
|
|
58
|
-
return ['remark', 'no alternative alleles'];
|
|
59
|
-
}
|
|
60
|
-
const soTerms = new Set();
|
|
61
|
-
let descriptions = new Set();
|
|
62
|
-
alt.forEach(a => {
|
|
63
|
-
let [soTerm, description] = this._getSOAndDescFromAltDefs(ref, a);
|
|
64
|
-
if (!soTerm) {
|
|
65
|
-
;
|
|
66
|
-
[soTerm, description] = this._getSOAndDescByExamination(ref, a);
|
|
67
|
-
}
|
|
68
|
-
if (soTerm && description) {
|
|
69
|
-
soTerms.add(soTerm);
|
|
70
|
-
descriptions.add(description);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
// Combine descriptions like ["SNV G -> A", "SNV G -> T"] to ["SNV G -> A,T"]
|
|
74
|
-
if (descriptions.size > 1) {
|
|
75
|
-
const prefixes = new Set([...descriptions].map(desc => {
|
|
76
|
-
const prefix = desc.split('->');
|
|
77
|
-
return prefix[1] ? prefix[0] : desc;
|
|
78
|
-
}));
|
|
79
|
-
const new_descs = [...prefixes].map(prefix => {
|
|
80
|
-
const suffixes = [...descriptions]
|
|
81
|
-
.map(desc => {
|
|
82
|
-
const pref = desc.split('-> ');
|
|
83
|
-
return pref[1] && pref[0] === prefix ? pref[1] : '';
|
|
84
|
-
})
|
|
85
|
-
.filter(f => !!f);
|
|
86
|
-
return suffixes.length
|
|
87
|
-
? prefix + '-> ' + suffixes.join(',')
|
|
88
|
-
: [...descriptions].join(',');
|
|
89
|
-
});
|
|
90
|
-
descriptions = new Set(new_descs);
|
|
91
|
-
}
|
|
92
|
-
if (soTerms.size) {
|
|
93
|
-
return [[...soTerms].join(','), [...descriptions].join(',')];
|
|
94
|
-
}
|
|
95
|
-
return [undefined, undefined];
|
|
96
|
-
}
|
|
97
|
-
_getSOAndDescFromAltDefs(ref, alt) {
|
|
98
|
-
if (typeof alt === 'string' && !alt.startsWith('<')) {
|
|
99
|
-
return [undefined, undefined];
|
|
100
|
-
}
|
|
101
|
-
// look for a definition with an SO type for this
|
|
102
|
-
let soTerm = VCFFeature._altTypeToSO[alt];
|
|
103
|
-
// if no SO term but ALT is in metadata, assume sequence_variant
|
|
104
|
-
if (!soTerm && this.parser.getMetadata('ALT', alt)) {
|
|
105
|
-
soTerm = 'sequence_variant';
|
|
106
|
-
}
|
|
107
|
-
if (soTerm) {
|
|
108
|
-
return [soTerm, alt];
|
|
109
|
-
}
|
|
110
|
-
// try to look for a definition for a parent term if we can
|
|
111
|
-
const modAlt = alt.split(':');
|
|
112
|
-
if (modAlt.length > 1) {
|
|
113
|
-
return this._getSOAndDescFromAltDefs(ref, `<${modAlt.slice(0, modAlt.length - 1).join(':')}>`);
|
|
114
|
-
}
|
|
115
|
-
// no parent
|
|
116
|
-
return [undefined, undefined];
|
|
117
|
-
}
|
|
118
|
-
// note: term SNV is used instead of SNP because SO definition of SNP says
|
|
119
|
-
// abundance must be at least 1% in population, and can't be sure we meet
|
|
120
|
-
// that
|
|
121
|
-
_getSOAndDescByExamination(ref, alt) {
|
|
122
|
-
const bnd = (0, vcf_1.parseBreakend)(alt);
|
|
123
|
-
if (bnd) {
|
|
124
|
-
return ['breakend', alt];
|
|
125
|
-
}
|
|
126
|
-
else if (ref.length === 1 && alt.length === 1) {
|
|
127
|
-
return ['SNV', this._makeDescriptionString('SNV', ref, alt)];
|
|
128
|
-
}
|
|
129
|
-
else if (alt === '<INS>') {
|
|
130
|
-
return ['insertion', alt];
|
|
131
|
-
}
|
|
132
|
-
else if (alt === '<DEL>') {
|
|
133
|
-
return ['deletion', alt];
|
|
134
|
-
}
|
|
135
|
-
else if (alt === '<INV>') {
|
|
136
|
-
return ['deletion', alt];
|
|
137
|
-
}
|
|
138
|
-
else if (alt === '<TRA>') {
|
|
139
|
-
return ['translocation', alt];
|
|
140
|
-
}
|
|
141
|
-
else if (alt.includes('<')) {
|
|
142
|
-
return ['sv', alt];
|
|
143
|
-
}
|
|
144
|
-
else if (ref.length === alt.length) {
|
|
145
|
-
if (ref.split('').reverse().join('') === alt) {
|
|
146
|
-
return ['inversion', this._makeDescriptionString('inversion', ref, alt)];
|
|
147
|
-
}
|
|
148
|
-
return [
|
|
149
|
-
'substitution',
|
|
150
|
-
this._makeDescriptionString('substitution', ref, alt),
|
|
151
|
-
];
|
|
152
|
-
}
|
|
153
|
-
else if (ref.length <= alt.length) {
|
|
154
|
-
return ['insertion', this._makeDescriptionString('insertion', ref, alt)];
|
|
155
|
-
}
|
|
156
|
-
else if (ref.length > alt.length) {
|
|
157
|
-
return ['deletion', this._makeDescriptionString('deletion', ref, alt)];
|
|
158
|
-
}
|
|
159
|
-
return ['indel', this._makeDescriptionString('indel', ref, alt)];
|
|
160
|
-
}
|
|
161
|
-
_makeDescriptionString(soTerm, ref, alt) {
|
|
162
|
-
return `${soTerm} ${ref} -> ${alt}`;
|
|
163
|
-
}
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
|
-
toJSON() {
|
|
166
|
-
return {
|
|
167
|
-
uniqueId: this._id,
|
|
168
|
-
...this.variant,
|
|
169
|
-
...this.data,
|
|
170
|
-
samples: this.variant.SAMPLES,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
exports.default = VCFFeature;
|
|
175
|
-
VCFFeature._altTypeToSO = {
|
|
176
|
-
DEL: 'deletion',
|
|
177
|
-
INS: 'insertion',
|
|
178
|
-
DUP: 'duplication',
|
|
179
|
-
INV: 'inversion',
|
|
180
|
-
INVDUP: 'inverted duplication',
|
|
181
|
-
CNV: 'copy_number_variation',
|
|
182
|
-
TRA: 'translocation',
|
|
183
|
-
'DUP:TANDEM': 'tandem_duplication',
|
|
184
|
-
NON_REF: 'sequence_variant',
|
|
185
|
-
'*': 'sequence_variant',
|
|
186
|
-
};
|
|
187
|
-
//# sourceMappingURL=VcfFeature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VcfFeature.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfFeature.ts"],"names":[],"mappings":";;AACA,mCAAyC;AAyBzC,MAAqB,UAAU;IAW7B,8DAA8D;IAC9D,YAAY,IAA+C;QACzD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAA;IACpB,CAAC;IAED,8DAA8D;IAC9D,GAAG,CAAC,KAAa;QACf,OAAO,KAAK,KAAK,SAAS;YACxB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO;YACtB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK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,CAAA;SACvE;QAED,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;IAClE,CAAC;IAED,sBAAsB,CAAC,MAAc,EAAE,GAAW,EAAE,GAAW;QAC7D,OAAO,GAAG,MAAM,IAAI,GAAG,OAAO,GAAG,EAAE,CAAA;IACrC,CAAC;IAED,8DAA8D;IAC9D,MAAM;QACJ,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,GAAG;YAClB,GAAG,IAAI,CAAC,OAAO;YACf,GAAG,IAAI,CAAC,IAAI;YACZ,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;SAC9B,CAAA;IACH,CAAC;;AA9NH,6BA+NC;AA7FQ,uBAAY,GAA0C;IAC3D,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,WAAW;IAChB,MAAM,EAAE,sBAAsB;IAC9B,GAAG,EAAE,uBAAuB;IAC5B,GAAG,EAAE,eAAe;IACpB,YAAY,EAAE,oBAAoB;IAClC,OAAO,EAAE,kBAAkB;IAC3B,GAAG,EAAE,kBAAkB;CACxB,CAAA"}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { parseBreakend } from '@gmod/vcf';
|
|
2
|
-
export default class VCFFeature {
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
constructor(args) {
|
|
5
|
-
this.variant = args.variant;
|
|
6
|
-
this.parser = args.parser;
|
|
7
|
-
this.data = this.dataFromVariant(this.variant);
|
|
8
|
-
this._id = args.id;
|
|
9
|
-
}
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
-
get(field) {
|
|
12
|
-
return field === 'samples'
|
|
13
|
-
? this.variant.SAMPLES
|
|
14
|
-
: this.data[field] || this.variant[field];
|
|
15
|
-
}
|
|
16
|
-
set() { }
|
|
17
|
-
parent() {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
children() {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
tags() {
|
|
24
|
-
const t = [
|
|
25
|
-
...Object.keys(this.data),
|
|
26
|
-
...Object.keys(this.variant),
|
|
27
|
-
'samples',
|
|
28
|
-
];
|
|
29
|
-
return t;
|
|
30
|
-
}
|
|
31
|
-
id() {
|
|
32
|
-
return this._id;
|
|
33
|
-
}
|
|
34
|
-
dataFromVariant(variant) {
|
|
35
|
-
const { REF, ALT, POS, CHROM, INFO, ID } = variant;
|
|
36
|
-
const start = POS - 1;
|
|
37
|
-
const [SO_term, description] = this._getSOTermAndDescription(REF, ALT);
|
|
38
|
-
const isTRA = ALT === null || ALT === void 0 ? void 0 : ALT.some(f => f === '<TRA>');
|
|
39
|
-
const isSymbolic = ALT === null || ALT === void 0 ? void 0 : ALT.some(f => f.indexOf('<') !== -1);
|
|
40
|
-
return {
|
|
41
|
-
refName: CHROM,
|
|
42
|
-
start,
|
|
43
|
-
end: isSymbolic && INFO.END && !isTRA ? +INFO.END[0] : start + REF.length,
|
|
44
|
-
description,
|
|
45
|
-
type: SO_term,
|
|
46
|
-
name: ID === null || ID === void 0 ? void 0 : ID.join(','),
|
|
47
|
-
aliases: ID && ID.length > 1 ? variant.ID.slice(1) : undefined,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Get a sequence ontology (SO) term that describes the variant type
|
|
52
|
-
*/
|
|
53
|
-
_getSOTermAndDescription(ref, alt) {
|
|
54
|
-
// it's just a remark if there are no alternate alleles
|
|
55
|
-
if (!alt || alt.length === 0) {
|
|
56
|
-
return ['remark', 'no alternative alleles'];
|
|
57
|
-
}
|
|
58
|
-
const soTerms = new Set();
|
|
59
|
-
let descriptions = new Set();
|
|
60
|
-
alt.forEach(a => {
|
|
61
|
-
let [soTerm, description] = this._getSOAndDescFromAltDefs(ref, a);
|
|
62
|
-
if (!soTerm) {
|
|
63
|
-
;
|
|
64
|
-
[soTerm, description] = this._getSOAndDescByExamination(ref, a);
|
|
65
|
-
}
|
|
66
|
-
if (soTerm && description) {
|
|
67
|
-
soTerms.add(soTerm);
|
|
68
|
-
descriptions.add(description);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
// Combine descriptions like ["SNV G -> A", "SNV G -> T"] to ["SNV G -> A,T"]
|
|
72
|
-
if (descriptions.size > 1) {
|
|
73
|
-
const prefixes = new Set([...descriptions].map(desc => {
|
|
74
|
-
const prefix = desc.split('->');
|
|
75
|
-
return prefix[1] ? prefix[0] : desc;
|
|
76
|
-
}));
|
|
77
|
-
const new_descs = [...prefixes].map(prefix => {
|
|
78
|
-
const suffixes = [...descriptions]
|
|
79
|
-
.map(desc => {
|
|
80
|
-
const pref = desc.split('-> ');
|
|
81
|
-
return pref[1] && pref[0] === prefix ? pref[1] : '';
|
|
82
|
-
})
|
|
83
|
-
.filter(f => !!f);
|
|
84
|
-
return suffixes.length
|
|
85
|
-
? prefix + '-> ' + suffixes.join(',')
|
|
86
|
-
: [...descriptions].join(',');
|
|
87
|
-
});
|
|
88
|
-
descriptions = new Set(new_descs);
|
|
89
|
-
}
|
|
90
|
-
if (soTerms.size) {
|
|
91
|
-
return [[...soTerms].join(','), [...descriptions].join(',')];
|
|
92
|
-
}
|
|
93
|
-
return [undefined, undefined];
|
|
94
|
-
}
|
|
95
|
-
_getSOAndDescFromAltDefs(ref, alt) {
|
|
96
|
-
if (typeof alt === 'string' && !alt.startsWith('<')) {
|
|
97
|
-
return [undefined, undefined];
|
|
98
|
-
}
|
|
99
|
-
// look for a definition with an SO type for this
|
|
100
|
-
let soTerm = VCFFeature._altTypeToSO[alt];
|
|
101
|
-
// if no SO term but ALT is in metadata, assume sequence_variant
|
|
102
|
-
if (!soTerm && this.parser.getMetadata('ALT', alt)) {
|
|
103
|
-
soTerm = 'sequence_variant';
|
|
104
|
-
}
|
|
105
|
-
if (soTerm) {
|
|
106
|
-
return [soTerm, alt];
|
|
107
|
-
}
|
|
108
|
-
// try to look for a definition for a parent term if we can
|
|
109
|
-
const modAlt = alt.split(':');
|
|
110
|
-
if (modAlt.length > 1) {
|
|
111
|
-
return this._getSOAndDescFromAltDefs(ref, `<${modAlt.slice(0, modAlt.length - 1).join(':')}>`);
|
|
112
|
-
}
|
|
113
|
-
// no parent
|
|
114
|
-
return [undefined, undefined];
|
|
115
|
-
}
|
|
116
|
-
// note: term SNV is used instead of SNP because SO definition of SNP says
|
|
117
|
-
// abundance must be at least 1% in population, and can't be sure we meet
|
|
118
|
-
// that
|
|
119
|
-
_getSOAndDescByExamination(ref, alt) {
|
|
120
|
-
const bnd = parseBreakend(alt);
|
|
121
|
-
if (bnd) {
|
|
122
|
-
return ['breakend', alt];
|
|
123
|
-
}
|
|
124
|
-
else if (ref.length === 1 && alt.length === 1) {
|
|
125
|
-
return ['SNV', this._makeDescriptionString('SNV', ref, alt)];
|
|
126
|
-
}
|
|
127
|
-
else if (alt === '<INS>') {
|
|
128
|
-
return ['insertion', alt];
|
|
129
|
-
}
|
|
130
|
-
else if (alt === '<DEL>') {
|
|
131
|
-
return ['deletion', alt];
|
|
132
|
-
}
|
|
133
|
-
else if (alt === '<INV>') {
|
|
134
|
-
return ['deletion', alt];
|
|
135
|
-
}
|
|
136
|
-
else if (alt === '<TRA>') {
|
|
137
|
-
return ['translocation', alt];
|
|
138
|
-
}
|
|
139
|
-
else if (alt.includes('<')) {
|
|
140
|
-
return ['sv', alt];
|
|
141
|
-
}
|
|
142
|
-
else if (ref.length === alt.length) {
|
|
143
|
-
if (ref.split('').reverse().join('') === alt) {
|
|
144
|
-
return ['inversion', this._makeDescriptionString('inversion', ref, alt)];
|
|
145
|
-
}
|
|
146
|
-
return [
|
|
147
|
-
'substitution',
|
|
148
|
-
this._makeDescriptionString('substitution', ref, alt),
|
|
149
|
-
];
|
|
150
|
-
}
|
|
151
|
-
else if (ref.length <= alt.length) {
|
|
152
|
-
return ['insertion', this._makeDescriptionString('insertion', ref, alt)];
|
|
153
|
-
}
|
|
154
|
-
else if (ref.length > alt.length) {
|
|
155
|
-
return ['deletion', this._makeDescriptionString('deletion', ref, alt)];
|
|
156
|
-
}
|
|
157
|
-
return ['indel', this._makeDescriptionString('indel', ref, alt)];
|
|
158
|
-
}
|
|
159
|
-
_makeDescriptionString(soTerm, ref, alt) {
|
|
160
|
-
return `${soTerm} ${ref} -> ${alt}`;
|
|
161
|
-
}
|
|
162
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
|
-
toJSON() {
|
|
164
|
-
return {
|
|
165
|
-
uniqueId: this._id,
|
|
166
|
-
...this.variant,
|
|
167
|
-
...this.data,
|
|
168
|
-
samples: this.variant.SAMPLES,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
VCFFeature._altTypeToSO = {
|
|
173
|
-
DEL: 'deletion',
|
|
174
|
-
INS: 'insertion',
|
|
175
|
-
DUP: 'duplication',
|
|
176
|
-
INV: 'inversion',
|
|
177
|
-
INVDUP: 'inverted duplication',
|
|
178
|
-
CNV: 'copy_number_variation',
|
|
179
|
-
TRA: 'translocation',
|
|
180
|
-
'DUP:TANDEM': 'tandem_duplication',
|
|
181
|
-
NON_REF: 'sequence_variant',
|
|
182
|
-
'*': 'sequence_variant',
|
|
183
|
-
};
|
|
184
|
-
//# sourceMappingURL=VcfFeature.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VcfFeature.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfFeature.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAyBzC,MAAM,CAAC,OAAO,OAAO,UAAU;IAW7B,8DAA8D;IAC9D,YAAY,IAA+C;QACzD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QACz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