From aed77334e5ffd4923290c8bfcfb9dfe0daa262be Mon Sep 17 00:00:00 2001 From: Jeremy Stone <74574922+jstone-uw@users.noreply.github.com> Date: Wed, 15 May 2024 09:13:56 -0700 Subject: [PATCH 1/2] Allow Ter in the heatmap. To date, the heatmap has only accepted the single-character code "*" for stop codons. This usage was present in some old score sets, but it is not valid MAVE-HGVS notation. We will continue to support single-character notation for both amino acids and stop codons in the heatmap, but here we allow Ter as well. On the server side, single-character notation is not accepted, and the old score sets with invalid strings will be updated. --- src/components/ScoreSetHeatmap.vue | 12 +++++++++--- src/lib/heatmap.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/ScoreSetHeatmap.vue b/src/components/ScoreSetHeatmap.vue index 125c7a68..2e25e57c 100644 --- a/src/components/ScoreSetHeatmap.vue +++ b/src/components/ScoreSetHeatmap.vue @@ -165,6 +165,10 @@ export default { prepareSimpleVariantInstances: function(scores) { let numComplexVariantInstances = 0 + + // Count of variants that do not appear to be complex but are don't have a valid substitution + let numIgnoredVariantInstances = 0 + const simpleVariantInstances = _.filter( scores.map((score) => { const variant = parseSimpleProVariant(score.hgvs_pro) @@ -172,16 +176,18 @@ export default { numComplexVariantInstances++ return null } - if (variant.substitution == 'Ter') { + const row = heatmapRowForVariant(variant.substitution) + if (row == null) { + numIgnoredVariantInstances++ return null } const x = variant.position - const y = HEATMAP_ROWS.length - 1 - heatmapRowForVariant(variant.substitution) + const y = HEATMAP_ROWS.length - 1 - row return {x, y, score: score.score, details: _.omit(score, 'score')} }), (x) => x != null ) - return {simpleVariantInstances, numComplexVariantInstances} + return {simpleVariantInstances, numComplexVariantInstances, numIgnoredVariantInstances} }, prepareSimpleVariants: function(scores) { diff --git a/src/lib/heatmap.ts b/src/lib/heatmap.ts index 50cb4770..bac098e2 100644 --- a/src/lib/heatmap.ts +++ b/src/lib/heatmap.ts @@ -3,7 +3,7 @@ import {AMINO_ACIDS, AMINO_ACIDS_BY_HYDROPHILIA} from './amino-acids.js' /** Codes used in the right part of a MaveHGVS-pro string representing a single variation in a protein sequence. */ const MAVE_HGVS_PRO_CHANGE_CODES = [ {codes: {single: '='}}, // Synonymous AA variant - {codes: {single: '*'}}, // Stop codon + {codes: {single: '*', triple: 'TER'}}, // Stop codon {codes: {single: '-', triple: 'DEL'}} // Deletion ] From 3460d1e4f7c3985b32d2bcc8ac10e63a4ec58355 Mon Sep 17 00:00:00 2001 From: Jeremy Stone <74574922+jstone-uw@users.noreply.github.com> Date: Wed, 15 May 2024 11:45:56 -0700 Subject: [PATCH 2/2] Allow single-character codes for deletion and nonsense mutations when generating the heatmap. This should not occur now that we have replaced noncompliant single-character deletions with Ter, but since the heatmap itself supports * and -, we'll relax the regular expression used when parsing simple mavehgvs_pro strings. --- src/lib/mave-hgvs.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/mave-hgvs.ts b/src/lib/mave-hgvs.ts index eece4b7f..a36cb52d 100644 --- a/src/lib/mave-hgvs.ts +++ b/src/lib/mave-hgvs.ts @@ -15,8 +15,13 @@ interface SimpleProteinVariation { substitution: string } -/** Regular expression for parsing simple MaveHGVS-pro expressions. */ -const proVariantRegex = /^p\.([A-Za-z]{3})([0-9]+)([A-Za-z]{3}|=)$/ +/** + * Regular expression for parsing simple MaveHGVS-pro expressions. + * + * MaveHGVS doesn't allow single-character codes in substitutions, but for flexibility we allow * and - here. These are + * properly represented as Ter and del in MaveHGVS. + */ +const proVariantRegex = /^p\.([A-Za-z]{3})([0-9]+)([A-Za-z]{3}|=|\*|-)$/ /** * Parse a MaveHGVS protein variant representing a variation at one locus.