Skip to content

Commit

Permalink
Cleaner indel feature description
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 7, 2023
1 parent 273aa6b commit 653bc07
Showing 1 changed file with 22 additions and 12 deletions.
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 653bc07

Please sign in to comment.