Skip to content

Commit

Permalink
Add test for null ALT
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 13, 2024
1 parent 8b8fdb3 commit ef0475d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
29 changes: 29 additions & 0 deletions plugins/variants/src/VcfFeature/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -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",
}
`;
19 changes: 19 additions & 0 deletions plugins/variants/src/VcfFeature/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
4 changes: 2 additions & 2 deletions plugins/variants/src/VcfFeature/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('<TRA>')
const isSymbolic = ALT.some(f => f.includes('<'))
const isTRA = ALT?.includes('<TRA>')

Check failure on line 75 in plugins/variants/src/VcfFeature/index.ts

View workflow job for this annotation

GitHub Actions / Lint, typecheck, test

Unnecessary optional chain on a non-nullish value
const isSymbolic = ALT?.some(f => f.includes('<'))

Check failure on line 76 in plugins/variants/src/VcfFeature/index.ts

View workflow job for this annotation

GitHub Actions / Lint, typecheck, test

Unnecessary optional chain on a non-nullish value

return {
refName: CHROM,
Expand Down

0 comments on commit ef0475d

Please sign in to comment.