Skip to content

Commit ed90514

Browse files
feat(lapis): pass through coverage from SILO in mutation endpoints (#1094)
resolves #1091
1 parent b1cc7fd commit ed90514

File tree

10 files changed

+65
-28
lines changed

10 files changed

+65
-28
lines changed

lapis-e2e/test/aminoAcidMutations.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ describe('The /aminoAcidMutations endpoint', () => {
8888
it('should correctly handle nucleotide insertion requests', async () => {
8989
const expectedFirstResultWithNucleotideInsertion = {
9090
count: 1,
91+
coverage: 1,
9192
mutation: 'E:T9I',
9293
mutationFrom: 'T',
9394
mutationTo: 'I',
@@ -109,6 +110,7 @@ describe('The /aminoAcidMutations endpoint', () => {
109110
it('should correctly handle amino acid insertion requests', async () => {
110111
const expectedFirstResultWithAminoAcidInsertion = {
111112
count: 1,
113+
coverage: 1,
112114
mutation: 'N:A220V',
113115
mutationFrom: 'A',
114116
mutationTo: 'V',
@@ -140,15 +142,15 @@ describe('The /aminoAcidMutations endpoint', () => {
140142

141143
expect(resultText).to.contain(
142144
String.raw`
143-
mutation,count,proportion,sequenceName,mutationFrom,mutationTo,position
145+
mutation,count,coverage,proportion,sequenceName,mutationFrom,mutationTo,position
144146
`.trim()
145147
);
146148

147149
expect(resultText).to.contain(
148150
String.raw`
149-
N:A220V,1,0.058823529411764705,N,A,V,220
150-
S:A222V,3,0.1875,S,A,V,222
151-
ORF1a:A2529V,3,0.17647058823529413,ORF1a,A,V,2529
151+
N:A220V,1,17,0.058823529411764705,N,A,V,220
152+
S:A222V,3,16,0.1875,S,A,V,222
153+
ORF1a:A2529V,3,17,0.17647058823529413,ORF1a,A,V,2529
152154
`.trim()
153155
);
154156
});
@@ -166,15 +168,15 @@ ORF1a:A2529V,3,0.17647058823529413,ORF1a,A,V,2529
166168

167169
expect(resultText).to.contain(
168170
String.raw`
169-
mutation count proportion sequenceName mutationFrom mutationTo position
171+
mutation count coverage proportion sequenceName mutationFrom mutationTo position
170172
`.trim()
171173
);
172174

173175
expect(resultText).to.contain(
174176
String.raw`
175-
N:A220V 1 0.058823529411764705 N A V 220
176-
S:A222V 3 0.1875 S A V 222
177-
ORF1a:A2529V 3 0.17647058823529413 ORF1a A V 2529
177+
N:A220V 1 17 0.058823529411764705 N A V 220
178+
S:A222V 3 16 0.1875 S A V 222
179+
ORF1a:A2529V 3 17 0.17647058823529413 ORF1a A V 2529
178180
`.trim()
179181
);
180182
});

lapis-e2e/test/nucleotideMutations.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ describe('The /nucleotideMutations endpoint', () => {
106106
it('should correctly handle nucleotide insertion requests', async () => {
107107
const expectedFirstResultWithNucleotideInsertion = {
108108
count: 1,
109+
coverage: 1,
109110
mutation: 'C241T',
110111
proportion: 1.0,
111112
mutationFrom: 'C',
@@ -127,6 +128,7 @@ describe('The /nucleotideMutations endpoint', () => {
127128
it('should correctly handle amino acid insertion requests', async () => {
128129
const expectedFirstResultWithAminoAcidInsertion = {
129130
count: 1,
131+
coverage: 1,
130132
mutation: 'G210T',
131133
proportion: 1.0,
132134
mutationFrom: 'G',
@@ -158,15 +160,15 @@ describe('The /nucleotideMutations endpoint', () => {
158160

159161
expect(resultText).to.contain(
160162
String.raw`
161-
mutation,count,proportion,sequenceName,mutationFrom,mutationTo,position
163+
mutation,count,coverage,proportion,sequenceName,mutationFrom,mutationTo,position
162164
`.trim()
163165
);
164166

165167
expect(resultText).to.contain(
166168
String.raw`
167-
C7029T,1,0.0625,,C,T,7029
168-
C71-,1,0.058823529411764705,,C,-,71
169-
C7124T,2,0.11764705882352941,,C,T,7124
169+
C7029T,1,16,0.0625,,C,T,7029
170+
C71-,1,17,0.058823529411764705,,C,-,71
171+
C7124T,2,17,0.11764705882352941,,C,T,7124
170172
`.trim()
171173
);
172174
});
@@ -184,15 +186,15 @@ C7124T,2,0.11764705882352941,,C,T,7124
184186

185187
expect(resultText).to.contain(
186188
String.raw`
187-
mutation count proportion sequenceName mutationFrom mutationTo position
189+
mutation count coverage proportion sequenceName mutationFrom mutationTo position
188190
`.trim()
189191
);
190192

191193
expect(resultText).to.contain(
192194
String.raw`
193-
C7029T 1 0.0625 C T 7029
194-
C71- 1 0.058823529411764705 C - 71
195-
C7124T 2 0.11764705882352941 C T 7124
195+
C7029T 1 16 0.0625 C T 7029
196+
C71- 1 17 0.058823529411764705 C - 71
197+
C7124T 2 17 0.11764705882352941 C T 7124
196198
`.trim()
197199
);
198200
});

lapis/src/main/kotlin/org/genspectrum/lapis/model/SiloQueryModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class SiloQueryModel(
5959
NucleotideMutationResponse(
6060
mutation = mutation,
6161
count = it.count,
62+
coverage = it.coverage,
6263
proportion = it.proportion,
6364
sequenceName = when (referenceGenomeSchema.isSingleSegmented()) {
6465
true -> null
@@ -89,6 +90,7 @@ class SiloQueryModel(
8990
AminoAcidMutationResponse(
9091
mutation = "${it.sequenceName}:${it.mutation}",
9192
count = it.count,
93+
coverage = it.coverage,
9294
proportion = it.proportion,
9395
sequenceName = it.sequenceName,
9496
mutationFrom = it.mutationFrom,

lapis/src/main/kotlin/org/genspectrum/lapis/openApi/OpenApiDocs.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,16 @@ private fun nucleotideMutationProportionSchema() =
466466
.example(0.54321)
467467
.description(
468468
"Number of sequences with this mutation divided by the total number sequences matching the " +
469-
"given filter criteria with non-ambiguous reads at that position",
469+
"given filter criteria with non-ambiguous reads at that position (i.e. count/coverage).",
470470
),
471471
"count" to IntegerSchema()
472472
.example(1234)
473473
.description("Total number of sequences with this mutation matching the given sequence filter criteria"),
474+
"coverage" to IntegerSchema()
475+
.example(2345)
476+
.description(
477+
"Total number of sequences with non-ambiguous reads matching the given sequence filter criteria",
478+
),
474479
"sequenceName" to StringSchema()
475480
.example("sequence1")
476481
.description(
@@ -496,11 +501,16 @@ private fun aminoAcidMutationProportionSchema() =
496501
.example(0.54321)
497502
.description(
498503
"Number of sequences with this mutation divided by the total number sequences matching the " +
499-
"given filter criteria with non-ambiguous reads at that position",
504+
"given filter criteria with non-ambiguous reads at that position (i.e. count/coverage).",
500505
),
501506
"count" to IntegerSchema()
502507
.example(42)
503508
.description("Total number of sequences with this mutation matching the given sequence filter criteria"),
509+
"coverage" to IntegerSchema()
510+
.example(2345)
511+
.description(
512+
"Total number of sequences with non-ambiguous reads matching the given sequence filter criteria",
513+
),
504514
"sequenceName" to StringSchema()
505515
.example("ORF1a")
506516
.description("The name of the gene in which the mutation occurs."),

lapis/src/main/kotlin/org/genspectrum/lapis/response/LapisResponse.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ data class LapisInfo(
5050
data class NucleotideMutationResponse(
5151
val mutation: String,
5252
val count: Int,
53+
val coverage: Int,
5354
val proportion: Double,
5455
val sequenceName: String?,
5556
val mutationFrom: String,
@@ -60,6 +61,7 @@ data class NucleotideMutationResponse(
6061
listOf(
6162
mutation,
6263
count.toString(),
64+
coverage.toString(),
6365
proportion.toString(),
6466
sequenceName ?: "",
6567
mutationFrom,
@@ -71,6 +73,7 @@ data class NucleotideMutationResponse(
7173
listOf(
7274
"mutation",
7375
"count",
76+
"coverage",
7477
"proportion",
7578
"sequenceName",
7679
"mutationFrom",
@@ -82,6 +85,7 @@ data class NucleotideMutationResponse(
8285
data class AminoAcidMutationResponse(
8386
val mutation: String,
8487
val count: Int,
88+
val coverage: Int,
8589
val proportion: Double,
8690
val sequenceName: String,
8791
val mutationFrom: String,
@@ -92,6 +96,7 @@ data class AminoAcidMutationResponse(
9296
listOf(
9397
mutation,
9498
count.toString(),
99+
coverage.toString(),
95100
proportion.toString(),
96101
sequenceName,
97102
mutationFrom,
@@ -103,6 +108,7 @@ data class AminoAcidMutationResponse(
103108
listOf(
104109
"mutation",
105110
"count",
111+
"coverage",
106112
"proportion",
107113
"sequenceName",
108114
"mutationFrom",

lapis/src/main/kotlin/org/genspectrum/lapis/response/SiloResponse.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ data class MutationData(
9090
val mutationFrom: String,
9191
val mutationTo: String,
9292
val position: Int,
93+
val coverage: Int,
9394
)
9495

9596
data class InsertionData(

lapis/src/test/kotlin/org/genspectrum/lapis/controller/LapisControllerTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class LapisControllerTest(
141141
.andExpect(jsonPath("\$.data[0].mutation").value("the mutation"))
142142
.andExpect(jsonPath("\$.data[0].proportion").value(0.5))
143143
.andExpect(jsonPath("\$.data[0].count").value(42))
144+
.andExpect(jsonPath("\$.data[0].coverage").value(52))
144145
.andExpect(header().stringValues("Lapis-Data-Version", "1234"))
145146
.andExpect(jsonPath("\$.info.dataVersion").value(1234))
146147
}
@@ -196,6 +197,7 @@ class LapisControllerTest(
196197
containsInAnyOrder(
197198
"mutation",
198199
"proportion",
200+
"coverage",
199201
"count",
200202
"sequenceName",
201203
"mutationFrom",
@@ -499,6 +501,7 @@ private fun someNucleotideMutationProportion() =
499501
NucleotideMutationResponse(
500502
mutation = "the mutation",
501503
count = 42,
504+
coverage = 52,
502505
proportion = 0.5,
503506
sequenceName = "sequenceName",
504507
mutationFrom = "G",
@@ -510,6 +513,7 @@ private fun someAminoAcidMutationProportion() =
510513
AminoAcidMutationResponse(
511514
mutation = "the mutation",
512515
count = 42,
516+
coverage = 52,
513517
proportion = 0.5,
514518
sequenceName = "sequenceName",
515519
mutationFrom = "G",

lapis/src/test/kotlin/org/genspectrum/lapis/controller/MockData.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ object MockDataForEndpoints {
303303
NucleotideMutationResponse(
304304
mutation = "sequenceName:A1234T",
305305
count = 2345,
306+
coverage = 3456,
306307
proportion = 0.987,
307308
sequenceName = "sequenceName",
308309
mutationFrom = "A",
@@ -315,6 +316,7 @@ object MockDataForEndpoints {
315316
{
316317
"mutation": "sequenceName:A1234T",
317318
"count": 2345,
319+
"coverage": 3456,
318320
"proportion": 0.987,
319321
"sequenceName": "sequenceName",
320322
"mutationFrom": "A",
@@ -324,13 +326,13 @@ object MockDataForEndpoints {
324326
]
325327
""".trimIndent(),
326328
expectedCsv = """
327-
mutation,count,proportion,sequenceName,mutationFrom,mutationTo,position
328-
sequenceName:A1234T,2345,0.987,sequenceName,A,T,1234
329+
mutation,count,coverage,proportion,sequenceName,mutationFrom,mutationTo,position
330+
sequenceName:A1234T,2345,3456,0.987,sequenceName,A,T,1234
329331
330332
""".trimIndent(),
331333
expectedTsv = """
332-
mutation count proportion sequenceName mutationFrom mutationTo position
333-
sequenceName:A1234T 2345 0.987 sequenceName A T 1234
334+
mutation count coverage proportion sequenceName mutationFrom mutationTo position
335+
sequenceName:A1234T 2345 3456 0.987 sequenceName A T 1234
334336
335337
""".trimIndent(),
336338
)
@@ -341,6 +343,7 @@ object MockDataForEndpoints {
341343
AminoAcidMutationResponse(
342344
mutation = "sequenceName:A1234T",
343345
count = 2345,
346+
coverage = 3456,
344347
proportion = 0.987,
345348
sequenceName = "sequenceName",
346349
mutationFrom = "A",
@@ -353,6 +356,7 @@ object MockDataForEndpoints {
353356
{
354357
"mutation": "sequenceName:A1234T",
355358
"count": 2345,
359+
"coverage": 3456,
356360
"proportion": 0.987,
357361
"sequenceName": "sequenceName",
358362
"mutationFrom": "A",
@@ -362,13 +366,13 @@ object MockDataForEndpoints {
362366
]
363367
""".trimIndent(),
364368
expectedCsv = """
365-
mutation,count,proportion,sequenceName,mutationFrom,mutationTo,position
366-
sequenceName:A1234T,2345,0.987,sequenceName,A,T,1234
369+
mutation,count,coverage,proportion,sequenceName,mutationFrom,mutationTo,position
370+
sequenceName:A1234T,2345,3456,0.987,sequenceName,A,T,1234
367371
368372
""".trimIndent(),
369373
expectedTsv = """
370-
mutation count proportion sequenceName mutationFrom mutationTo position
371-
sequenceName:A1234T 2345 0.987 sequenceName A T 1234
374+
mutation count coverage proportion sequenceName mutationFrom mutationTo position
375+
sequenceName:A1234T 2345 3456 0.987 sequenceName A T 1234
372376
373377
""".trimIndent(),
374378
)

lapis/src/test/kotlin/org/genspectrum/lapis/model/SiloQueryModelTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import java.util.stream.Stream
3131
private val someMutationData = MutationData(
3232
mutation = "A1234B",
3333
count = 1234,
34+
coverage = 2345,
3435
proportion = 0.1234,
3536
sequenceName = "sequenceName",
3637
mutationFrom = "A",
@@ -118,6 +119,7 @@ class SiloQueryModelTest {
118119
val expectedMutation = NucleotideMutationResponse(
119120
mutation = "A1234B",
120121
count = 1234,
122+
coverage = 2345,
121123
proportion = 0.1234,
122124
sequenceName = null,
123125
mutationFrom = "A",
@@ -140,6 +142,7 @@ class SiloQueryModelTest {
140142
val expectedMutation = NucleotideMutationResponse(
141143
mutation = "sequenceName:A1234B",
142144
count = 1234,
145+
coverage = 2345,
143146
proportion = 0.1234,
144147
sequenceName = "sequenceName",
145148
mutationFrom = "A",
@@ -161,6 +164,7 @@ class SiloQueryModelTest {
161164
val expectedMutation = AminoAcidMutationResponse(
162165
mutation = "sequenceName:A1234B",
163166
count = 1234,
167+
coverage = 2345,
164168
proportion = 0.1234,
165169
sequenceName = "sequenceName",
166170
mutationFrom = "A",

lapis/src/test/kotlin/org/genspectrum/lapis/silo/SiloClientTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ class SiloClientTest(
106106
.withContentType(MediaType.APPLICATION_JSON_UTF_8)
107107
.withBody(
108108
"""
109-
{"count": 51,"mutation": "C3037T","mutationFrom": "C","mutationTo": "T","position": 3037,"proportion": 1,"sequenceName": "main"}
110-
{"count": 52,"mutation": "C14408T","mutationFrom": "C","mutationTo": "T","position": 14408,"proportion": 1,"sequenceName": "main"}
109+
{"count": 51,"mutation": "C3037T","mutationFrom": "C","mutationTo": "T","position": 3037,"proportion": 1,"sequenceName": "main","coverage":100}
110+
{"count": 52,"mutation": "C14408T","mutationFrom": "C","mutationTo": "T","position": 14408,"proportion": 1,"sequenceName": "main","coverage":101}
111111
""",
112112
),
113113
)
@@ -127,6 +127,7 @@ class SiloClientTest(
127127
mutationFrom = "C",
128128
mutationTo = "T",
129129
position = 3037,
130+
coverage = 100,
130131
),
131132
MutationData(
132133
mutation = "C14408T",
@@ -136,6 +137,7 @@ class SiloClientTest(
136137
mutationFrom = "C",
137138
mutationTo = "T",
138139
position = 14408,
140+
coverage = 101,
139141
),
140142
),
141143
)

0 commit comments

Comments
 (0)