Skip to content

Commit

Permalink
feat: add variant query to FilterExpressionMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKellerer committed Apr 27, 2023
1 parent e01acda commit 64f0c8b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,36 @@ class SiloFilterExpressionMapperTest {
assertThat(result, equalTo(expectedResult))
}

@Test
fun `given a query with an empty variantQuery then it should throw an error`() {
val filterParameter = mapOf("variantQuery" to "")

val exception = assertThrows<IllegalArgumentException> { underTest.map(filterParameter) }
assertThat(exception.message, containsString("variantQuery cannot be empty"))
}

@Test
fun `given a query with a variantQuery alongside nucleotideMutation filter then it should throw an error`() {
val filterParameter = mapOf(
"nucleotideMutations" to "A123T",
"variantQuery" to "A123T",
)

val exception = assertThrows<IllegalArgumentException> { underTest.map(filterParameter) }
assertThat(exception.message, containsString("variantQuery cannot be used with other variant filters"))
}

@Test
fun `given a query with a variantQuery alongside pangoLineage filter then it should throw an error`() {
val filterParameter = mapOf(
"pangoLineage" to "A.1.2.3",
"variantQuery" to "A123T",
)

val exception = assertThrows<IllegalArgumentException> { underTest.map(filterParameter) }
assertThat(exception.message, containsString("variantQuery cannot be used with other variant filters"))
}

companion object {
@JvmStatic
fun getFilterParametersWithExpectedSiloQuery() = listOf(
Expand Down Expand Up @@ -260,6 +290,33 @@ class SiloFilterExpressionMapperTest {
),
),
),
Arguments.of(
mapOf(
"variantQuery" to "300G & 400A",
),
And(
listOf(
And(
listOf(
NucleotideSymbolEquals(300, "G"),
NucleotideSymbolEquals(400, "A"),
),
),
),
),
),
Arguments.of(
mapOf(
"variantQuery" to "300G",
"some_metadata" to "ABC",
),
And(
listOf(
StringEquals("some_metadata", "ABC"),
NucleotideSymbolEquals(300, "G"),
),
),
),
)

@JvmStatic
Expand Down
9 changes: 9 additions & 0 deletions siloLapisTests/test/aggregatedQueries/variantQuery.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"testCaseName": "variant query",
"lapisRequest": {
"variantQuery": "B.1.1.7"
},
"expected": {
"count": 48
}
}

0 comments on commit 64f0c8b

Please sign in to comment.