From 8df6f1d52dae3665f70ccf6cf9cf5f08424b4d91 Mon Sep 17 00:00:00 2001 From: Alexander Taepper Date: Sat, 23 Mar 2024 08:33:32 +0100 Subject: [PATCH] feat: return mutation as object that does not need to be reparsed --- .../test/queries/aaMutDistribution.json | 104 +++++++++--- .../test/queries/aaMutDistribution_all.json | 48 ++++-- .../test/queries/aaMutDistribution_min0.json | 14 +- .../queries/aaMutDistribution_multiple.json | 144 ++++++++++++----- .../queries/aaMutDistribution_very_low.json | 14 +- .../test/queries/nOf_2of3_mutations.json | 32 +++- .../queries/sequenceStartEndMutations.json | 152 +++++++++++++----- include/silo/query_engine/actions/mutations.h | 4 +- src/silo/query_engine/actions/mutations.cpp | 15 +- 9 files changed, 394 insertions(+), 133 deletions(-) diff --git a/endToEndTests/test/queries/aaMutDistribution.json b/endToEndTests/test/queries/aaMutDistribution.json index 0ae4cf80a..44c0e7172 100644 --- a/endToEndTests/test/queries/aaMutDistribution.json +++ b/endToEndTests/test/queries/aaMutDistribution.json @@ -13,157 +13,209 @@ "expectedQueryResult": [ { "count": 37, - "mutation": "T19R", + "mutationFrom": "T", + "mutationTo": "R", + "position": 19, "proportion": 0.38144329896907214, "sequenceName": "S" }, { "count": 37, - "mutation": "G142D", + "mutationFrom": "G", + "mutationTo": "D", + "position": 142, "proportion": 0.4065934065934066, "sequenceName": "S" }, { "count": 35, - "mutation": "E156-", + "mutationFrom": "E", + "mutationTo": "-", + "position": 156, "proportion": 0.3723404255319149, "sequenceName": "S" }, { "count": 35, - "mutation": "F157-", + "mutationFrom": "F", + "mutationTo": "-", + "position": 157, "proportion": 0.3723404255319149, "sequenceName": "S" }, { "count": 34, - "mutation": "R158G", + "mutationFrom": "R", + "mutationTo": "G", + "position": 158, "proportion": 0.3617021276595745, "sequenceName": "S" }, { "count": 34, - "mutation": "G339D", + "mutationFrom": "G", + "mutationTo": "D", + "position": 339, "proportion": 0.3434343434343434, "sequenceName": "S" }, { "count": 33, - "mutation": "S373P", + "mutationFrom": "S", + "mutationTo": "P", + "position": 373, "proportion": 0.336734693877551, "sequenceName": "S" }, { "count": 33, - "mutation": "S375F", + "mutationFrom": "S", + "mutationTo": "F", + "position": 375, "proportion": 0.3333333333333333, "sequenceName": "S" }, { "count": 38, - "mutation": "L452R", + "mutationFrom": "L", + "mutationTo": "R", + "position": 452, "proportion": 0.4318181818181818, "sequenceName": "S" }, { "count": 32, - "mutation": "S477N", + "mutationFrom": "S", + "mutationTo": "N", + "position": 477, "proportion": 0.34408602150537637, "sequenceName": "S" }, { "count": 69, - "mutation": "T478K", + "mutationFrom": "T", + "mutationTo": "K", + "position": 478, "proportion": 0.7340425531914894, "sequenceName": "S" }, { "count": 31, - "mutation": "E484A", + "mutationFrom": "E", + "mutationTo": "A", + "position": 484, "proportion": 0.3333333333333333, "sequenceName": "S" }, { "count": 31, - "mutation": "Q493R", + "mutationFrom": "Q", + "mutationTo": "R", + "position": 493, "proportion": 0.3333333333333333, "sequenceName": "S" }, { "count": 30, - "mutation": "Q498R", + "mutationFrom": "Q", + "mutationTo": "R", + "position": 498, "proportion": 0.3225806451612903, "sequenceName": "S" }, { "count": 41, - "mutation": "N501Y", + "mutationFrom": "N", + "mutationTo": "Y", + "position": 501, "proportion": 0.44086021505376344, "sequenceName": "S" }, { "count": 30, - "mutation": "Y505H", + "mutationFrom": "Y", + "mutationTo": "H", + "position": 505, "proportion": 0.3225806451612903, "sequenceName": "S" }, { "count": 98, - "mutation": "D614G", + "mutationFrom": "D", + "mutationTo": "G", + "position": 614, "proportion": 0.98989898989899, "sequenceName": "S" }, { "count": 37, - "mutation": "H655Y", + "mutationFrom": "H", + "mutationTo": "Y", + "position": 655, "proportion": 0.37373737373737376, "sequenceName": "S" }, { "count": 34, - "mutation": "N679K", + "mutationFrom": "N", + "mutationTo": "K", + "position": 679, "proportion": 0.34, "sequenceName": "S" }, { "count": 42, - "mutation": "P681H", + "mutationFrom": "P", + "mutationTo": "H", + "position": 681, "proportion": 0.42, "sequenceName": "S" }, { "count": 38, - "mutation": "P681R", + "mutationFrom": "P", + "mutationTo": "R", + "position": 681, "proportion": 0.38, "sequenceName": "S" }, { "count": 31, - "mutation": "N764K", + "mutationFrom": "N", + "mutationTo": "K", + "position": 764, "proportion": 0.3263157894736842, "sequenceName": "S" }, { "count": 34, - "mutation": "D796Y", + "mutationFrom": "D", + "mutationTo": "Y", + "position": 796, "proportion": 0.3434343434343434, "sequenceName": "S" }, { "count": 34, - "mutation": "D950N", + "mutationFrom": "D", + "mutationTo": "N", + "position": 950, "proportion": 0.35051546391752575, "sequenceName": "S" }, { "count": 33, - "mutation": "Q954H", + "mutationFrom": "Q", + "mutationTo": "H", + "position": 954, "proportion": 0.336734693877551, "sequenceName": "S" }, { "count": 34, - "mutation": "N969K", + "mutationFrom": "N", + "mutationTo": "K", + "position": 969, "proportion": 0.3434343434343434, "sequenceName": "S" } diff --git a/endToEndTests/test/queries/aaMutDistribution_all.json b/endToEndTests/test/queries/aaMutDistribution_all.json index 7e19ead09..c6640832c 100644 --- a/endToEndTests/test/queries/aaMutDistribution_all.json +++ b/endToEndTests/test/queries/aaMutDistribution_all.json @@ -12,73 +12,97 @@ "expectedQueryResult": [ { "count": 46, - "mutation": "R203K", + "mutationFrom": "R", + "mutationTo": "K", + "position": 203, "proportion": 0.46, "sequenceName": "N" }, { "count": 46, - "mutation": "G204R", + "mutationFrom": "G", + "mutationTo": "R", + "position": 204, "proportion": 0.46, "sequenceName": "N" }, { "count": 64, - "mutation": "T3255I", + "mutationFrom": "T", + "mutationTo": "I", + "position": 3255, "proportion": 0.6464646464646465, "sequenceName": "ORF1a" }, { "count": 44, - "mutation": "S3675-", + "mutationFrom": "S", + "mutationTo": "-", + "position": 3675, "proportion": 0.4489795918367347, "sequenceName": "ORF1a" }, { "count": 44, - "mutation": "G3676-", + "mutationFrom": "G", + "mutationTo": "-", + "position": 3676, "proportion": 0.4444444444444444, "sequenceName": "ORF1a" }, { "count": 98, - "mutation": "P314L", + "mutationFrom": "P", + "mutationTo": "L", + "position": 314, "proportion": 0.98, "sequenceName": "ORF1b" }, { "count": 37, - "mutation": "G142D", + "mutationFrom": "G", + "mutationTo": "D", + "position": 142, "proportion": 0.4065934065934066, "sequenceName": "S" }, { "count": 38, - "mutation": "L452R", + "mutationFrom": "L", + "mutationTo": "R", + "position": 452, "proportion": 0.4318181818181818, "sequenceName": "S" }, { "count": 69, - "mutation": "T478K", + "mutationFrom": "T", + "mutationTo": "K", + "position": 478, "proportion": 0.7340425531914894, "sequenceName": "S" }, { "count": 41, - "mutation": "N501Y", + "mutationFrom": "N", + "mutationTo": "Y", + "position": 501, "proportion": 0.44086021505376344, "sequenceName": "S" }, { "count": 98, - "mutation": "D614G", + "mutationFrom": "D", + "mutationTo": "G", + "position": 614, "proportion": 0.98989898989899, "sequenceName": "S" }, { "count": 42, - "mutation": "P681H", + "mutationFrom": "P", + "mutationTo": "H", + "position": 681, "proportion": 0.42, "sequenceName": "S" } diff --git a/endToEndTests/test/queries/aaMutDistribution_min0.json b/endToEndTests/test/queries/aaMutDistribution_min0.json index 7e76e942e..e6fc22436 100644 --- a/endToEndTests/test/queries/aaMutDistribution_min0.json +++ b/endToEndTests/test/queries/aaMutDistribution_min0.json @@ -5,7 +5,7 @@ "type": "AminoAcidMutations", "sequenceName": "E", "minProportion": 0.0, - "orderByFields": ["mutation"] + "orderByFields": ["mutationFrom", "position", "mutationTo"] }, "filterExpression": { "type": "True" @@ -14,19 +14,25 @@ "expectedQueryResult": [ { "count": 1, - "mutation": "F20L", + "mutationFrom": "F", + "mutationTo": "L", + "position": 20, "proportion": 0.010101010101010102, "sequenceName": "E" }, { "count": 1, - "mutation": "L18I", + "mutationFrom": "L", + "mutationTo": "I", + "position": 18, "proportion": 0.010101010101010102, "sequenceName": "E" }, { "count": 34, - "mutation": "T9I", + "mutationFrom": "T", + "mutationTo": "I", + "position": 9, "proportion": 0.3469387755102041, "sequenceName": "E" } diff --git a/endToEndTests/test/queries/aaMutDistribution_multiple.json b/endToEndTests/test/queries/aaMutDistribution_multiple.json index 69bb4ae0d..fbb70f425 100644 --- a/endToEndTests/test/queries/aaMutDistribution_multiple.json +++ b/endToEndTests/test/queries/aaMutDistribution_multiple.json @@ -13,217 +13,289 @@ "expectedQueryResult": [ { "count": 37, - "mutation": "T19R", + "mutationFrom": "T", + "mutationTo": "R", + "position": 19, "proportion": 0.38144329896907214, "sequenceName": "S" }, { "count": 37, - "mutation": "G142D", + "mutationFrom": "G", + "mutationTo": "D", + "position": 142, "proportion": 0.4065934065934066, "sequenceName": "S" }, { "count": 35, - "mutation": "E156-", + "mutationFrom": "E", + "mutationTo": "-", + "position": 156, "proportion": 0.3723404255319149, "sequenceName": "S" }, { "count": 35, - "mutation": "F157-", + "mutationFrom": "F", + "mutationTo": "-", + "position": 157, "proportion": 0.3723404255319149, "sequenceName": "S" }, { "count": 34, - "mutation": "R158G", + "mutationFrom": "R", + "mutationTo": "G", + "position": 158, "proportion": 0.3617021276595745, "sequenceName": "S" }, { "count": 34, - "mutation": "G339D", + "mutationFrom": "G", + "mutationTo": "D", + "position": 339, "proportion": 0.3434343434343434, "sequenceName": "S" }, { "count": 33, - "mutation": "S373P", + "mutationFrom": "S", + "mutationTo": "P", + "position": 373, "proportion": 0.336734693877551, "sequenceName": "S" }, { "count": 33, - "mutation": "S375F", + "mutationFrom": "S", + "mutationTo": "F", + "position": 375, "proportion": 0.3333333333333333, "sequenceName": "S" }, { "count": 38, - "mutation": "L452R", + "mutationFrom": "L", + "mutationTo": "R", + "position": 452, "proportion": 0.4318181818181818, "sequenceName": "S" }, { "count": 32, - "mutation": "S477N", + "mutationFrom": "S", + "mutationTo": "N", + "position": 477, "proportion": 0.34408602150537637, "sequenceName": "S" }, { "count": 69, - "mutation": "T478K", + "mutationFrom": "T", + "mutationTo": "K", + "position": 478, "proportion": 0.7340425531914894, "sequenceName": "S" }, { "count": 31, - "mutation": "E484A", + "mutationFrom": "E", + "mutationTo": "A", + "position": 484, "proportion": 0.3333333333333333, "sequenceName": "S" }, { "count": 31, - "mutation": "Q493R", + "mutationFrom": "Q", + "mutationTo": "R", + "position": 493, "proportion": 0.3333333333333333, "sequenceName": "S" }, { "count": 30, - "mutation": "Q498R", + "mutationFrom": "Q", + "mutationTo": "R", + "position": 498, "proportion": 0.3225806451612903, "sequenceName": "S" }, { "count": 41, - "mutation": "N501Y", + "mutationFrom": "N", + "mutationTo": "Y", + "position": 501, "proportion": 0.44086021505376344, "sequenceName": "S" }, { "count": 30, - "mutation": "Y505H", + "mutationFrom": "Y", + "mutationTo": "H", + "position": 505, "proportion": 0.3225806451612903, "sequenceName": "S" }, { "count": 98, - "mutation": "D614G", + "mutationFrom": "D", + "mutationTo": "G", + "position": 614, "proportion": 0.98989898989899, "sequenceName": "S" }, { "count": 37, - "mutation": "H655Y", + "mutationFrom": "H", + "mutationTo": "Y", + "position": 655, "proportion": 0.37373737373737376, "sequenceName": "S" }, { "count": 34, - "mutation": "N679K", + "mutationFrom": "N", + "mutationTo": "K", + "position": 679, "proportion": 0.34, "sequenceName": "S" }, { "count": 42, - "mutation": "P681H", + "mutationFrom": "P", + "mutationTo": "H", + "position": 681, "proportion": 0.42, "sequenceName": "S" }, { "count": 38, - "mutation": "P681R", + "mutationFrom": "P", + "mutationTo": "R", + "position": 681, "proportion": 0.38, "sequenceName": "S" }, { "count": 31, - "mutation": "N764K", + "mutationFrom": "N", + "mutationTo": "K", + "position": 764, "proportion": 0.3263157894736842, "sequenceName": "S" }, { "count": 34, - "mutation": "D796Y", + "mutationFrom": "D", + "mutationTo": "Y", + "position": 796, "proportion": 0.3434343434343434, "sequenceName": "S" }, { "count": 34, - "mutation": "D950N", + "mutationFrom": "D", + "mutationTo": "N", + "position": 950, "proportion": 0.35051546391752575, "sequenceName": "S" }, { "count": 33, - "mutation": "Q954H", + "mutationFrom": "Q", + "mutationTo": "H", + "position": 954, "proportion": 0.336734693877551, "sequenceName": "S" }, { "count": 34, - "mutation": "N969K", + "mutationFrom": "N", + "mutationTo": "K", + "position": 969, "proportion": 0.3434343434343434, "sequenceName": "S" }, { "count": 34, - "mutation": "P13L", + "mutationFrom": "P", + "mutationTo": "L", + "position": 13, "proportion": 0.3469387755102041, "sequenceName": "N" }, { "count": 34, - "mutation": "E31-", + "mutationFrom": "E", + "mutationTo": "-", + "position": 31, "proportion": 0.3469387755102041, "sequenceName": "N" }, { "count": 34, - "mutation": "R32-", + "mutationFrom": "R", + "mutationTo": "-", + "position": 32, "proportion": 0.3469387755102041, "sequenceName": "N" }, { "count": 34, - "mutation": "S33-", + "mutationFrom": "S", + "mutationTo": "-", + "position": 33, "proportion": 0.3469387755102041, "sequenceName": "N" }, { "count": 36, - "mutation": "D63G", + "mutationFrom": "D", + "mutationTo": "G", + "position": 63, "proportion": 0.3673469387755102, "sequenceName": "N" }, { "count": 46, - "mutation": "R203K", + "mutationFrom": "R", + "mutationTo": "K", + "position": 203, "proportion": 0.46, "sequenceName": "N" }, { "count": 38, - "mutation": "R203M", + "mutationFrom": "R", + "mutationTo": "M", + "position": 203, "proportion": 0.38, "sequenceName": "N" }, { "count": 46, - "mutation": "G204R", + "mutationFrom": "G", + "mutationTo": "R", + "position": 204, "proportion": 0.46, "sequenceName": "N" }, { "count": 30, - "mutation": "G215C", + "mutationFrom": "G", + "mutationTo": "C", + "position": 215, "proportion": 0.3, "sequenceName": "N" }, { "count": 37, - "mutation": "D377Y", + "mutationFrom": "D", + "mutationTo": "Y", + "position": 377, "proportion": 0.37755102040816324, "sequenceName": "N" } diff --git a/endToEndTests/test/queries/aaMutDistribution_very_low.json b/endToEndTests/test/queries/aaMutDistribution_very_low.json index b2e754601..693c21bcd 100644 --- a/endToEndTests/test/queries/aaMutDistribution_very_low.json +++ b/endToEndTests/test/queries/aaMutDistribution_very_low.json @@ -5,7 +5,7 @@ "type": "AminoAcidMutations", "sequenceName": "E", "minProportion": 0.0001, - "orderByFields": ["mutation"] + "orderByFields": ["mutationFrom", "position", "mutationTo"] }, "filterExpression": { "type": "True" @@ -14,19 +14,25 @@ "expectedQueryResult": [ { "count": 1, - "mutation": "F20L", + "mutationFrom": "F", + "mutationTo": "L", + "position": 20, "proportion": 0.010101010101010102, "sequenceName": "E" }, { "count": 1, - "mutation": "L18I", + "mutationFrom": "L", + "mutationTo": "I", + "position": 18, "proportion": 0.010101010101010102, "sequenceName": "E" }, { "count": 34, - "mutation": "T9I", + "mutationFrom": "T", + "mutationTo": "I", + "position": 9, "proportion": 0.3469387755102041, "sequenceName": "E" } diff --git a/endToEndTests/test/queries/nOf_2of3_mutations.json b/endToEndTests/test/queries/nOf_2of3_mutations.json index b6939b01b..9ff4b9189 100644 --- a/endToEndTests/test/queries/nOf_2of3_mutations.json +++ b/endToEndTests/test/queries/nOf_2of3_mutations.json @@ -31,49 +31,65 @@ "expectedQueryResult": [ { "count": 1, - "mutation": "A1-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 1, "proportion": 1, "sequenceName": "main" }, { "count": 1, - "mutation": "T2-", + "mutationFrom": "T", + "mutationTo": "-", + "position": 2, "proportion": 1, "sequenceName": "main" }, { "count": 53, - "mutation": "C241T", + "mutationFrom": "C", + "mutationTo": "T", + "position": 241, "proportion": 1, "sequenceName": "main" }, { "count": 51, - "mutation": "C3037T", + "mutationFrom": "C", + "mutationTo": "T", + "position": 3037, "proportion": 1, "sequenceName": "main" }, { "count": 52, - "mutation": "C14408T", + "mutationFrom": "C", + "mutationTo": "T", + "position": 14408, "proportion": 1, "sequenceName": "main" }, { "count": 53, - "mutation": "A23403G", + "mutationFrom": "A", + "mutationTo": "G", + "position": 23403, "proportion": 1, "sequenceName": "main" }, { "count": 4, - "mutation": "G29868-", + "mutationFrom": "G", + "mutationTo": "-", + "position": 29868, "proportion": 1, "sequenceName": "main" }, { "count": 4, - "mutation": "A29869-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29869, "proportion": 0.8, "sequenceName": "main" } diff --git a/endToEndTests/test/queries/sequenceStartEndMutations.json b/endToEndTests/test/queries/sequenceStartEndMutations.json index e31b0d8c4..155c90f07 100644 --- a/endToEndTests/test/queries/sequenceStartEndMutations.json +++ b/endToEndTests/test/queries/sequenceStartEndMutations.json @@ -24,229 +24,305 @@ "expectedQueryResult": [ { "count": 42, - "mutation": "A1-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 1, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "C3037T", + "mutationFrom": "C", + "mutationTo": "T", + "position": 3037, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "C14408T", + "mutationFrom": "C", + "mutationTo": "T", + "position": 14408, "proportion": 1, "sequenceName": "main" }, { "count": 40, - "mutation": "A23403G", + "mutationFrom": "A", + "mutationTo": "G", + "position": 23403, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "C29870-", + "mutationFrom": "C", + "mutationTo": "-", + "position": 29870, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29871-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29871, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29872-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29872, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29873-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29873, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29874-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29874, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29875-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29875, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29876-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29876, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29877-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29877, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29878-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29878, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29879-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29879, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29880-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29880, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29881-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29881, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29882-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29882, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29883-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29883, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29884-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29884, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29885-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29885, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29886-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29886, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29887-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29887, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29888-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29888, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29889-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29889, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29890-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29890, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29891-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29891, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29892-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29892, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29893-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29893, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29894-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29894, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29895-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29895, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29896-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29896, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29897-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29897, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29898-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29898, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29899-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29899, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29900-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29900, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29901-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29901, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29902-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29902, "proportion": 1, "sequenceName": "main" }, { "count": 42, - "mutation": "A29903-", + "mutationFrom": "A", + "mutationTo": "-", + "position": 29903, "proportion": 1, "sequenceName": "main" } diff --git a/include/silo/query_engine/actions/mutations.h b/include/silo/query_engine/actions/mutations.h index 8ffc4c643..a38a56617 100644 --- a/include/silo/query_engine/actions/mutations.h +++ b/include/silo/query_engine/actions/mutations.h @@ -32,7 +32,9 @@ class Mutations : public Action { std::vector sequence_names; double min_proportion; - const std::string MUTATION_FIELD_NAME = "mutation"; + const std::string MUTATION_FROM_FIELD_NAME = "mutationFrom"; + const std::string MUTATION_TO_FIELD_NAME = "mutationTo"; + const std::string POSITION_FIELD_NAME = "position"; const std::string SEQUENCE_FIELD_NAME = "sequenceName"; const std::string PROPORTION_FIELD_NAME = "proportion"; const std::string COUNT_FIELD_NAME = "count"; diff --git a/src/silo/query_engine/actions/mutations.cpp b/src/silo/query_engine/actions/mutations.cpp index 1af582123..678355d96 100644 --- a/src/silo/query_engine/actions/mutations.cpp +++ b/src/silo/query_engine/actions/mutations.cpp @@ -166,7 +166,11 @@ SymbolMap> Mutations::calculateMut template void Mutations::validateOrderByFields(const Database& /*database*/) const { const std::vector result_field_names{ - {MUTATION_FIELD_NAME, PROPORTION_FIELD_NAME, COUNT_FIELD_NAME} + {MUTATION_FROM_FIELD_NAME, + MUTATION_TO_FIELD_NAME, + POSITION_FIELD_NAME, + PROPORTION_FIELD_NAME, + COUNT_FIELD_NAME} }; for (const OrderByField& field : order_by_fields) { @@ -217,9 +221,12 @@ void Mutations::addMutationsToOutput( const std:: map>> fields{ - {MUTATION_FIELD_NAME, - SymbolType::symbolToChar(symbol_in_reference_genome) + - std::to_string(pos + 1) + SymbolType::symbolToChar(symbol)}, + { + MUTATION_FROM_FIELD_NAME, + std::string(1, SymbolType::symbolToChar(symbol_in_reference_genome)), + }, + {MUTATION_TO_FIELD_NAME, std::string(1, SymbolType::symbolToChar(symbol))}, + {POSITION_FIELD_NAME, static_cast(pos + 1)}, {SEQUENCE_FIELD_NAME, sequence_name}, {PROPORTION_FIELD_NAME, proportion}, {COUNT_FIELD_NAME, static_cast(count)}