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 041be88
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 122 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()
})
6 changes: 3 additions & 3 deletions plugins/variants/src/VcfFeature/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ export default class VCFFeature implements Feature {
dataFromVariant(variant: {
REF: string
POS: number
ALT: string[]
ALT?: string[]
CHROM: string
INFO: any
ID?: string[]
}): FeatureData {
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>')
const isSymbolic = ALT?.some(f => f.includes('<'))

return {
refName: CHROM,
Expand Down
2 changes: 1 addition & 1 deletion products/jbrowse-cli/src/commands/text-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export default class TextIndex extends JBrowseCommand {
await this.indexDriver({
trackConfigs,
outLocation: outFlag,
name: trackConfigs.length > 1 ? 'aggregate' : path.basename(file[0]!),
name: trackConfigs.length > 1 ? 'aggregate' : path.basename(file[0]),

Check failure on line 364 in products/jbrowse-cli/src/commands/text-index.ts

View workflow job for this annotation

GitHub Actions / Lint, typecheck, test

Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
quiet,
attributes: attributes.split(','),
typesToExclude: exclude.split(','),
Expand Down
Loading

0 comments on commit 041be88

Please sign in to comment.