From caa8713df7887f01187957167a388af7705a36b5 Mon Sep 17 00:00:00 2001 From: Jonas Kellerer Date: Thu, 14 Dec 2023 17:09:28 +0100 Subject: [PATCH] feat: allow loweer case for mutations --- .../genspectrum/lapis/request/AminoAcidMutation.kt | 4 ++-- .../genspectrum/lapis/request/NucleotideMutation.kt | 5 +++-- .../lapis/request/AminoAcidMutationTest.kt | 4 ++++ .../lapis/request/NucleotideMutationTest.kt | 12 ++++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/request/AminoAcidMutation.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/request/AminoAcidMutation.kt index 420f9b60..3bc8fb8a 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/request/AminoAcidMutation.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/request/AminoAcidMutation.kt @@ -26,7 +26,7 @@ data class AminoAcidMutation(val gene: String, val position: Int, val symbol: St return AminoAcidMutation( gene, position, - matchGroups["symbolTo"]?.value, + matchGroups["symbolTo"]?.value?.uppercase(), ) } } @@ -34,7 +34,7 @@ data class AminoAcidMutation(val gene: String, val position: Int, val symbol: St private val AMINO_ACID_MUTATION_REGEX = Regex( - """^((?[a-zA-Z0-9_-]+):)(?[A-Z]?)(?\d+)(?[A-Z.-])?$""", + """^((?[a-zA-Z0-9_-]+):)(?[a-zA-Z]?)(?\d+)(?[a-zA-Z.-])?$""", ) @JsonComponent diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/request/NucleotideMutation.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/request/NucleotideMutation.kt index aec265a6..98ecc08d 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/request/NucleotideMutation.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/request/NucleotideMutation.kt @@ -24,7 +24,7 @@ data class NucleotideMutation(val sequenceName: String?, val position: Int, val return NucleotideMutation( matchGroups["sequenceName"]?.value, position, - matchGroups["symbolTo"]?.value, + matchGroups["symbolTo"]?.value?.uppercase(), ) } } @@ -32,7 +32,8 @@ data class NucleotideMutation(val sequenceName: String?, val position: Int, val private val NUCLEOTIDE_MUTATION_REGEX = Regex( - """^((?[a-zA-Z0-9_-]+)(?=:):)?(?[A-Z]?)(?\d+)(?[A-Z.-])?$""", + @Suppress("ktlint:standard:max-line-length") + """^((?[a-zA-Z0-9_-]+)(?=:):)?(?[a-zA-Z]?)(?\d+)(?[a-zA-Z.-])?$""", ) @JsonComponent diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/request/AminoAcidMutationTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/request/AminoAcidMutationTest.kt index 8405a0e4..b9208bfd 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/request/AminoAcidMutationTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/request/AminoAcidMutationTest.kt @@ -68,6 +68,10 @@ class AminoAcidMutationTest { "\"ORF1b:123X\"", AminoAcidMutation("ORF1b", 123, "X"), ), + Arguments.of( + "\"gene:123a\"", + AminoAcidMutation("gene", 123, "A"), + ), ) @JvmStatic diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/request/NucleotideMutationTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/request/NucleotideMutationTest.kt index 15e2173b..bbdd3f44 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/request/NucleotideMutationTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/request/NucleotideMutationTest.kt @@ -68,6 +68,18 @@ class NucleotideMutationTest { "\"sequence-Name_1:123X\"", NucleotideMutation("sequence-Name_1", 123, "X"), ), + Arguments.of( + "\"g123A\"", + NucleotideMutation(null, 123, "A"), + ), + Arguments.of( + "\"G123a\"", + NucleotideMutation(null, 123, "A"), + ), + Arguments.of( + "\"g123a\"", + NucleotideMutation(null, 123, "A"), + ), ) @JvmStatic