-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement maybe mutation filters #551
- Loading branch information
1 parent
f7bddbc
commit 1860d4f
Showing
11 changed files
with
165 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
lapis2/src/main/kotlin/org/genspectrum/lapis/request/MaybeMutationWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.genspectrum.lapis.request | ||
|
||
|
||
interface MaybeMutation<Self : MaybeMutation<Self>> { | ||
val maybe: Boolean | ||
|
||
fun asMaybe(): Self | ||
} | ||
|
||
val MAYBE_REGEX = Regex("""^MAYBE\((?<mutationCandidate>.+)\)$""") | ||
|
||
inline fun <reified T : MaybeMutation<T>> wrapWithMaybeMutationParser( | ||
mutationCandidate: String, | ||
mutationParser: (String) -> T, | ||
) = | ||
when (val match = MAYBE_REGEX.find(mutationCandidate)) { | ||
null -> mutationParser(mutationCandidate) | ||
else -> mutationParser(match.groups["mutationCandidate"]!!.value).asMaybe() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
siloLapisTests/test/aggregatedQueries/maybeAminoAcidMutation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"testCaseName": "maybe amino acid mutation", | ||
"lapisRequest": { | ||
"aminoAcidMutations": ["MAYBE(S:22)"] | ||
}, | ||
"expected": [ | ||
{ | ||
"count": 3 | ||
} | ||
] | ||
} |
Oops, something went wrong.