Skip to content

Commit

Permalink
feat: allow loweer case for mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKellerer committed Dec 18, 2023
1 parent 45e931e commit caa8713
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ data class AminoAcidMutation(val gene: String, val position: Int, val symbol: St
return AminoAcidMutation(
gene,
position,
matchGroups["symbolTo"]?.value,
matchGroups["symbolTo"]?.value?.uppercase(),
)
}
}
}

private val AMINO_ACID_MUTATION_REGEX =
Regex(
"""^((?<gene>[a-zA-Z0-9_-]+):)(?<symbolFrom>[A-Z]?)(?<position>\d+)(?<symbolTo>[A-Z.-])?$""",
"""^((?<gene>[a-zA-Z0-9_-]+):)(?<symbolFrom>[a-zA-Z]?)(?<position>\d+)(?<symbolTo>[a-zA-Z.-])?$""",
)

@JsonComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ data class NucleotideMutation(val sequenceName: String?, val position: Int, val
return NucleotideMutation(
matchGroups["sequenceName"]?.value,
position,
matchGroups["symbolTo"]?.value,
matchGroups["symbolTo"]?.value?.uppercase(),
)
}
}
}

private val NUCLEOTIDE_MUTATION_REGEX =
Regex(
"""^((?<sequenceName>[a-zA-Z0-9_-]+)(?=:):)?(?<symbolFrom>[A-Z]?)(?<position>\d+)(?<symbolTo>[A-Z.-])?$""",
@Suppress("ktlint:standard:max-line-length")
"""^((?<sequenceName>[a-zA-Z0-9_-]+)(?=:):)?(?<symbolFrom>[a-zA-Z]?)(?<position>\d+)(?<symbolTo>[a-zA-Z.-])?$""",
)

@JsonComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class AminoAcidMutationTest {
"\"ORF1b:123X\"",
AminoAcidMutation("ORF1b", 123, "X"),
),
Arguments.of(
"\"gene:123a\"",
AminoAcidMutation("gene", 123, "A"),
),
)

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit caa8713

Please sign in to comment.