Skip to content

Commit

Permalink
Use shortened VCF feature description for some types of insertions an…
Browse files Browse the repository at this point in the history
…d deletions (#3901)
  • Loading branch information
cmdcolin committed Sep 7, 2023
1 parent 7fcaa4e commit 8e17ca6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15009,7 +15009,7 @@ exports[`vcf file import 1`] = `
"QUAL": 1112.65,
"REF": "AAAAAAAAAGAAAAG",
"aliases": undefined,
"description": "deletion AAAAAAAAAGAAAAG -> A",
"description": "14bp DEL",
"end": 41256103,
"name": "rs373413425",
"refName": "17",
Expand Down
34 changes: 22 additions & 12 deletions plugins/variants/src/VcfFeature/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ export function getSOTermAndDescription(
)

descriptions = new Set(
[...prefixes].map(prefix => {
const suffixes = descs
.map(desc => {
const pref = desc.split('-> ')
return pref[1] && pref[0] === prefix ? pref[1] : ''
})
.filter(f => !!f)
[...prefixes]
.map(r => r.trim())
.map(prefix => {
const suffixes = descs
.map(desc => desc.split('->').map(r => r.trim()))
.map(pref => (pref[1] && pref[0] === prefix ? pref[1] : ''))
.filter(f => !!f)

return suffixes.length ? prefix + '-> ' + suffixes.join(',') : prefix
}),
return suffixes.length ? `${prefix} -> ${suffixes.join(',')}` : prefix
}),
)
}
if (soTerms.size) {
Expand Down Expand Up @@ -115,7 +115,7 @@ export function getSOAndDescByExamination(ref: string, alt: string) {
} else if (alt === '<DEL>') {
return ['deletion', alt]
} else if (alt === '<INV>') {
return ['deletion', alt]
return ['inversion', alt]
} else if (alt === '<TRA>') {
return ['translocation', alt]
} else if (alt.includes('<')) {
Expand All @@ -125,9 +125,19 @@ export function getSOAndDescByExamination(ref: string, alt: string) {
? ['inversion', makeDescriptionString('inversion', ref, alt)]
: ['substitution', makeDescriptionString('substitution', ref, alt)]
} else if (ref.length <= alt.length) {
return ['insertion', makeDescriptionString('insertion', ref, alt)]
const len = alt.length - ref.length
const lena = len.toLocaleString('en-US')
return [
'insertion',
len > 5 ? lena + 'bp INS' : makeDescriptionString('insertion', ref, alt),
]
} else if (ref.length > alt.length) {
return ['deletion', makeDescriptionString('deletion', ref, alt)]
const len = ref.length - alt.length
const lena = len.toLocaleString('en-US')
return [
'deletion',
len > 5 ? lena + 'bp DEL' : makeDescriptionString('deletion', ref, alt),
]
}

return ['indel', makeDescriptionString('indel', ref, alt)]
Expand Down

0 comments on commit 8e17ca6

Please sign in to comment.