From ef0475df5977d4be903d2f59b50f006b4145413d Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 13 Sep 2024 11:47:27 -0400 Subject: [PATCH] Add test for null ALT --- .../__snapshots__/index.test.ts.snap | 29 +++++++++++++++++++ plugins/variants/src/VcfFeature/index.test.ts | 19 ++++++++++++ plugins/variants/src/VcfFeature/index.ts | 4 +-- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 plugins/variants/src/VcfFeature/__snapshots__/index.test.ts.snap diff --git a/plugins/variants/src/VcfFeature/__snapshots__/index.test.ts.snap b/plugins/variants/src/VcfFeature/__snapshots__/index.test.ts.snap new file mode 100644 index 0000000000..6923e05b04 --- /dev/null +++ b/plugins/variants/src/VcfFeature/__snapshots__/index.test.ts.snap @@ -0,0 +1,29 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`null ALT 1`] = ` +{ + "ALT": null, + "CHROM": "chr1", + "FILTER": "PASS", + "ID": [ + "rs123", + ], + "INFO": { + "HELLO": [ + "world", + ], + }, + "POS": 100, + "QUAL": 29, + "REF": "G", + "aliases": undefined, + "description": "no alternative alleles", + "end": 100, + "name": "rs123", + "refName": "chr1", + "samples": {}, + "start": 99, + "type": "remark", + "uniqueId": "myuniqueid", +} +`; diff --git a/plugins/variants/src/VcfFeature/index.test.ts b/plugins/variants/src/VcfFeature/index.test.ts index 8be809d7b5..74e1d38e36 100644 --- a/plugins/variants/src/VcfFeature/index.test.ts +++ b/plugins/variants/src/VcfFeature/index.test.ts @@ -142,3 +142,22 @@ test('multiple SNV2', () => { }) expect(f.get('description')).toEqual('insertion G -> AT,<*>') }) + +// see example 1.1 in VCF 4.3 spec, indicates the . in ALT field indicates +// "a site that is called monomorphic reference (i.e. with no alternate alleles" +test('null ALT', () => { + const parser = new VcfParser({ + header: + '#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tBAMs/caudaus.sorted.sam', + }) + const line = 'chr1\t100\trs123\tG\t.\t29\tPASS\tHELLO=world' + + const variant = parser.parseLine(line) + + const f = new VcfFeature({ + parser, + variant, + id: 'myuniqueid', + }) + expect(f.toJSON()).toMatchSnapshot() +}) diff --git a/plugins/variants/src/VcfFeature/index.ts b/plugins/variants/src/VcfFeature/index.ts index 16865eff91..d9ff474cf7 100644 --- a/plugins/variants/src/VcfFeature/index.ts +++ b/plugins/variants/src/VcfFeature/index.ts @@ -72,8 +72,8 @@ export default class VCFFeature implements Feature { const { REF, ALT, POS, CHROM, INFO, ID } = variant const start = POS - 1 const [type, description] = getSOTermAndDescription(REF, ALT, this.parser) - const isTRA = ALT.includes('') - const isSymbolic = ALT.some(f => f.includes('<')) + const isTRA = ALT?.includes('') + const isSymbolic = ALT?.some(f => f.includes('<')) return { refName: CHROM,