Skip to content

Commit

Permalink
feat: nucleotideMutations ary aminoAcidMutations endpoint return CSV/TSV
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKellerer committed Sep 5, 2023
1 parent 26c9ce0 commit cc3926c
Show file tree
Hide file tree
Showing 6 changed files with 653 additions and 35 deletions.
10 changes: 9 additions & 1 deletion lapis2/src/main/kotlin/org/genspectrum/lapis/OpenApiDocs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ fun buildOpenApiSchema(sequenceFilterFields: SequenceFilterFields, databaseConfi
.properties(nucleotideMutationProportionSchema()),
),
)
.addSchemas(NUCLEOTIDE_MUTATIONS_SCHEMA, nucleotideMutations())
.addSchemas(
AMINO_ACID_MUTATIONS_RESPONSE_SCHEMA,
lapisResponseSchema(
Expand All @@ -128,7 +129,6 @@ fun buildOpenApiSchema(sequenceFilterFields: SequenceFilterFields, databaseConfi
.properties(aminoAcidMutationProportionSchema()),
),
)
.addSchemas(NUCLEOTIDE_MUTATIONS_SCHEMA, nucleotideMutations())
.addSchemas(AMINO_ACID_MUTATIONS_SCHEMA, aminoAcidMutations())
.addSchemas(ORDER_BY_FIELDS_SCHEMA, orderByGetSchema())
.addSchemas(LIMIT_SCHEMA, limitSchema())
Expand All @@ -147,6 +147,13 @@ private fun lapisResponseSchema(dataSchema: Schema<Any>) =
private fun metadataFieldSchemas(databaseConfig: DatabaseConfig) =
databaseConfig.schema.metadata.associate { it.name to Schema<String>().type(mapToOpenApiType(it.type)) }

private fun proportionSchema() =
mapOf(
"mutation" to Schema<String>().type("string").description("The mutation that was found."),
"proportion" to Schema<String>().type("number").description("The proportion of sequences having the mutation."),
"count" to Schema<String>().type("number").description("The number of sequences matching having the mutation."),
)

private fun mapToOpenApiType(type: MetadataType): String = when (type) {
MetadataType.STRING -> "string"
MetadataType.PANGO_LINEAGE -> "string"
Expand Down Expand Up @@ -193,6 +200,7 @@ private fun nucleotideMutationProportionSchema() =
"proportion" to Schema<String>().type("number").description("The proportion of sequences having the mutation."),
"count" to Schema<String>().type("number").description("The number of sequences matching having the mutation."),
)

private fun aminoAcidMutationProportionSchema() =
mapOf(
"mutation" to Schema<String>().type("string").description(
Expand Down
Loading

0 comments on commit cc3926c

Please sign in to comment.